Skip to content

Commit

Permalink
Introduce --verbose flag that enables logs.Warn logs (#600)
Browse files Browse the repository at this point in the history
* Introduce --verbose flag that enables logs.Warn logs

* regenerate docs
  • Loading branch information
imjasonh authored Feb 17, 2022
1 parent 3fc720f commit 70f0273
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 10 deletions.
5 changes: 0 additions & 5 deletions cmd/ko/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ package main

import (
"log"
"os"

"github.com/google/go-containerregistry/pkg/logs"
"github.com/google/ko/pkg/commands"
)

Expand All @@ -36,9 +34,6 @@ For more information see:
`

func main() {
logs.Warn.SetOutput(os.Stderr)
logs.Progress.SetOutput(os.Stderr)

log.Print(Deprecation258)

if err := commands.Root.Execute(); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion doc/ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ ko [flags]
### Options

```
-h, --help help for ko
-h, --help help for ko
-v, --verbose Enable debug logs
```

### SEE ALSO
Expand Down
6 changes: 6 additions & 0 deletions doc/ko_apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ ko apply -f FILENAME [flags]
-W, --watch Continuously monitor the transitive dependencies of the passed yaml files, and redeploy whenever anything changes. (DEPRECATED)
```

### Options inherited from parent commands

```
-v, --verbose Enable debug logs
```

### SEE ALSO

* [ko](ko.md) - Rapidly iterate with Go, Containers, and Kubernetes.
Expand Down
6 changes: 6 additions & 0 deletions doc/ko_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ ko build IMPORTPATH... [flags]
--tarball string File to save images tarballs
```

### Options inherited from parent commands

```
-v, --verbose Enable debug logs
```

### SEE ALSO

* [ko](ko.md) - Rapidly iterate with Go, Containers, and Kubernetes.
Expand Down
6 changes: 6 additions & 0 deletions doc/ko_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ ko create -f FILENAME [flags]
-W, --watch Continuously monitor the transitive dependencies of the passed yaml files, and redeploy whenever anything changes. (DEPRECATED)
```

### Options inherited from parent commands

```
-v, --verbose Enable debug logs
```

### SEE ALSO

* [ko](ko.md) - Rapidly iterate with Go, Containers, and Kubernetes.
Expand Down
6 changes: 6 additions & 0 deletions doc/ko_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ ko delete [flags]
-h, --help help for delete
```

### Options inherited from parent commands

```
-v, --verbose Enable debug logs
```

### SEE ALSO

* [ko](ko.md) - Rapidly iterate with Go, Containers, and Kubernetes.
Expand Down
6 changes: 6 additions & 0 deletions doc/ko_deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ ko deps IMAGE [flags]
--sbom string Format for SBOM output (supports: spdx, go.version-m). (default "spdx")
```

### Options inherited from parent commands

```
-v, --verbose Enable debug logs
```

### SEE ALSO

* [ko](ko.md) - Rapidly iterate with Go, Containers, and Kubernetes.
Expand Down
6 changes: 6 additions & 0 deletions doc/ko_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ ko login [OPTIONS] [SERVER] [flags]
-u, --username string Username
```

### Options inherited from parent commands

```
-v, --verbose Enable debug logs
```

### SEE ALSO

* [ko](ko.md) - Rapidly iterate with Go, Containers, and Kubernetes.
Expand Down
6 changes: 6 additions & 0 deletions doc/ko_resolve.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ ko resolve -f FILENAME [flags]
-W, --watch Continuously monitor the transitive dependencies of the passed yaml files, and redeploy whenever anything changes. (DEPRECATED)
```

### Options inherited from parent commands

```
-v, --verbose Enable debug logs
```

### SEE ALSO

* [ko](ko.md) - Rapidly iterate with Go, Containers, and Kubernetes.
Expand Down
6 changes: 6 additions & 0 deletions doc/ko_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ ko run IMPORTPATH [flags]
--tarball string File to save images tarballs
```

### Options inherited from parent commands

```
-v, --verbose Enable debug logs
```

### SEE ALSO

* [ko](ko.md) - Rapidly iterate with Go, Containers, and Kubernetes.
Expand Down
6 changes: 6 additions & 0 deletions doc/ko_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ ko version [flags]
-h, --help help for version
```

### Options inherited from parent commands

```
-v, --verbose Enable debug logs
```

### SEE ALSO

* [ko](ko.md) - Rapidly iterate with Go, Containers, and Kubernetes.
Expand Down
4 changes: 0 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ import (
"os"
"os/signal"

"github.com/google/go-containerregistry/pkg/logs"
"github.com/google/ko/pkg/commands"
)

func main() {
logs.Warn.SetOutput(os.Stderr)
logs.Progress.SetOutput(os.Stderr)

ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()
if err := commands.Root.ExecuteContext(ctx); err != nil {
Expand Down
13 changes: 13 additions & 0 deletions pkg/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,35 @@
package commands

import (
"os"

cranecmd "github.com/google/go-containerregistry/cmd/crane/cmd"
"github.com/google/go-containerregistry/pkg/logs"
"github.com/spf13/cobra"
)

var Root = New()

func New() *cobra.Command {
var verbose bool
root := &cobra.Command{
Use: "ko",
Short: "Rapidly iterate with Go, Containers, and Kubernetes.",
SilenceUsage: true, // Don't show usage on errors
DisableAutoGenTag: true,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if verbose {
logs.Warn.SetOutput(os.Stderr)
logs.Debug.SetOutput(os.Stderr)
}
logs.Progress.SetOutput(os.Stderr)
},
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
},
}
root.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable debug logs")

AddKubeCommands(root)

// Also add the auth group from crane to facilitate logging into a
Expand Down

0 comments on commit 70f0273

Please sign in to comment.