Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ spec:
```bash
kubectl apply -f workspace.yaml
kubectl apply -f task.yaml
kubectl get tasks -w
axon get tasks -w
```

</details>
Expand Down
2 changes: 1 addition & 1 deletion examples/01-simple-task/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ kubectl apply -f examples/01-simple-task/
3. **Watch the Task:**

```bash
kubectl get tasks -w
axon get tasks -w
```

4. **Stream the agent logs:**
Expand Down
2 changes: 1 addition & 1 deletion examples/02-task-with-workspace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ kubectl apply -f examples/02-task-with-workspace/
4. **Watch the Task:**

```bash
kubectl get tasks -w
axon get tasks -w
```

5. **Stream the agent logs:**
Expand Down
4 changes: 2 additions & 2 deletions examples/03-taskspawner-github-issues/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ kubectl apply -f examples/03-taskspawner-github-issues/
4. **Verify the spawner is running:**

```bash
kubectl get taskspawners -w
axon get taskspawners -w
```

5. **Create a test issue** with the `bug` label in your repository. The
Expand All @@ -52,7 +52,7 @@ kubectl get taskspawners -w
6. **Watch spawned Tasks:**

```bash
kubectl get tasks -w
axon get tasks -w
```

7. **Cleanup:**
Expand Down
4 changes: 2 additions & 2 deletions examples/04-taskspawner-cron/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ kubectl apply -f examples/04-taskspawner-cron/
5. **Verify the spawner is running:**

```bash
kubectl get taskspawners -w
axon get taskspawners -w
```

6. **Watch spawned Tasks after the schedule fires:**

```bash
kubectl get tasks -w
axon get tasks -w
```

7. **Cleanup:**
Expand Down
2 changes: 1 addition & 1 deletion examples/05-task-with-agentconfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ kubectl apply -f examples/05-task-with-agentconfig/
5. **Watch the Task:**

```bash
kubectl get tasks -w
axon get tasks -w
```

6. **Stream the agent logs:**
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ kubectl apply -f examples/<example-directory>/
5. Watch the Task progress:

```bash
kubectl get tasks -w
axon get tasks -w
```

## Tips
Expand Down
51 changes: 48 additions & 3 deletions internal/cli/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func newGetCommand(cfg *ClientConfig) *cobra.Command {

func newGetTaskSpawnerCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Command {
var output string
var watch bool

cmd := &cobra.Command{
Use: "taskspawner [name]",
Expand All @@ -45,6 +46,14 @@ func newGetTaskSpawnerCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Com
return fmt.Errorf("unknown output format %q: must be one of yaml, json", output)
}

if watch && output != "" {
return fmt.Errorf("--watch is not supported with --output")
}

if watch && len(args) == 1 {
return fmt.Errorf("--watch is only supported when listing resources")
}

if *allNamespaces && len(args) == 1 {
return fmt.Errorf("a resource cannot be retrieved by name across all namespaces")
}
Expand Down Expand Up @@ -74,11 +83,16 @@ func newGetTaskSpawnerCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Com
}
}

tsList := &axonv1alpha1.TaskSpawnerList{}
var listOpts []client.ListOption
if !*allNamespaces {
listOpts = append(listOpts, client.InNamespace(ns))
}

if watch {
return watchTaskSpawners(ctx, cl, listOpts, *allNamespaces)
}

tsList := &axonv1alpha1.TaskSpawnerList{}
if err := cl.List(ctx, tsList, listOpts...); err != nil {
return fmt.Errorf("listing task spawners: %w", err)
}
Expand All @@ -97,6 +111,7 @@ func newGetTaskSpawnerCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Com
}

cmd.Flags().StringVarP(&output, "output", "o", "", "Output format (yaml or json)")
cmd.Flags().BoolVarP(&watch, "watch", "w", false, "Watch for changes")

