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

Add cli subcommands for manipulating Sources #2375

Merged
merged 6 commits into from
Feb 4, 2025

Conversation

damemi
Copy link
Contributor

@damemi damemi commented Feb 3, 2025

This adds a new odigos sources subcommand for manipulating Sources:

  • odigos sources create ...
  • odigos sources update ...
  • odigos sources delete ...

Each command takes the following flags:

  • --namespace: The namespace of the Source to act on
  • --workload-kind: Applies the command to all Sources with the matching label
  • --workload-name: Applies the command to all Sources with the matching label
  • --workload-namespace: Applies the command to all Sources with the matching label
  • --group: Applies the command to all Sources in the group

Create

This command creates a Source, for example:

odigos sources create my-source --workload-kind=Deployment --workload-name=FooBar --workload-namespace=default

It requires the kind, name, and namespace flags (enforced by the Source validation webhook, along with all other checks provided by that webhook).

It also provides the following flags:

  • --disable-instrumentation: set spec.disableInstrumentation: <value> (default: false)

Update

This command updates any Sources matching the label flags, for example:

odigos sources update --workload-kind=DaemonSet --disable-instrumentation

Because this can update many Sources at once, there is a confirmation prompt.

It also provides the following flags:

  • --all-namespaces: apply the change to Sources in all namespaces
  • --yes: Skip the confirmation prompt
  • --set-group: Add the odigos.io/group-<value> label to the Source
  • --remove-group: Remove the odigos.io/group-<value> label from the Source

Delete

This command deletes all Sources matching the provided labels, for example:

odigos sources delete --group mygroup --all-namespaces

It also provides the following flags:

  • --all-namespaces: apply the change to Sources in all namespaces
  • --yes: Skip the confirmation prompt

Copy link

@damemi damemi force-pushed the sources-subcommand branch 2 times, most recently from 7a086eb to 3be76f3 Compare February 3, 2025 21:54
@damemi damemi force-pushed the sources-subcommand branch from 3be76f3 to 535cd3a Compare February 3, 2025 21:57
@damemi damemi changed the title Add subcommands for manipulating Sources Add cli subcommands for manipulating Sources Feb 3, 2025
@damemi damemi force-pushed the sources-subcommand branch from 535cd3a to 69904d0 Compare February 3, 2025 22:00
@damemi damemi force-pushed the sources-subcommand branch from 69904d0 to b42996d Compare February 3, 2025 22:02
Copy link
Collaborator

@RonFed RonFed left a comment

Choose a reason for hiding this comment

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

🥇

Comment on lines +225 to +228
sourceFlags.StringVar(&workloadKindFlag, workloadKindFlagName, "", "Kubernetes Kind for entity (one of: Deployment, DaemonSet, StatefulSet, Namespace)")
sourceFlags.StringVar(&workloadNameFlag, workloadNameFlagName, "", "Name of entity for Source")
sourceFlags.StringVar(&workloadNamespaceFlag, workloadNamespaceFlagName, "", "Namespace of entity for Source")
sourceFlags.StringVar(&sourceGroupFlag, sourceGroupFlagName, "", "Name of Source group to use")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wonder if we should add a short flag as well for these flags

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about that, it's kind of annoying to type the full flag out each time

@damemi damemi enabled auto-merge (squash) February 4, 2025 14:39
@damemi damemi force-pushed the sources-subcommand branch from 6de5372 to 6efdc64 Compare February 4, 2025 14:56
@damemi damemi merged commit 6544c9d into odigos-io:main Feb 4, 2025
41 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants