fix nakedret
@@ -82,61 +82,59 @@ func applyTerraform(tf string, cluster *config.Cluster) error {
return nil
}
-func loadMachineControllerCredentials(p config.ProviderName) (data map[string]string, err error) {
+func loadMachineControllerCredentials(p config.ProviderName) (map[string]string, error) {
+ var (
+ err error
data = map[string]string{}
+ )
switch p {
case config.ProviderNameAWS:
if data["AWS_ACCESS_KEY_ID"], err = getEnvVar("AWS_ACCESS_KEY_ID"); err != nil {
- return
+ return nil, err
}
if data["AWS_SECRET_ACCESS_KEY"], err = getEnvVar("AWS_SECRET_ACCESS_KEY"); err != nil {
- return
+ return nil, err
}
-
case config.ProviderNameOpenStack:
if data["OS_AUTH_URL"], err = getEnvVar("OS_AUTH_URL"); err != nil {
- return
+ return nil, err
}
if data["OS_USER_NAME"], err = getEnvVar("OS_USER_NAME"); err != nil {
- return
+ return nil, err
}
if data["OS_PASSWORD"], err = getEnvVar("OS_PASSWORD"); err != nil {
- return
+ return nil, err
}
if data["OS_DOMAIN_NAME"], err = getEnvVar("OS_DOMAIN_NAME"); err != nil {
- return
+ return nil, err
}
if data["OS_TENANT_NAME"], err = getEnvVar("OS_TENANT_NAME"); err != nil {
- return
+ return nil, err
}
-
case config.ProviderNameHetzner:
if data["HZ_TOKEN"], err = getEnvVar("HZ_TOKEN"); err != nil {
- return
+ return nil, err
}
-
case config.ProviderNameDigitalOcean:
if data["DO_TOKEN"], err = getEnvVar("DO_TOKEN"); err != nil {
- return
+ return nil, err
}
-
case config.ProviderNameVSphere:
if data["VSPHERE_ADDRESS"], err = getEnvVar("VSPHERE_ADDRESS"); err != nil {
- return
+ return nil, err
}
if data["VSPHERE_USERNAME"], err = getEnvVar("VSPHERE_USERNAME"); err != nil {
- return
+ return nil, err
}
if data["VSPHERE_PASSWORD"], err = getEnvVar("VSPHERE_PASSWORD"); err != nil {
- return
+ return nil, err
}
-
default:
err = fmt.Errorf("missing cloud provider credentials")
}
- return
+ return data, err
}
func getEnvVar(ev string) (data string, err error) {
