Skip to content

Commit

Permalink
Merge pull request #1883 from gdbranco/chore/revert-ocm-6883
Browse files Browse the repository at this point in the history
Revert ocm-6883
  • Loading branch information
openshift-merge-bot[bot] authored and gdbranco committed Mar 28, 2024
1 parent 29a97ea commit eb8d019
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
6 changes: 3 additions & 3 deletions cmd/create/admin/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 15 additions & 10 deletions cmd/describe/admin/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/dlt/admin/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 18 additions & 1 deletion hack/commit-msg-verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit eb8d019

Please sign in to comment.