diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2022-04-26 15:53:36 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2022-04-27 04:39:05 -0400 |
commit | 7259a6315c7f7d97665d928de6357fc3cbcae136 (patch) | |
tree | a47443744f1e5cd7504e15bba29fb0a661ef6f3d /cmd/podman/play | |
parent | 5ac00a7287e4a9e6292f4a6ca5dfa9a02e5ca907 (diff) | |
download | podman-7259a6315c7f7d97665d928de6357fc3cbcae136.tar.gz podman-7259a6315c7f7d97665d928de6357fc3cbcae136.tar.bz2 podman-7259a6315c7f7d97665d928de6357fc3cbcae136.zip |
Truncate annotations when generating kubernetes yaml files
Kubernetes only allows 63 characters in an annotation. Make sure
that we only add 63 or less charaters when generating kube. Warn
if containers or pods have longer length and truncate.
Discussion: https://github.com/containers/podman/discussions/13901
Fixes: https://github.com/containers/podman/issues/13962
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman/play')
-rw-r--r-- | cmd/podman/play/kube.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go index e92516eb4..40d14a609 100644 --- a/cmd/podman/play/kube.go +++ b/cmd/podman/play/kube.go @@ -178,7 +178,11 @@ func kube(cmd *cobra.Command, args []string) error { if kubeOptions.Annotations == nil { kubeOptions.Annotations = make(map[string]string) } - kubeOptions.Annotations[splitN[0]] = splitN[1] + annotation := splitN[1] + if len(annotation) > define.MaxKubeAnnotation { + return errors.Errorf("annotation exceeds maximum size, %d, of kubernetes annotation: %s", define.MaxKubeAnnotation, annotation) + } + kubeOptions.Annotations[splitN[0]] = annotation } yamlfile := args[0] if yamlfile == "-" { |