Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove camel case config #203

Merged
merged 8 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/tests/it/client/helper.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
agentAddress = "/var/run/api.sock"
agent_address = "/var/run/api.sock"
cmd = "/run/client/assert.sh"
cmdArgs = ""
certDir = "/run/client/certs/"
renewSignal = "SIGUSR1"
svidFileName = "svid.crt"
svidKeyFileName = "svid.key"
svidBundleFileName = "root.crt"
cmd_args = ""
cert_dir = "/run/client/certs/"
renew_signal = "SIGUSR1"
svid_file_name = "svid.crt"
svid_key_file_name = "svid.key"
svid_bundle_file_name = "root.crt"
14 changes: 7 additions & 7 deletions .github/tests/it/go-server/helper.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
agentAddress = "/var/run/api.sock"
agent_address = "/var/run/api.sock"
cmd = ""
cmdArgs = ""
certDir = "/run/go-server/certs/"
renewSignal = "SIGUSR1"
svidFileName = "svid.crt"
svidKeyFileName = "svid.key"
svidBundleFileName = "root.crt"
cmd_args = ""
cert_dir = "/run/go-server/certs/"
renew_signal = "SIGUSR1"
svid_file_name = "svid.crt"
svid_key_file_name = "svid.key"
svid_bundle_file_name = "root.crt"
16 changes: 8 additions & 8 deletions .github/tests/it/mysql/helper.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
agentAddress = "/var/run/api.sock"
agent_address = "/var/run/api.sock"
cmd = "mysql"
cmdArgs = "-e \"ALTER INSTANCE RELOAD TLS;\""
certDir = "/var/lib/mysql/"
renewSignal = "SIGUSR1"
svidFileName = "server-cert.pem"
svidKeyFileName = "server-key.pem"
svidBundleFileName = "ca.pem"
addIntermediatesToBundle = true
cmd_args = "-e \"ALTER INSTANCE RELOAD TLS;\""
cert_dir = "/var/lib/mysql/"
renew_signal = "SIGUSR1"
svid_file_name = "server-cert.pem"
svid_key_file_name = "server-key.pem"
svid_bundle_file_name = "ca.pem"
add_intermediates_to_bundle = true
14 changes: 7 additions & 7 deletions .github/tests/it/postgres/helper.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
agentAddress = "/var/run/api.sock"
agent_address = "/var/run/api.sock"
cmd = "/run/postgresql/reload_certificates.sh"
cmdArgs = ""
certDir = "/run/postgresql/certs/"
renewSignal = "SIGUSR1"
svidFileName = "svid.crt"
svidKeyFileName = "svid.key"
svidBundleFileName = "root.crt"
cmd_args = ""
cert_dir = "/run/postgresql/certs/"
renew_signal = "SIGUSR1"
svid_file_name = "svid.crt"
svid_key_file_name = "svid.key"
svid_bundle_file_name = "root.crt"
102 changes: 17 additions & 85 deletions cmd/spiffe-helper/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,24 @@ const (
)

type Config struct {
AddIntermediatesToBundle bool `hcl:"add_intermediates_to_bundle"`
AddIntermediatesToBundleDeprecated bool `hcl:"addIntermediatesToBundle"`
AgentAddress string `hcl:"agent_address"`
AgentAddressDeprecated string `hcl:"agentAddress"`
Cmd string `hcl:"cmd"`
CmdArgs string `hcl:"cmd_args"`
PIDFileName string `hcl:"pid_file_name"`
CmdArgsDeprecated string `hcl:"cmdArgs"`
CertDir string `hcl:"cert_dir"`
CertDirDeprecated string `hcl:"certDir"`
CertFileMode int `hcl:"cert_file_mode"`
KeyFileMode int `hcl:"key_file_mode"`
JWTBundleFileMode int `hcl:"jwt_bundle_file_mode"`
JWTSVIDFileMode int `hcl:"jwt_svid_file_mode"`
IncludeFederatedDomains bool `hcl:"include_federated_domains"`
RenewSignal string `hcl:"renew_signal"`
RenewSignalDeprecated string `hcl:"renewSignal"`
DaemonMode *bool `hcl:"daemon_mode"`
AddIntermediatesToBundle bool `hcl:"add_intermediates_to_bundle"`
AgentAddress string `hcl:"agent_address"`
Cmd string `hcl:"cmd"`
CmdArgs string `hcl:"cmd_args"`
PIDFileName string `hcl:"pid_file_name"`
CertDir string `hcl:"cert_dir"`
CertFileMode int `hcl:"cert_file_mode"`
KeyFileMode int `hcl:"key_file_mode"`
JWTBundleFileMode int `hcl:"jwt_bundle_file_mode"`
JWTSVIDFileMode int `hcl:"jwt_svid_file_mode"`
IncludeFederatedDomains bool `hcl:"include_federated_domains"`
RenewSignal string `hcl:"renew_signal"`
DaemonMode *bool `hcl:"daemon_mode"`

// x509 configuration
SVIDFileName string `hcl:"svid_file_name"`
SVIDFileNameDeprecated string `hcl:"svidFileName"`
SVIDKeyFileName string `hcl:"svid_key_file_name"`
SVIDKeyFileNameDeprecated string `hcl:"svidKeyFileName"`
SVIDBundleFileName string `hcl:"svid_bundle_file_name"`
SVIDBundleFileNameDeprecated string `hcl:"svidBundleFileName"`
SVIDFileName string `hcl:"svid_file_name"`
SVIDKeyFileName string `hcl:"svid_key_file_name"`
SVIDBundleFileName string `hcl:"svid_bundle_file_name"`

// JWT configuration
JWTSVIDs []JWTConfig `hcl:"jwt_svids"`
Expand Down Expand Up @@ -94,7 +86,7 @@ func (c *Config) ParseConfigFlagOverrides(daemonModeFlag bool, daemonModeFlagNam
}
}

