Allow agents as application for secrets#13421
Conversation
|
Thanks for your pull request! Unfortunately, it doesn't meet the requirements for review:
Please update your PR to address the above. This PR will be automatically closed in 4 days if these requirements are not met. Full contribution requirements
|
There was a problem hiding this comment.
Pull request overview
Adds support for the new agents application when setting GitHub secrets via gh secret set --app.
Changes:
- Introduces
Agentsas a supported secret application in shared secret app parsing/validation. - Extends
gh secret set --appflag enum to acceptagents. - Adds/updates unit tests to cover the new application in parsing and set flows.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/cmd/secret/shared/shared.go | Adds Agents app constant and enables it in app parsing + entity support checks. |
| pkg/cmd/secret/shared/shared_test.go | Adds a GetSecretApp test case for the new agents app. |
| pkg/cmd/secret/set/set.go | Allows --app agents via the enum flag options for secret set. |
| pkg/cmd/secret/set/set_test.go | Adds a setRun repo test case verifying API paths/payload for agents. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| case Actions: | ||
| return entity == Repository || entity == Organization || entity == Environment | ||
| case Agents: | ||
| return entity == Repository || entity == Organization | ||
| case Codespaces: |
| cmd.Flags().BoolVar(&opts.DoNotStore, "no-store", false, "Print the encrypted, base64-encoded value instead of storing it on GitHub") | ||
| cmd.Flags().StringVarP(&opts.EnvFile, "env-file", "f", "", "Load secret names and values from a dotenv-formatted `file`") | ||
| cmdutil.StringEnumFlag(cmd, &opts.Application, "app", "a", "", []string{shared.Actions, shared.Codespaces, shared.Dependabot}, "Set the application for a secret") | ||
| cmdutil.StringEnumFlag(cmd, &opts.Application, "app", "a", "", []string{shared.Actions, shared.Agents, shared.Codespaces, shared.Dependabot}, "Set the application for a secret") |
| { | ||
| name: "Agents", | ||
| opts: &SetOptions{ | ||
| Application: "agents", | ||
| }, |
|
Hey @tenjaa - thanks for the PR. I'll echo the copilot review comment, and say we should expand this to the other commands under The big thing that came to mind for me on this is what to do about GHES support, since it won't have this secret type. Maybe it's fine since the user needs to provide this command and the API will return an error when they do - but for commands like |
|
@BagToad Thanks for the instant reaction! I adapted the copilot findings except the third one (there is a comment why this doesn't make sense in my opinion).
Do you have an idea how? I guess through opts.config.authentication you could get the host but there is no flag like |
| { | ||
| name: "Agents repo", | ||
| cli: "--app Agents", | ||
| wants: ListOptions{ | ||
| Application: "Agents", | ||
| }, | ||
| }, |
| { | ||
| name: "Agents org", | ||
| cli: "cool --app agents --org UmbrellaCorporation", | ||
| wants: DeleteOptions{ | ||
| SecretName: "cool", | ||
| OrgName: "UmbrellaCorporation", | ||
| Application: "Agents", | ||
| }, |
| name: "Agents org", | ||
| args: `random_secret --org coolOrg --body "random value" --visibility selected --repos "coolRepo,cli/cli" --app Agents`, | ||
| wants: SetOptions{ | ||
| SecretName: "random_secret", | ||
| Visibility: shared.Selected, | ||
| RepositoryNames: []string{"coolRepo", "cli/cli"}, | ||
| Body: "random value", | ||
| OrgName: "coolOrg", | ||
| Application: "Agents", | ||
| }, | ||
| }, |
|
@tenjaa honestly, I'm leaning towards not doing anything at all for GHES in this specific case. Since these fields are optional, the API will return an error, like you mentioned, and that's probably good enough. I'm still thinking about it, and I will check with the other maintainers to make sure they agree. But for your knowledge and context, here's how GHES in cli/internal/featuredetection/feature_detection.go Lines 158 to 160 in 2b7e776 |
Fixes #13419
I built it locally and ran
bin/gh secret set TEST_SECRET -a agents -b 123 -o <my-org>and it worked exactly as expected.What might be missing is another test? I looked through it and added a little bit but maybe a maintainer has a little more input regarding that.