config.go 834 B

1234567891011121314151617181920212223242526272829303132333435
  1. package gcs
  2. import (
  3. "github.com/imgproxy/imgproxy/v3/config"
  4. "github.com/imgproxy/imgproxy/v3/ensure"
  5. )
  6. // Config holds the configuration for Google Cloud Storage transport
  7. type Config struct {
  8. Key string // Google Cloud Storage service account key
  9. Endpoint string // Google Cloud Storage endpoint URL
  10. }
  11. // NewDefaultConfig returns a new default configuration for Google Cloud Storage transport
  12. func NewDefaultConfig() Config {
  13. return Config{
  14. Key: "",
  15. Endpoint: "",
  16. }
  17. }
  18. // LoadConfigFromEnv loads configuration from the global config package
  19. func LoadConfigFromEnv(c *Config) (*Config, error) {
  20. c = ensure.Ensure(c, NewDefaultConfig)
  21. c.Key = config.GCSKey
  22. c.Endpoint = config.GCSEndpoint
  23. return c, nil
  24. }
  25. // Validate checks the configuration for errors
  26. func (c *Config) Validate() error {
  27. return nil
  28. }