github.com/uber/kraken@v0.1.4/lib/backend/config.go (about)

     1  // Copyright (c) 2016-2019 Uber Technologies, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  package backend
    15  
    16  import (
    17  	"github.com/uber/kraken/utils/bandwidth"
    18  	"github.com/uber/kraken/utils/memsize"
    19  )
    20  
    21  // Config defines the union of configuration for all backends. Only one is
    22  // allowed for each config file.
    23  type Config struct {
    24  	Namespace string                 `yaml:"namespace"`
    25  	Backend   map[string]interface{} `yaml:"backend"`
    26  
    27  	// If enabled, throttles upload / download bandwidth.
    28  	Bandwidth bandwidth.Config `yaml:"bandwidth"`
    29  }
    30  
    31  func (c Config) applyDefaults() Config {
    32  	for k := range c.Backend {
    33  		// TODO: don't hard code backend client name
    34  		if k == "s3" {
    35  			if c.Bandwidth.IngressBitsPerSec == 0 {
    36  				c.Bandwidth.IngressBitsPerSec = 10 * 8 * memsize.Gbit
    37  			}
    38  			if c.Bandwidth.EgressBitsPerSec == 0 {
    39  				c.Bandwidth.EgressBitsPerSec = 8 * memsize.Gbit
    40  			}
    41  		}
    42  	}
    43  	return c
    44  }
    45  
    46  // Auth defines auth credentials for corresponding namespaces.
    47  // It has to be different due to langley secrets overlay structure.
    48  type Auth map[string]AuthConfig
    49  
    50  // AuthConfig defines the union of authentication credentials for all type of
    51  // remote backends.
    52  type AuthConfig map[string]interface{}