Skip to content

Commit

Permalink
Add act logs command (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok authored May 13, 2022
1 parent e389470 commit a6adafa
Show file tree
Hide file tree
Showing 58 changed files with 174 additions and 55 deletions.
1 change: 1 addition & 0 deletions cmd/cli/cmd/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func NewCmd() *cobra.Command {
NewGet(),
NewWatch(),
NewWait(),
NewLogs(),
)
return root
}
Expand Down
50 changes: 50 additions & 0 deletions cmd/cli/cmd/action/logs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package action

import (
"github.com/argoproj/argo-workflows/v3/cmd/argo/commands"
"github.com/argoproj/argo-workflows/v3/cmd/argo/commands/client"

"capact.io/capact/internal/cli"
"capact.io/capact/internal/cli/heredoc"

"github.com/spf13/cobra"
)

// NewLogs returns a new cobra.Command for getting Action's logs.
// TODO: this should be done via Gateway once the subscription is implemented.
func NewLogs() *cobra.Command {
cmd := commands.NewLogsCommand()
cmd.Use = "logs ACTION [POD]"
cmd.Short = "Print the Action's logs"
cmd.Long = heredoc.Doc(`
Print the Action's logs
NOTE: An action needs to be created and run in order to run this command.
This command calls the Kubernetes API directly. As a result, KUBECONFIG has to be configured
with the same cluster as the one which the Gateway points to.`)

cmd.Example = heredoc.WithCLIName(`
# Print the logs of an Action:
<cli> logs example
# Follow the logs of an Action:
<cli> logs example --follow
# Print the logs of single container in a pod
<cli> logs example step-pod -c step-pod-container
# Print the logs of an Action's step:
<cli> logs example step-pod
# Print the logs of the latest executed Action:
<cli> logs @latest
`, cli.Name)

client.AddKubectlFlagsToCmd(cmd)

for _, hide := range argoHiddenFlags {
_ = cmd.PersistentFlags().MarkHidden(hide)
}

return cmd
}
2 changes: 1 addition & 1 deletion cmd/cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func NewRoot() *cobra.Command {
},
}

rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "Path to the YAML config file")
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "C", "", "Path to the YAML config file")
cli.RegisterVerboseModeFlag(rootCmd.PersistentFlags())

rootCmd.AddCommand(
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ capact [flags]
### Options

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-h, --help help for capact
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```
Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/docs/capact_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This command consists of multiple subcommands to interact with target Actions
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand All @@ -25,6 +25,7 @@ This command consists of multiple subcommands to interact with target Actions
* [capact action create](capact_action_create.md) - Creates/renders a new Action with a specified Interface
* [capact action delete](capact_action_delete.md) - Deletes the Action
* [capact action get](capact_action_get.md) - Displays one or multiple Actions
* [capact action logs](capact_action_logs.md) - Print the Action's logs
* [capact action run](capact_action_run.md) - Queues up a specified Action for processing by the workflow engine
* [capact action wait](capact_action_wait.md) - Wait for a specific condition of a given Action
* [capact action watch](capact_action_watch.md) - Watch an Action until it has completed execution
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_action_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ capact action create INTERFACE [flags]
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_action_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ capact action delete --name-regex='upgrade-*' --namespace=foo
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_action_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ capact action get funny-stallman -ojson
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
67 changes: 67 additions & 0 deletions cmd/cli/docs/capact_action_logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: capact action logs
---

## capact action logs

Print the Action's logs

### Synopsis

Print the Action's logs

NOTE: An action needs to be created and run in order to run this command.
This command calls the Kubernetes API directly. As a result, KUBECONFIG has to be configured
with the same cluster as the one which the Gateway points to.

```
capact action logs ACTION [POD] [flags]
```

### Examples

```
# Print the logs of an Action:
capact logs example
# Follow the logs of an Action:
capact logs example --follow
# Print the logs of single container in a pod
capact logs example step-pod -c step-pod-container
# Print the logs of an Action's step:
capact logs example step-pod
# Print the logs of the latest executed Action:
capact logs @latest
```

### Options

```
-c, --container string Print the logs of this container (default "main")
-f, --follow Specify if the logs should be streamed.
--grep string grep for lines
-h, --help help for logs
-n, --namespace string If present, the namespace scope for this CLI request
--no-color Disable colorized output
-p, --previous Specify if the previously terminated container logs should be returned.
--since duration Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Only one of since-time / since may be used.
--since-time string Only return logs after a specific date (RFC3339). Defaults to all logs. Only one of since-time / since may be used.
--tail int If set, the number of lines from the end of the logs to show. If not specified, logs are shown from the creation of the container or sinceSeconds or sinceTime (default -1)
--timestamps Include timestamps on each line in the log output
```

### Options inherited from parent commands

```
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

### SEE ALSO

* [capact action](capact_action.md) - This command consists of multiple subcommands to interact with target Actions

2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_action_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ capact action run ACTION [flags]
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_action_wait.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ capact act wait --for=phase=READY_TO_RUN example
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_action_watch.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ capact action watch @latest
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Subcommand for alpha features in the CLI
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_alpha_archive-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Subcommand for various manifest generation operations
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_alpha_archive-images_helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ capact alpha archive-images helm --version 0.5.0 --output-stdout | gzip > myimag
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ capact completion [bash|zsh|fish|powershell] [flags]
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Display or change configuration settings for the Hub
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_config_get-contexts.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ capact config get-contexts
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_config_set-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ capact config set-context localhost:8080
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This command consists of multiple subcommands to interact with a Capact environm
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_environment_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This command consists of multiple subcommands to create a Capact environment
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_environment_create_k3d.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ capact environment create k3d [flags]
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_environment_create_kind.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ capact environment create kind [flags]
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_environment_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This command consists of multiple subcommands to delete created Capact environme
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_environment_delete_k3d.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ capact environment delete k3d [flags]
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_environment_delete_kind.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ capact environment delete kind [flags]
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_hub.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This command consists of multiple subcommands to interact with Hub server.
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_hub_implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This command consists of multiple subcommands to interact with Implementations s
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_hub_implementation_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ capact hub implementations get cap.interface.database.postgresql.install -oyaml
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_hub_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This command consists of multiple subcommands to interact with Interfaces stored
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_hub_interface_browse.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ capact hub interface browse [flags]
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/docs/capact_hub_interface_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ capact hub interfaces get cap.interface.database.postgresql.install -ojson
### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
-C, --config string Path to the YAML config file
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

Expand Down
Loading

0 comments on commit a6adafa

Please sign in to comment.