From 2b5020144282aa69dcfe9dbe260dc2e194b7f525 Mon Sep 17 00:00:00 2001 From: juanvallejo Date: Fri, 22 Jun 2018 16:28:28 -0400 Subject: [PATCH] add --read-only opt to oc set volumes --- contrib/completions/bash/oc | 4 ++++ contrib/completions/zsh/oc | 4 ++++ pkg/oc/cli/cmd/set/volume.go | 3 +++ 3 files changed, 11 insertions(+) diff --git a/contrib/completions/bash/oc b/contrib/completions/bash/oc index 300a7198ed4d..26411ffdc7de 100644 --- a/contrib/completions/bash/oc +++ b/contrib/completions/bash/oc @@ -17528,6 +17528,8 @@ _oc_set_volumes() local_nonpersistent_flags+=("--overwrite") flags+=("--path=") local_nonpersistent_flags+=("--path=") + flags+=("--read-only") + local_nonpersistent_flags+=("--read-only") flags+=("--remove") local_nonpersistent_flags+=("--remove") flags+=("--secret-name=") @@ -17972,6 +17974,8 @@ _oc_volumes() local_nonpersistent_flags+=("--overwrite") flags+=("--path=") local_nonpersistent_flags+=("--path=") + flags+=("--read-only") + local_nonpersistent_flags+=("--read-only") flags+=("--remove") local_nonpersistent_flags+=("--remove") flags+=("--secret-name=") diff --git a/contrib/completions/zsh/oc b/contrib/completions/zsh/oc index 8027f57bb9bc..8c76e4375996 100644 --- a/contrib/completions/zsh/oc +++ b/contrib/completions/zsh/oc @@ -17670,6 +17670,8 @@ _oc_set_volumes() local_nonpersistent_flags+=("--overwrite") flags+=("--path=") local_nonpersistent_flags+=("--path=") + flags+=("--read-only") + local_nonpersistent_flags+=("--read-only") flags+=("--remove") local_nonpersistent_flags+=("--remove") flags+=("--secret-name=") @@ -18114,6 +18116,8 @@ _oc_volumes() local_nonpersistent_flags+=("--overwrite") flags+=("--path=") local_nonpersistent_flags+=("--path=") + flags+=("--read-only") + local_nonpersistent_flags+=("--read-only") flags+=("--remove") local_nonpersistent_flags+=("--remove") flags+=("--secret-name=") diff --git a/pkg/oc/cli/cmd/set/volume.go b/pkg/oc/cli/cmd/set/volume.go index 1d8361e4538d..0a3bd412d8fc 100644 --- a/pkg/oc/cli/cmd/set/volume.go +++ b/pkg/oc/cli/cmd/set/volume.go @@ -144,6 +144,7 @@ type AddVolumeOptions struct { SecretName string Source string + ReadOnly bool CreateClaim bool ClaimName string ClaimSize string @@ -200,6 +201,7 @@ func NewCmdVolume(fullName string, f kcmdutil.Factory, out, errOut io.Writer) *c cmd.Flags().StringVar(&addOpts.SubPath, "sub-path", "", "Path within the local volume from which the container's volume should be mounted. Optional param for --add or --remove") cmd.Flags().StringVarP(&addOpts.DefaultMode, "default-mode", "", "", "The default mode bits to create files with. Can be between 0000 and 0777. Defaults to 0644.") cmd.Flags().BoolVar(&addOpts.Overwrite, "overwrite", false, "If true, replace existing volume source with the provided name and/or volume mount for the given resource") + cmd.Flags().BoolVar(&addOpts.ReadOnly, "read-only", false, "Mount volume as ReadOnly. Optional param for --add or --remove") cmd.Flags().StringVar(&addOpts.Path, "path", "", "Host path. Must be provided for hostPath volume type") cmd.Flags().StringVar(&addOpts.ConfigMapName, "configmap-name", "", "Name of the persisted config map. Must be provided for configmap volume type") cmd.Flags().StringVar(&addOpts.SecretName, "secret-name", "", "Name of the persisted secret. Must be provided for secret volume type") @@ -681,6 +683,7 @@ func (v *VolumeOptions) setVolumeMount(spec *kapi.PodSpec, info *resource.Info) volumeMount := &kapi.VolumeMount{ Name: v.Name, MountPath: path.Clean(opts.MountPath), + ReadOnly: opts.ReadOnly, } if len(opts.SubPath) > 0 { volumeMount.SubPath = path.Clean(opts.SubPath)