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: added label and annotation for git credentials secret #162

Merged
merged 4 commits into from
Oct 27, 2021

Conversation

xbaran4
Copy link
Contributor

@xbaran4 xbaran4 commented Oct 11, 2021

Signed-off-by: xbaran4 pbaran@redhat.com

What does this PR do?

Adds label and annotation for git credentails secret. These are then recognized by devworkspace controller to mount the credentials into the workspace.

Screenshot/screencast of this PR

What issues does this PR fix or reference?

eclipse-che/che#20432

How to test this PR?

  1. Deploy che with che-server image quay.io/pbaran/che-server:factory-flow and devworkspaces enabled
  2. Update devworkspace operator to v0.10.0 because v.0.9.0 does not have related PR. (make install from https://github.com/devfile/devworkspace-operator)
  3. Run and follow scripts 1. to 4. from https://github.com/skabashnyuk/gitsrv/tree/main/bitbucket to setup bitbucket
  4. Create repository in bitbucket and push a v2 devfile to it.
  5. Try factory.
  6. You should be asked for permisions and then it should resolve a devfile and create devworkspace from it.
  7. Check for git-credentials-secret in your user namespace and see that it has:
    annotation controller.devfile.io/mount-path: /home/theia/.git-credentials
    label controller.devfile.io/git-credential: "true"
    image
  8. SSH into theia container and look for /home/theia/.git-credentials/credentials
    image

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

Signed-off-by: xbaran4 <pbaran@redhat.com>
@che-bot
Copy link
Contributor

che-bot commented Oct 11, 2021

Can one of the admins verify this patch?

@xbaran4 xbaran4 marked this pull request as ready for review October 18, 2021 07:38
Copy link
Contributor

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from a DWO perspective, though maybe DWO annotations/labels should be grouped into one file.

// Adding devworkspace label here and not in the default map,
// in case of a secret from previous version that does not have it
Map<String, String> labels = new HashMap<>(LABELS);
labels.put(LABEL_DEV_WORKSPACE_CREDENTIAL, "true");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me, why we can't use the original LABELS map here. The (LABEL_DEV_WORKSPACE_CREDENTIAL, "true") looks like a constant, so why we can't add it in the LABELS directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we use LABELS here


while searching for already existing git credential secret.
There might be this secret but does not have the DW label because it was created before this PR.

@@ -124,11 +130,16 @@ public void createOrReplace(PersonalAccessToken personalAccessToken)
annotations.put(ANNOTATION_SCM_URL, personalAccessToken.getScmProviderUrl());
annotations.put(ANNOTATION_SCM_USERNAME, personalAccessToken.getScmUserName());
annotations.put(ANNOTATION_CHE_USERID, personalAccessToken.getCheUserId());
annotations.put(ANNOTATION_DEV_WORKSPACE_MOUNT_PATH, CREDENTIALS_MOUNT_PATH);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add this directly into DEFAULT_SECRET_ANNOTATIONS map? Looks like a constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

private static final Map<String, String> LABELS =
ImmutableMap.of(
"app.kubernetes.io/part-of", "che.eclipse.org",
"app.kubernetes.io/component", "workspace-secret");
"app.kubernetes.io/part-of",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep old formatting? It's a map, so having key, value on same line looks better to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I thought maven fmt would put it back for me :)

Signed-off-by: xbaran4 <pbaran@redhat.com>
@xbaran4 xbaran4 requested a review from sparkoo October 19, 2021 12:19
@xbaran4 xbaran4 merged commit fdb4bd5 into eclipse-che:main Oct 27, 2021
@che-bot che-bot added this to the 7.39 milestone Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants