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

Override TLS flags individually for meta commands #11592

Merged
merged 2 commits into from
Dec 1, 2021
Merged
Changes from 1 commit
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
40 changes: 27 additions & 13 deletions command/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ type ApiClientFactory func() (*api.Client, error)
// the default command line arguments and env vars.
func (m *Meta) clientConfig() *api.Config {
config := api.DefaultConfig()

if m.flagAddress != "" {
config.Address = m.flagAddress
}
Expand All @@ -131,23 +132,36 @@ func (m *Meta) clientConfig() *api.Config {
config.Namespace = m.namespace
}

// If we need custom TLS configuration, then set it
if m.caCert != "" || m.caPath != "" || m.clientCert != "" || m.clientKey != "" || m.tlsServerName != "" || m.insecure {
t := &api.TLSConfig{
CACert: m.caCert,
CAPath: m.caPath,
ClientCert: m.clientCert,
ClientKey: m.clientKey,
TLSServerName: m.tlsServerName,
Insecure: m.insecure,
}
config.TLSConfig = t
}

if m.token != "" {
config.SecretID = m.token
}

// If the user has passed custom TLS configuration, override with that.
// Refactored to address issue #11539
DerekStrickland marked this conversation as resolved.
Show resolved Hide resolved
if m.caCert != "" {
config.TLSConfig.CACert = m.caCert
}

if m.caPath != "" {
config.TLSConfig.CAPath = m.caPath
}

if m.clientCert != "" {
config.TLSConfig.ClientCert = m.clientCert
}

if m.clientKey != "" {
config.TLSConfig.ClientKey = m.clientKey
}

if m.tlsServerName != "" {
config.TLSConfig.TLSServerName = m.tlsServerName
}

if m.insecure {
config.TLSConfig.Insecure = m.insecure
}

return config
}

Expand Down