UffizziCloud / uffizzi_cli

The command-line interface for the Uffizzi API
Apache License 2.0
87 stars 46 forks source link

Tagging and/or other metadata for Previews and other Uffizzi Resources #136

Open axisofentropy opened 2 years ago

axisofentropy commented 2 years ago

When creating and updating Uffizzi Resources, especially Preview Deployments, users should be able to "tag" and/or add other arbitrary metadata to the Resource. When listing Resources, users should be able to "query" for results that match specified metadata.

Which service(s) is this request for? Both open-source and platform. CLI to start and maybe web interface soon?

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard? Right now our reusable GitHub Actions workflow creates comments on Pull Requests when a Preview is created, and then later refers back to this comment for the Deployment ID as the authoritative association between the Preview and the Pull Request.

Describe the solution you'd like Instead of using GitHub comments to store this association state, I believe we should instead enable metadata i.e. "tagging" for each Uffizzi Deployment. This will enable many user stories we can't yet imagine, beyond simply associating Pull Requests.

We should probably use simple "labels" of key-value pairs. Some useful examples:

CLI Design

First, we should probably enable a JSON output mode for uffizzi preview list and other similar commands. This by itself will enable lots of user stories.

Next, add a way for users to specify metadata when running uffizzi preview create and uffizzi preview update. We may also consider a uffizzi preview set-label command?

Finally, add an easy way to filter the output of uffizzi preview list and other list commands. The immediate goal is for users to list and and all previews that are associated with a particular GitHub Pull Request.

For more powerful queries for uffizzi preview list and other list commands, we should consider JMESPATH which is becoming a popular JSON query language.

Examples of similar behavior:

https://en.wikipedia.org/wiki/Metadata

moklidia commented 2 years ago

For developers:

1) Add the metadata jsonb field to the deployments 2) Add the --output-json format to the uffizzi preview list command 3) Add the --set-label option to the uffizzi preview create and uffizzi preview update. It should be saved in metadata in the following format:

  metadata: {
    labels: {
      github: {
        repository: 'feature/#24_my_awesome_feature',
        pull_request: {
          number: '24',
        }
      }
    }
  }

4) Add the --filter option to uffizzi preview list 5) Update the manuals

moklidia commented 2 years ago

Related core task https://github.com/UffizziCloud/uffizzi_app/issues/221

the38th commented 2 years ago

@axisofentropy what fields of deployments should be outputed after preview list command with --output=json flag? for now we outputting just id and metadata(labels)

moklidia commented 2 years ago

@the38th For the scope of this task let's only add json output for previews. Let's add all data from deployments to the output.

the38th commented 2 years ago

for qa: to set label for deployment you need add flag --set-labels(-s) to uffizzi preview create or uffizzi preview update commands. Example of label - --set-labels github.pull_request.number=23 Example for multiple labels - --set-labels="github.pull_request.number=23 github.repository=my_awesome_repository" to filter list of previews by label you will need to add flag --filter to uffizzi preview list command, format of labels for filter the same as for --set-labels flag for output previews in json format you will need to add flag --output json to uffizzi preview list command

NealArw commented 2 years ago

TESTED - OK. Ready for UAT

fedorov-dualboot commented 2 years ago

TESTED on prod - OK.

image image image