github.com/code-to-go/safepool.lib@v0.0.0-20221205180519-ee25e63c226e/transport/config.go (about) 1 package transport 2 3 import ( 4 "os" 5 6 "gopkg.in/yaml.v3" 7 ) 8 9 type Config struct { 10 SFTP *SFTPConfig `json:"sftp,omitempty" yaml:"sftp,omitempty"` 11 S3 *S3Config `json:"s3,omitempty" yaml:"s3,omitempty"` 12 Local *LocalConfig `json:"local,omitempty" yaml:"local,omitempty"` 13 } 14 15 func ReadConfig(name string) (Config, error) { 16 var c Config 17 data, err := os.ReadFile(name) 18 if err != nil { 19 return c, err 20 } 21 err = yaml.Unmarshal(data, &c) 22 return c, err 23 } 24 25 var SampleConfig = Config{ 26 SFTP: &SFTPConfig{ 27 Addr: "hostname", 28 Username: "username", 29 Password: "password when not using private key authentication", 30 KeyPath: "path when using private key authentication", 31 Base: "local path on the sftp server", 32 }, 33 S3: &S3Config{ 34 Region: "AWS region, i.e. eu-central-1", 35 Endpoint: "S3 endpoint, i.e. s3.eu-central-1.amazonaws.com", 36 Bucket: "S3 bucket name", 37 AccessKey: "S3 access key", 38 Secret: "S3 secret key", 39 }, 40 }