Skip to content

Commit

Permalink
refactor(config): rename config var SSLEnabled to TLSEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Icikowski committed Jan 6, 2023
1 parent 9acf163 commit ac73555
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/config/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import (
type ServiceConfig struct {
Port int `env:"PORT" json:"port"`
SecuredPort int `env:"SECURED_PORT" json:"securedPort"`
SSLEnabled bool `env:"SSL_ENABLED" envDefault:"false" json:"sslEnabled"`
TLSEnabled bool `env:"TLS_ENABLED" envDefault:"false" json:"tlsEnabled"`
TLSCertPath string `env:"TLS_CERT_PATH" json:"tlsCertPath"`
TLSKeyPath string `env:"TLS_KEY_PATH" json:"tlsKeyPath"`

tlsCert tls.Certificate
}

// LoadCerts attempts to load CA & TLS certificates defined in configuration
// LoadCerts attempts to load TLS certificates defined in configuration
func (c *ServiceConfig) LoadCerts() error {
if !c.SSLEnabled {
if !c.TLSEnabled {
return nil
}

Expand All @@ -34,7 +34,7 @@ func (c *ServiceConfig) LoadCerts() error {

// GetTLSConfig returns the *tls.Config based on given configuration
func (c *ServiceConfig) GetTLSConfig() *tls.Config {
if !c.SSLEnabled {
if !c.TLSEnabled {
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions src/config/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestLoadCerts(t *testing.T) {
genFunc func(*testing.T) (string, string)
errorExpected bool
}{
"SSL disabled": {
"TLS disabled": {
sslEnabled: false,
genFunc: noopCertGen,
errorExpected: false,
Expand All @@ -147,7 +147,7 @@ func TestLoadCerts(t *testing.T) {
name, tc := name, tc
t.Run(name, func(t *testing.T) {
conf := &config.ServiceConfig{
SSLEnabled: tc.sslEnabled,
TLSEnabled: tc.sslEnabled,
}
conf.TLSCertPath, conf.TLSKeyPath = tc.genFunc(t)

Expand All @@ -173,7 +173,7 @@ func TestGetTLSConfig(t *testing.T) {
name, tc := name, tc
t.Run(name, func(t *testing.T) {
conf := &config.ServiceConfig{
SSLEnabled: tc.sslEnabled,
TLSEnabled: tc.sslEnabled,
}
actual := conf.GetTLSConfig()

Expand Down
4 changes: 2 additions & 2 deletions src/services/admin/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ func (s *AdminAPIService) buildServers() (*http.Server, *http.Server) {
s.log.Debug().Dict("ports", zerolog.Dict().
Int("plain", s.cfg.Port).
Int("secured", s.cfg.SecuredPort),
).Bool("sslEnabled", s.cfg.SSLEnabled).Msg("building servers")
).Bool("sslEnabled", s.cfg.TLSEnabled).Msg("building servers")

plainServer := &http.Server{
Addr: fmt.Sprintf(":%d", s.cfg.Port),
Handler: s.handler,
}

var securedServer *http.Server
if s.cfg.SSLEnabled {
if s.cfg.TLSEnabled {
securedServer = &http.Server{
Addr: fmt.Sprintf(":%d", s.cfg.SecuredPort),
TLSConfig: s.cfg.GetTLSConfig(),
Expand Down
4 changes: 2 additions & 2 deletions src/services/content/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ func (s *ContentService) buildServers() (*http.Server, *http.Server) {
s.log.Debug().Dict("ports", zerolog.Dict().
Int("plain", s.cfg.Port).
Int("secured", s.cfg.SecuredPort),
).Bool("sslEnabled", s.cfg.SSLEnabled).Msg("building servers")
).Bool("sslEnabled", s.cfg.TLSEnabled).Msg("building servers")

plainServer := &http.Server{
Addr: fmt.Sprintf(":%d", s.cfg.Port),
Handler: s.handler,
}

var securedServer *http.Server
if s.cfg.SSLEnabled {
if s.cfg.TLSEnabled {
securedServer = &http.Server{
Addr: fmt.Sprintf(":%d", s.cfg.SecuredPort),
TLSConfig: s.cfg.GetTLSConfig(),
Expand Down

0 comments on commit ac73555

Please sign in to comment.