Skip to content

Commit 6bc4a49

Browse files
committed
feat: add annotations on core types with --annotation filter on browse/workspace list
1 parent 3adaabc commit 6bc4a49

29 files changed

+289
-33
lines changed

cmd/internal/browse.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func RegisterBrowseCmd(ctx *context.Context, rootCmd *cobra.Command) {
5757
RegisterFlag(ctx, browseCmd, *flags.FilterNamespaceFlag)
5858
RegisterFlag(ctx, browseCmd, *flags.FilterVerbFlag)
5959
RegisterFlag(ctx, browseCmd, *flags.FilterTagFlag)
60+
RegisterFlag(ctx, browseCmd, *flags.FilterAnnotationFlag)
6061
RegisterFlag(ctx, browseCmd, *flags.FilterExecSubstringFlag)
6162
RegisterFlag(ctx, browseCmd, *flags.AllNamespacesFlag)
6263
RegisterFlag(ctx, browseCmd, *flags.VisibilityFlag)
@@ -105,6 +106,7 @@ func executableLibrary(ctx *context.Context, cmd *cobra.Command, _ []string) {
105106

106107
verbFilter := flags.ValueFor[string](cmd, *flags.FilterVerbFlag, false)
107108
tagsFilter := flags.ValueFor[[]string](cmd, *flags.FilterTagFlag, false)
109+
annotationFilter := flags.ValueFor[[]string](cmd, *flags.FilterAnnotationFlag, false)
108110
subStr := flags.ValueFor[string](cmd, *flags.FilterExecSubstringFlag, false)
109111

110112
visStr := flags.ValueFor[string](cmd, *flags.VisibilityFlag, false)
@@ -129,12 +131,13 @@ func executableLibrary(ctx *context.Context, cmd *cobra.Command, _ []string) {
129131
libraryModel := execIO.NewLibraryView(
130132
ctx, allWs, allExecs,
131133
execIO.Filter{
132-
Workspace: wsFilter,
133-
Namespace: nsFilter,
134-
Verb: executable.Verb(verbFilter),
135-
Tags: tagsFilter,
136-
Substring: subStr,
137-
Visibility: visibilityFilter,
134+
Workspace: wsFilter,
135+
Namespace: nsFilter,
136+
Verb: executable.Verb(verbFilter),
137+
Tags: tagsFilter,
138+
Annotations: annotationFilter,
139+
Substring: subStr,
140+
Visibility: visibilityFilter,
138141
},
139142
runFunc,
140143
)
@@ -161,6 +164,7 @@ func listExecutables(ctx *context.Context, cmd *cobra.Command, _ []string) {
161164

162165
verbFilter := flags.ValueFor[string](cmd, *flags.FilterVerbFlag, false)
163166
tagsFilter := flags.ValueFor[[]string](cmd, *flags.FilterTagFlag, false)
167+
annotationFilter := flags.ValueFor[[]string](cmd, *flags.FilterAnnotationFlag, false)
164168
outputFormat := flags.ValueFor[string](cmd, *flags.OutputFormatFlag, false)
165169
substr := flags.ValueFor[string](cmd, *flags.FilterExecSubstringFlag, false)
166170

@@ -183,6 +187,7 @@ func listExecutables(ctx *context.Context, cmd *cobra.Command, _ []string) {
183187
FilterByNamespace(nsFilter).
184188
FilterByVerb(executable.Verb(verbFilter)).
185189
FilterByTags(tagsFilter).
190+
FilterByAnnotations(annotationFilter).
186191
FilterBySubstring(substr)
187192

188193
if TUIEnabled(ctx, cmd) {

cmd/internal/flags/types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ var FilterTagFlag = &Metadata{
8787
Required: false,
8888
}
8989

90+
var FilterAnnotationFlag = &Metadata{
91+
Name: "annotation",
92+
Usage: "Filter by annotations. Format: 'key=value' for exact value match, " +
93+
"or 'key' for presence regardless of value. Repeat the flag for multiple selectors; " +
94+
"all selectors must match (AND).",
95+
Default: []string{},
96+
Required: false,
97+
}
98+
9099
var OutputFormatFlag = &Metadata{
91100
Name: "output",
92101
Shorthand: "o",

cmd/internal/template.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ func registerListTemplateCmd(ctx *context.Context, templateCmd *cobra.Command) {
123123
}
124124

125125
func listTemplateFunc(ctx *context.Context, cmd *cobra.Command, _ []string) {
126-
// TODO: include unregistered templates within the current ws
126+
// TODO: include unregistered templates within the current ws;
127+
// add --annotation filter flags (mirroring browse / workspace list)
127128
tmpls, err := filesystem.LoadFlowFileTemplates(ctx.Config.Templates)
128129
if err != nil {
129130
logger.Log().FatalErr(err)

cmd/internal/workspace.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,14 @@ func registerListWorkspaceCmd(ctx *context.Context, wsCmd *cobra.Command) {
363363
}
364364
RegisterFlag(ctx, listCmd, *flags.OutputFormatFlag)
365365
RegisterFlag(ctx, listCmd, *flags.FilterTagFlag)
366+
RegisterFlag(ctx, listCmd, *flags.FilterAnnotationFlag)
366367
wsCmd.AddCommand(listCmd)
367368
}
368369

369370
func listWorkspaceFunc(ctx *context.Context, cmd *cobra.Command, _ []string) {
370371
outputFormat := flags.ValueFor[string](cmd, *flags.OutputFormatFlag, false)
371372
tagsFilter := flags.ValueFor[[]string](cmd, *flags.FilterTagFlag, false)
373+
annotationFilter := flags.ValueFor[[]string](cmd, *flags.FilterAnnotationFlag, false)
372374

373375
workspaceCache, err := ctx.WorkspacesCache.GetLatestData()
374376
if err != nil {
@@ -382,6 +384,9 @@ func listWorkspaceFunc(ctx *context.Context, cmd *cobra.Command, _ []string) {
382384
if !common.Tags(ws.Tags).HasAnyTag(tagsFilter) {
383385
continue
384386
}
387+
if !common.Annotations(ws.Annotations).MatchesAnnotationSelectors(annotationFilter) {
388+
continue
389+
}
385390
filteredWorkspaces = append(filteredWorkspaces, ws)
386391
}
387392

docs/cli/flow_browse.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ flow browse [EXECUTABLE-REFERENCE] [flags]
1919
### Options
2020

2121
```
22-
-a, --all List from all namespaces.
23-
-f, --filter string Filter executable by reference substring.
24-
-h, --help help for browse
25-
-l, --list Show a simple list view of executables instead of interactive discovery.
26-
-n, --namespace string Filter executables by namespace.
27-
-o, --output string Output format. One of: yaml, json, or tui.
28-
-t, --tag stringArray Filter by tags.
29-
-v, --verb string Filter executables by verb.
30-
--visibility string Filter by visibility level (hierarchical). Valid: public, private, internal, hidden. Default: private
31-
-w, --workspace string Filter executables by workspace.
22+
-a, --all List from all namespaces.
23+
--annotation stringArray Filter by annotations. Format: 'key=value' for exact value match, or 'key' for presence regardless of value. Repeat the flag for multiple selectors; all selectors must match (AND).
24+
-f, --filter string Filter executable by reference substring.
25+
-h, --help help for browse
26+
-l, --list Show a simple list view of executables instead of interactive discovery.
27+
-n, --namespace string Filter executables by namespace.
28+
-o, --output string Output format. One of: yaml, json, or tui.
29+
-t, --tag stringArray Filter by tags.
30+
-v, --verb string Filter executables by verb.
31+
--visibility string Filter by visibility level (hierarchical). Valid: public, private, internal, hidden. Default: private
32+
-w, --workspace string Filter executables by workspace.
3233
```
3334

3435
### Options inherited from parent commands

docs/cli/flow_workspace_list.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ flow workspace list [flags]
99
### Options
1010

1111
```
12-
-h, --help help for list
13-
-o, --output string Output format. One of: yaml, json, or tui.
14-
-t, --tag stringArray Filter by tags.
12+
--annotation stringArray Filter by annotations. Format: 'key=value' for exact value match, or 'key' for presence regardless of value. Repeat the flag for multiple selectors; all selectors must match (AND).
13+
-h, --help help for list
14+
-o, --output string Output format. One of: yaml, json, or tui.
15+
-t, --tag stringArray Filter by tags.
1516
```
1617

1718
### Options inherited from parent commands

docs/public/schemas/flowfile_schema.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
"type": "string"
1313
}
1414
},
15+
"CommonAnnotations": {
16+
"description": "A map of arbitrary string key/value metadata attached to the object.\nAnnotations are intended for use by external tools and integrations to\nstore system metadata. Unlike tags, annotations are not used for\nfiltering or display in the Flow UI - treat them as opaque state.\nKeys should be namespaced (e.g. `my-tool.example.com/state`) to avoid\ncollisions between tools.\n",
17+
"type": "object",
18+
"additionalProperties": {
19+
"type": "string"
20+
}
21+
},
1522
"CommonTags": {
1623
"description": "A list of tags.\nTags can be used with list commands to filter returned data.\n",
1724
"type": "array",
@@ -42,6 +49,10 @@
4249
"$ref": "#/definitions/CommonAliases",
4350
"default": []
4451
},
52+
"annotations": {
53+
"$ref": "#/definitions/CommonAnnotations",
54+
"default": {}
55+
},
4556
"description": {
4657
"description": "A description of the executable.\nThis description is rendered as markdown in the interactive UI.\n",
4758
"type": "string",
@@ -673,6 +684,10 @@
673684
"Verb": {}
674685
},
675686
"properties": {
687+
"annotations": {
688+
"$ref": "#/definitions/CommonAnnotations",
689+
"default": {}
690+
},
676691
"description": {
677692
"description": "A description of the executables defined within the flow file. This description will used as a shared description\nfor all executables in the flow file.\n",
678693
"type": "string",

docs/public/schemas/template_schema.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@
4646
}
4747
}
4848
},
49+
"CommonAnnotations": {
50+
"description": "A map of arbitrary string key/value metadata attached to the object.\nAnnotations are intended for use by external tools and integrations to\nstore system metadata. Unlike tags, annotations are not used for\nfiltering or display in the Flow UI - treat them as opaque state.\nKeys should be namespaced (e.g. `my-tool.example.com/state`) to avoid\ncollisions between tools.\n",
51+
"type": "object",
52+
"additionalProperties": {
53+
"type": "string"
54+
}
55+
},
4956
"ExecutableRef": {
5057
"description": "A reference to an executable.\nThe format is `\u003cverb\u003e \u003cworkspace\u003e/\u003cnamespace\u003e:\u003cexecutable name\u003e`.\nFor example, `exec ws/ns:my-workflow`.\n\n- If the workspace is not specified, the current workspace will be used.\n- If the namespace is not specified, the current namespace will be used.\n- Excluding the name will reference the executable with a matching verb but an unspecified name and namespace (e.g. `exec ws` or simply `exec`).\n",
5158
"type": "string"
@@ -135,6 +142,10 @@
135142
}
136143
},
137144
"properties": {
145+
"annotations": {
146+
"$ref": "#/definitions/CommonAnnotations",
147+
"default": {}
148+
},
138149
"artifacts": {
139150
"description": "A list of artifacts to be copied after generating the flow file.",
140151
"type": "array",

docs/public/schemas/workspace_schema.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
"description": "Configuration for a workspace in the Flow CLI.\nThis configuration is used to define the settings for a workspace.\nEvery workspace has a workspace config file named `flow.yaml` in the root of the workspace directory.\n",
66
"type": "object",
77
"definitions": {
8+
"CommonAnnotations": {
9+
"description": "A map of arbitrary string key/value metadata attached to the object.\nAnnotations are intended for use by external tools and integrations to\nstore system metadata. Unlike tags, annotations are not used for\nfiltering or display in the Flow UI - treat them as opaque state.\nKeys should be namespaced (e.g. `my-tool.example.com/state`) to avoid\ncollisions between tools.\n",
10+
"type": "object",
11+
"additionalProperties": {
12+
"type": "string"
13+
}
14+
},
815
"CommonTags": {
916
"description": "A list of tags.\nTags can be used with list commands to filter returned data.\n",
1017
"type": "array",
@@ -45,6 +52,10 @@
4552
}
4653
},
4754
"properties": {
55+
"annotations": {
56+
"$ref": "#/definitions/CommonAnnotations",
57+
"default": {}
58+
},
4859
"description": {
4960
"description": "A description of the workspace. This description is rendered as markdown in the interactive UI.",
5061
"type": "string",

docs/types/flowfile.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ in order to be discovered by the CLI. It's configuration is used to define a gro
1818

1919
| Field | Description | Type | Default | Required |
2020
| ----- | ----------- | ---- | ------- | :--------: |
21+
| `annotations` | | [CommonAnnotations](#commonannotations) | map[] | |
2122
| `description` | A description of the executables defined within the flow file. This description will used as a shared description for all executables in the flow file. | `string` | | |
2223
| `descriptionFile` | A path to a markdown file that contains the description of the executables defined within the flow file. | `string` | | |
2324
| `executables` | | `array` ([Executable](#executable)) | [] | |
@@ -39,6 +40,21 @@ Alternate names that can be used to reference the executable in the CLI.
3940

4041

4142

43+
### CommonAnnotations
44+
45+
A map of arbitrary string key/value metadata attached to the object.
46+
Annotations are intended for use by external tools and integrations to
47+
store system metadata. Unlike tags, annotations are not used for
48+
filtering or display in the Flow UI - treat them as opaque state.
49+
Keys should be namespaced (e.g. `my-tool.example.com/state`) to avoid
50+
collisions between tools.
51+
52+
53+
**Type:** `map` (`string` -> `string`)
54+
55+
56+
57+
4258
### CommonTags
4359

4460
A list of tags.
@@ -86,6 +102,7 @@ Executables are the building blocks of workflows and are used to define the acti
86102
| Field | Description | Type | Default | Required |
87103
| ----- | ----------- | ---- | ------- | :--------: |
88104
| `aliases` | | [CommonAliases](#commonaliases) | [] | |
105+
| `annotations` | | [CommonAnnotations](#commonannotations) | map[] | |
89106
| `description` | A description of the executable. This description is rendered as markdown in the interactive UI. | `string` | | |
90107
| `exec` | | [ExecutableExecExecutableType](#executableexecexecutabletype) | | |
91108
| `launch` | | [ExecutableLaunchExecutableType](#executablelaunchexecutabletype) | | |

0 commit comments

Comments
 (0)