| 1 |
// Copyright 2019 The Kubernetes Authors. |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package types |
| 5 |
|
| 6 |
type Label struct { |
| 7 |
// Pairs contains the key-value pairs for labels to add |
| 8 |
Pairs map[string]string `json:"pairs,omitempty" yaml:"pairs,omitempty"` |
| 9 |
// IncludeSelectors indicates whether the transformer should include the |
| 10 |
// fieldSpecs for selectors. Custom fieldSpecs specified by |
| 11 |
// FieldSpecs will be merged with builtin fieldSpecs if this |
| 12 |
// is true. |
| 13 |
IncludeSelectors bool `json:"includeSelectors,omitempty" yaml:"includeSelectors,omitempty"` |
| 14 |
// IncludeTemplates indicates whether the transformer should include the |
| 15 |
// spec/template/metadata fieldSpec. Custom fieldSpecs specified by |
| 16 |
// FieldSpecs will be merged with spec/template/metadata fieldSpec if this |
| 17 |
// is true. If IncludeSelectors is true, IncludeTemplates is not needed. |
| 18 |
IncludeTemplates bool `json:"includeTemplates,omitempty" yaml:"includeTemplates,omitempty"` |
| 19 |
FieldSpecs []FieldSpec `json:"fields,omitempty" yaml:"fields,omitempty"` |
| 20 |
} |
| 21 |
|
| 22 |
func labelFromCommonLabels(commonLabels map[string]string) *Label { |
| 23 |
if len(commonLabels) == 0 { |
| 24 |
return nil |
| 25 |
} |
| 26 |
return &Label{ |
| 27 |
Pairs: commonLabels, |
| 28 |
IncludeSelectors: true, |
| 29 |
} |
| 30 |
} |