15107: Update "go get" uses in test/package scripts.
[arvados.git] / lib / config / deprecated.go
index 593a9bdcbcaf51b19a40b91a0fd083a3def2f3ba..7b11e090eeee7479effd5c37b8c834798041c0a7 100644 (file)
@@ -7,6 +7,7 @@ package config
 import (
        "fmt"
        "io/ioutil"
+       "net/url"
        "os"
        "strings"
 
@@ -531,14 +532,14 @@ func (ldr *Loader) loadOldKeepBalanceConfig(cfg *arvados.Config) error {
                cluster.API.KeepServiceRequestTimeout = *oc.RequestTimeout
        }
 
-       msg := "The %s configuration option is no longer supported. Please remove it from your configuration file. Keep-balance will operate on all configured volumes."
+       msg := "The %s configuration option is no longer supported. Please remove it from your configuration file. See the keep-balance upgrade notes at https://doc.arvados.org/admin/upgrading.html for more details."
 
        // If the keep service type provided is "disk" silently ignore it, since
        // this is what ends up being done anyway.
        if oc.KeepServiceTypes != nil {
                numTypes := len(*oc.KeepServiceTypes)
                if numTypes != 0 && !(numTypes == 1 && (*oc.KeepServiceTypes)[0] == "disk") {
-                       return fmt.Errorf(msg, "KeepServiceType")
+                       return fmt.Errorf(msg, "KeepServiceTypes")
                }
        }
 
@@ -549,3 +550,30 @@ func (ldr *Loader) loadOldKeepBalanceConfig(cfg *arvados.Config) error {
        cfg.Clusters[cluster.ClusterID] = *cluster
        return nil
 }
+
+func (ldr *Loader) loadOldEnvironmentVariables(cfg *arvados.Config) error {
+       if os.Getenv("ARVADOS_API_TOKEN") == "" && os.Getenv("ARVADOS_API_HOST") == "" {
+               return nil
+       }
+       cluster, err := cfg.GetCluster("")
+       if err != nil {
+               return err
+       }
+       if tok := os.Getenv("ARVADOS_API_TOKEN"); tok != "" && cluster.SystemRootToken == "" {
+               ldr.Logger.Warn("SystemRootToken missing from cluster config, falling back to ARVADOS_API_TOKEN environment variable")
+               cluster.SystemRootToken = tok
+       }
+       if apihost := os.Getenv("ARVADOS_API_HOST"); apihost != "" && cluster.Services.Controller.ExternalURL.Host == "" {
+               ldr.Logger.Warn("Services.Controller.ExternalURL missing from cluster config, falling back to ARVADOS_API_HOST(_INSECURE) environment variables")
+               u, err := url.Parse("https://" + apihost)
+               if err != nil {
+                       return fmt.Errorf("cannot parse ARVADOS_API_HOST: %s", err)
+               }
+               cluster.Services.Controller.ExternalURL = arvados.URL(*u)
+               if i := os.Getenv("ARVADOS_API_HOST_INSECURE"); i != "" && i != "0" {
+                       cluster.TLS.Insecure = true
+               }
+       }
+       cfg.Clusters[cluster.ClusterID] = *cluster
+       return nil
+}