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

List available auth methods in command output #400

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ release:
$(call build,tcld,windows,amd64,.exe)

tools:
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1
shakeelrao marked this conversation as resolved.
Show resolved Hide resolved
@go install github.com/golang/mock/mockgen@latest

lint:
Expand Down
20 changes: 19 additions & 1 deletion app/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ const (
AuthMethodAPIKeyOrMTLS = "api_key_or_mtls"
)

var (
AuthMethods = []string{
AuthMethodRestricted,
AuthMethodMTLS,
AuthMethodAPIKey,
AuthMethodAPIKeyOrMTLS,
}
)

var (
CaCertificateFlag = &cli.StringFlag{
Name: CaCertificateFlagName,
Expand Down Expand Up @@ -927,7 +936,8 @@ func NewNamespaceCommand(getNamespaceClientFn GetNamespaceClientFn) (CommandOut,
ResourceVersionFlag,
&cli.StringFlag{
Name: authMethodFlagName,
Usage: "The authentication method used for the namespace (e.g. 'mtls', 'api_key')",
Aliases: []string{"am"},
Usage: fmt.Sprintf("The authentication method used for the namespace (i.e. %s)", formatAuthMethods()),
Required: true,
},
},
Expand Down Expand Up @@ -1997,6 +2007,14 @@ func compareCodecSpec(existing, replacement *namespace.CodecServerPropertySpec)
return diff.Diff(string(existingBytes), string(replacementBytes)), nil
}

func formatAuthMethods() string {
var methods []string
for _, m := range AuthMethods {
methods = append(methods, fmt.Sprintf("'%s'", m))
}
return strings.Join(methods, ", ")
}

func disruptiveChange(old namespace.AuthMethod, new namespace.AuthMethod) bool {
return old != namespace.AUTH_METHOD_RESTRICTED && new != namespace.AUTH_METHOD_API_KEY_OR_MTLS
}
Expand Down
Loading