Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/go/rpk/pkg/cli/security/role/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ go_library(
"@com_github_spf13_cobra//:cobra",
"@com_github_twmb_franz_go_pkg_kadm//:kadm",
"@com_github_twmb_types//:types",
"@io_k8s_apimachinery//pkg/util/validation",
],
)

Expand Down
15 changes: 15 additions & 0 deletions src/go/rpk/pkg/cli/security/role/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ package role

import (
"fmt"
"os"
"strings"

dataplanev1 "buf.build/gen/go/redpandadata/dataplane/protocolbuffers/go/redpanda/api/dataplane/v1"
"connectrpc.com/connect"
Expand All @@ -20,6 +22,7 @@ import (
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/publicapi"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/util/validation"
)

type createResponse struct {
Expand All @@ -45,6 +48,18 @@ flag in the 'rpk security acl create' command.`,
config.CheckExitServerlessAdmin(prof)

roleName := args[0]
if msgs := validation.IsDNS1123Subdomain(roleName); len(msgs) > 0 {
fmt.Fprintf(os.Stderr,
`Warning: role name %q is not a valid DNS-1123 subdomain (RFC 1123):
- %s
This role cannot be adopted by a RedpandaRole CR in the Redpanda
Kubernetes operator, since the operator binds the role name to the
CR's metadata.name. Consider using a lowercase name (letters, digits,
'-', '.') if you may migrate to operator-managed roles.
`,
roleName, strings.Join(msgs, "\n - "),
)
}
if prof.CheckFromCloud() {
cl, err := publicapi.DataplaneClientFromRpkProfile(prof)
out.MaybeDie(err, "unable to initialize cloud API client: %v", err)
Expand Down
Loading