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

Apply GitHub server flag when resolving factory URL #701

Merged
merged 3 commits into from
Jul 29, 2024
Merged

Conversation

vinokurig
Copy link
Contributor

What does this PR do?

Fix an issue when starting a workspace using a public GitHub Server repo fails.

Screenshot/screencast of this PR

What issues does this PR fix or reference?

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

How to test this PR?

Start a workspace from a public GitHub Enterprise Server repository with a devfile.
See: workspace starts

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.

@@ -78,6 +79,7 @@ public abstract class AbstractGithubURLParser {
this.apiClient = githubApiClient;
this.disableSubdomainIsolation = disableSubdomainIsolation;
this.providerName = providerName;
this.isGitHubServer = !isNullOrEmpty(oauthEndpoint);
Copy link
Member

Choose a reason for hiding this comment

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

why if there is no OAuth endpoint we treat is as GitHub server?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the oauth endpoint is not set, it means that the provider is GitHub SAAS by default. Otherwise we treat it as GitHub Server

Copy link
Member

Choose a reason for hiding this comment

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

@vinokurig can we possibly extract this logic to the separate method and add javdoc clarity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some javadoc above the variable

@@ -100,7 +102,7 @@ public boolean isValid(@NotNull String url) {
// Check if the given URL is a valid GitHub URL by reaching the endpoint of the GitHub
// server and analysing the response. This query basically only needs to be performed if the
// specified repository URL does not point to GitHub SaaS.
|| (!GITHUB_SAAS_ENDPOINT.equals(endpoint) && isApiRequestRelevant(trimmedUrl));
|| (!isGitHubServer && isApiRequestRelevant(trimmedUrl));
Copy link
Member

Choose a reason for hiding this comment

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

any tests for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately we can not test it because we use new GitHub client on each call

@vinokurig
Copy link
Contributor Author

/retest

2 similar comments
@vinokurig
Copy link
Contributor Author

/retest

@vinokurig
Copy link
Contributor Author

/retest

@artaleks9
Copy link
Contributor

Verified on Eclipse Che with quay.io/eclipse/che-server:pr-701 - the functionality works properly.

@@ -78,6 +79,7 @@ public abstract class AbstractGithubURLParser {
this.apiClient = githubApiClient;
this.disableSubdomainIsolation = disableSubdomainIsolation;
this.providerName = providerName;
this.isGitHubServer = !isNullOrEmpty(oauthEndpoint);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
this.isGitHubServer = !isNullOrEmpty(oauthEndpoint);
this.isGitHubServer = !isNullOrEmpty(oauthEndpoint) || GITHUB_SAAS_ENDPOINT.equals(oauthEndpoint);

This way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the suggestion, but I have commited: && !GITHUB_SAAS_ENDPOINT.equals(oauthEndpoint)

@vinokurig
Copy link
Contributor Author

/retest

Comment on lines +82 to +83
this.isGitHubServer =
!isNullOrEmpty(oauthEndpoint) && !GITHUB_SAAS_ENDPOINT.equals(oauthEndpoint);
Copy link
Member

Choose a reason for hiding this comment

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

I struggle to understand this line. Could it be extracted to a separate method with Javadoc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some javadoc above the variable

Copy link

openshift-ci bot commented Jul 25, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: artaleks9, ibuziuk, tolusha, vinokurig

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

@vinokurig
Copy link
Contributor Author

/retest

@vinokurig vinokurig merged commit fb0178f into main Jul 29, 2024
28 checks passed
@vinokurig vinokurig deleted the CRW-6831 branch July 29, 2024 07:44
@devstudio-release
Copy link

Build 3.16 :: server_3.x/350: Console, Changes, Git Data

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.16 :: server_3.x/350: SUCCESS

Upstream sync done; /DS_CI/sync-to-downstream_3.x/7330 triggered

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.16 :: update-digests_3.x/7174: UNSTABLE

No new images detected: nothing to do!

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.

5 participants