allow tests to pass with dummy creds
parent
020c2f102e
commit
36deb4cb06
|
@ -60,7 +60,7 @@ func enableOrDisableGCPAuth(cfg *config.ClusterConfig, name string, val string)
|
||||||
|
|
||||||
func enableAddonGCPAuth(cfg *config.ClusterConfig) error {
|
func enableAddonGCPAuth(cfg *config.ClusterConfig) error {
|
||||||
if !Force && detect.IsOnGCE() {
|
if !Force && detect.IsOnGCE() {
|
||||||
exit.Message(reason.InternalCredsNotFound, "It seems that you are running in GCE, which means authentication should work without the GCP Auth addon. If you would still like to authenticate using a credentials file, use the --force flag.")
|
exit.Message(reason.InternalCredsNotNeeded, "It seems that you are running in GCE, which means authentication should work without the GCP Auth addon. If you would still like to authenticate using a credentials file, use the --force flag.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab command runner from running cluster
|
// Grab command runner from running cluster
|
||||||
|
@ -88,10 +88,14 @@ func enableAddonGCPAuth(cfg *config.ClusterConfig) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force here will allow tests to pass with false credentials
|
||||||
token, err := creds.TokenSource.Token()
|
token, err := creds.TokenSource.Token()
|
||||||
if err != nil {
|
if err != nil && !Force {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only try to add secret if Token was found
|
||||||
|
if err == nil {
|
||||||
data := map[string][]byte{
|
data := map[string][]byte{
|
||||||
".dockercfg": []byte(fmt.Sprintf(`{"https://gcr.io":{"username":"oauth2accesstoken","password":"%s","email":"none"}}`, token.AccessToken)),
|
".dockercfg": []byte(fmt.Sprintf(`{"https://gcr.io":{"username":"oauth2accesstoken","password":"%s","email":"none"}}`, token.AccessToken)),
|
||||||
}
|
}
|
||||||
|
@ -134,6 +138,7 @@ func enableAddonGCPAuth(cfg *config.ClusterConfig) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// First check if the project env var is explicitly set
|
// First check if the project env var is explicitly set
|
||||||
projectEnv := os.Getenv("GOOGLE_CLOUD_PROJECT")
|
projectEnv := os.Getenv("GOOGLE_CLOUD_PROJECT")
|
||||||
|
|
|
@ -120,6 +120,7 @@ var (
|
||||||
InternalViewTmpl = Kind{ID: "MK_VIEW_TMPL", ExitCode: ExProgramError}
|
InternalViewTmpl = Kind{ID: "MK_VIEW_TMPL", ExitCode: ExProgramError}
|
||||||
InternalYamlMarshal = Kind{ID: "MK_YAML_MARSHAL", ExitCode: ExProgramError}
|
InternalYamlMarshal = Kind{ID: "MK_YAML_MARSHAL", ExitCode: ExProgramError}
|
||||||
InternalCredsNotFound = Kind{ID: "MK_CREDENTIALS_NOT_FOUND", ExitCode: ExProgramNotFound, Style: style.Shrug}
|
InternalCredsNotFound = Kind{ID: "MK_CREDENTIALS_NOT_FOUND", ExitCode: ExProgramNotFound, Style: style.Shrug}
|
||||||
|
InternalCredsNotNeeded = Kind{ID: "MK_CREDENTIALS_NOT_NEEDED", ExitCode: ExProgramNotFound, Style: style.Shrug}
|
||||||
InternalSemverParse = Kind{ID: "MK_SEMVER_PARSE", ExitCode: ExProgramError}
|
InternalSemverParse = Kind{ID: "MK_SEMVER_PARSE", ExitCode: ExProgramError}
|
||||||
DaemonizeError = Kind{ID: "MK_DAEMONIZE", ExitCode: ExProgramError}
|
DaemonizeError = Kind{ID: "MK_DAEMONIZE", ExitCode: ExProgramError}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue