Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added label selectors to argo cron list. Fixes #11158 #11202

Merged
merged 4 commits into from
Jun 26, 2023

Conversation

dbragdon1
Copy link
Contributor

Fixes #11158 by adding label selectors to argo cron list command.

Motivation

As stated in #11158 :

My team has many different cronworkflows, and we often use the argo cron list command to summarize them. Sometimes we wish to only view different groups of related workflows, which we cluster together using kubernetes labels. We really like the functionality of argo cron list for the information it provides regarding last runs, next runs, etc, but sometimes we only want to select a subset of cronworkflows based on specific labels. Currently our solution is to pipe the output of argo cron list to something like grep, but this only allows us to filter the result based on the name of the cronworkflow.

Modifications

Added --selector flag to argo cron list command to support selectively querying CronWorkflow objects based on labels defined under metadata section. Functionality is identical to the kubectl --selector flag.

Optional -l flag now appears in usage message:

Usage:
  argo cron list [flags]

Flags:
  -A, --all-namespaces    Show workflows from all namespaces
  -h, --help              help for list
  -o, --output string     Output format. One of: wide|name
  -l, --selector string   Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). Matching objects must satisfy all of the specified label constraints.

Example:

If a workflow is created with the following metadata:

apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
  name: test-cwf-with-labels
  labels:
    client: importantclient

You can query for this label by running

argo cron list -l client=importantclient

or

argo cron list --selector client=importantclient

and the result will be the standard argo cron list output:

NAME                   AGE   LAST RUN   NEXT RUN   SCHEDULE    TIMEZONE              SUSPENDED
test-cwf-with-labels   1h    40s        19s        * * * * *   America/Los_Angeles   false

Verification

Added List with Labels unit test to test/e2e/cli_test.go which creates two cron workflows, one with label client: importantclient and one without, calls argo cron list -l client=importantclient, and makes sure that only cron workflow with appropriate labels is selected.

Copy link
Member

@terrytangyuan terrytangyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to make codegen -B STATIC_FILES=false to fix the CI failures

Signed-off-by: Dylan Bragdon <dylan.bragdon@gmail.com>
Signed-off-by: Dylan Bragdon <dylan.bragdon@gmail.com>
Signed-off-by: Dylan Bragdon <dylan.bragdon@gmail.com>
@terrytangyuan terrytangyuan enabled auto-merge (squash) June 26, 2023 19:12
@terrytangyuan terrytangyuan merged commit 29d63c5 into argoproj:master Jun 26, 2023
22 checks passed
JPZ13 pushed a commit to pipekit/argo-workflows that referenced this pull request Jul 4, 2023
…rgoproj#11202)

Signed-off-by: Dylan Bragdon <dylan.bragdon@gmail.com>
@agilgur5 agilgur5 added the area/cli The `argo` CLI label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli The `argo` CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add label selectors to argo cron list command
3 participants