Skip to content

Commit

Permalink
Support allow_unauthenticated: false (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
abstrctn authored May 6, 2021
1 parent a30c5c8 commit aad35f6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,11 @@ func CreateExecutionPlan(cfg *Config) ([]string, error) {
args = append(args, "--set-env-vars", envStr)
}

// If --quiet and none selected, GCP defaults to --no-allow-unauthenticated
if cfg.AllowUnauthenticated {
args = append(args, "--allow-unauthenticated")
} else {
args = append(args, "--no-allow-unauthenticated")
}

if cfg.Concurrency != "" {
Expand Down
30 changes: 30 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,36 @@ func TestParseAndRunConfig(t *testing.T) {
cfgExpectedProjectId: "my-project-id",
planExpectedFlags: []string{"--to-tags=tag=100"},
},
{
env: map[string]string{
"PLUGIN_ACTION": "deploy", "PLUGIN_SERVICE": "my-service",
"PLUGIN_IMAGE": "my-image", "PLUGIN_TOKEN": validGCPKey,
"PLUGIN_ALLOW_UNAUTHENTICATED": "true"},
planExpectedOk: true,
cfgExpectedOk: true,
cfgExpectedProjectId: "my-project-id",
planExpectedFlags: []string{"--allow-unauthenticated"},
},
{
env: map[string]string{
"PLUGIN_ACTION": "deploy", "PLUGIN_SERVICE": "my-service",
"PLUGIN_IMAGE": "my-image", "PLUGIN_TOKEN": validGCPKey,
"PLUGIN_ALLOW_UNAUTHENTICATED": "false"},
planExpectedOk: true,
cfgExpectedOk: true,
cfgExpectedProjectId: "my-project-id",
planExpectedFlags: []string{"--no-allow-unauthenticated"},
},
// gcloud defaults to --no-allow-unauthenticated if parameter not passed
{
env: map[string]string{
"PLUGIN_ACTION": "deploy", "PLUGIN_SERVICE": "my-service",
"PLUGIN_IMAGE": "my-image", "PLUGIN_TOKEN": validGCPKey},
planExpectedOk: true,
cfgExpectedOk: true,
cfgExpectedProjectId: "my-project-id",
planExpectedFlags: []string{"--no-allow-unauthenticated"},
},
} {
name := fmt.Sprintf("env:[%s]", tst.env)
t.Run(name, func(t *testing.T) {
Expand Down

0 comments on commit aad35f6

Please sign in to comment.