Skip to content

Adding --join-method flag to teleport configure command#52937

Merged
WilliamLoy merged 5 commits intomasterfrom
williamloy/add-join-flag
Mar 13, 2025
Merged

Adding --join-method flag to teleport configure command#52937
WilliamLoy merged 5 commits intomasterfrom
williamloy/add-join-flag

Conversation

@WilliamLoy
Copy link
Copy Markdown
Contributor

@WilliamLoy WilliamLoy commented Mar 10, 2025

A customer requested the --join-method flag be made available as an option when using the teleport configure command.

I didn't see a technical reason as to why this flag wasn't already available in the command so I've added it to this PR.

Changelog: Added a --join-method flag to the teleport configure command

@WilliamLoy
Copy link
Copy Markdown
Contributor Author

@rosstimothy I'd appreciate a review if you have the time.

Comment thread tool/teleport/common/teleport.go Outdated
Copy link
Copy Markdown
Contributor

@rosstimothy rosstimothy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but I think we can future proof things a bit if we don't hardcode the join methods and instead leverage types.JoinMethods.

What do you think about the following change?

diff --git a/go.mod b/go.mod
index 89090133d3..eab9cbd704 100644
--- a/go.mod
+++ b/go.mod
@@ -592,3 +592,5 @@ replace (
 	github.com/redis/go-redis/v9 => github.com/gravitational/redis/v9 v9.6.1-teleport.1
 	github.com/vulcand/predicate => github.com/gravitational/predicate v1.3.2
 )
+
+exclude google.golang.org/grpc/stats/opentelemetry v0.0.0-20241028142157-ada6787961b3
diff --git a/tool/teleport/common/teleport.go b/tool/teleport/common/teleport.go
index 4ab0ad433e..699da3468d 100644
--- a/tool/teleport/common/teleport.go
+++ b/tool/teleport/common/teleport.go
@@ -395,6 +395,11 @@ func Run(options Options) (app *kingpin.Application, executedCommand string, con
 	scpc.Flag("local-addr", "local address which accepted the request").StringVar(&scpFlags.LocalAddr)
 	scpc.Arg("target", "").StringsVar(&scpFlags.Target)
 
+	joinMethods := make([]string, 0, len(types.JoinMethods))
+	for _, m := range types.JoinMethods {
+		joinMethods = append(joinMethods, string(m))
+	}
+
 	// dump flags
 	dump.Flag("cluster-name",
 		"Unique cluster name, e.g. example.com.").StringVar(&dumpFlags.ClusterName)
@@ -412,7 +417,7 @@ func Run(options Options) (app *kingpin.Application, executedCommand string, con
 	dump.Flag("key-file", "Path to a TLS key file for the proxy.").ExistingFileVar(&dumpFlags.KeyFile)
 	dump.Flag("data-dir", "Path to a directory where Teleport keep its data.").Default(defaults.DataDir).StringVar(&dumpFlags.DataDir)
 	dump.Flag("token", "Invitation token or path to file with token value to register with an auth server.").StringVar(&dumpFlags.AuthToken)
-	dump.Flag("join-method", "Method to use to join the cluster (token, iam, ec2, kubernetes, azure, gcp, oracle, github, circleci, gitlab, tpm)").Default("token").EnumVar(&dumpFlags.JoinMethod, "token", "iam", "ec2", "kubernetes", "azure", "gcp", "oracle", "github", "circleci", "tpm")
+	dump.Flag("join-method", fmt.Sprintf("Method to use to join the cluster (%s)", strings.Join(joinMethods, ", "))).Default("token").EnumVar(&dumpFlags.JoinMethod, joinMethods...)
 	dump.Flag("roles", "Comma-separated list of roles to create config with.").StringVar(&dumpFlags.Roles)
 	dump.Flag("auth-server", "Address of the auth server.").StringVar(&dumpFlags.AuthServer)
 	dump.Flag("proxy", "Address of the proxy.").StringVar(&dumpFlags.ProxyAddress)
@@ -430,6 +435,7 @@ func Run(options Options) (app *kingpin.Application, executedCommand string, con
 	dumpNodeConfigure.Flag("output",
 		`Write to stdout with "--output=stdout", default config file with "--output=file" or custom path with --output=file:///path`).Short('o').Default(
 		teleport.SchemeStdout).StringVar(&dumpFlags.output)
+
 	dumpNodeConfigure.Flag("version", "Teleport configuration version.").Default(defaults.TeleportConfigVersionV3).StringVar(&dumpFlags.Version)
 	dumpNodeConfigure.Flag("public-addr", "The hostport that the node advertises for the SSH endpoint.").StringVar(&dumpFlags.PublicAddr)
 	dumpNodeConfigure.Flag("data-dir", "Path to a directory where Teleport keep its data.").Default(defaults.DataDir).StringVar(&dumpFlags.DataDir)
@@ -438,7 +444,7 @@ func Run(options Options) (app *kingpin.Application, executedCommand string, con
 	dumpNodeConfigure.Flag("proxy", "Address of the proxy server.").StringVar(&dumpFlags.ProxyAddress)
 	dumpNodeConfigure.Flag("labels", "Comma-separated list of labels to add to newly created nodes ex) env=staging,cloud=aws.").StringVar(&dumpFlags.NodeLabels)
 	dumpNodeConfigure.Flag("ca-pin", "Comma-separated list of SKPI hashes for the CA used to verify the auth server.").StringVar(&dumpFlags.CAPin)
-	dumpNodeConfigure.Flag("join-method", "Method to use to join the cluster (token, iam, ec2, kubernetes, azure, gcp, oracle, github, circleci, gitlab, tpm)").Default("token").EnumVar(&dumpFlags.JoinMethod, "token", "iam", "ec2", "kubernetes", "azure", "gcp", "oracle", "github", "circleci", "tpm")
+	dumpNodeConfigure.Flag("join-method", fmt.Sprintf("Method to use to join the cluster (%s)", strings.Join(joinMethods, ", "))).Default("token").EnumVar(&dumpFlags.JoinMethod, joinMethods...)
 	dumpNodeConfigure.Flag("node-name", "Name for the Teleport node.").StringVar(&dumpFlags.NodeName)
 	dumpNodeConfigure.Flag("silent", "Suppress user hint message.").BoolVar(&dumpFlags.Silent)
 	dumpNodeConfigure.Flag("azure-client-id", "Sets the client ID of the managed identity to join with. Only applies to the 'azure' join method.").StringVar(&dumpFlags.AzureClientID)

@WilliamLoy
Copy link
Copy Markdown
Contributor Author

@rosstimothy I incorporated your suggestion. Thank you.

Comment thread tool/teleport/common/teleport.go Outdated
Comment thread tool/teleport/common/teleport.go Outdated
WilliamLoy and others added 2 commits March 11, 2025 16:54
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from klizhentas March 13, 2025 02:47
@WilliamLoy WilliamLoy added this pull request to the merge queue Mar 13, 2025
Merged via the queue into master with commit bb142ed Mar 13, 2025
42 checks passed
@WilliamLoy WilliamLoy deleted the williamloy/add-join-flag branch March 13, 2025 03:17
@public-teleport-github-review-bot
Copy link
Copy Markdown

@WilliamLoy See the table below for backport results.

Branch Result
branch/v15 Failed
branch/v16 Failed
branch/v17 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants