@@ -39,6 +39,7 @@ type addMetadataOptions struct {
39
39
mapValidator func (map [string ]string ) error
40
40
kind kindOfAdd
41
41
labelsWithoutSelector bool
42
+ includeTemplates bool
42
43
}
43
44
44
45
// newCmdAddAnnotation adds one or more commonAnnotations to the kustomization file.
@@ -83,6 +84,9 @@ func newCmdAddLabel(fSys filesys.FileSystem, v func(map[string]string) error) *c
83
84
cmd .Flags ().BoolVar (& o .labelsWithoutSelector , "without-selector" , false ,
84
85
"using add labels without selector option" ,
85
86
)
87
+ cmd .Flags ().BoolVar (& o .includeTemplates , "include-templates" , false ,
88
+ "include labels in templates (requires --without-selector)" ,
89
+ )
86
90
return cmd
87
91
}
88
92
@@ -132,7 +136,11 @@ func (o *addMetadataOptions) addAnnotations(m *types.Kustomization) error {
132
136
133
137
func (o * addMetadataOptions ) addLabels (m * types.Kustomization ) error {
134
138
if o .labelsWithoutSelector {
135
- m .Labels = append (m .Labels , types.Label {Pairs : make (map [string ]string ), IncludeSelectors : false })
139
+ m .Labels = append (m .Labels , types.Label {
140
+ Pairs : make (map [string ]string ),
141
+ IncludeSelectors : false ,
142
+ IncludeTemplates : o .includeTemplates ,
143
+ })
136
144
return o .writeToMap (m .Labels [len (m .Labels )- 1 ].Pairs , label )
137
145
}
138
146
if m .CommonLabels == nil {
0 commit comments