Skip to content

Commit

Permalink
fixup! info: guide to obtain credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcheung committed Jul 8, 2020
1 parent 4f038f2 commit 8d25ccb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions internal/config/moduleconfig/module_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Parameter struct {
Execute string `yaml:"execute,omitempty"`
Value string `yaml:"value,omitempty"`
Default string `yaml:"default,omitempty"`
Info string `yaml:"info,omitempty"`
}

type TemplateConfig struct {
Expand Down
14 changes: 7 additions & 7 deletions internal/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ func mapVendorToPrompts(projectCred globalconfig.ProjectCredential, vendor strin
Field: "accessKeyId",
Label: "AWS Access Key ID",
Default: projectCred.AWSResourceConfig.AccessKeyID,
Info: `AWS Access Key ID/Secret: used for provisioning infrastructure in AWS
The token can be generated at https://console.aws.amazon.com/iam/home?#/security_credentials`,
},
Condition: CustomCondition(customAwsMustInputCondition),
Validate: ValidateAKID,
Info: `AWS Access Key ID/Secret: used for provisioning infrastructure in AWS
The token can be generated at https://console.aws.amazon.com/iam/home?#/security_credentials`,
},
{
Parameter: moduleconfig.Parameter{
Expand All @@ -260,12 +260,12 @@ The token can be generated at https://console.aws.amazon.com/iam/home?#/security
Field: "accessToken",
Label: "Github Personal Access Token with access to the above organization",
Default: projectCred.GithubResourceConfig.AccessToken,
Info: `Github personal access token: used for creating repositories for your project
Requires the following permissions: [repo::public_repo, admin::orgread:org]
The token can be created at https://github.com/settings/tokens`,
},
Condition: NoCondition,
Validate: NoValidation,
Info: `Github personal access token: used for creating repositories for your project
Requires the following permissions: [repo::public_repo, admin::orgread:org]
The token can be created at https://github.com/settings/tokens`,
}
prompts = append(prompts, githubPrompt)
case "circleci":
Expand All @@ -274,11 +274,11 @@ The token can be created at https://github.com/settings/tokens`,
Field: "apiKey",
Label: "Circleci api key for CI/CD",
Default: projectCred.CircleCiResourceConfig.ApiKey,
Info: `CircleCI api token: used for setting up CI/CD for your project
The token can be created at https://app.circleci.com/settings/user/tokens`,
},
Condition: NoCondition,
Validate: NoValidation,
Info: `CircleCI api token: used for setting up CI/CD for your project
The token can be created at https://app.circleci.com/settings/user/tokens`,
}
prompts = append(prompts, circleCiPrompt)
}
Expand Down
5 changes: 2 additions & 3 deletions internal/init/prompts.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type PromptHandler struct {
moduleconfig.Parameter
Condition CustomConditionSignature
Validate func(string) error
Info string
}

type CredentialPrompts struct {
Expand Down Expand Up @@ -95,8 +94,8 @@ func (p PromptHandler) GetParam(projectParams map[string]string) string {
var result string

if p.Condition(projectParams) {
if p.Info != "" {
flog.Guidef(p.Info)
if p.Parameter.Info != "" {
flog.Guidef(p.Parameter.Info)
}
// TODO: figure out scope of projectParams per project
// potentially dangerous to have cross module env leaking
Expand Down
4 changes: 0 additions & 4 deletions internal/init/prompts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

func TestGetParam(t *testing.T) {

promptInfo := ""
projectParams := map[string]string{}
t.Run("Should execute params without prompt", func(t *testing.T) {
param := moduleconfig.Parameter{
Expand All @@ -24,7 +23,6 @@ func TestGetParam(t *testing.T) {
param,
initPrompts.NoCondition,
initPrompts.NoValidation,
promptInfo,
}

result := prompt.GetParam(projectParams)
Expand All @@ -41,7 +39,6 @@ func TestGetParam(t *testing.T) {
param,
initPrompts.NoCondition,
initPrompts.NoValidation,
promptInfo,
}

result := prompt.GetParam(map[string]string{
Expand All @@ -60,7 +57,6 @@ func TestGetParam(t *testing.T) {
param,
initPrompts.NoCondition,
initPrompts.NoValidation,
promptInfo,
}

result := prompt.GetParam(projectParams)
Expand Down

0 comments on commit 8d25ccb

Please sign in to comment.