Skip to content

Commit

Permalink
Add timeout flag
Browse files Browse the repository at this point in the history
  • Loading branch information
alenkacz committed Jan 4, 2021
1 parent fb9ab89 commit 817c371
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ It expects kubeconfig/user that is allowed to create namespace in the default se
You can configure what the CLI does via flags:
```
--debug 'print out debug logs as well'
--namespace 'namespace into which cert-manager is installed'
--timeout 'set timeout after which we give up waiting for cert-manager'
```
### As a library
Expand Down
4 changes: 3 additions & 1 deletion pkg/cmd/verify/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Options struct {
Streams *genericclioptions.IOStreams
DebugLogs bool
CertManagerNamespace string
Timeout time.Duration
}

func NewOptions() *Options {
Expand Down Expand Up @@ -53,6 +54,7 @@ func NewCmd() *cobra.Command {

rootCmd.Flags().BoolVar(&options.DebugLogs, "debug", false, "If true, will print out debug logs (default false)")
rootCmd.Flags().StringVarP(&options.CertManagerNamespace, "namespace", "n", defaultInstallationNamespace, "Namespace in which cert-manager is installed")
rootCmd.Flags().DurationVar(&options.Timeout, "timeout", defaultTimeout, "Timeout after which we give up waiting for cert-manager to be ready.")

options.ConfigFlags.AddFlags(rootCmd.Flags())
rootCmd.SetOut(options.Streams.Out)
Expand All @@ -70,7 +72,7 @@ func (o *Options) Execute() error {
logrus.SetLevel(logrus.DebugLevel)
}

ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)
ctx, cancel := context.WithTimeout(context.Background(), o.Timeout)
defer cancel()

config, err := o.ConfigFlags.ToRESTConfig()
Expand Down

0 comments on commit 817c371

Please sign in to comment.