Skip to content

Commit

Permalink
feat(CLI): Add -v and --verbose to Argo CLI (#2814)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Apr 27, 2020
1 parent 1d30f70 commit 31358d6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
9 changes: 8 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Checklist:
**Anything else we need to know?**:

**Environment**:

- Argo version:
```
$ argo version
Expand All @@ -31,16 +32,22 @@ $ kubectl version -o yaml
```

**Other debugging information (if applicable)**:

- workflow result:

```
argo get <workflowname>
argo --loglevel DEBUG get <workflowname>
```

- executor logs:

```
kubectl logs <failedpodname> -c init
kubectl logs <failedpodname> -c wait
```

- workflow-controller logs:

```
kubectl logs -n argo $(kubectl get pods -l app=workflow-controller -n argo -o name)
```
Expand Down
8 changes: 8 additions & 0 deletions cmd/argo/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"fmt"

"github.com/argoproj/pkg/cli"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/argoproj/argo"
"github.com/argoproj/argo/cmd/argo/commands/clustertemplate"

"github.com/argoproj/argo/cmd/argo/commands/auth"
Expand Down Expand Up @@ -62,10 +64,16 @@ If you're using the Argo Server (e.g. because you need large workflow support or

// global log level
var logLevel string
var verbose bool
command.PersistentPreRun = func(cmd *cobra.Command, args []string) {
if verbose {
logLevel = "debug"
}
cli.SetLogLevel(logLevel)
log.WithField("version", argo.GetVersion()).Debug("CLI version")
}
command.PersistentFlags().StringVar(&logLevel, "loglevel", "info", "Set the logging level. One of: debug|info|warn|error")
command.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enabled verbose logging, i.e. --loglevel debug")

return command
}
2 changes: 2 additions & 0 deletions pkg/apiclient/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package apiclient
import (
"context"

log "github.com/sirupsen/logrus"
"k8s.io/client-go/tools/clientcmd"

clusterworkflowtmplpkg "github.com/argoproj/argo/pkg/apiclient/clusterworkflowtemplate"
Expand Down Expand Up @@ -38,6 +39,7 @@ func NewClient(argoServer string, authSupplier func() string, clientConfig clien
}

func NewClientFromOpts(opts Opts) (context.Context, Client, error) {
log.WithField("opts", opts).Debug("Client options")
if opts.ArgoServerOpts.URL != "" {
return newArgoServerClient(opts.ArgoServerOpts, opts.AuthSupplier())
} else {
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/manifests/mixins/argo-server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ spec:
containers:
- name: argo-server
args:
- -v
- server
- --namespaced
- --auth-mode
- client
- --loglevel
- debug
- --secure
imagePullPolicy: Never
env:
Expand Down

0 comments on commit 31358d6

Please sign in to comment.