Skip to content

Commit

Permalink
feat: add autocomplete for labels for archived workflow (argoproj#6776)
Browse files Browse the repository at this point in the history
Signed-off-by: Tianchu Zhao <evantczhao@gmail.com>
Signed-off-by: kriti-sc <kathuriakriti1@gmail.com>
  • Loading branch information
tczhao authored and kriti-sc committed Oct 24, 2021
1 parent ef60221 commit 2612992
Show file tree
Hide file tree
Showing 32 changed files with 2,275 additions and 673 deletions.
24 changes: 24 additions & 0 deletions api/jsonschema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5429,6 +5429,30 @@
"io.argoproj.workflow.v1alpha1.Item": {
"description": "Item expands a single workflow step into multiple parallel steps The value of Item can be a map, string, bool, or number"
},
"io.argoproj.workflow.v1alpha1.LabelKeys": {
"description": "LabelKeys is list of keys",
"properties": {
"items": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"io.argoproj.workflow.v1alpha1.LabelValues": {
"description": "Labels is list of workflow labels",
"properties": {
"items": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"io.argoproj.workflow.v1alpha1.LifecycleHook": {
"properties": {
"arguments": {
Expand Down
126 changes: 126 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,108 @@
}
}
},
"/api/v1/archived-workflows-label-keys": {
"get": {
"tags": [
"ArchivedWorkflowService"
],
"operationId": "ArchivedWorkflowService_ListArchivedWorkflowLabelKeys",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.LabelKeys"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/grpc.gateway.runtime.Error"
}
}
}
}
},
"/api/v1/archived-workflows-label-values": {
"get": {
"tags": [
"ArchivedWorkflowService"
],
"operationId": "ArchivedWorkflowService_ListArchivedWorkflowLabelValues",
"parameters": [
{
"type": "string",
"description": "A selector to restrict the list of returned objects by their labels.\nDefaults to everything.\n+optional.",
"name": "listOptions.labelSelector",
"in": "query"
},
{
"type": "string",
"description": "A selector to restrict the list of returned objects by their fields.\nDefaults to everything.\n+optional.",
"name": "listOptions.fieldSelector",
"in": "query"
},
{
"type": "boolean",
"description": "Watch for changes to the described resources and return them as a stream of\nadd, update, and remove notifications. Specify resourceVersion.\n+optional.",
"name": "listOptions.watch",
"in": "query"
},
{
"type": "boolean",
"description": "allowWatchBookmarks requests watch events with type \"BOOKMARK\".\nServers that do not implement bookmarks may ignore this flag and\nbookmarks are sent at the server's discretion. Clients should not\nassume bookmarks are returned at any specific interval, nor may they\nassume the server will send any BOOKMARK event during a session.\nIf this is not a watch, this field is ignored.\nIf the feature gate WatchBookmarks is not enabled in apiserver,\nthis field is ignored.\n+optional.",
"name": "listOptions.allowWatchBookmarks",
"in": "query"
},
{
"type": "string",
"description": "resourceVersion sets a constraint on what resource versions a request may be served from.\nSee https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for\ndetails.\n\nDefaults to unset\n+optional",
"name": "listOptions.resourceVersion",
"in": "query"
},
{
"type": "string",
"description": "resourceVersionMatch determines how resourceVersion is applied to list calls.\nIt is highly recommended that resourceVersionMatch be set for list calls where\nresourceVersion is set\nSee https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for\ndetails.\n\nDefaults to unset\n+optional",
"name": "listOptions.resourceVersionMatch",
"in": "query"
},
{
"type": "string",
"format": "int64",
"description": "Timeout for the list/watch call.\nThis limits the duration of the call, regardless of any activity or inactivity.\n+optional.",
"name": "listOptions.timeoutSeconds",
"in": "query"
},
{
"type": "string",
"format": "int64",
"description": "limit is a maximum number of responses to return for a list call. If more items exist, the\nserver will set the `continue` field on the list metadata to a value that can be used with the\nsame initial query to retrieve the next set of results. Setting a limit may return fewer than\nthe requested amount of items (up to zero items) in the event all requested objects are\nfiltered out and clients should only use the presence of the continue field to determine whether\nmore results are available. Servers may choose not to support the limit argument and will return\nall of the available results. If limit is specified and the continue field is empty, clients may\nassume that no more results are available. This field is not supported if watch is true.\n\nThe server guarantees that the objects returned when using continue will be identical to issuing\na single list call without a limit - that is, no objects created, modified, or deleted after the\nfirst request is issued will be included in any subsequent continued requests. This is sometimes\nreferred to as a consistent snapshot, and ensures that a client that is using limit to receive\nsmaller chunks of a very large result can ensure they see all possible objects. If objects are\nupdated during a chunked list the version of the object that was present at the time the first list\nresult was calculated is returned.",
"name": "listOptions.limit",
"in": "query"
},
{
"type": "string",
"description": "The continue option should be set when retrieving more results from the server. Since this value is\nserver defined, clients may only use the continue value from a previous query result with identical\nquery parameters (except for the value of continue) and the server may reject a continue value it\ndoes not recognize. If the specified continue value is no longer valid whether due to expiration\n(generally five to fifteen minutes) or a configuration change on the server, the server will\nrespond with a 410 ResourceExpired error together with a continue token. If the client needs a\nconsistent list, it must restart their list without the continue field. Otherwise, the client may\nsend another list request with the token received with the 410 error, the server will respond with\na list starting from the next key, but from the latest snapshot, which is inconsistent from the\nprevious list results - objects that are created, modified, or deleted after the first list request\nwill be included in the response, as long as their keys are after the \"next key\".\n\nThis field is not supported when watch is true. Clients may start a watch from the last\nresourceVersion value returned by the server and not miss any modifications.",
"name": "listOptions.continue",
"in": "query"
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.LabelValues"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/grpc.gateway.runtime.Error"
}
}
}
}
},
"/api/v1/archived-workflows/{uid}": {
"get": {
"tags": [
Expand Down Expand Up @@ -9573,6 +9675,30 @@
"io.argoproj.workflow.v1alpha1.Item": {
"description": "Item expands a single workflow step into multiple parallel steps The value of Item can be a map, string, bool, or number"
},
"io.argoproj.workflow.v1alpha1.LabelKeys": {
"description": "LabelKeys is list of keys",
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"io.argoproj.workflow.v1alpha1.LabelValues": {
"description": "Labels is list of workflow labels",
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"io.argoproj.workflow.v1alpha1.LifecycleHook": {
"type": "object",
"required": [
Expand Down
29 changes: 29 additions & 0 deletions cmd/argo/commands/archive/list_label_keys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package archive

import (
"fmt"

"github.com/argoproj/pkg/errors"
"github.com/spf13/cobra"

"github.com/argoproj/argo-workflows/v3/cmd/argo/commands/client"
workflowarchivepkg "github.com/argoproj/argo-workflows/v3/pkg/apiclient/workflowarchive"
)

func NewListLabelKeyCommand() *cobra.Command {
command := &cobra.Command{
Use: "list-label-keys",
Short: "list workflows label keys in the archive",
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewArchivedWorkflowServiceClient()
errors.CheckError(err)
keys, err := serviceClient.ListArchivedWorkflowLabelKeys(ctx, &workflowarchivepkg.ListArchivedWorkflowLabelKeysRequest{})
errors.CheckError(err)
for _, str := range keys.Items {
fmt.Printf("%s\n", str)
}
},
}
return command
}
41 changes: 41 additions & 0 deletions cmd/argo/commands/archive/list_label_values.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package archive

import (
"fmt"

"github.com/argoproj/pkg/errors"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/argoproj/argo-workflows/v3/cmd/argo/commands/client"
workflowarchivepkg "github.com/argoproj/argo-workflows/v3/pkg/apiclient/workflowarchive"
)

func NewListLabelValueCommand() *cobra.Command {
var (
selector string
)
command := &cobra.Command{
Use: "list-label-values",
Short: "get workflow label values in the archive",
Run: func(cmd *cobra.Command, args []string) {
listOpts := &metav1.ListOptions{
LabelSelector: selector,
}

ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewArchivedWorkflowServiceClient()
errors.CheckError(err)
labels, err := serviceClient.ListArchivedWorkflowLabelValues(ctx, &workflowarchivepkg.ListArchivedWorkflowLabelValuesRequest{ListOptions: listOpts})
errors.CheckError(err)

for _, str := range labels.Items {
fmt.Printf("%s\n", str)
}
},
}
command.Flags().StringVarP(&selector, "selector", "l", "", "Selector (label query) to query on, allows 1 value (e.g. -l key1)")
err := command.MarkFlagRequired("selector")
errors.CheckError(err)
return command
}
2 changes: 2 additions & 0 deletions cmd/argo/commands/archive/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ func NewArchiveCommand() *cobra.Command {
command.AddCommand(NewListCommand())
command.AddCommand(NewGetCommand())
command.AddCommand(NewDeleteCommand())
command.AddCommand(NewListLabelKeyCommand())
command.AddCommand(NewListLabelValueCommand())
return command
}
2 changes: 2 additions & 0 deletions docs/cli/argo_archive.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ argo archive [flags]
* [argo archive delete](argo_archive_delete.md) - delete a workflow in the archive
* [argo archive get](argo_archive_get.md) - get a workflow in the archive
* [argo archive list](argo_archive_list.md) - list workflows in the archive
* [argo archive list-label-keys](argo_archive_list-label-keys.md) - list workflows label keys in the archive
* [argo archive list-label-values](argo_archive_list-label-values.md) - get workflow label values in the archive

49 changes: 49 additions & 0 deletions docs/cli/argo_archive_list-label-keys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## argo archive list-label-keys

list workflows label keys in the archive

```
argo archive list-label-keys [flags]
```

### Options

```
-h, --help help for list-label-keys
```

### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use
--context string The name of the kubeconfig context to use
--gloglevel int Set the glog logging level
--insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
-k, --insecure-skip-verify If true, the Argo Server's certificate will not be checked for validity. This will make your HTTPS connections insecure. Defaults to the ARGO_INSECURE_SKIP_VERIFY environment variable.
--instanceid string submit with a specific controller's instance id label. Default to the ARGO_INSTANCEID environment variable.
--kubeconfig string Path to a kube config. Only required if out-of-cluster
--loglevel string Set the logging level. One of: debug|info|warn|error (default "info")
-n, --namespace string If present, the namespace scope for this CLI request
--password string Password for basic authentication to the API server
--request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
-e, --secure Whether or not the server is using TLS with the Argo Server. Defaults to the ARGO_SECURE environment variable. (default true)
--server string The address and port of the Kubernetes API server
--tls-server-name string If provided, this name will be used to validate server certificate. If this is not provided, hostname used to contact the server is used.
--token string Bearer token for authentication to the API server
--user string The name of the kubeconfig user to use
--username string Username for basic authentication to the API server
-v, --verbose Enabled verbose logging, i.e. --loglevel debug
```

### SEE ALSO

* [argo archive](argo_archive.md) - manage the workflow archive

50 changes: 50 additions & 0 deletions docs/cli/argo_archive_list-label-values.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## argo archive list-label-values

get workflow label values in the archive

```
argo archive list-label-values [flags]
```

### Options

```
-h, --help help for list-label-values
-l, --selector string Selector (label query) to query on, allows 1 value (e.g. -l key1)
```

### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use
--context string The name of the kubeconfig context to use
--gloglevel int Set the glog logging level
--insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
-k, --insecure-skip-verify If true, the Argo Server's certificate will not be checked for validity. This will make your HTTPS connections insecure. Defaults to the ARGO_INSECURE_SKIP_VERIFY environment variable.
--instanceid string submit with a specific controller's instance id label. Default to the ARGO_INSTANCEID environment variable.
--kubeconfig string Path to a kube config. Only required if out-of-cluster
--loglevel string Set the logging level. One of: debug|info|warn|error (default "info")
-n, --namespace string If present, the namespace scope for this CLI request
--password string Password for basic authentication to the API server
--request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
-e, --secure Whether or not the server is using TLS with the Argo Server. Defaults to the ARGO_SECURE environment variable. (default true)
--server string The address and port of the Kubernetes API server
--tls-server-name string If provided, this name will be used to validate server certificate. If this is not provided, hostname used to contact the server is used.
--token string Bearer token for authentication to the API server
--user string The name of the kubeconfig user to use
--username string Username for basic authentication to the API server
-v, --verbose Enabled verbose logging, i.e. --loglevel debug
```

### SEE ALSO

* [argo archive](argo_archive.md) - manage the workflow archive

Loading

0 comments on commit 2612992

Please sign in to comment.