pulumi / esc

Pulumi ESC (Environments, Secrets, and Configuration) for cloud applications and infrastructure.
https://www.pulumi.com/product/esc/
Apache License 2.0
216 stars 7 forks source link

cli: add support for environment tags #345

Closed dschaller closed 2 months ago

dschaller commented 3 months ago

add new CLI commands for CRUD operations against environment tags

> esc env tag ls localumi/env-a

This command lists all tags on the environment in the format below
Name: <tag name>
Value: <tag value>
Last updated at <timestamp> by <user>

> esc env tag localumi/env-b owner dschaller
This command adds a new tag to the specified environment and returns the new tag output similar to the format from list.
If there is already a tag with the specified key (e.g. owner) it will update the value to the new value.

Optionally, users can pass in another argument to specify an update to the key.
> esc env tag localumi/env-b owner Owner dschaller

> esc env tag rm localumi/env-b owner
This command removes a tag from the specified environment with the specified name
dschaller commented 3 months ago

Also open to the idea of esc env tag rm and esc env tag update by ID both taking another argument as the tag or tag ID if it makes more sense

pgavlin commented 3 months ago

The tag IDs are a bit surprising. We don't typically expose IDs like this--I would have expected this to act exactly like stack tags.

infrastructure ❯ pulumi stack tag   
Manage stack tags

Stacks have associated metadata in the form of tags. Each tag consists of a name
and value. The `get`, `ls`, `rm`, and `set` commands can be used to manage tags.
Some tags are automatically assigned based on the environment each time a stack
is updated.

Usage:
  pulumi stack tag [command]

Available Commands:
  get         Get a single stack tag value
  ls          List all stack tags
  rm          Remove a stack tag
  set         Set a stack tag

Flags:
  -h, --help           help for tag
  -s, --stack string   The name of the stack to operate on. Defaults to the current stack

Global Flags:
      --color string                 Colorize output. Choices are: always, never, raw, auto (default "auto")
  -C, --cwd string                   Run pulumi as if it had been started in another directory
      --disable-integrity-checking   Disable integrity checking of checkpoint files
  -e, --emoji                        Enable emojis in the output (default true)
  -Q, --fully-qualify-stack-names    Show fully-qualified stack names
      --logflow                      Flow log settings to child processes (like plugins)
      --logtostderr                  Log to stderr instead of to files
      --memprofilerate int           Enable more precise (and expensive) memory allocation profiles by setting runtime.MemProfileRate
      --non-interactive              Disable interactive mode for all commands
      --profiling string             Emit CPU and memory profiles and an execution trace to '[filename].[pid].{cpu,mem,trace}', respectively
      --tracing file:                Emit tracing to the specified endpoint. Use the file: scheme to write tracing data to a local file
  -v, --verbose int                  Enable verbose logging (e.g., v=3); anything >3 is very verbose

Use "pulumi stack tag [command] --help" for more information about a command.
dschaller commented 3 months ago

👍 I can change the behavior to mirror stack tags.

I intentionally made some tweaks to these commands vs the stack tags for a few reasons:

dschaller commented 2 months ago

@pgavlin updated these commands to more closely align with stack tags

As an aside there is also a fix to show local time if the UTC flag is not set since most of the timestamps coming back from the server are UTC

pgavlin commented 2 months ago

Could you update the PR description with the new command structure? Also--while the example output is nice, it's a bit tough to parse. I think I'd prefer a brief plain-english description of what each command does to the output.

dschaller commented 2 months ago

@pgavlin updated the description