mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
* add labels in template/metadata by default * update comment * fix kustomization labels test * Add spec/template/metadata/labels when includeTemplate is true * remove unnecessary test changes * add error wrap * Revert "add error wrap" This reverts commit 0a203df83edb90a400b35d5521487b984619e919. * add error wrap at template fieldSpec merge
31 lines
1.2 KiB
Go
31 lines
1.2 KiB
Go
// Copyright 2019 The Kubernetes Authors.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package types
|
|
|
|
type Label struct {
|
|
// Pairs contains the key-value pairs for labels to add
|
|
Pairs map[string]string `json:"pairs,omitempty" yaml:"pairs,omitempty"`
|
|
// IncludeSelectors inidicates should transformer include the
|
|
// fieldSpecs for selectors. Custom fieldSpecs specified by
|
|
// FieldSpecs will be merged with builtin fieldSpecs if this
|
|
// is true.
|
|
IncludeSelectors bool `json:"includeSelectors,omitempty" yaml:"includeSelectors,omitempty"`
|
|
// IncludeTemplates inidicates should transformer include the
|
|
// spec/template/metadata fieldSpec. Custom fieldSpecs specified by
|
|
// FieldSpecs will be merged with spec/template/metadata fieldSpec if this
|
|
// is true. If IncludeSelectors is true, IncludeTemplates is not needed.
|
|
IncludeTemplates bool `json:"includeTemplates,omitempty" yaml:"includeTemplates,omitempty"`
|
|
FieldSpecs []FieldSpec `json:"fields,omitempty" yaml:"fields,omitempty"`
|
|
}
|
|
|
|
func labelFromCommonLabels(commonLabels map[string]string) *Label {
|
|
if len(commonLabels) == 0 {
|
|
return nil
|
|
}
|
|
return &Label{
|
|
Pairs: commonLabels,
|
|
IncludeSelectors: true,
|
|
}
|
|
}
|