Skip to content

Add a disable ssl option#3

Merged
LightJack05 merged 4 commits intomainfrom
disable-ssl-option
Dec 28, 2025
Merged

Add a disable ssl option#3
LightJack05 merged 4 commits intomainfrom
disable-ssl-option

Conversation

@LightJack05
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings December 28, 2025 19:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a configuration option to disable SSL for PostgreSQL database connections. The change introduces a new DisableSSL boolean field that controls whether sslmode=disable is appended to the connection string.

  • Added DisableSSL boolean field to DatabaseConfig struct
  • Loads DisableSSL from DATABASE_CONFIG_DISABLE_SSL environment variable
  • Conditionally appends ?sslmode=disable to connection string when DisableSSL is true

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
databaseConfig.go Adds DisableSSL boolean field to the configuration struct
loadConfig.go Parses DATABASE_CONFIG_DISABLE_SSL environment variable and handles errors
getDatabaseConnectionString.go Conditionally appends ?sslmode=disable query parameter when SSL is disabled

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

loadConfig.go Outdated
Comment on lines 26 to 28
loadedConfig.DisableSSL, err = strconv.ParseBool(os.Getenv("DATABASE_CONFIG_DISABLE_SSL"))
if err != nil {
return fmt.Errorf("Invalid DisableSSL value: %v", err)
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The strconv.ParseBool function returns an error when the environment variable is empty or not set. This makes DisableSSL a required configuration field, which is likely not the intended behavior for an optional feature like disabling SSL. Consider providing a default value (false) when the environment variable is not set or empty, similar to how DatabasePort has a default value on line 32. This would allow the feature to be truly optional.

Suggested change
loadedConfig.DisableSSL, err = strconv.ParseBool(os.Getenv("DATABASE_CONFIG_DISABLE_SSL"))
if err != nil {
return fmt.Errorf("Invalid DisableSSL value: %v", err)
disableSSLStr := os.Getenv("DATABASE_CONFIG_DISABLE_SSL")
if disableSSLStr != "" {
loadedConfig.DisableSSL, err = strconv.ParseBool(disableSSLStr)
if err != nil {
return fmt.Errorf("Invalid DisableSSL value: %v", err)
}

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings December 28, 2025 19:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return fmt.Sprintf("postgres://%s:%s@%s:%d/%s", activeConfig.DatabaseUser, activeConfig.DatabasePass, activeConfig.DatabaseHost, activeConfig.DatabasePort, activeConfig.DatabaseName)
dbString := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", activeConfig.DatabaseUser, activeConfig.DatabasePass, activeConfig.DatabaseHost, activeConfig.DatabasePort, activeConfig.DatabaseName)
if activeConfig.DisableSSL {
dbString += "?sslmode=disable"
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When DisableSSL is false, no sslmode parameter is added to the connection string. This means the default behavior depends on the PostgreSQL driver's default, which may vary. Consider explicitly setting sslmode=require (or another appropriate mode like sslmode=verify-full) when SSL is enabled to ensure consistent and secure behavior across different environments.

Suggested change
dbString += "?sslmode=disable"
dbString += "?sslmode=disable"
} else {
dbString += "?sslmode=require"

Copilot uses AI. Check for mistakes.
@LightJack05 LightJack05 merged commit 1e73431 into main Dec 28, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant