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

Implement global tsh config file: /etc/tsh.yaml #12598

Merged
merged 8 commits into from
May 13, 2022

Conversation

Tener
Copy link
Contributor

@Tener Tener commented May 12, 2022

  • The user config file is merged into global config file, taking precedence.
  • If the global config file is absent, no error is raised.
  • Path to global file defaults to /etc/tsh.yaml, can be overridden with TELEPORT_TSH_CONFIG.

Original, partial spec in RFD: https://github.com/gravitational/teleport/blob/master/rfd/0061-tsh-aliases.md#global-tsh-config

Fixes #12342.

Tener added 2 commits May 12, 2022 14:15
* The user config file is merged into global config file, taking precedence.
* If the global config file is absent, no error is raised.
@github-actions github-actions bot added documentation tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels May 12, 2022
@Tener Tener requested a review from lxea May 12, 2022 12:31
docs/pages/setup/reference/cli.mdx Outdated Show resolved Hide resolved
docs/pages/setup/reference/cli.mdx Outdated Show resolved Hide resolved
docs/pages/setup/reference/cli.mdx Outdated Show resolved Hide resolved
@@ -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.
Copy link
Collaborator

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)

Suggested change
// 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 {
Copy link
Contributor

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.

Copy link
Contributor Author

@Tener Tener May 13, 2022

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.

@Tener Tener enabled auto-merge (squash) May 13, 2022 06:56
@Tener Tener merged commit 80bdb11 into master May 13, 2022
@github-actions
Copy link

@Tener See the table below for backport results.

Branch Result
branch/v8 Failed
branch/v9 Failed

Tener added a commit that referenced this pull request May 13, 2022
* 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.
Tener added a commit that referenced this pull request May 13, 2022
* 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.
Tener added a commit that referenced this pull request May 13, 2022
* 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.
Tener added a commit that referenced this pull request May 16, 2022
* 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.
@Tener Tener deleted the tener/global-tsh-config-12342 branch May 16, 2022 07:39
@webvictim webvictim mentioned this pull request Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-required documentation tsh tsh - Teleport's command line tool for logging into nodes running Teleport.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for node-global tsh config
3 participants