Skip to content

Commit

Permalink
Merge pull request #18377 from deads2k/cli-18-priority
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 18390, 18389, 18290, 18377, 18385).

UPSTREAM: <carry>: hack out the oapi for restmapping resources when m…

…ore than one is present



If there is more than one kind or resource for a value (the CLI uses this for deciding what to do about deploymentconfigs as a for instance), anything in that list that is an openshift resource (I've only listed one to prove the concept), will be removed.

I think that referencing names from a file will still work since that should come back with one match.

@juanvallejo can you see if files containing oapi resources still work.
@soltysh @mfojtik @smarterclayton is this a thing we can live with? It will finally make the groupified resources have priority on the CLI.
@DirectXMan12 I really wish this had not worked.
  • Loading branch information
openshift-merge-robot authored Feb 2, 2018
2 parents 84cbae1 + 422b026 commit 1fef218
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/oc/cli/describe/describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func describerMap(clientConfig *rest.Config, kclient kclientset.Interface, host
authorizationapi.Kind("ClusterRole"): &ClusterRoleDescriber{oauthorizationClient},
authorizationapi.Kind("RoleBindingRestriction"): &RoleBindingRestrictionDescriber{oauthorizationClient},
oauthapi.Kind("OAuthAccessToken"): &OAuthAccessTokenDescriber{oauthClient},
authorizationapi.Kind("Identity"): &IdentityDescriber{userClient},
userapi.Kind("Identity"): &IdentityDescriber{userClient},
userapi.Kind("User"): &UserDescriber{userClient},
userapi.Kind("Group"): &GroupDescriber{userClient},
userapi.Kind("UserIdentityMapping"): &UserIdentityMappingDescriber{userClient},
Expand Down
2 changes: 1 addition & 1 deletion test/cmd/admin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ os::test::junit::declare_suite_start "cmd/admin/groups"
os::cmd::expect_success_and_text 'oc adm groups new shortoutputgroup -o name' 'groups/shortoutputgroup'
os::cmd::expect_failure_and_text 'oc adm groups new shortoutputgroup' 'groups.user.openshift.io "shortoutputgroup" already exists'
os::cmd::expect_failure_and_text 'oc adm groups new errorgroup -o blah' 'error: output format "blah" not recognized'
os::cmd::expect_failure_and_text 'oc get groups/errorgroup' 'groups "errorgroup" not found'
os::cmd::expect_failure_and_text 'oc get groups/errorgroup' 'groups.user.openshift.io "errorgroup" not found'
os::cmd::expect_success_and_text 'oc adm groups new group1 foo bar' 'group1.*foo, bar'
os::cmd::expect_success_and_text 'oc get groups/group1 --no-headers' 'foo, bar'
os::cmd::expect_success 'oc adm groups add-users group1 baz'
Expand Down
4 changes: 2 additions & 2 deletions test/cmd/authentication.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ listprojecttoken="$(oc process -f "${OS_ROOT}/test/testdata/authentication/scope
# this token doesn't have rights to see any projects even though it can hit the list endpoint, so an empty list is correct
# we'll add another scope that allows listing all known projects even if this token has no other powers in them.
os::cmd::expect_success_and_not_text "oc get projects --token='${listprojecttoken}'" "${project}"
os::cmd::expect_failure_and_text "oc get user/~ --token='${listprojecttoken}'" 'prevent this action; User "scoped-user" cannot get users at the cluster scope'
os::cmd::expect_failure_and_text "oc get user/~ --token='${listprojecttoken}'" 'prevent this action; User "scoped-user" cannot get users.user.openshift.io at the cluster scope'
os::cmd::expect_failure_and_text "oc get pods --token='${listprojecttoken}' -n '${project}'" "prevent this action; User \"scoped-user\" cannot list pods in project \"${project}\""

listprojecttoken="$(oc process -f "${OS_ROOT}/test/testdata/authentication/scoped-token-template.yaml" TOKEN_PREFIX=listallprojects SCOPE=user:list-projects USER_NAME="${username}" USER_UID="${useruid}" | oc create -f - -o name | awk -F/ '{print $2}')"
os::cmd::expect_success_and_text "oc get projects --token='${listprojecttoken}'" "${project}"

adminnonescalatingpowerstoken="$(oc process -f "${OS_ROOT}/test/testdata/authentication/scoped-token-template.yaml" TOKEN_PREFIX=admin SCOPE=role:admin:* USER_NAME="${username}" USER_UID="${useruid}" | oc create -f - -o name | awk -F/ '{print $2}')"
os::cmd::expect_failure_and_text "oc get user/~ --token='${adminnonescalatingpowerstoken}'" 'prevent this action; User "scoped-user" cannot get users at the cluster scope'
os::cmd::expect_failure_and_text "oc get user/~ --token='${adminnonescalatingpowerstoken}'" 'prevent this action; User "scoped-user" cannot get users.user.openshift.io at the cluster scope'
os::cmd::expect_failure_and_text "oc get secrets --token='${adminnonescalatingpowerstoken}' -n '${project}'" "prevent this action; User \"scoped-user\" cannot list secrets in project \"${project}\""
os::cmd::expect_success_and_text "oc get 'projects/${project}' --token='${adminnonescalatingpowerstoken}' -n '${project}'" "${project}"

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1fef218

Please sign in to comment.