Skip to content

Commit

Permalink
Merge pull request #1887 from marcolan018/ocm-6883-1
Browse files Browse the repository at this point in the history
OCM-6883 | fix: disable the feature for custom username of cluster admin
  • Loading branch information
openshift-merge-bot[bot] authored and gdbranco committed Mar 29, 2024
1 parent eb8d019 commit 2f619ab
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cmd/create/cluster/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ func initFlags(cmd *cobra.Command) {
- Be at least 14 characters (ASCII-standard) without whitespaces
- Include uppercase letters, lowercase letters, and numbers or symbols (ASCII-standard characters only)`,
)
flags.MarkHidden("cluster-admin-user")

flags.StringVar(
&args.AuditLogRoleARN,
Expand Down Expand Up @@ -864,9 +865,9 @@ func run(cmd *cobra.Command, _ []string) {
os.Exit(1)
}
createAdminUser := args.createAdminUser
clusterAdminUser := strings.Trim(args.clusterAdminUser, " \t")
clusterAdminUser := admin.ClusterAdminUsername //strings.Trim(args.clusterAdminUser, " \t")
clusterAdminPassword := strings.Trim(args.clusterAdminPassword, " \t")
if (createAdminUser || clusterAdminUser != "" || clusterAdminPassword != "") && isHostedCP {
if (createAdminUser || clusterAdminPassword != "") && isHostedCP {
r.Reporter.Errorf("Setting Cluster Admin is only supported in classic ROSA clusters")
os.Exit(1)
}
Expand Down Expand Up @@ -1016,15 +1017,15 @@ func run(cmd *cobra.Command, _ []string) {
}

// Errors when users elects for cluster admin via flags and elects for hosted control plane via interactive prompt"
if isHostedCP && (createAdminUser || clusterAdminPassword != "" || clusterAdminUser != "") {
if isHostedCP && (createAdminUser || clusterAdminPassword != "") {
r.Reporter.Errorf("Setting Cluster Admin is only supported in classic ROSA clusters")
os.Exit(1)
}

// isClusterAdmin is a flag indicating if user wishes to create cluster admin
isClusterAdmin := false
if !isHostedCP {
if createAdminUser || clusterAdminPassword != "" || clusterAdminUser != "" {
if createAdminUser || clusterAdminPassword != "" {
isClusterAdmin = true
// user supplies create-admin-user flag without cluster-admin-password will generate random password
if clusterAdminPassword == "" {
Expand Down Expand Up @@ -1064,7 +1065,7 @@ func run(cmd *cobra.Command, _ []string) {
os.Exit(1)
}
if isClusterAdmin {
clusterAdminUser = idp.GetIdpUserNameFromPrompt(cmd, r, "cluster-admin-user", clusterAdminUser)
//clusterAdminUser = idp.GetIdpUserNameFromPrompt(cmd, r, "cluster-admin-user", clusterAdminUser, true)
isCustomAdminPassword, err := interactive.GetBool(interactive.Input{
Question: "Create custom password for cluster admin",
Default: false,
Expand Down Expand Up @@ -1188,7 +1189,9 @@ func run(cmd *cobra.Command, _ []string) {
externalAuthProvidersEnabled := args.externalAuthProvidersEnabled
if externalAuthProvidersEnabled {
if !isHostedCP {
r.Reporter.Errorf("External authentication configuration is only supported for a Hosted Control Plane cluster.")
r.Reporter.Errorf(
"External authentication configuration is only supported for a Hosted Control Plane cluster.",
)
os.Exit(1)
}
}
Expand Down

0 comments on commit 2f619ab

Please sign in to comment.