config.go 909 B

1234567891011121314151617181920212223242526272829
  1. package storage
  2. import "git.linuxforward.com/byom/byom-golang-lib/pkg/errors"
  3. // Config holds the storage configuration
  4. type Config struct {
  5. Endpoint string `yaml:"endpoint"`
  6. AccessKeyID string `yaml:"access_key_id"`
  7. SecretAccessKey string `yaml:"secret_access_key"`
  8. UseSSL bool `yaml:"use_ssl"`
  9. BucketName string `yaml:"bucket_name"`
  10. }
  11. // Validate implements the config.Validator interface
  12. func (c *Config) Validate() error {
  13. if c.Endpoint == "" {
  14. return errors.NewConfigError("storage.endpoint", errors.ErrInvalidInput)
  15. }
  16. if c.AccessKeyID == "" {
  17. return errors.NewConfigError("storage.access_key_id", errors.ErrInvalidInput)
  18. }
  19. if c.SecretAccessKey == "" {
  20. return errors.NewConfigError("storage.secret_access_key", errors.ErrInvalidInput)
  21. }
  22. if c.BucketName == "" {
  23. return errors.NewConfigError("storage.bucket_name", errors.ErrInvalidInput)
  24. }
  25. return nil
  26. }