Skip to content

Commit

Permalink
add: Postgres SSL mode defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-dee7 committed Jul 8, 2023
1 parent b81f606 commit bd37475
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/oci-dist-spec-storj-s3-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ jobs:
yq e -i '.environment = "ci"' config.yaml
yq e -i '.dfs.storj.type = "s3"' config.yaml
yq e -i '.dfs.storj.enabled = "true"' config.yaml
STORJ_CI_ACCESS_KEY=${{ secrets.STORJ_CI_ACCESS_KEY }} yq e -i '.dfs.storj.access_key = env(STORJ_CI_ACCESS_KEY)' config.yaml
STORJ_CI_SECRET_KEY=${{ secrets.STORJ_CI_SECRET_KEY }} yq e -i '.dfs.storj.secret_key = env(STORJ_CI_SECRET_KEY)' config.yaml
STORJ_CI_ACCESS_KEY=${{ secrets.STORJ_CI_ACCESS_KEY }} yq e -i '.dfs.storj.access_key = env(STORJ_CI_ACCESS_KEY)' config.yaml
STORJ_CI_BUCKET_NAME=${{ secrets.STORJ_CI_BUCKET_NAME }} yq e -i '.dfs.storj.bucket_name = env(STORJ_CI_BUCKET_NAME)' config.yaml
STORJ_CI_ACCESS_GRANT_TOKEN=${{ secrets.STORJ_CI_ACCESS_GRANT_TOKEN }} yq e -i '.dfs.storj.access_grant_token = env(STORJ_CI_ACCESS_GRANT_TOKEN)' config.yaml
STORJ_CI_ENDPOINT=${{ secrets.STORJ_CI_ENDPOINT }} yq e -i '.dfs.storj.endpoint = env(STORJ_CI_ENDPOINT)' config.yaml
Expand Down
10 changes: 7 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type (
Host string `yaml:"host" mapstructure:"host" validate:"required"`
Password string `yaml:"password" mapstructure:"password" validate:"required"`
Database string `yaml:"name" mapstructure:"name" validate:"required"`
SSLMode string `yaml:"ssl_mode" mapstructure:"ssl_mode" validate:"-"`
Port int `yaml:"port" mapstructure:"port" validate:"required"`
}

Expand Down Expand Up @@ -177,6 +178,7 @@ func NewStoreConfig() (*Store, error) {
Database: viper.GetString("DB_NAME"),
Host: viper.GetString("DB_HOST"),
Port: viper.GetInt("DB_PORT"),
SSLMode: viper.GetString("DB_SSL_MODE"),
}

return storeConfig, nil
Expand Down Expand Up @@ -227,10 +229,12 @@ func translateError(err error, trans ut.Translator) error {
}

func (sc *Store) Endpoint() string {
return fmt.Sprintf(
"postgres://%s:%s@%s:%d/%s?pool_max_conns=1000&sslmode=disable",
sc.User, sc.Password, sc.Host, sc.Port, sc.Database,
pgurl := fmt.Sprintf(
"postgres://%s:%s@%s:%d/%s?pool_max_conns=1000&sslmode=%s",
sc.User, sc.Password, sc.Host, sc.Port, sc.Database, sc.SSLMode,
)

return pgurl
}

func (oc *OpenRegistryConfig) Endpoint() string {
Expand Down
4 changes: 4 additions & 0 deletions config/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,8 @@ func setDefaultsForStorageBackend(cfg *OpenRegistryConfig) {
cfg.DFS.Storj.MinChunkSize = fiveMBInBytes
}
}

if cfg.StoreConfig.SSLMode == "" {
cfg.StoreConfig.SSLMode = "disable"
}
}

0 comments on commit bd37475

Please sign in to comment.