github.com/uber/kraken@v0.1.4/lib/backend/s3backend/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 s3backend 15 16 import ( 17 "github.com/c2h5oh/datasize" 18 19 "github.com/uber/kraken/lib/backend" 20 ) 21 22 // Config defines s3 connection specific 23 // parameters and authetication credentials 24 type Config struct { 25 Username string `yaml:"username"` // IAM username for selecting credentials. 26 Region string `yaml:"region"` // AWS S3 region 27 Bucket string `yaml:"bucket"` // S3 bucket 28 Endpoint string `yaml:"endpoint"` // S3 endpoint 29 DisableSSL bool `yaml:"disable_ssl"` // use clear HTTP when talking to endpoint 30 S3ForcePathStyle bool `yaml:"force_path_style"` // use path style instead of DNS style 31 32 RootDirectory string `yaml:"root_directory"` // S3 root directory for docker images 33 UploadPartSize int64 `yaml:"upload_part_size"` // part size s3 manager uses for upload 34 DownloadPartSize int64 `yaml:"download_part_size"` // part size s3 manager uses for download 35 36 UploadConcurrency int `yaml:"upload_concurrency"` // # of concurrent go-routines s3 manager uses for upload 37 DownloadConcurrency int `yaml:"download_concurrency"` // # of concurrent go-routines s3 manager uses for download 38 39 // ListMaxKeys sets the max keys returned per page. 40 ListMaxKeys int `yaml:"list_max_keys"` 41 42 // BufferGuard protects download from downloading into an oversized buffer 43 // when io.WriterAt is not implemented. 44 BufferGuard datasize.ByteSize `yaml:"buffer_guard"` 45 46 // NamePath identifies which namepath.Pather to use. 47 NamePath string `yaml:"name_path"` 48 } 49 50 // UserAuthConfig defines authentication configuration overlayed by Langley. 51 // Each key is the iam username of the credentials. 52 type UserAuthConfig map[string]AuthConfig 53 54 // AuthConfig matches Langley format. 55 type AuthConfig struct { 56 S3 struct { 57 AccessKeyID string `yaml:"aws_access_key_id"` 58 AccessSecretKey string `yaml:"aws_secret_access_key"` 59 SessionToken string `yaml:"aws_session_token"` 60 } `yaml:"s3"` 61 } 62 63 func (c *Config) applyDefaults() { 64 if c.UploadPartSize == 0 { 65 c.UploadPartSize = backend.DefaultPartSize 66 } 67 if c.DownloadPartSize == 0 { 68 c.DownloadPartSize = backend.DefaultPartSize 69 } 70 if c.UploadConcurrency == 0 { 71 c.UploadConcurrency = backend.DefaultConcurrency 72 } 73 if c.DownloadConcurrency == 0 { 74 c.DownloadConcurrency = backend.DefaultConcurrency 75 } 76 if c.BufferGuard == 0 { 77 c.BufferGuard = backend.DefaultBufferGuard 78 } 79 if c.ListMaxKeys == 0 { 80 c.ListMaxKeys = backend.DefaultListMaxKeys 81 } 82 }