From eb8d019f964f781f694212afa0bd4f41fbb61db6 Mon Sep 17 00:00:00 2001 From: "openshift-merge-bot[bot]" <148852131+openshift-merge-bot[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:05:36 +0000 Subject: [PATCH] Merge pull request #1883 from gdbranco/chore/revert-ocm-6883 Revert ocm-6883 --- cmd/create/admin/cmd.go | 6 +++--- cmd/describe/admin/cmd.go | 25 +++++++++++++++---------- cmd/dlt/admin/cmd.go | 6 +++--- hack/commit-msg-verify.sh | 19 ++++++++++++++++++- 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/cmd/create/admin/cmd.go b/cmd/create/admin/cmd.go index 7536c85d3..0042ccc19 100644 --- a/cmd/create/admin/cmd.go +++ b/cmd/create/admin/cmd.go @@ -39,9 +39,9 @@ const MaxPasswordLength = 23 var Cmd = &cobra.Command{ Use: "admin", - Short: "Creates the 'cluster-admin' user to login to the cluster", - Long: "Creates the 'cluster-admin' user with an auto-generated password to login to the cluster", - Example: ` # Create the 'cluster-admin' user to login to the cluster + Short: "Creates an admin user to login to the cluster", + Long: "Creates a cluster-admin user with an auto-generated password to login to the cluster", + Example: ` # Create an admin user to login to the cluster rosa create admin -c mycluster -p MasterKey123`, Run: run, Args: cobra.NoArgs, diff --git a/cmd/describe/admin/cmd.go b/cmd/describe/admin/cmd.go index 1d42e8335..6c1a6f6f3 100644 --- a/cmd/describe/admin/cmd.go +++ b/cmd/describe/admin/cmd.go @@ -22,7 +22,6 @@ import ( cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1" "github.com/spf13/cobra" - "github.com/openshift/rosa/cmd/create/admin" cadmin "github.com/openshift/rosa/cmd/create/admin" "github.com/openshift/rosa/pkg/ocm" "github.com/openshift/rosa/pkg/rosa" @@ -54,20 +53,26 @@ func run(_ *cobra.Command, _ []string) { os.Exit(1) } - admins, err := r.OCMClient.GetUsers(cluster.ID(), admin.ClusterAdminGroupname) + if cluster.ExternalAuthConfig().Enabled() { + r.Reporter.Errorf( + "Describing the 'cluster-admin' user is not supported for clusters with external authentication configured.", + ) + os.Exit(1) + } + + // Try to find an existing htpasswd identity provider and + // check if cluster-admin user already exists + existingClusterAdminIdp, _, err := cadmin.FindIDPWithAdmin(cluster, r) if err != nil { r.Reporter.Errorf(err.Error()) os.Exit(1) } - - if len(admins) != 0 { - for _, admin := range admins { - r.Reporter.Infof("There is '%s' user on cluster '%s'. To login, run the following command:\n"+ - " oc login %s --username %s", - admin.ID(), clusterKey, cluster.API().URL(), admin.ID()) - } + if existingClusterAdminIdp != nil { + r.Reporter.Infof("There is '%s' user on cluster '%s'. To login, run the following command:\n"+ + " oc login %s --username %s", + cadmin.ClusterAdminUsername, clusterKey, cluster.API().URL(), cadmin.ClusterAdminUsername) } else { - r.Reporter.Warnf("There is no %s user on cluster '%s'. To create it run the following command:\n"+ + r.Reporter.Warnf("There is no '%s' user on cluster '%s'. To create it run the following command:\n"+ " rosa create admin -c %s", cadmin.ClusterAdminUsername, clusterKey, clusterKey) os.Exit(0) } diff --git a/cmd/dlt/admin/cmd.go b/cmd/dlt/admin/cmd.go index c42e7bff1..accd01c70 100644 --- a/cmd/dlt/admin/cmd.go +++ b/cmd/dlt/admin/cmd.go @@ -86,9 +86,9 @@ func (d *DeleteUserAdminFromIDP) deleteAdmin(r *rosa.Runtime, identityProvider * var Cmd = &cobra.Command{ Use: "admin", - Short: "Deletes the 'cluster-admin' user", - Long: "Deletes the 'cluster-admin' user used to login to the cluster", - Example: ` # Delete the 'cluster-admin' user + Short: "Deletes the admin user", + Long: "Deletes the cluster-admin user used to login to the cluster", + Example: ` # Delete the admin user rosa delete admin --cluster=mycluster`, Run: run, Args: cobra.NoArgs, diff --git a/hack/commit-msg-verify.sh b/hack/commit-msg-verify.sh index 63f7baa1d..56fb1f26c 100755 --- a/hack/commit-msg-verify.sh +++ b/hack/commit-msg-verify.sh @@ -4,7 +4,24 @@ PULL_BASE_SHA="${PULL_BASE_SHA:-$(git merge-base master HEAD)}" PULL_PULL_SHA="${PULL_PULL_SHA:-HEAD}" -pattern="^[A-Z]+-[0-9]+ \| (feat|fix|docs|style|refactor|test|chore|build|ci|perf): .*$" +# Lists of GitHub users for whom the commit validation should be skipped: +# # This contains the bots used in the ROSA project +# * openshift-merge-bot[bot] - bot responsible for merigng MRs +# * openshift-ci[bot] - bot responsible for running tests / approvals +declare -a skip_pr_authors=( + "openshift-ci[bot]" + "openshift-merge-bot[bot]" +) +echo "The PR Author is \"${PULL_AUTHOR}\"" +for skip_pr_author in "${skip_pr_authors[@]}" +do + if [ "${PULL_AUTHOR}" = "${skip_pr_author}" ]; then + echo "The commits created by this PR author (probably bot) should be skipped!!!" + exit 0 + fi +done + +pattern="^(Revert \")?[A-Z]+-[0-9]+ \| (feat|fix|docs|style|refactor|test|chore|build|ci|perf): .*$" commits=$(git rev-list --no-merges $PULL_BASE_SHA..$PULL_PULL_SHA)