Skip to content

Commit

Permalink
Improve comments and style
Browse files Browse the repository at this point in the history
Co-authored-by: Corentin Néau <tan.neau@suse.com>
  • Loading branch information
raulcabello and weyfonk committed Apr 20, 2023
1 parent 3b62dd4 commit 4bb90a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions modules/agent/pkg/deployer/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,8 @@ func nonReady(plan apply.Plan, ignoreOptions fleet.IgnoreOptions) (result []flee
}
if u, ok := obj.(*unstructured.Unstructured); ok {
if ignoreOptions.Conditions != nil {
err := excludeIgnoredConditions(u, ignoreOptions)
if err != nil {
logrus.Errorf("failed to ignore conditions: %v", err)
if err := excludeIgnoredConditions(u, ignoreOptions); err != nil {
logrus.Errorf("failed to ignore conditions: %w", err)

Check failure on line 281 in modules/agent/pkg/deployer/monitor.go

View workflow job for this annotation

GitHub Actions / unit-test

github.com/sirupsen/logrus.Errorf does not support error-wrapping directive %w
}
}

Expand All @@ -300,7 +299,7 @@ func nonReady(plan apply.Plan, ignoreOptions fleet.IgnoreOptions) (result []flee
return result
}

// excludeIgnoredConditions remove the conditions that are included in ignoreOptions from the object passed as a parameter
// excludeIgnoredConditions removes the conditions that are included in ignoreOptions from the object passed as a parameter
func excludeIgnoredConditions(obj *unstructured.Unstructured, ignoreOptions fleet.IgnoreOptions) error {
conditions, _, err := unstructured.NestedSlice(obj.Object, "status", "conditions")
if err != nil {
Expand Down Expand Up @@ -338,10 +337,12 @@ func shouldExcludeCondition(conditions map[string]interface{}, ignoredConditions
if len(ignoredConditions) > len(conditions) {
return false
}

for k, v := range ignoredConditions {
if vc, found := conditions[k]; !found || vc != v {
return false
}
}

return true
}
2 changes: 1 addition & 1 deletion modules/agent/pkg/deployer/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestExcludeIgnoredConditions(t *testing.T) {
}}
uPodInitialized, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&podInitialized)
if err != nil {
t.Errorf("can't convert podInitializedAndNotReady to unstructured: %v", err)
t.Errorf("can't convert podInitialized to unstructured: %v", err)
}
tests := map[string]struct {
obj *unstructured.Unstructured
Expand Down

0 comments on commit 4bb90a6

Please sign in to comment.