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

Expand TELEPORT_SITE environment to tsh login, fixes #2668 #2675

Merged
merged 1 commit into from
Apr 24, 2019
Merged
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
10 changes: 9 additions & 1 deletion tool/tsh/tsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const (
clusterEnvVar = "TELEPORT_SITE"
clusterHelp = "Specify the cluster to connect"
bindAddrEnvVar = "TELEPORT_LOGIN_BIND_ADDR"
authEnvVar = "TELEPORT_AUTH"
)

// Run executes TSH client. same as main() but easier to test
Expand All @@ -192,7 +193,7 @@ func Run(args []string, underTest bool) {
app.Flag("compat", "OpenSSH compatibility flag").Hidden().StringVar(&cf.Compatibility)
app.Flag("cert-format", "SSH certificate format").StringVar(&cf.CertificateFormat)
app.Flag("insecure", "Do not verify server's certificate and host name. Use only in test environments").Default("false").BoolVar(&cf.InsecureSkipVerify)
app.Flag("auth", "Specify the type of authentication connector to use.").StringVar(&cf.AuthConnector)
app.Flag("auth", "Specify the type of authentication connector to use.").Envar(authEnvVar).StringVar(&cf.AuthConnector)
app.Flag("namespace", "Namespace of the cluster").Default(defaults.Namespace).Hidden().StringVar(&cf.Namespace)
app.Flag("gops", "Start gops endpoint on a given address").Hidden().BoolVar(&cf.Gops)
app.Flag("gops-addr", "Specify gops addr to listen on").Hidden().StringVar(&cf.GopsAddr)
Expand Down Expand Up @@ -360,6 +361,13 @@ func onLogin(cf *CLIConf) {
key *client.Key
)

// populate cluster name from environment variables
// only if not set by argument (that does not support env variables)
clusterName := os.Getenv(clusterEnvVar)
if cf.SiteName == "" {
cf.SiteName = clusterName
}

if cf.IdentityFileIn != "" {
utils.FatalError(trace.BadParameter("-i flag cannot be used here"))
}
Expand Down