diff --git a/pkg/recipe/labeling.go b/pkg/recipe/labeling.go index 2cd2e3c..494c8f2 100644 --- a/pkg/recipe/labeling.go +++ b/pkg/recipe/labeling.go @@ -128,7 +128,10 @@ func (l *Labeling) labelOrUnset( obj *unstructured.Unstructured, ) error { var isInclude bool - for _, name := range l.Label.FilterByNames { + if len(l.Label.IncludeByNames) == 0 { + isInclude = true + } + for _, name := range l.Label.IncludeByNames { if name == obj.GetName() { isInclude = true break @@ -195,5 +198,10 @@ func (l *Labeling) labelAll() (*types.LabelResult, error) { // Run applyies the desired labels or unsets them // against the resource(s) func (l *Labeling) Run() (*types.LabelResult, error) { + if len(l.Label.ApplyLabels) == 0 { + return nil, errors.Errorf( + "Invalid label operation: Missing ApplyLabels", + ) + } return l.labelAll() } diff --git a/types/recipe/label.go b/types/recipe/label.go index e1ed9ed..cfab781 100644 --- a/types/recipe/label.go +++ b/types/recipe/label.go @@ -29,13 +29,15 @@ type Label struct { // labeled State *unstructured.Unstructured `json:"state"` - // Filter the resources by these names + // Include the resources by these names // // Optional - FilterByNames []string `json:"filterByNames,omitempty"` + IncludeByNames []string `json:"includeByNames,omitempty"` // ApplyLabels represents the labels that need to be - // applied + // applied against the selected resources + // + // This is mandatory field ApplyLabels map[string]string `json:"applyLabels"` // AutoUnset removes the labels from the resources if