summaryrefslogtreecommitdiff
path: root/pkg/specgen
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-05-07 05:36:26 -0400
committerGitHub <noreply@github.com>2021-05-07 05:36:26 -0400
commit0c411278ce89c8db1569da6333001c41c78ca0a2 (patch)
tree15fa1c8439ae3c0adc9bd5fa9e74ecd2d61cad56 /pkg/specgen
parent141ba94f9735d88a494f252ad7aa78fd4b86d8ea (diff)
parent72f4f389f0a77d226e36413cb54c3867ae25700d (diff)
downloadpodman-0c411278ce89c8db1569da6333001c41c78ca0a2.tar.gz
podman-0c411278ce89c8db1569da6333001c41c78ca0a2.tar.bz2
podman-0c411278ce89c8db1569da6333001c41c78ca0a2.zip
Merge pull request #10202 from EduardoVega/9763-kube-auto-update
Add support to preserve auto-update labels in play / generate kube
Diffstat (limited to 'pkg/specgen')
-rw-r--r--pkg/specgen/generate/kube/kube.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go
index 73c1c31ba..ccce3edba 100644
--- a/pkg/specgen/generate/kube/kube.go
+++ b/pkg/specgen/generate/kube/kube.go
@@ -100,6 +100,8 @@ type CtrSpecGenOptions struct {
SecretsManager *secrets.SecretsManager
// LogDriver which should be used for the container
LogDriver string
+ // Labels define key-value pairs of metadata
+ Labels map[string]string
}
func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGenerator, error) {
@@ -278,6 +280,19 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
s.NetNS.NSMode = specgen.Host
}
+ // Add labels that come from kube
+ if len(s.Labels) == 0 {
+ // If there are no labels, let's use the map that comes
+ // from kube
+ s.Labels = opts.Labels
+ } else {
+ // If there are already labels in the map, append the ones
+ // obtained from kube
+ for k, v := range opts.Labels {
+ s.Labels[k] = v
+ }
+ }
+
return s, nil
}