Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Rework workspace commands to be able to work with user namespace permissions only #849

Merged
merged 8 commits into from
Sep 16, 2020

Conversation

mmorhun
Copy link
Contributor

@mmorhun mmorhun commented Sep 9, 2020

Signed-off-by: Mykola Morhun mmorhun@redhat.com

What does this PR do?

All workspace commands are reworked in order to be able to work correctly if current user doesn't have permissions to read Che Server namespace. However, in such case we cannot automatically retrieve Che API URL, so it is required from user to provide it in --che-api-endpoint argument.
Also this PR moves all Che API related methods into a separate singleton class.

How to test

The following commands are supposed to be run manually one by one on a CRC cluster with a user which has no permissions for Che Server namespace.

Test commands
OS_TOKEN=$(oc whoami --show-token)
AT=$(curl -k -X POST -d "client_id=che-public" -d "subject_token=${OS_TOKEN}" -d "subject_issuer=openshift-v4" --data-urlencode "grant_type=urn:ietf:params:oauth:grant-type:token-exchange" --data-urlencode "subject_token_type=urn:ietf:params:oauth:token-type:access_token" https://keycloak-che.apps-crc.testing/auth/realms/che/protocol/openid-connect/token | jq -r .access_token)
ARGS="--access-token=$AT --che-api-endpoint=https://che-che.apps-crc.testing/api"

cat <<EOF >> devfile.yaml
metadata:
  generateName: wksp-custom-
apiVersion: 1.0.0
EOF

./chectl workspace:create $ARGS
./chectl workspace:list $ARGS
./chectl workspace:start $WID $ARGS
./chectl workspace:logs --workspace $WID --namespace=user-che
./chectl workspace:inject -k $ARGS
./chectl workspace:stop $WID $ARGS
./chectl workspace:delete $WID $ARGS

What issues does this PR fix or reference?

https://issues.redhat.com/browse/CRW-803

@AndrienkoAleksandr
Copy link
Contributor

@mmorhun you have failed tests.

@mmorhun mmorhun changed the title Rework workspace commands to be able to work with user namespace permissions only feat: Rework workspace commands to be able to work with user namespace permissions only Sep 10, 2020
@mmorhun
Copy link
Contributor Author

mmorhun commented Sep 11, 2020

/retest

1 similar comment
@flacatus
Copy link
Collaborator

/retest

@flacatus
Copy link
Collaborator

@mmorhun Openshift CI seems today is unstable. Ci centos jobs are removing so, should not work in this PR. Should be run tests in github actions: #851

src/api/che-api-client.ts Outdated Show resolved Hide resolved
src/api/che-api-client.ts Outdated Show resolved Hide resolved
src/api/che.ts Show resolved Hide resolved
src/api/kube.ts Show resolved Hide resolved
src/api/kube.ts Outdated Show resolved Hide resolved
src/common-flags.ts Outdated Show resolved Hide resolved
src/common-flags.ts Outdated Show resolved Hide resolved
src/commands/workspace/stop.ts Outdated Show resolved Hide resolved
src/commands/workspace/stop.ts Show resolved Hide resolved
src/commands/workspace/list.ts Outdated Show resolved Hide resolved
…issions only

Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
@mmorhun
Copy link
Contributor Author

mmorhun commented Sep 16, 2020

Rebased

Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: AndrienkoAleksandr, mmorhun, tolusha
To complete the pull request process, please assign
You can assign the PR to them by writing /assign in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mmorhun
Copy link
Contributor Author

mmorhun commented Sep 16, 2020

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants