diff --git a/CHANGELOG.md b/CHANGELOG.md index 069775d..c1a0ec7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## Unreleased -* Deprecate `SSL_DOMAIN` in favor of `TLS_DOMAIN` +* [BREAKING] Rename the `SSL_DOMAIN` env to `TLS_DOMAIN` ## v0.1.3 / 2024-03-21 diff --git a/cmd/thrust/main.go b/cmd/thrust/main.go index 78871bb..a78f76d 100644 --- a/cmd/thrust/main.go +++ b/cmd/thrust/main.go @@ -13,8 +13,6 @@ func setLogger(level slog.Level) { } func main() { - setLogger(slog.LevelWarn) - config, err := internal.NewConfig() if err != nil { fmt.Printf("ERROR: %s\n", err) diff --git a/internal/config.go b/internal/config.go index 26bddde..a22d6f2 100644 --- a/internal/config.go +++ b/internal/config.go @@ -61,12 +61,6 @@ type Config struct { LogLevel slog.Level } -var warn func(msg string, args ...any) - -func init() { - warn = slog.Warn -} - func NewConfig() (*Config, error) { if len(os.Args) < 2 { return nil, errors.New("missing upstream command") @@ -77,12 +71,6 @@ func NewConfig() (*Config, error) { logLevel = slog.LevelDebug } - sslDomain := getEnvString("SSL_DOMAIN", "") - if sslDomain != "" { - warn("SSL_DOMAIN is deprecated. Use TLS_DOMAIN instead.", "SSL_DOMAIN", sslDomain) - } - tlsDomain := getEnvString("TLS_DOMAIN", sslDomain) - return &Config{ TargetPort: getEnvInt("TARGET_PORT", defaultTargetPort), UpstreamCommand: os.Args[1], @@ -93,7 +81,7 @@ func NewConfig() (*Config, error) { XSendfileEnabled: getEnvBool("X_SENDFILE_ENABLED", true), MaxRequestBody: getEnvInt("MAX_REQUEST_BODY", defaultMaxRequestBody), - TLSDomain: tlsDomain, + TLSDomain: getEnvString("TLS_DOMAIN", ""), ACMEDirectoryURL: getEnvString("ACME_DIRECTORY", defaultACMEDirectoryURL), EAB_KID: getEnvString("EAB_KID", ""), EAB_HMACKey: getEnvString("EAB_HMAC_KEY", ""), diff --git a/internal/config_test.go b/internal/config_test.go index edfff0e..8353c89 100644 --- a/internal/config_test.go +++ b/internal/config_test.go @@ -11,64 +11,23 @@ import ( func TestConfig_tls(t *testing.T) { t.Run("with no ENV", func(t *testing.T) { - var calls int - warn = func(msg string, args ...any) { - calls++ - } usingProgramArgs(t, "thruster", "echo", "hello") c, err := NewConfig() require.NoError(t, err) - assert.Equal(t, calls, 0) assert.Equal(t, "", c.TLSDomain) }) - t.Run("with deprecated SSL_DOMAIN", func(t *testing.T) { - var warns []string - warn = func(msg string, args ...any) { - warns = append(warns, msg) - } - usingProgramArgs(t, "thruster", "echo", "hello") - usingEnvVar(t, "SSL_DOMAIN", "example.com") - - c, err := NewConfig() - require.NoError(t, err) - - assert.Equal(t, warns, []string{"SSL_DOMAIN is deprecated. Use TLS_DOMAIN instead."}) - assert.Equal(t, "example.com", c.TLSDomain) - }) - t.Run("with TLS_DOMAIN", func(t *testing.T) { - var calls int - warn = func(msg string, args ...any) { - calls++ - } usingProgramArgs(t, "thruster", "echo", "hello") usingEnvVar(t, "TLS_DOMAIN", "example.com") c, err := NewConfig() require.NoError(t, err) - assert.Equal(t, calls, 0) assert.Equal(t, "example.com", c.TLSDomain) }) - - t.Run("with both SSL_DOMAIN and TLS_DOMAIN", func(t *testing.T) { - var warns []string - warn = func(msg string, args ...any) { - warns = append(warns, msg) - } - usingProgramArgs(t, "thruster", "echo", "hello") - usingEnvVar(t, "SSL_DOMAIN", "ssl.example.com") - usingEnvVar(t, "TLS_DOMAIN", "tls.example.com") - - c, err := NewConfig() - require.NoError(t, err) - - assert.Equal(t, warns, []string{"SSL_DOMAIN is deprecated. Use TLS_DOMAIN instead."}) - assert.Equal(t, "tls.example.com", c.TLSDomain) - }) } func TestConfig_defaults(t *testing.T) {