Skip to content

Commit

Permalink
Review 1
Browse files Browse the repository at this point in the history
  • Loading branch information
smarterclayton committed Feb 21, 2016
1 parent 8466424 commit 0f30adc
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 133 deletions.
39 changes: 2 additions & 37 deletions contrib/completions/bash/oc
Original file line number Diff line number Diff line change
Expand Up @@ -1388,19 +1388,18 @@ _oc_set_probe()
flags+=("--output-version=")
flags+=("--period-seconds=")
flags+=("--readiness")
flags+=("--remove")
flags+=("--selector=")
two_word_flags+=("-l")
flags+=("--show-all")
flags+=("-a")
flags+=("--show-labels")
flags+=("--sort-by=")
flags+=("--success-threshold=")
flags+=("--template=")
two_word_flags+=("-t")
flags+=("--timeout-seconds=")
flags+=("--unset")
flags+=("--alsologtostderr")
flags+=("--api-version=")
flags+=("--boot-id-file=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
flags_completion+=("_filedir")
Expand All @@ -1414,50 +1413,16 @@ _oc_set_probe()
flags+=("--config=")
flags_with_completion+=("--config")
flags_completion+=("_filedir")
flags+=("--container-hints=")
flags+=("--context=")
flags+=("--docker=")
flags+=("--docker-only")
flags+=("--docker-root=")
flags+=("--docker-run=")
flags+=("--enable-load-reader")
flags+=("--event-storage-age-limit=")
flags+=("--event-storage-event-limit=")
flags+=("--global-housekeeping-interval=")
flags+=("--google-json-key=")
flags+=("--housekeeping-interval=")
flags+=("--httptest.serve=")
flags+=("--insecure-skip-tls-verify")
flags+=("--ir-data-source=")
flags+=("--ir-dbname=")
flags+=("--ir-influxdb-host=")
flags+=("--ir-namespace-only")
flags+=("--ir-password=")
flags+=("--ir-percentile=")
flags+=("--ir-user=")
flags+=("--log-backtrace-at=")
flags+=("--log-cadvisor-usage")
flags+=("--log-dir=")
flags+=("--log-flush-frequency=")
flags+=("--logtostderr")
flags+=("--machine-id-file=")
flags+=("--match-server-version")
flags+=("--namespace=")
two_word_flags+=("-n")
flags+=("--nosystemd")
flags+=("--server=")
flags+=("--stderrthreshold=")
flags+=("--storage-driver-buffer-duration=")
flags+=("--storage-driver-db=")
flags+=("--storage-driver-host=")
flags+=("--storage-driver-password=")
flags+=("--storage-driver-secure")
flags+=("--storage-driver-table=")
flags+=("--storage-driver-user=")
flags+=("--token=")
flags+=("--user=")
flags+=("--v=")
flags+=("--vmodule=")

must_have_one_flag=()
must_have_one_noun=()
Expand Down
39 changes: 2 additions & 37 deletions contrib/completions/bash/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -4725,19 +4725,18 @@ _openshift_cli_set_probe()
flags+=("--output-version=")
flags+=("--period-seconds=")
flags+=("--readiness")
flags+=("--remove")
flags+=("--selector=")
two_word_flags+=("-l")
flags+=("--show-all")
flags+=("-a")
flags+=("--show-labels")
flags+=("--sort-by=")
flags+=("--success-threshold=")
flags+=("--template=")
two_word_flags+=("-t")
flags+=("--timeout-seconds=")
flags+=("--unset")
flags+=("--alsologtostderr")
flags+=("--api-version=")
flags+=("--boot-id-file=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
flags_completion+=("_filedir")
Expand All @@ -4751,50 +4750,16 @@ _openshift_cli_set_probe()
flags+=("--config=")
flags_with_completion+=("--config")
flags_completion+=("_filedir")
flags+=("--container-hints=")
flags+=("--context=")
flags+=("--docker=")
flags+=("--docker-only")
flags+=("--docker-root=")
flags+=("--docker-run=")
flags+=("--enable-load-reader")
flags+=("--event-storage-age-limit=")
flags+=("--event-storage-event-limit=")
flags+=("--global-housekeeping-interval=")
flags+=("--google-json-key=")
flags+=("--housekeeping-interval=")
flags+=("--httptest.serve=")
flags+=("--insecure-skip-tls-verify")
flags+=("--ir-data-source=")
flags+=("--ir-dbname=")
flags+=("--ir-influxdb-host=")
flags+=("--ir-namespace-only")
flags+=("--ir-password=")
flags+=("--ir-percentile=")
flags+=("--ir-user=")
flags+=("--log-backtrace-at=")
flags+=("--log-cadvisor-usage")
flags+=("--log-dir=")
flags+=("--log-flush-frequency=")
flags+=("--logtostderr")
flags+=("--machine-id-file=")
flags+=("--match-server-version")
flags+=("--namespace=")
two_word_flags+=("-n")
flags+=("--nosystemd")
flags+=("--server=")
flags+=("--stderrthreshold=")
flags+=("--storage-driver-buffer-duration=")
flags+=("--storage-driver-db=")
flags+=("--storage-driver-host=")
flags+=("--storage-driver-password=")
flags+=("--storage-driver-secure")
flags+=("--storage-driver-table=")
flags+=("--storage-driver-user=")
flags+=("--token=")
flags+=("--user=")
flags+=("--v=")
flags+=("--vmodule=")

must_have_one_flag=()
must_have_one_noun=()
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/oc_by_example_content.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,7 @@ Update a probe on a pod template
[options="nowrap"]
----
# Clear both readiness and liveness probes off all containers
$ oc set probe dc/registry --unset --readiness --liveness
$ oc set probe dc/registry --remove --readiness --liveness
# Set an exec action as a liveness probe to run 'echo ok'
$ oc set probe dc/registry --liveness -- echo ok
Expand Down
18 changes: 9 additions & 9 deletions pkg/cmd/cli/cmd/set/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ initial-delay-seconds values, otherwise as your application evolves you may sudd
to fail.`

probeExample = ` # Clear both readiness and liveness probes off all containers
$ %[1]s probe dc/registry --unset --readiness --liveness
$ %[1]s probe dc/registry --remove --readiness --liveness
# Set an exec action as a liveness probe to run 'echo ok'
$ %[1]s probe dc/registry --liveness -- echo ok
Expand Down Expand Up @@ -84,7 +84,7 @@ type ProbeOptions struct {

Readiness bool
Liveness bool
Unset bool
Remove bool

OpenTCPSocket string
HTTPGet string
Expand Down Expand Up @@ -115,7 +115,7 @@ func NewCmdProbe(fullName string, f *clientcmd.Factory, out, errOut io.Writer) *
ContainerSelector: "*",
}
cmd := &cobra.Command{
Use: "probe RESOURCE/NAME [--readiness|--liveness] ...",
Use: "probe RESOURCE/NAME --readiness|--liveness (--get-url=URL|--open-tcp=PORT|-- CMD)",
Short: "Update a probe on a pod template",
Long: probeLong,
Example: fmt.Sprintf(probeExample, fullName),
Expand All @@ -138,9 +138,9 @@ func NewCmdProbe(fullName string, f *clientcmd.Factory, out, errOut io.Writer) *
cmd.Flags().BoolVar(&options.All, "all", options.All, "Select all resources in the namespace of the specified resource types")
cmd.Flags().StringSliceVarP(&options.Filenames, "filename", "f", options.Filenames, "Filename, directory, or URL to file to use to edit the resource.")

cmd.Flags().BoolVar(&options.Unset, "unset", options.Unset, "If true, remove the specified probe(s).")
cmd.Flags().BoolVar(&options.Readiness, "readiness", options.Readiness, "Set a readiness probe to indicate when this container should receive traffic")
cmd.Flags().BoolVar(&options.Liveness, "liveness", options.Liveness, "Set a liveness probe to verify this container is running")
cmd.Flags().BoolVar(&options.Remove, "remove", options.Remove, "If true, remove the specified probe(s).")
cmd.Flags().BoolVar(&options.Readiness, "readiness", options.Readiness, "Set or remove a readiness probe to indicate when this container should receive traffic")
cmd.Flags().BoolVar(&options.Liveness, "liveness", options.Liveness, "Set or remove a liveness probe to verify this container is running")

cmd.Flags().StringVar(&options.OpenTCPSocket, "open-tcp", options.OpenTCPSocket, "A port number or port name to attempt to open via TCP.")
cmd.Flags().StringVar(&options.HTTPGet, "get-url", options.HTTPGet, "A URL to perform an HTTP GET on (you can omit the host, have a string port, or omit the scheme.")
Expand Down Expand Up @@ -246,8 +246,8 @@ func (o *ProbeOptions) Validate() error {
}

switch {
case o.Unset && count != 0:
return fmt.Errorf("--unset may not be used with any flag except --readiness or --liveness")
case o.Remove && count != 0:
return fmt.Errorf("--remove may not be used with any flag except --readiness or --liveness")
case count > 1:
return fmt.Errorf("you may only set one of --get-url, --open-tcp, or command")
case len(o.OpenTCPSocket) > 0 && intOrString(o.OpenTCPSocket).IntVal > 65535:
Expand Down Expand Up @@ -350,7 +350,7 @@ func (o *ProbeOptions) Run() error {
}

func (o *ProbeOptions) updateContainer(container *kapi.Container) {
if o.Unset {
if o.Remove {
if o.Readiness {
container.ReadinessProbe = nil
}
Expand Down
Loading

0 comments on commit 0f30adc

Please sign in to comment.