func (c *Config) ValidateConfig(log logrus.FieldLogger) error {
func (c *Config) ValidateConfig() error {
if err := c.checkForUnknownConfig(); err != nil {
return err
}
Expand All @@ -103,62 +95,6 @@ func (c *Config) ValidateConfig(log logrus.FieldLogger) error {
return err
}

if c.AgentAddressDeprecated != "" {
if c.AgentAddress != "" {
return errors.New("use of agent_address and agentAddress found, use only agent_address")
}
log.Warn(getWarning("agentAddress", "agent_address"))
c.AgentAddress = c.AgentAddressDeprecated
}

if c.CmdArgsDeprecated != "" {
if c.CmdArgs != "" {
return errors.New("use of cmd_args and cmdArgs found, use only cmd_args")
}
log.Warn(getWarning("cmdArgs", "cmd_args"))
c.CmdArgs = c.CmdArgsDeprecated
}

if c.CertDirDeprecated != "" {
if c.CertDir != "" {
return errors.New("use of cert_dir and certDir found, use only cert_dir")
}
log.Warn(getWarning("certDir", "cert_dir"))
c.CertDir = c.CertDirDeprecated
}

if c.SVIDFileNameDeprecated != "" {
if c.SVIDFileName != "" {
return errors.New("use of svid_file_name and svidFileName found, use only svid_file_name")
}
log.Warn(getWarning("svidFileName", "svid_file_name"))
c.SVIDFileName = c.SVIDFileNameDeprecated
}

if c.SVIDKeyFileNameDeprecated != "" {
if c.SVIDKeyFileName != "" {
return errors.New("use of svid_key_file_name and svidKeyFileName found, use only svid_key_file_name")
}
log.Warn(getWarning("svidKeyFileName", "svid_key_file_name"))
c.SVIDKeyFileName = c.SVIDKeyFileNameDeprecated
}

if c.SVIDBundleFileNameDeprecated != "" {
if c.SVIDBundleFileName != "" {
return errors.New("use of svid_bundle_file_name and svidBundleFileName found, use only svid_bundle_file_name")
}
log.Warn(getWarning("svidBundleFileName", "svid_bundle_file_name"))
c.SVIDBundleFileName = c.SVIDBundleFileNameDeprecated
}

if c.RenewSignalDeprecated != "" {
if c.RenewSignal != "" {
return errors.New("use of renew_signal and renewSignal found, use only renew_signal")
}
log.Warn(getWarning("renewSignal", "renew_signal"))
c.RenewSignal = c.RenewSignalDeprecated
}

for _, jwtConfig := range c.JWTSVIDs {
if jwtConfig.JWTSVIDFilename == "" {
return errors.New("'jwt_file_name' is required in 'jwt_svids'")
Expand Down Expand Up @@ -275,10 +211,6 @@ func validateJWTConfig(c *Config) (bool, bool) {
return jwtBundleEmptyCount == 0, len(c.JWTSVIDs) > 0
}

func getWarning(s1 string, s2 string) string {
return s1 + " will be deprecated, should be used as " + s2
}

func countEmpty(configs ...string) int {
cnt := 0
for _, config := range configs {
Expand Down
Loading