Skip to content

Commit

Permalink
fix: lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <xpf6677@163.com>
  • Loading branch information
Peefy committed Dec 19, 2023
1 parent 4a718f2 commit c5b47cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion input/v1beta1/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type RunSpec struct {
// Target determines what object the export output should be applied to
// +kubebuilder:default:=Resources
// +kubebuilder:validation:Enum:=PatchDesired;PatchResources;Resources;XR
Target Target `json:"target,required"`
Target Target `json:"target"`
}

type Target string
Expand Down
12 changes: 6 additions & 6 deletions obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ func addResourcesTo(o any, conf addResourcesConf) error {
return merged
}

switch o.(type) {
switch val := o.(type) {
case map[resource.Name]*resource.DesiredComposed:
// Resources
desired := o.(map[resource.Name]*resource.DesiredComposed)
desired := val
for _, d := range conf.data {
name := resource.Name(d.Name)
u := unstructured.Unstructured{
Expand All @@ -176,7 +176,7 @@ func addResourcesTo(o any, conf addResourcesConf) error {
}
case desiredMatch:
// PatchDesired
matches := o.(desiredMatch)
matches := val
// Set the Match data on the desired resource stored as keys
for obj, matchData := range matches {
// There may be multiple data patches to the DesiredComposed object
Expand Down Expand Up @@ -243,7 +243,7 @@ func setData(data any, path string, o any, overwrite bool) error {
}
default:
// Reached a leaf node, add the JSON path to the desired resource
switch o.(type) {
switch val := o.(type) {
case *resource.DesiredComposed:
path = strings.TrimPrefix(path, ".")

Expand All @@ -253,7 +253,7 @@ func setData(data any, path string, o any, overwrite bool) error {
return nil
}

r := o.(*resource.DesiredComposed).Resource
r := val.Resource
if r == nil {
return errors.New("cannot set data on a nil DesiredComposed resource")
}
Expand All @@ -273,7 +273,7 @@ func setData(data any, path string, o any, overwrite bool) error {
// The composite does not do any matching to update so there is no need to skip here
// on apiVersion, kind or metadata.name

r := o.(*resource.Composite).Resource
r := val.Resource
if r == nil {
return fmt.Errorf("cannot set data on a nil XR")
}
Expand Down

0 comments on commit c5b47cd

Please sign in to comment.