-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Implement global tsh config file: /etc/tsh.yaml
#12598
Conversation
* The user config file is merged into global config file, taking precedence. * If the global config file is absent, no error is raised.
tool/tsh/tshconfig.go
Outdated
@@ -46,6 +52,26 @@ type ExtraProxyHeaders struct { | |||
Headers map[string]string `yaml:"headers,omitempty"` | |||
} | |||
|
|||
// Merge two configs into one. The config from parameter has higher priority. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: (Just so it's a little clearer)
// Merge two configs into one. The config from parameter has higher priority. | |
// Merge two configs into one. The passed in otherConfig has higher priority. |
// Merge two configs into one. The config from parameter has higher priority. | ||
func (config *TshConfig) Merge(otherConfig *TshConfig) TshConfig { | ||
baseConfig := config | ||
if baseConfig == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the nil
check necessary here? The loadAllConfigs
is not ignoring errors from loadConfig
(which could generate those nil
pointers).
In addition, it feels a bit contra-intuitive to call a method from a nil
pointer (even if it is possible), so calling something like (*config)(nil).Merge(otherConfig)
would return a valid result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semantically nil
and &TshConfig{}
have exactly the same amount of information: zero, so it makes sense for the function to treat them equally. These assignments make it easier to implement the rest of the function, as I don't need to be on guard against nil pointers.
In the future (when I implement the rest of the RFD) there will be more fields to merge and having nil pointers makes it uglier.
* Implement global tsh config file: `/etc/tsh.yaml`. The default location can be changed with `TELEPORT_GLOBAL_TSH_CONFIG` env var. * The user config file is merged with the global config file. The user config file has a higher priority. * If the global config file is absent, no error is raised.
* Implement global tsh config file: `/etc/tsh.yaml`. The default location can be changed with `TELEPORT_GLOBAL_TSH_CONFIG` env var. * The user config file is merged with the global config file. The user config file has a higher priority. * If the global config file is absent, no error is raised.
* Implement global tsh config file: `/etc/tsh.yaml`. The default location can be changed with `TELEPORT_GLOBAL_TSH_CONFIG` env var. * The user config file is merged with the global config file. The user config file has a higher priority. * If the global config file is absent, no error is raised.
* Implement global tsh config file: `/etc/tsh.yaml`. The default location can be changed with `TELEPORT_GLOBAL_TSH_CONFIG` env var. * The user config file is merged with the global config file. The user config file has a higher priority. * If the global config file is absent, no error is raised.
/etc/tsh.yaml
, can be overridden withTELEPORT_TSH_CONFIG
.Original, partial spec in RFD: https://github.com/gravitational/teleport/blob/master/rfd/0061-tsh-aliases.md#global-tsh-config
Fixes #12342.