15881: Move Google, SSO, and PAM configs into their own sections.
[arvados.git] / sdk / go / arvados / config.go
index 80381aced5c9b485ddc91d3349c08b1a3667f1ca..7ab8d9e1f64e0260125a010be633062cb4305fa9 100644 (file)
@@ -11,7 +11,7 @@ import (
        "net/url"
        "os"
 
-       "git.curoverse.com/arvados.git/sdk/go/config"
+       "git.arvados.org/arvados.git/sdk/go/config"
 )
 
 var DefaultConfigFile = func() string {
@@ -23,7 +23,8 @@ var DefaultConfigFile = func() string {
 }()
 
 type Config struct {
-       Clusters map[string]Cluster
+       Clusters         map[string]Cluster
+       AutoReloadConfig bool
 }
 
 // GetConfig returns the current system config, loading it from
@@ -57,6 +58,16 @@ func (sc *Config) GetCluster(clusterID string) (*Cluster, error) {
        }
 }
 
+type WebDAVCacheConfig struct {
+       TTL                  Duration
+       UUIDTTL              Duration
+       MaxBlockEntries      int
+       MaxCollectionEntries int
+       MaxCollectionBytes   int64
+       MaxPermissionEntries int
+       MaxUUIDEntries       int
+}
+
 type Cluster struct {
        ClusterID       string `json:"-"`
        ManagementToken string
@@ -72,6 +83,8 @@ type Cluster struct {
                DisabledAPIs                   StringSet
                MaxIndexDatabaseRead           int
                MaxItemsPerResponse            int
+               MaxConcurrentRequests          int
+               MaxKeepBlobBuffers             int
                MaxRequestAmplification        int
                MaxRequestSize                 int
                RailsSessionSecretToken        string
@@ -79,6 +92,7 @@ type Cluster struct {
                SendTimeout                    Duration
                WebsocketClientEventQueue      int
                WebsocketServerEventQueue      int
+               KeepServiceRequestTimeout      Duration
        }
        AuditLogs struct {
                MaxAge             Duration
@@ -86,27 +100,74 @@ type Cluster struct {
                UnloggedAttributes StringSet
        }
        Collections struct {
-               BlobSigning          bool
-               BlobSigningKey       string
-               BlobSigningTTL       Duration
-               CollectionVersioning bool
-               DefaultTrashLifetime Duration
-               DefaultReplication   int
-               ManagedProperties    map[string]struct {
+               BlobSigning              bool
+               BlobSigningKey           string
+               BlobSigningTTL           Duration
+               BlobTrash                bool
+               BlobTrashLifetime        Duration
+               BlobTrashCheckInterval   Duration
+               BlobTrashConcurrency     int
+               BlobDeleteConcurrency    int
+               BlobReplicateConcurrency int
+               CollectionVersioning     bool
+               DefaultTrashLifetime     Duration
+               DefaultReplication       int
+               ManagedProperties        map[string]struct {
                        Value     interface{}
                        Function  string
                        Protected bool
                }
-               PreserveVersionIfIdle Duration
-               TrashSweepInterval    Duration
-               TrustAllContent       bool
+               PreserveVersionIfIdle        Duration
+               TrashSweepInterval           Duration
+               TrustAllContent              bool
+               ForwardSlashNameSubstitution string
+
+               BlobMissingReport        string
+               BalancePeriod            Duration
+               BalanceCollectionBatch   int
+               BalanceCollectionBuffers int
+
+               WebDAVCache WebDAVCacheConfig
        }
        Git struct {
+               GitCommand   string
+               GitoliteHome string
                Repositories string
        }
        Login struct {
-               ProviderAppSecret string
-               ProviderAppID     string
+               LDAP struct {
+                       Enable             bool
+                       URL                URL
+                       StartTLS           bool
+                       InsecureTLS        bool
+                       StripDomain        string
+                       AppendDomain       string
+                       SearchAttribute    string
+                       SearchBindUser     string
+                       SearchBindPassword string
+                       SearchBase         string
+                       SearchFilters      string
+                       EmailAttribute     string
+                       UsernameAttribute  string
+               }
+               Google struct {
+                       Enable                  bool
+                       ClientID                string
+                       ClientSecret            string
+                       AlternateEmailAddresses bool
+               }
+               PAM struct {
+                       Enable             bool
+                       Service            string
+                       DefaultEmailDomain string
+               }
+               SSO struct {
+                       Enable            bool
+                       ProviderAppID     string
+                       ProviderAppSecret string
+               }
+               LoginCluster       string
+               RemoteTokenRefresh Duration
        }
        Mail struct {
                MailchimpAPIKey                string
@@ -142,7 +203,9 @@ type Cluster struct {
                NewUsersAreActive                     bool
                UserNotifierEmailFrom                 string
                UserProfileNotificationAddress        string
+               PreferDomainForUsername               string
        }
+       Volumes   map[string]Volume
        Workbench struct {
                ActivationContactLink            string
                APIClientConnectTimeout          Duration
@@ -177,9 +240,55 @@ type Cluster struct {
                }
                UserProfileFormMessage string
                VocabularyURL          string
+               WelcomePageHTML        string
+               InactivePageHTML       string
+               SSHHelpPageHTML        string
+               SSHHelpHostSuffix      string
        }
 
-       EnableBetaController14287 bool
+       ForceLegacyAPI14 bool
+}
+
+type Volume struct {
+       AccessViaHosts   map[URL]VolumeAccess
+       ReadOnly         bool
+       Replication      int
+       StorageClasses   map[string]bool
+       Driver           string
+       DriverParameters json.RawMessage
+}
+
+type S3VolumeDriverParameters struct {
+       AccessKey          string
+       SecretKey          string
+       Endpoint           string
+       Region             string
+       Bucket             string
+       LocationConstraint bool
+       IndexPageSize      int
+       ConnectTimeout     Duration
+       ReadTimeout        Duration
+       RaceWindow         Duration
+       UnsafeDelete       bool
+}
+
+type AzureVolumeDriverParameters struct {
+       StorageAccountName   string
+       StorageAccountKey    string
+       StorageBaseURL       string
+       ContainerName        string
+       RequestTimeout       Duration
+       ListBlobsRetryDelay  Duration
+       ListBlobsMaxAttempts int
+}
+
+type DirectoryVolumeDriverParameters struct {
+       Root      string
+       Serialize bool
+}
+
+type VolumeAccess struct {
+       ReadOnly bool
 }
 
 type Services struct {
@@ -225,7 +334,13 @@ func (su URL) MarshalText() ([]byte, error) {
        return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
 }
 
-type ServiceInstance struct{}
+func (su URL) String() string {
+       return (*url.URL)(&su).String()
+}
+
+type ServiceInstance struct {
+       Rendezvous string `json:",omitempty"`
+}
 
 type PostgreSQL struct {
        Connection     PostgreSQLConnection
@@ -277,7 +392,7 @@ type ContainersConfig struct {
        Logging struct {
                MaxAge                       Duration
                LogBytesPerEvent             int
-               LogSecondsBetweenEvents      int
+               LogSecondsBetweenEvents      Duration
                LogThrottlePeriod            Duration
                LogThrottleBytes             int
                LogThrottleLines             int
@@ -306,6 +421,7 @@ type CloudVMsConfig struct {
        Enable bool
 
        BootProbeCommand     string
+       DeployRunnerBinary   string
        ImageID              string
        MaxCloudOpsPerSecond int
        MaxProbesPerSecond   int
@@ -333,6 +449,24 @@ var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
 // UnmarshalJSON handles old config files that provide an array of
 // instance types instead of a hash.
 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
+       fixup := func(t InstanceType) (InstanceType, error) {
+               if t.ProviderType == "" {
+                       t.ProviderType = t.Name
+               }
+               if t.Scratch == 0 {
+                       t.Scratch = t.IncludedScratch + t.AddedScratch
+               } else if t.AddedScratch == 0 {
+                       t.AddedScratch = t.Scratch - t.IncludedScratch
+               } else if t.IncludedScratch == 0 {
+                       t.IncludedScratch = t.Scratch - t.AddedScratch
+               }
+
+               if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
+                       return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
+               }
+               return t, nil
+       }
+
        if len(data) > 0 && data[0] == '[' {
                var arr []InstanceType
                err := json.Unmarshal(data, &arr)
@@ -348,19 +482,9 @@ func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
                        if _, ok := (*it)[t.Name]; ok {
                                return errDuplicateInstanceTypeName
                        }
-                       if t.ProviderType == "" {
-                               t.ProviderType = t.Name
-                       }
-                       if t.Scratch == 0 {
-                               t.Scratch = t.IncludedScratch + t.AddedScratch
-                       } else if t.AddedScratch == 0 {
-                               t.AddedScratch = t.Scratch - t.IncludedScratch
-                       } else if t.IncludedScratch == 0 {
-                               t.IncludedScratch = t.Scratch - t.AddedScratch
-                       }
-
-                       if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
-                               return fmt.Errorf("%v: Scratch != (IncludedScratch + AddedScratch)", t.Name)
+                       t, err := fixup(t)
+                       if err != nil {
+                               return err
                        }
                        (*it)[t.Name] = t
                }
@@ -376,8 +500,9 @@ func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
        *it = InstanceTypeMap(hash)
        for name, t := range *it {
                t.Name = name
-               if t.ProviderType == "" {
-                       t.ProviderType = name
+               t, err := fixup(t)
+               if err != nil {
+                       return err
                }
                (*it)[name] = t
        }