aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-03-10 14:36:53 -0500
committerGitHub <noreply@github.com>2022-03-10 14:36:53 -0500
commit7ba81ead38d0c4fb2e583224257a0497789552fc (patch)
treef7e546f59992980f64b75857a2e5aa0b4751a62b /cmd/podman
parenta5e327941423983529b771a03691dc2fe2390e0f (diff)
parentfeaa1a134a4fd0a7d25bab485708a201321bfb56 (diff)
downloadpodman-7ba81ead38d0c4fb2e583224257a0497789552fc.tar.gz
podman-7ba81ead38d0c4fb2e583224257a0497789552fc.tar.bz2
podman-7ba81ead38d0c4fb2e583224257a0497789552fc.zip
Merge pull request #13445 from rhatdan/annotation
Add podman play kube --annotation
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/play/kube.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go
index 563a6251c..3067f0d54 100644
--- a/cmd/podman/play/kube.go
+++ b/cmd/podman/play/kube.go
@@ -4,6 +4,7 @@ import (
"fmt"
"net"
"os"
+ "strings"
"github.com/containers/common/pkg/auth"
"github.com/containers/common/pkg/completion"
@@ -31,7 +32,8 @@ type playKubeOptionsWrapper struct {
}
var (
- macs []string
+ annotations []string
+ macs []string
// https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/
defaultSeccompRoot = "/var/lib/kubelet/seccomp"
kubeOptions = playKubeOptionsWrapper{}
@@ -61,6 +63,13 @@ func init() {
flags := kubeCmd.Flags()
flags.SetNormalizeFunc(utils.AliasFlags)
+ annotationFlagName := "annotation"
+ flags.StringSliceVar(
+ &annotations,
+ annotationFlagName, []string{},
+ "Add annotations to pods (key=value)",
+ )
+ _ = kubeCmd.RegisterFlagCompletionFunc(annotationFlagName, completion.AutocompleteNone)
credsFlagName := "creds"
flags.StringVar(&kubeOptions.CredentialsCLI, credsFlagName, "", "`Credentials` (USERNAME:PASSWORD) to use for authenticating to a registry")
_ = kubeCmd.RegisterFlagCompletionFunc(credsFlagName, completion.AutocompleteNone)
@@ -161,6 +170,16 @@ func kube(cmd *cobra.Command, args []string) error {
kubeOptions.Password = creds.Password
}
+ for _, annotation := range annotations {
+ splitN := strings.SplitN(annotation, "=", 2)
+ if len(splitN) > 2 {
+ return errors.Errorf("annotation %q must include an '=' sign", annotation)
+ }
+ if kubeOptions.Annotations == nil {
+ kubeOptions.Annotations = make(map[string]string)
+ }
+ kubeOptions.Annotations[splitN[0]] = splitN[1]
+ }
yamlfile := args[0]
if yamlfile == "-" {
yamlfile = "/dev/stdin"