diff options
author | Eduardo Vega <edvegavalerio@gmail.com> | 2021-05-01 09:20:56 -0600 |
---|---|---|
committer | Eduardo Vega <edvegavalerio@gmail.com> | 2021-05-06 21:21:43 -0600 |
commit | 72f4f389f0a77d226e36413cb54c3867ae25700d (patch) | |
tree | fe3dd4944ed43cefffb9b22f0d6c7b64212b4fa6 /pkg/specgen | |
parent | 034470e5be8cfeef8ce0e0d2f47587a660682219 (diff) | |
download | podman-72f4f389f0a77d226e36413cb54c3867ae25700d.tar.gz podman-72f4f389f0a77d226e36413cb54c3867ae25700d.tar.bz2 podman-72f4f389f0a77d226e36413cb54c3867ae25700d.zip |
Adds support to preserve auto update labels in generate and play kube
In the case of generate kube the auto-update labels will be converted into kube annotations and for play kube they will be converted back to labels since that's what podman understands
Signed-off-by: Eduardo Vega <edvegavalerio@gmail.com>
Diffstat (limited to 'pkg/specgen')
-rw-r--r-- | pkg/specgen/generate/kube/kube.go | 15 |
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 } |