cmd.ValidArgsFunction = completeTaskSpawnerNames(cfg)
_ = cmd.RegisterFlagCompletionFunc("output", cobra.FixedCompletions([]string{"yaml", "json"}, cobra.ShellCompDirectiveNoFileComp))
Expand All @@ -106,6 +121,7 @@ func newGetTaskSpawnerCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Com

func newGetTaskCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Command {
var output string
var watch bool

cmd := &cobra.Command{
Use: "task [name]",
Expand All @@ -117,6 +133,14 @@ func newGetTaskCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Command {
return fmt.Errorf("unknown output format %q: must be one of yaml, json", output)
}

if watch && output != "" {
return fmt.Errorf("--watch is not supported with --output")
}

if watch && len(args) == 1 {
return fmt.Errorf("--watch is only supported when listing resources")
}

if *allNamespaces && len(args) == 1 {
return fmt.Errorf("a resource cannot be retrieved by name across all namespaces")
}
Expand Down Expand Up @@ -146,11 +170,16 @@ func newGetTaskCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Command {
}
}

taskList := &axonv1alpha1.TaskList{}
var listOpts []client.ListOption
if !*allNamespaces {
listOpts = append(listOpts, client.InNamespace(ns))
}

if watch {
return watchTasks(ctx, cl, listOpts, *allNamespaces)
}

taskList := &axonv1alpha1.TaskList{}
if err := cl.List(ctx, taskList, listOpts...); err != nil {
return fmt.Errorf("listing tasks: %w", err)
}
Expand All @@ -169,6 +198,7 @@ func newGetTaskCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Command {
}

cmd.Flags().StringVarP(&output, "output", "o", "", "Output format (yaml or json)")
cmd.Flags().BoolVarP(&watch, "watch", "w", false, "Watch for changes")

cmd.ValidArgsFunction = completeTaskNames(cfg)
_ = cmd.RegisterFlagCompletionFunc("output", cobra.FixedCompletions([]string{"yaml", "json"}, cobra.ShellCompDirectiveNoFileComp))
Expand All @@ -178,6 +208,7 @@ func newGetTaskCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Command {

func newGetWorkspaceCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Command {
var output string
var watch bool

cmd := &cobra.Command{
Use: "workspace [name]",
Expand All @@ -189,6 +220,14 @@ func newGetWorkspaceCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Comma
return fmt.Errorf("unknown output format %q: must be one of yaml, json", output)
}

if watch && output != "" {
return fmt.Errorf("--watch is not supported with --output")
}

if watch && len(args) == 1 {
return fmt.Errorf("--watch is only supported when listing resources")
}

if *allNamespaces && len(args) == 1 {
return fmt.Errorf("a resource cannot be retrieved by name across all namespaces")
}
Expand Down Expand Up @@ -218,11 +257,16 @@ func newGetWorkspaceCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Comma
}
}

wsList := &axonv1alpha1.WorkspaceList{}
var listOpts []client.ListOption
if !*allNamespaces {
listOpts = append(listOpts, client.InNamespace(ns))
}

if watch {
return watchWorkspaces(ctx, cl, listOpts, *allNamespaces)
}

wsList := &axonv1alpha1.WorkspaceList{}
if err := cl.List(ctx, wsList, listOpts...); err != nil {
return fmt.Errorf("listing workspaces: %w", err)
}
Expand All @@ -241,6 +285,7 @@ func newGetWorkspaceCommand(cfg *ClientConfig, allNamespaces *bool) *cobra.Comma
}

cmd.Flags().StringVarP(&output, "output", "o", "", "Output format (yaml or json)")
cmd.Flags().BoolVarP(&watch, "watch", "w", false, "Watch for changes")

cmd.ValidArgsFunction = completeWorkspaceNames(cfg)
_ = cmd.RegisterFlagCompletionFunc("output", cobra.FixedCompletions([]string{"yaml", "json"}, cobra.ShellCompDirectiveNoFileComp))
Expand Down
Loading