Skip to content

Commit 367e45b

Browse files
authored
Merge pull request #355 from werf/fix/external-secrets-readying-when-no-status
fix: external secrets readying if external secret has no status
2 parents ad76758 + cd33f46 commit 367e45b

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

pkg/tracker/generic/ready_condition.go

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,40 @@ func NewResourceStatusIndicator(object *unstructured.Unstructured) (indicator *i
1515

1616
var matchedCondition *ResourceStatusJSONPathCondition
1717
for _, condition := range ResourceStatusJSONPathConditions {
18-
if condition.GroupKind != nil && *condition.GroupKind != groupKind {
19-
continue
20-
}
18+
exactCondition := condition.GroupKind != nil
2119

22-
currentValue, found, err := utils.JSONPath(condition.JSONPath, object.UnstructuredContent())
23-
if err != nil {
24-
return nil, "", fmt.Errorf("jsonpath error: %w", err)
25-
} else if !found {
26-
continue
27-
}
20+
if exactCondition {
21+
exactMatch := *condition.GroupKind == groupKind
22+
if !exactMatch {
23+
continue
24+
}
2825

29-
knownValues := lo.Union(condition.ReadyValues, condition.PendingValues, condition.FailedValues)
26+
currentValue, _, err := utils.JSONPath(condition.JSONPath, object.UnstructuredContent())
27+
if err != nil {
28+
return nil, "", fmt.Errorf("jsonpath error: %w", err)
29+
}
3030

31-
if lo.Contains(knownValues, currentValue) {
3231
matchedCondition = condition
3332
matchedCondition.CurrentValue = currentValue
3433
break
34+
} else {
35+
currentValue, found, err := utils.JSONPath(condition.JSONPath, object.UnstructuredContent())
36+
if err != nil {
37+
return nil, "", fmt.Errorf("jsonpath error: %w", err)
38+
} else if !found {
39+
continue
40+
}
41+
42+
knownValues := lo.Union(condition.ReadyValues, condition.PendingValues, condition.FailedValues)
43+
44+
if lo.Contains(knownValues, currentValue) {
45+
matchedCondition = condition
46+
matchedCondition.CurrentValue = currentValue
47+
break
48+
}
3549
}
3650
}
51+
3752
if matchedCondition == nil {
3853
return nil, "", nil
3954
}

0 commit comments

Comments
 (0)