Changes requested by @codyoss

This commit is contained in:
Ryan Kohler
2022-04-22 10:00:51 -07:00
parent 13e7453c5b
commit ec7aeb6565
3 changed files with 325 additions and 88 deletions

View File

@@ -171,7 +171,7 @@ type CredentialSource struct {
URL string `json:"url"`
Headers map[string]string `json:"headers"`
Executable ExecutableConfig `json:"executable"`
Executable *ExecutableConfig `json:"executable"`
EnvironmentID string `json:"environment_id"`
RegionURL string `json:"region_url"`
@@ -187,7 +187,7 @@ type ExecutableConfig struct {
OutputFile string `json:"output_file"`
}
// parse determines the type of CredentialSource needed
// parse determines the type of CredentialSource needed.
func (c *Config) parse(ctx context.Context) (baseCredentialSource, error) {
if len(c.CredentialSource.EnvironmentID) > 3 && c.CredentialSource.EnvironmentID[:3] == "aws" {
if awsVersion, err := strconv.Atoi(c.CredentialSource.EnvironmentID[3:]); err == nil {
@@ -213,8 +213,8 @@ func (c *Config) parse(ctx context.Context) (baseCredentialSource, error) {
return fileCredentialSource{File: c.CredentialSource.File, Format: c.CredentialSource.Format}, nil
} else if c.CredentialSource.URL != "" {
return urlCredentialSource{URL: c.CredentialSource.URL, Headers: c.CredentialSource.Headers, Format: c.CredentialSource.Format, ctx: ctx}, nil
} else if c.CredentialSource.Executable.Command != "" {
return CreateExecutableCredential(c.CredentialSource.Executable, c, ctx), nil
} else if c.CredentialSource.Executable != nil {
return CreateExecutableCredential(*c.CredentialSource.Executable, c, ctx), nil
}
return nil, fmt.Errorf("oauth2/google: unable to parse credential source")
}