github.com/uber/kraken@v0.1.4/lib/backend/gcsbackend/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 gcsbackend
    15  
    16  import (
    17  	"github.com/c2h5oh/datasize"
    18  
    19  	"github.com/uber/kraken/lib/backend"
    20  )
    21  
    22  // Config defines gcs connection specific
    23  // parameters and authetication credentials
    24  type Config struct {
    25  	Username string `yaml:"username"` // IAM username for selecting credentials.
    26  	Location string `yaml:"location"` // Location of the bucket. Defautls to "US".
    27  	Bucket   string `yaml:"bucket"`   // GCS bucket
    28  
    29  	RootDirectory   string `yaml:"root_directory"`   // GCS root directory for docker images
    30  	UploadChunkSize int64  `yaml:"upload_part_size"` // part size gcs manager uses for upload
    31  
    32  	// ListMaxKeys sets the max keys returned per page.
    33  	ListMaxKeys int `yaml:"list_max_keys"`
    34  
    35  	// BufferGuard protects download from downloading into an oversized buffer
    36  	// when io.WriterAt is not implemented.
    37  	BufferGuard datasize.ByteSize `yaml:"buffer_guard"`
    38  
    39  	// NamePath identifies which namepath.Pather to use.
    40  	NamePath string `yaml:"name_path"`
    41  }
    42  
    43  // UserAuthConfig defines authentication configuration overlayed by Langley.
    44  // Each key is the iam username of the credentials.
    45  type UserAuthConfig map[string]AuthConfig
    46  
    47  // AuthConfig matches Langley format.
    48  type AuthConfig struct {
    49  	GCS struct {
    50  		AccessBlob string `yaml:"access_blob"`
    51  	} `yaml:"gcs"`
    52  }
    53  
    54  func (c *Config) applyDefaults() {
    55  	if c.UploadChunkSize == 0 {
    56  		c.UploadChunkSize = backend.DefaultPartSize
    57  	}
    58  	if c.BufferGuard == 0 {
    59  		c.BufferGuard = backend.DefaultBufferGuard
    60  	}
    61  	if c.ListMaxKeys == 0 {
    62  		c.ListMaxKeys = backend.DefaultListMaxKeys
    63  	}
    64  }