Преглед изворни кода

Fix provider TLS path handling

Signed-off-by: Moritz Johner <beller.moritz@googlemail.com>
Moritz Johner пре 2 месеци
родитељ
комит
8905601184
2 измењених фајлова са 5 додато и 13 уклоњено
  1. 2 10
      providers/v2/common/grpc/server/tls.go
  2. 3 3
      providers/v2/common/grpc/server/tls_test.go

+ 2 - 10
providers/v2/common/grpc/server/tls.go

@@ -46,11 +46,10 @@ type TLSConfig struct {
 	KeyFile    string
 }
 
-// DefaultTLSConfig returns a TLSConfig with default values.
-// TLS_CERT_DIR can override the directory that contains the provider TLS assets.
+// DefaultTLSConfig returns a TLSConfig with fixed provider TLS asset paths.
 func DefaultTLSConfig() *TLSConfig {
 	return &TLSConfig{
-		CertDir:    getEnvOrDefault("TLS_CERT_DIR", DefaultCertDir),
+		CertDir:    DefaultCertDir,
 		CACertFile: DefaultCACertFile,
 		CertFile:   DefaultCertFile,
 		KeyFile:    DefaultKeyFile,
@@ -115,13 +114,6 @@ func TLSVersionName(version uint16) string {
 	}
 }
 
-func getEnvOrDefault(key, defaultValue string) string {
-	if value := os.Getenv(key); value != "" {
-		return value
-	}
-	return defaultValue
-}
-
 func resolveCertPath(certDir, fileName string) (string, error) {
 	cleanDir := filepath.Clean(certDir)
 

+ 3 - 3
providers/v2/common/grpc/server/tls_test.go

@@ -21,7 +21,7 @@ import (
 	"testing"
 )
 
-func TestDefaultTLSConfigUsesFixedTLSFilenames(t *testing.T) {
+func TestDefaultTLSConfigUsesFixedTLSAssetPaths(t *testing.T) {
 	t.Setenv("TLS_CERT_DIR", "/custom/certs")
 	t.Setenv("TLS_CA_CERT_FILE", "custom-ca.pem")
 	t.Setenv("TLS_CERT_FILE", "custom-cert.pem")
@@ -29,8 +29,8 @@ func TestDefaultTLSConfigUsesFixedTLSFilenames(t *testing.T) {
 
 	got := DefaultTLSConfig()
 
-	if got.CertDir != "/custom/certs" {
-		t.Fatalf("DefaultTLSConfig() cert dir = %q, want %q", got.CertDir, "/custom/certs")
+	if got.CertDir != DefaultCertDir {
+		t.Fatalf("DefaultTLSConfig() cert dir = %q, want %q", got.CertDir, DefaultCertDir)
 	}
 	if got.CACertFile != DefaultCACertFile {
 		t.Fatalf("DefaultTLSConfig() CA file = %q, want %q", got.CACertFile, DefaultCACertFile)