Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the secret data struct #125

Merged
merged 11 commits into from
Apr 6, 2022
8 changes: 2 additions & 6 deletions pkg/secret/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ type secretParser struct {
secretRegex *regexp.Regexp
}

type secretData struct {
SecretMap map[string]string `json:"data"`
}

// New return new secret parser
func New(logger lumber.Logger) core.SecretParser {
return &secretParser{
Expand All @@ -33,7 +29,7 @@ func New(logger lumber.Logger) core.SecretParser {

// GetRepoSecret read repo secrets from given path
func (s *secretParser) GetRepoSecret(path string) (map[string]string, error) {
var secretData secretData
var secretData map[string]string
if _, err := os.Stat(path); os.IsNotExist(err) {
s.logger.Debugf("failed to find user env secrets in path %s, as path does not exists", path)
return nil, nil
Expand All @@ -49,7 +45,7 @@ func (s *secretParser) GetRepoSecret(path string) (map[string]string, error) {
}

// extract secretmap from data map[data: map[secretname:secretvalue]]
return secretData.SecretMap, nil
return secretData, nil
}

// GetOauthSecret parses the oauth secret
Expand Down
8 changes: 3 additions & 5 deletions testutils/testdata/secretTestData/secretfile.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"data" : {
"abc": "val",
"xyz": "val2"
}
}
"abc": "val",
"xyz": "val2"
}