Revert "Revert "Added functionality for org-level codespaces secrets (#6171)" (#6223)"

This reverts commit eaabd35b76.
This commit is contained in:
Ashwin Jeyaseelan 2022-09-15 15:53:28 -07:00 committed by GitHub
parent 0ecd424901
commit b47ed57694
8 changed files with 35 additions and 6 deletions

View file

@ -41,7 +41,7 @@ func NewCmdDelete(f *cmdutil.Factory, runF func(*DeleteOptions) error) *cobra.Co
Delete a secret on one of the following levels:
- repository (default): available to Actions runs or Dependabot in a repository
- environment: available to Actions runs for a deployment environment in a repository
- organization: available to Actions runs or Dependabot within an organization
- organization: available to Actions runs, Dependabot, or Codespaces within an organization
- user: available to Codespaces for your user
`),
Args: cobra.ExactArgs(1),

View file

@ -73,6 +73,15 @@ func TestNewCmdDelete(t *testing.T) {
Application: "Dependabot",
},
},
{
name: "Codespaces org",
cli: "cool --app codespaces --org UmbrellaCorporation",
wants: DeleteOptions{
SecretName: "cool",
OrgName: "UmbrellaCorporation",
Application: "Codespaces",
},
},
}
for _, tt := range tests {
@ -219,6 +228,14 @@ func Test_removeRun_org(t *testing.T) {
},
wantPath: "orgs/UmbrellaCorporation/dependabot/secrets/tVirus",
},
{
name: "Codespaces org",
opts: &DeleteOptions{
Application: "codespaces",
OrgName: "UmbrellaCorporation",
},
wantPath: "orgs/UmbrellaCorporation/codespaces/secrets/tVirus",
},
}
for _, tt := range tests {

View file

@ -46,7 +46,7 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
List secrets on one of the following levels:
- repository (default): available to Actions runs or Dependabot in a repository
- environment: available to Actions runs for a deployment environment in a repository
- organization: available to Actions runs or Dependabot within an organization
- organization: available to Actions runs, Dependabot, or Codespaces within an organization
- user: available to Codespaces for your user
`),
Aliases: []string{"ls"},

View file

@ -15,7 +15,7 @@ func NewCmdSecret(f *cmdutil.Factory) *cobra.Command {
Short: "Manage GitHub secrets",
Long: heredoc.Doc(`
Secrets can be set at the repository, or organization level for use in
GitHub Actions or Dependabot. User and repository secrets can be set for
GitHub Actions or Dependabot. User, organization, and repository secrets can be set for
use in GitHub Codespaces. Environment secrets can be set for use in
GitHub Actions. Run "gh help secret set" to learn how to get started.
`),

View file

@ -58,7 +58,7 @@ func NewCmdSet(f *cmdutil.Factory, runF func(*SetOptions) error) *cobra.Command
Set a value for a secret on one of the following levels:
- repository (default): available to Actions runs or Dependabot in a repository
- environment: available to Actions runs for a deployment environment in a repository
- organization: available to Actions runs or Dependabot within an organization
- organization: available to Actions runs, Dependabot, or Codespaces within an organization
- user: available to Codespaces for your user
Organization and user secrets can optionally be restricted to only be available to

View file

@ -165,6 +165,18 @@ func TestNewCmdSet(t *testing.T) {
Application: "Dependabot",
},
},
{
name: "Codespaces org",
cli: `random_secret -ocoolOrg -b"random value" -vselected -r"coolRepo,cli/cli" -aCodespaces`,
wants: SetOptions{
SecretName: "random_secret",
Visibility: shared.Selected,
RepositoryNames: []string{"coolRepo", "cli/cli"},
Body: "random value",
OrgName: "coolOrg",
Application: "Codespaces",
},
},
}
for _, tt := range tests {

View file

@ -85,7 +85,7 @@ func IsSupportedSecretEntity(app App, entity SecretEntity) bool {
case Actions:
return entity == Repository || entity == Organization || entity == Environment
case Codespaces:
return entity == User || entity == Repository
return entity == User || entity == Organization || entity == Repository
case Dependabot:
return entity == Repository || entity == Organization
default:

View file

@ -167,9 +167,9 @@ func TestIsSupportedSecretEntity(t *testing.T) {
supportedEntities: []SecretEntity{
User,
Repository,
Organization,
},
unsupportedEntities: []SecretEntity{
Organization,
Environment,
Unknown,
},