@@ -14,7 +14,6 @@ import (
1414 "github.com/commitdev/zero/internal/config/globalconfig"
1515 "github.com/commitdev/zero/internal/config/projectconfig"
1616 "github.com/manifoldco/promptui"
17- "gopkg.in/yaml.v2"
1817)
1918
2019// Secrets - AWS prompted credentials
@@ -61,67 +60,6 @@ func GetAWSProfileCredentials(credsPath string, profileName string, creds global
6160 return creds
6261}
6362
64- func GetSecrets (baseDir string ) Secrets {
65-
66- secretsFile := filepath .Join (baseDir , "secrets.yaml" )
67- if fileExists (secretsFile ) {
68- log .Println ("secrets.yaml exists ..." )
69- return readSecrets (secretsFile )
70- } else {
71- // Get the user's home dir
72- usr , err := user .Current ()
73- if err != nil {
74- log .Fatal (err )
75- }
76- credsFile := filepath .Join (usr .HomeDir , ".aws/credentials" )
77-
78- var secrets Secrets
79-
80- // Load the credentials file to look for profiles
81- profiles , err := GetAWSProfiles ()
82- if err == nil {
83- profilePrompt := promptui.Select {
84- Label : "Select AWS Profile" ,
85- Items : profiles ,
86- }
87-
88- _ , profileResult , _ := profilePrompt .Run ()
89-
90- creds , err := credentials .NewSharedCredentials (credsFile , profileResult ).Get ()
91- if err == nil {
92- secrets = Secrets {
93- AWS : AWS {
94- AccessKeyID : creds .AccessKeyID ,
95- SecretAccessKey : creds .SecretAccessKey ,
96- },
97- }
98- }
99- }
100-
101- // We couldn't load the credentials file, get the user to just paste them
102- if secrets .AWS == (AWS {}) {
103- promptAWSCredentials (& secrets )
104- }
105-
106- if secrets .CircleCIKey == "" || secrets .GithubToken == "" {
107- ciPrompt := promptui.Select {
108- Label : "Which Continuous integration provider do you want to use?" ,
109- Items : []string {"CircleCI" , "GitHub Actions" },
110- }
111-
112- _ , ciResult , _ := ciPrompt .Run ()
113-
114- if ciResult == "CircleCI" {
115- promptCircleCICredentials (& secrets )
116- } else if ciResult == "GitHub Actions" {
117- promptGitHubCredentials (& secrets )
118- }
119- }
120-
121- return secrets
122- }
123- }
124-
12563// GetAWSProfiles returns a list of AWS forprofiles set up on the user's sytem
12664func GetAWSProfiles () ([]string , error ) {
12765 usr , err := user .Current ()
@@ -145,38 +83,6 @@ func GetAWSProfiles() ([]string, error) {
14583 return profiles , nil
14684}
14785
148- func readSecrets (secretsFile string ) Secrets {
149- data , err := ioutil .ReadFile (secretsFile )
150- if err != nil {
151- log .Fatalln (err )
152- }
153-
154- awsSecrets := Secrets {}
155-
156- err = yaml .Unmarshal (data , & awsSecrets )
157- if err != nil {
158- log .Fatalln (err )
159- }
160-
161- return awsSecrets
162- }
163-
164- func writeSecrets (secretsFile string , s Secrets ) {
165- secretsYaml , err := yaml .Marshal (& s )
166-
167- if err != nil {
168- log .Fatalf ("error: %v" , err )
169- panic (err )
170- }
171-
172- err = ioutil .WriteFile (secretsFile , []byte (secretsYaml ), 0644 )
173-
174- if err != nil {
175- log .Fatalf ("error: %v" , err )
176- panic (err )
177- }
178- }
179-
18086func ValidateAKID (input string ) error {
18187 // 20 uppercase alphanumeric characters
18288 var awsAccessKeyIDPat = regexp .MustCompile (`^[A-Z0-9]{20}$` )
0 commit comments