-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathconfig.go
40 lines (32 loc) · 855 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package goss
import (
"errors"
)
type Config struct {
Endpoint string `yaml:"endpoint"`
AccessKey string `yaml:"access_key"`
SecretKey string `yaml:"secret_key"`
Region string `yaml:"region"`
Bucket string `yaml:"bucket"`
UseSsl *bool `yaml:"use_ssl"`
HostnameImmutable *bool `yaml:"hostname_immutable"`
}
func (c *Config) validate() error {
if c.Bucket == "" || c.AccessKey == "" || c.SecretKey == "" || c.Endpoint == "" || c.Region == "" {
return errors.New("configuration not correct")
}
return nil
}
func (c *Config) url() string {
prefix := "https://"
if c.UseSsl != nil && !*c.UseSsl {
prefix = "http://"
}
return prefix + c.Endpoint
}
func (c *Config) hostnameImmutable() bool {
if c.HostnameImmutable != nil {
return *c.HostnameImmutable
}
return false
}