From feaa1a134a4fd0a7d25bab485708a201321bfb56 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 9 Mar 2022 17:30:01 -0500 Subject: Add podman play kube --annotation Allow users to add annotions in the podman play kube command. This PR Also fixes the fact that annotations in the pod spec were not being passed down to containers. Fixes: https://github.com/containers/podman/issues/12968 Signed-off-by: Daniel J Walsh --- pkg/domain/entities/play.go | 2 ++ pkg/domain/infra/abi/play.go | 7 +++++++ pkg/domain/infra/tunnel/play.go | 3 +++ 3 files changed, 12 insertions(+) (limited to 'pkg/domain') diff --git a/pkg/domain/entities/play.go b/pkg/domain/entities/play.go index 7614a4012..c9dc3f08c 100644 --- a/pkg/domain/entities/play.go +++ b/pkg/domain/entities/play.go @@ -8,6 +8,8 @@ import ( // PlayKubeOptions controls playing kube YAML files. type PlayKubeOptions struct { + // Annotations - Annotations to add to Pods + Annotations map[string]string // Authfile - path to an authentication file. Authfile string // Indicator to build all images with Containerfile or Dockerfile diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index 155b06105..3242e64a2 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -79,6 +79,13 @@ func (ic *ContainerEngine) PlayKube(ctx context.Context, path string, options en podTemplateSpec.ObjectMeta = podYAML.ObjectMeta podTemplateSpec.Spec = podYAML.Spec + for name, val := range options.Annotations { + if podYAML.Annotations == nil { + podYAML.Annotations = make(map[string]string) + } + podYAML.Annotations[name] = val + } + r, err := ic.playKubePod(ctx, podTemplateSpec.ObjectMeta.Name, &podTemplateSpec, options, &ipIndex, podYAML.Annotations, configMaps) if err != nil { return nil, err diff --git a/pkg/domain/infra/tunnel/play.go b/pkg/domain/infra/tunnel/play.go index 55844730b..cd51262d0 100644 --- a/pkg/domain/infra/tunnel/play.go +++ b/pkg/domain/infra/tunnel/play.go @@ -16,6 +16,9 @@ func (ic *ContainerEngine) PlayKube(ctx context.Context, path string, opts entit if len(opts.LogOptions) > 0 { options.WithLogOptions(opts.LogOptions) } + if opts.Annotations != nil { + options.WithAnnotations(opts.Annotations) + } options.WithNoHosts(opts.NoHosts) if s := opts.SkipTLSVerify; s != types.OptionalBoolUndefined { options.WithSkipTLSVerify(s == types.OptionalBoolTrue) -- cgit v1.2.3-54-g00ecf