Skip to content

Commit

Permalink
improve env
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAkulov committed Jun 26, 2019
1 parent 5d3a0d0 commit 984700e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 48 deletions.
49 changes: 22 additions & 27 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,39 +82,34 @@ GLOBAL OPTIONS:
```

### Default Config
All options can be overwritten via environment variables

```yaml
clickhouse:
username: default
password: ""
host: localhost
port: 9000
data_path: ""
skip_tables:
username: default # CLICKHOUSE_USERNAME
password: "" # CLICKHOUSE_PASSWORD
host: localhost # CLICKHOUSE_HOST
port: 9000 # CLICKHOUSE_PORT
data_path: "" # CLICKHOUSE_DATA_PATH
skip_tables: # CLICKHOUSE_SKIP_TABLES
- system.*
s3:
access_key: ""
secret_key: ""
bucket: ""
endpoint: ""
region: us-east-1
acl: private
force_path_style: false
path: ""
disable_ssl: false
disable_progress_bar: false
# Define behavior for rewrite exists files with the same size. Must set to "skip", "etag" or "always"
# "skip" - the fastest but can make backup inconsistently
# "etag" - calculate etag for local files, set this if your network is very slow
overwrite_strategy: always
part_size: 5242880
delete_extra_files: true
strategy: archive
backups_to_keep_local: 0
backups_to_keep_s3: 0
compression_level: 1
access_key: "" # S3_ACCESS_KEY
secret_key: "" # S3_SECRET_KEY
bucket: "" # S3_BUCKET
endpoint: "" # S3_ENDPOINT
region: us-east-1 # S3_REGION
acl: private # S3_ACL
force_path_style: false # S3_FORCE_PATH_STYLE
path: "" # S3_PATH
disable_ssl: false # S3_DISABLE_SSL
disable_progress_bar: false # DISABLE_PROGRESS_BAR
part_size: 5242880 # S3_PART_SIZE
backups_to_keep_local: 0 # BACKUPS_TO_KEEP_LOCAL
backups_to_keep_s3: 0 # BACKUPS_TO_KEEP_S3
compression_level: 1 # S3_COMPRESSION_LEVEL
# supported: 'tar', 'lz4', 'bzip2', 'gzip', 'sz', 'xz'
compression_format: lz4
compression_format: lz4 # S3_COMPRESSION_FORMAT
```
## Examples
Expand Down
42 changes: 21 additions & 21 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,34 @@ type Config struct {

// S3Config - s3 settings section
type S3Config struct {
AccessKey string `yaml:"access_key"`
SecretKey string `yaml:"secret_key"`
Bucket string `yaml:"bucket"`
Endpoint string `yaml:"endpoint"`
Region string `yaml:"region"`
ACL string `yaml:"acl"`
ForcePathStyle bool `yaml:"force_path_style"`
Path string `yaml:"path"`
DisableSSL bool `yaml:"disable_ssl"`
DisableProgressBar bool `yaml:"disable_progress_bar"`
AccessKey string `yaml:"access_key" envconfig:"S3_ACCESS_KEY"`
SecretKey string `yaml:"secret_key" envconfig:"S3_SECRET_KEY"`
Bucket string `yaml:"bucket" envconfig:"S3_BUCKET"`
Endpoint string `yaml:"endpoint" envconfig:"S3_ENDPOINT"`
Region string `yaml:"region" envconfig:"S3_REGION"`
ACL string `yaml:"acl" envconfig:"S3_ACL"`
ForcePathStyle bool `yaml:"force_path_style" envconfig:"S3_FORCE_PATH_STYLE"`
Path string `yaml:"path" envconfig:"S3_PATH"`
DisableSSL bool `yaml:"disable_ssl" envconfig:"S3_DISABLE_SSL"`
DisableProgressBar bool `yaml:"disable_progress_bar" envconfig:"DISABLE_PROGRESS_BAR"`
OverwriteStrategy string `yaml:"overwrite_strategy"`
PartSize int64 `yaml:"part_size"`
PartSize int64 `yaml:"part_size" envconfig:"S3_PART_SIZE"`
DeleteExtraFiles bool `yaml:"delete_extra_files"`
Strategy string `yaml:"strategy"`
BackupsToKeepLocal int `yaml:"backups_to_keep_local"`
BackupsToKeepS3 int `yaml:"backups_to_keep_s3"`
CompressionLevel int `yaml:"compression_level"`
CompressionFormat string `yaml:"compression_format"`
BackupsToKeepLocal int `yaml:"backups_to_keep_local" envconfig:"BACKUPS_TO_KEEP_LOCAL"`
BackupsToKeepS3 int `yaml:"backups_to_keep_s3" envconfig:"BACKUPS_TO_KEEP_S3"`
CompressionLevel int `yaml:"compression_level" envconfig:"S3_COMPRESSION_LEVEL"`
CompressionFormat string `yaml:"compression_format" envconfig:"S3_COMPRESSION_FORMAT"`
}

// ClickHouseConfig - clickhouse settings section
type ClickHouseConfig struct {
Username string `yaml:"username"`
Password string `yaml:"password"`
Host string `yaml:"host"`
Port uint `yaml:"port"`
DataPath string `yaml:"data_path"`
SkipTables []string `yaml:"skip_tables"`
Username string `yaml:"username" envconfig:"CLICKHOUSE_USERNAME"`
Password string `yaml:"password" envconfig:"CLICKHOUSE_PASSWORD"`
Host string `yaml:"host" envconfig:"CLICKHOUSE_HOST"`
Port uint `yaml:"port" envconfig:"CLICKHOUSE_PORT"`
DataPath string `yaml:"data_path" envconfig:"CLICKHOUSE_DATA_PATH"`
SkipTables []string `yaml:"skip_tables" envconfig:"CLICKHOUSE_SKIP_TABLES"`
}

// LoadConfig - load config from file
Expand Down

0 comments on commit 984700e

Please sign in to comment.