Compare commits

...

255 Commits
7.54.0 ... main

Author SHA1 Message Date
Igor Vinokur aa213c3003
Update ch.qos.logback dependency version to latest (#687)
In order to fix the CVE-2023-6378 vulnerability, update ch.qos.logback maven dependency version to 1.5.6
2024-05-27 09:29:31 +03:00
Igor Vinokur 88cbaebd1a
Support raw devfile urls without yaml extension (#683)
On handling raw devfile urls, request content by the url, and check if the content is a devfile. If yes treat the url as a raw devfile url.

---------

Signed-off-by: ivinokur <ivinokur@redhat.com>
Co-authored-by: Anatolii Bazko <abazko@redhat.com>
2024-05-15 10:13:37 +03:00
che-bot e072c7642b
chore: Update from ubi8-minimal:8.9-1108 to ubi8-minimal:8.9-1161 (#681)
* chore: Update from ubi8-minimal:8.9-1108 to ubi8-minimal:8.9-1161

Signed-off-by: Nick Boldt <nboldt@redhat.com>

* chore: Update from ubi8-minimal:8.9-1108 to ubi8-minimal:8.9-1161

Signed-off-by: Nick Boldt <nboldt@redhat.com>

---------

Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2024-04-29 08:49:33 +03:00
che-bot b5f110c659
chore: Bump to 7.86.0-SNAPSHOT in main (#680)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2024-04-26 08:16:38 +03:00
Shmaraiev Oleksandr 95b1c390b2
Add info messages to git-flow tests (#676)
* Add info messages to tests
* Add 'waitFinishDeploymentCheServer' to avoid 'error: lost connection to pod'
2024-04-19 20:33:08 +03:00
Dmytro Nochevnov 858a12b3ff
Download chectl install script from che-incubator.github.io in tests (#677) 2024-04-17 14:22:19 +02:00
che-bot 7c07c3c135
chore: Bump to 7.85.0-SNAPSHOT in main (#675)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2024-04-09 15:52:32 +03:00
Igor Vinokur 2cfce0568a
Rework the Bitbucket Server oauth token validation (#673)
- Change the validation API request to get current user request. The /rest/api/1.0/application-properties request is irrelevant as it does not require a token.
- Pass oath token to the getPersonalAccessToken() API request in order to avoid circular getToken() request.
2024-04-08 09:30:02 +03:00
ivinokur c51919d1e3 fixup! Fix gitlab oauth token validation request 2024-04-04 11:10:45 +02:00
ivinokur 1fc4e07988 Fix gitlab oauth token validation request 2024-04-04 11:10:45 +02:00
sdawley 799fcb1d0e Updating tomcat version to 10.1.14 for CRW-4941
Signed-off-by: sdawley <sdawley@redhat.com>
2024-03-27 15:43:15 +01:00
Igor Vinokur 2e27c47f2f
Add provider name annotation to PAT secret (#670)
Add che.eclipse.org/scm-provider-name annotation to Personal Access Token secret.
2024-03-25 14:57:27 +02:00
ivinokur b8e0397b0a Update io.fabric8.kubernetes-client to 6.10.0 2024-03-22 18:13:04 +01:00
che-bot 661d852250
chore: Bump to 7.84.0-SNAPSHOT in main (#669)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2024-03-19 08:51:13 +02:00
Igor Vinokur ba6f30f963
Add Gitlab invalidate token implementation (#667) 2024-03-16 12:56:55 +02:00
Igor Vinokur dbe167276a
Encode redirect URL if needed on oauth1 callback request (#663)
The latest BItBucket Server decodes the callback url so that causes IllegalArgumentException error. Catch the error and decode the redirect url.
2024-03-16 06:26:52 +02:00
Anatolii Bazko 28002fb835
fix: Support BitBucket endpoint with path (#665)
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2024-03-12 10:22:04 +01:00
Igor Vinokur 6cdf6f655a
Do not pass oauth2 as a username to Git credentials for Bitbucket (#662)
Set bitbucket-***** as a token name annotation for bitbucket token secret. This is needed to pass username instead of oauth2 for bitbucket credentials
2024-03-07 11:08:33 +02:00
Anatolii Bazko 7dc7a61511
chore: Remote workspace-stop roles (#659)
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2024-03-05 12:38:09 +01:00
che-bot 60262e3a72
chore: Bump to 7.83.0-SNAPSHOT in main (#658) 2024-02-28 09:18:10 +02:00
Ilya Buziuk 5d79a849ef
Update CODEOWNERS (#657) 2024-02-27 17:27:09 +02:00
Igor Vinokur 3fef2347f0
Remove the DB related modules (#630) 2024-02-27 15:27:58 +02:00
Igor Vinokur aebdc3a04d
Add debug logs to KubernetesPersonalAccessTokenManager class (#656) 2024-02-21 20:24:27 +02:00
Igor Vinokur a691074548
Add debug logs to KubernetesPersonalAccessTokenManager class (#655) 2024-02-20 18:07:04 +02:00
Igor Vinokur f9f4c8e5d5
Encode redirect URL if needed on oauth callback request (#654)
Some SCM providers like BItBucket Server decode the callback url so that cause IllegalArgumentException error. Catch the error and decode the redirect url.
2024-02-19 19:07:07 +02:00
Igor Vinokur 4f8a84cb1d
Fetch oauth tokens from kubernetes secrets (#652)
Move AuthorisationRequestManager interface towsmaster/che-core-api-factory module in order to avoid circular dependency.
Rework the get oauth token method to return an oauth token from kubernetes secrets if token is not found in the system memory of the che-server pod. If provider name value is not configured in the kubernetes secret oauth token, get the token by mapping it by provider url from the secret and oauth provider name from the aouth config secret.
2024-02-08 10:22:51 +02:00
ivinokur 6f40c9856f Add isNullOrEmpty check to the BitbucketServerURLParser 2024-02-06 14:18:05 +01:00
che-bot 62f301c42d
chore: Bump to 7.82.0-SNAPSHOT in main (#651)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2024-02-02 19:53:07 +02:00
Shmaraiev Oleksandr 9422bf86ac
Add test 'che-smoke-test' as PR checks
* Add 'smoke-test' to OpenShift CI
* Add 'pod-che-smoke-test.yaml' component
* Add 'startSmokeTest' to 'common.sh'
* Update 'pod-oauth-factory-test.yaml' component
2024-01-30 12:06:23 +02:00
Nick Boldt be4383abac chore: remove Nick and Mario as code owners; add Sam
Change-Id: Ibb4d2cab011a42279ae93da528d7aa566bf4860d
Signed-off-by: Nick Boldt <nboldt@redhat.com>
2024-01-23 12:04:37 +01:00
Dmytro Nochevnov fa7d6442f5
Fix syntax error in Dockerfile of OpenShift CI jobs (#646)
Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com>
2024-01-19 13:25:47 +02:00
Dmytro Nochevnov e1ae06ec50
Get rid of failing curl in OpenShift CI jobs (#645)
Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com>
2024-01-19 12:15:49 +02:00
Dmytro Nochevnov 901a30ea8c
Move installation of oc client from Dockerfile to common.sh (#644)
Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com>
2024-01-18 16:41:12 +02:00
Dmytro Nochevnov 76913d93c2
Fix openshift-client-linux.tar.gz version in OpenShift CI job Dockerfile (#643)
Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com>
2024-01-17 15:40:00 +02:00
Dmytro Nochevnov dc7edf634e
Get more OpenShift CI image build command logs 2024-01-17 13:17:42 +02:00
Igor Vinokur 12a3a8a8e7
Remove devfile validation schema mechanism (#640)
Remove devfile validation schema mechanism and related stuff.
2024-01-17 09:21:44 +02:00
Nick Boldt 3fb1df91f7 chore: Update from ubi8-minimal:8.9-1029 to ubi8-minimal:8.9-1108
Signed-off-by: Nick Boldt <nboldt@redhat.com>
2024-01-15 14:40:57 +01:00
Nick Boldt 0e3b7c107c chore: Update from ubi8-minimal:8.9-1029 to ubi8-minimal:8.9-1108
Signed-off-by: Nick Boldt <nboldt@redhat.com>
2024-01-15 14:40:57 +01:00
Mykhailo Kuznietsov 978f2cdd21 chore: Bump to 7.81.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2024-01-11 15:35:09 +01:00
Igor Vinokur f547c681a8
Fix license headers (#638)
Fix maven build by updating corresponding license headers
2024-01-10 11:36:56 +02:00
Igor Vinokur 06e14c854d
Pass status code to Exception on Unauthorised to GitHub Error (#618)
Pass status code to Exception on Unauthorised to GitHub Error in order to be able to recognise GitHub Server url if oAuth is not configured and no PAT is present.
2024-01-10 10:46:02 +02:00
Igor Vinokur d077bdd93d
Add new devfile versions support (#637)
Add missing devfile versions to the list of supported devfile versions
Add corresponding jsons.
2024-01-09 18:16:34 +02:00
Shmaraiev Oleksandr 96ac9beb7f
Delete 'yq' from Dockerfile (#636) 2024-01-09 10:14:54 +02:00
Nick Boldt 4e067e94d7
Update README.md - add link to status badge (#575) 2023-12-28 22:34:36 +02:00
che-bot e3ccf70b64
chore: Bump to 7.80.0-SNAPSHOT in main (#628)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-12-28 02:23:26 +02:00
Shmaraiev Oleksandr 6b584db971
Create test to check 'git-oauth-setup-flow' as PR checks (#633)
* Add new components to implement 'git-oauth-setup-flow' test
* Update existing files to implement 'git-oauth-setup-flow' test
2023-12-27 17:44:40 +02:00
Mykhailo Kuznietsov cc4dac0922
fix: adapt to latest changes in build.sh that uses podman now (#629)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-12-21 15:38:22 +02:00
Igor Vinokur 151ef89772
Return oauth1 providers on registered oauth providers list request (#624)
Add the list of oauth1 providers to the list of registered oauth2 providers on get registered oauth providers API request.
2023-12-21 14:03:42 +02:00
Nick Boldt bda80f1d7b
chore(build): remove commented code that we didn't need for 7.77 release, as it's evidently safe to delete (#627)
Change-Id: I0d6db01942b35a1c5f31ad22718743dec8a90f23

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>
Co-authored-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>
2023-12-20 09:29:10 -04:00
Igor Vinokur 3ecfbcd8b1
Modify the `build.sh` script to work with podman (#559)
In order to be able to build images directly in a wotkspace container, add BUILDER variable to be able to execute the build.sh script not only with docker but with podman and buildah.
2023-12-11 16:11:05 +02:00
Anatolii Bazko f7a49f9fec
fix: work with Bitbucket users containing special characters in theirs names (#622)
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-12-07 17:35:43 +01:00
Igor Vinokur ebca10356e
Throw the API exception with authorization URL on SCMunauthorised error (#621)
Fixes a bug with broken oauth flow caused by https://github.com/eclipse-che/che-server/pull/615
2023-12-04 20:57:25 +02:00
Anatolii Bazko 7fe2a4dd3f
feat: Advanced authorization (#619)
* feat: Advanced authorization

Signed-off-by: Anatolii Bazko <abazko@redhat.com>

* Renames fields

Signed-off-by: Anatolii Bazko <abazko@redhat.com>

* Address remarks

Signed-off-by: Anatolii Bazko <abazko@redhat.com>

* Address remarks

Signed-off-by: Anatolii Bazko <abazko@redhat.com>

* Address remarks

Signed-off-by: Anatolii Bazko <abazko@redhat.com>

---------

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-12-04 15:55:35 +01:00
Mykhailo Kuznietsov 7acf4cc2d9 chore: Bump to 7.79.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-11-30 12:24:39 +01:00
Igor Vinokur 5baa3a7ccf
Align the unreachable devfile exception message (#615)
Add a common exception message and use it for cases when:

The devfile location is unavailable.
The devfile content is is not valid: e.g the response content is an html content of an scm authorisation page.
2023-11-28 18:09:57 +02:00
Igor Vinokur f34e80450b
Expand the raw devfile url resolver pattern with token query parameter (#616)
Rework the accept() check in the raw devfile url resolver to respect token query parameters e.g. https://raw.githubusercontent.com/vinokurig/private/main/devfile.yaml?token=<token>
2023-11-28 18:08:57 +02:00
Igor Vinokur 974c1b1890
Add support for PATs in GitHub Enterprise server (#603)
Add necessary checks to the GithubURLParser and AbstractGithubURLParser classes in order to support PAT for GitHub Enterprise server without configuring oAuth.
2023-11-21 11:11:06 +02:00
che-bot 6ca7127939
chore: Update from ubi8-minimal:8.7-1085 to ubi8-minimal:8.9-1029 (#612)
* chore: Update from ubi8-minimal:8.7-1085 to ubi8-minimal:8.9-1029

Signed-off-by: Nick Boldt <nboldt@redhat.com>

* chore: Update from ubi8-minimal:8.8-1072 to ubi8-minimal:8.9-1029

Signed-off-by: Nick Boldt <nboldt@redhat.com>

---------

Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2023-11-19 23:45:09 -04:00
Anatolii Bazko b9317fd1af
fix: Ignore PAT with emtpy SCM url (#610)
* fix: Ignore PAT with emtpy SCM url

Signed-off-by: Anatolii Bazko <abazko@redhat.com>


---------

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-11-17 16:37:19 +01:00
Anatolii Bazko b5e1e2a4a2
chore: Validate OAuth token secrets on namespace provisioning (#608)
* chore: Validate OAuth token secrets on namespace provisioning

Signed-off-by: Anatolii Bazko <abazko@redhat.com>

---------

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-11-15 15:08:48 +01:00
che-bot 92b37d2b6e
chore: Bump to 7.78.0-SNAPSHOT in main (#605)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-11-13 13:38:23 +02:00
Samantha Dawley 7192bf1302
Merge pull request #606 from eclipse-che/SDawley-patch-2
Update make-release.sh
2023-11-09 18:32:26 -05:00
Samantha Dawley c68b96d762
Update make-release.sh
I think we're missing a folder. Hopefully fix build.
2023-11-09 15:30:28 -05:00
Mykhailo Kuznietsov 77011bb3c8
fix: che-22646 use gh instead of hub (#604)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-11-09 14:43:43 +02:00
Anatolii Bazko 72f191bcda
feat: Allow to configure 2 github providers simultaneously (#598)
* feat: Support enabling Github enterprise and SaaS simultaneously on Dev Spaces

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-11-07 12:57:48 +01:00
Shmaraiev Oleksandr 2c198333ef
Fix up tests in the PR checks on Openshift CI
* Update 'devworkspace-test.yaml' file
2023-11-06 16:21:37 +02:00
Mykhailo Kuznietsov 26cf509ea7 chore: Bump to 7.77.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-11-06 09:39:16 +01:00
Igor Vinokur cb0c9f9d39
Fix update token on workspace start (#597)
Change the getHostName() function to getProviderUrl() in order to fix an error while updating an oauth token on workspace start.
Throw ScmUnauthorizedException if an oAuth token is not valid, for the dashboard to open the authorisation page and update the token.
2023-11-04 19:12:12 +02:00
Samantha Dawley c4156b61f5
Merge pull request #593 from eclipse-che/22616
chore: comment out node10 (updated to node18) and maven 3.6 (updated to 3.8) installs, as we likely don't need them (either not required or handled by GH action) #22616
2023-10-19 13:16:52 -04:00
Igor Vinokur ba49012fb2
Move dockerfiles to build/dockerfiles (#573)
Moves dockerfiles from dockerfiles/che to build/dockerfiles
Removes the endpoint-watcher, postgres and keycloak images.
Adds brew.Dockerfile from downstream.

Coauthored with @SDawley
2023-10-19 14:49:31 +03:00
Nick Boldt 270be77cc7 support building with podman too
Change-Id: I83fc89be6ad2411b64a4bf4e2308c048a9ab2ff4
Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-10-18 18:31:17 -03:00
Nick Boldt bfb531761d use maven 3.8 for typescript-dto build too
Change-Id: Ie70fa428ba1a68bbe663577947f05b6a2c4fe3a6
Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-10-18 18:25:24 -03:00
Nick Boldt 6e67a3b492 comment out node10 (updated to node18) and maven 3.6 (updated to 3.8) installs, as we likely don
't need them (either not required or handled by GH action) #22616

Change-Id: I5d0920b58e413247fd5466a269fb26b1af60578c
Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-10-18 17:38:57 -03:00
Samantha Dawley 473f67db7e
Update release.yml to install hub (#591)
Adding hub so the release workflow can run successfully.
I don't know where it came from previously, but if it was in Ubuntu by default it likely got taken out due to issues with the previous recommended install method:
https://github.com/mislav/hub/issues?q=is%3Aissue+snap
2023-10-18 17:06:34 -03:00
dependabot[bot] b2284aecee
chore(deps): bump maven-antrun-plugin from 3.0.0 to 3.1.0 (#484)
* chore(deps): bump maven-antrun-plugin from 3.0.0 to 3.1.0

Bumps [maven-antrun-plugin](https://github.com/apache/maven-antrun-plugin) from 3.0.0 to 3.1.0.
- [Release notes](https://github.com/apache/maven-antrun-plugin/releases)
- [Commits](https://github.com/apache/maven-antrun-plugin/compare/maven-antrun-plugin-3.0.0...maven-antrun-plugin-3.1.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-antrun-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update pom.xml

* Update pom.xml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Igor Vinokur <ivinokur@redhat.com>
2023-10-12 16:40:32 +03:00
dependabot[bot] 2adb6f6bee
chore(deps): bump maven-install-plugin from 3.0.0-M1 to 3.1.1 (#488)
* chore(deps): bump maven-install-plugin from 3.0.0-M1 to 3.1.1

Bumps [maven-install-plugin](https://github.com/apache/maven-install-plugin) from 3.0.0-M1 to 3.1.1.
- [Release notes](https://github.com/apache/maven-install-plugin/releases)
- [Commits](https://github.com/apache/maven-install-plugin/compare/maven-install-plugin-3.0.0-M1...maven-install-plugin-3.1.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-install-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update pom.xml

* Update pom.xml

* Update pom.xml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Igor Vinokur <ivinokur@redhat.com>
2023-10-12 16:00:18 +03:00
Igor Vinokur 148415c691
Respect authorisation request opt-out on workspace start (#576)
If user rejects an scm provider authorisation request while creating or starting existed workspace store the name of the scm provider in the workspace-preferences config-map. The workspace create/start step must proceed without token fetch step. If user creates another workspace or starts existed workspace from an scm provider which name is stored in the config-map, do not ask the authorisation as it was already rejected once.
2023-10-12 15:59:42 +03:00
dependabot[bot] 386f84962d
chore(deps): bump mockito-testng from 0.4.13 to 0.5.2 (#509)
* chore(deps): bump mockito-testng from 0.4.13 to 0.5.0

Bumps [mockito-testng](https://github.com/mockito/mockito-testng) from 0.4.13 to 0.5.0.
- [Release notes](https://github.com/mockito/mockito-testng/releases)
- [Changelog](https://github.com/mockito/mockito-testng/blob/master/docs/release-notes.md)
- [Commits](https://github.com/mockito/mockito-testng/compare/v0.4.13...v0.5.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-testng
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update pom.xml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Igor Vinokur <ivinokur@redhat.com>
2023-10-12 15:42:17 +03:00
Igor Vinokur f27f8b1589
Update minor maven dependencies (#577) 2023-10-12 14:38:05 +03:00
Igor 5d645e1d3c Update contributing.md file 2023-09-29 18:07:57 +02:00
Igor ea9bb95f7c Add CONTRIBUTING.md file 2023-09-29 18:07:57 +02:00
Mykhailo Kuznietsov 2f2a939823 chore: Bump to 7.76.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-09-28 10:13:22 +02:00
Igor Vinokur b2ff110da5
Encode the authentication reject error to build a proper callback url (#568)
Encode the &error_code=access_denied query param for the callback url in order to fix the bug when the authentication request appears again if it was rejected.
2023-09-27 14:20:27 +03:00
Nick Boldt 46592e65ce
chore: update to latest com.fasterxml.jackson 2.14.z (CRW-4790, #22548) (#571)
Change-Id: Iacdbd86ccc1480c8badbbc15ffe48bdb01206e44

Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-09-25 16:53:30 -03:00
che-bot 9a553b6344
chore: Update from ubi8-minimal:8.8-1037 to ubi8-minimal:8.8-1072 (#570)
Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2023-09-25 10:17:02 -03:00
Anatolii Bazko a28e1553d2
chore: Add tests to start a workspace from raw devfile and ssh urls f… (#569)
* chore: Add tests to start a workspace from raw devfile and ssh urls for GITEA provider

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-09-25 14:54:49 +02:00
Igor Vinokur b1da9ef121
Add an SSH Factory parameter resolver for unsupported SCM providers (#567)
Return the SSH factory resolver in order to handle SSH urls from unsupported SCM providers.
Add a priority value for all factory resolvers to be able to control resolver's priority.

---------

Co-authored-by: Aleksandr Shmaraiev <oshmarai@redhat.com>
2023-09-22 17:09:48 +03:00
Igor Vinokur 261be8f99d
Add a null check before reading GitHub response (#563)
Add a null check to prevent NullPointer exception while reading body from the GitHub API response. response.body() should not return null according to the java documentation, but the NullPointer exception was found in the customer debug logs
2023-09-21 10:48:32 +03:00
Anatolii Bazko a3cceea640
chore: Add tests to start a workspace from raw devfile and ssh urls when PAT configured (#566)
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-09-18 11:18:37 +02:00
Anatolii Bazko e337edc50f
chore: Add Eclipse Che server azure and gitlab providers tests (#564)
* chore: Add Eclipse Che server azure and gitlab providers tests

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-09-15 15:01:10 +02:00
Anatolii Bazko 3bac40d2a3
chore: Add PR checks to test workspace startup from raw devfile and s… (#562)
* chore: Add PR checks to test workspace startup from raw devfile and ssh urls for GitHub provider

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-09-14 10:12:58 +02:00
Anatolii Bazko f67bbbd52a
chore: Add PR check for BitBucket to start a workspace from a raw and… (#558)
* chore: Add PR check for BitBucket to start a workspace from a raw and ssh urls

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-09-12 15:45:41 +02:00
Nick Boldt 74924f84ae
chore: tweak dockerfile; (#560)
use latest ocp 4.12 oc binary;
fix typo in pom.xml
bump to latest mavn 3.9.4

Change-Id: Ie9d9aea49e7e46bec4814477489450b277f926b4

Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-09-12 09:17:48 -03:00
che-bot 033d310b0d
chore: Bump to 7.75.0-SNAPSHOT in main (#554)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-09-11 19:17:12 -03:00
Shmaraiev Oleksandr 8731ac153a
Add tests to check 'Azure DevOps' provider in PR checks (#552)
* Add tests to check git-flow on 'azure-devops' git-provider

* Refactor methods

* Upfdate tests

* Update 'pat-secret.yaml' file

* Update the '.ci/openshift-ci/Dockerfile'

* Exclude 'testFactoryResolverNoPatOAuth' from the test

* Fix variable name

* Refactor '<testClone>' methods to handle errors more informative
2023-09-11 15:15:17 -03:00
Shmaraiev Oleksandr a6ea66285f
Update command 'dnf install' (#556) 2023-09-08 10:27:14 +03:00
Shmaraiev Oleksandr 7686dab07a
Update Dockerfile to fix an error 'node is not installed' (#555)
* Update Dockerfile to fix an error

* Fix the image
2023-09-07 13:53:32 +03:00
Igor Vinokur 9d43803100
Simplify the Raw devfile filename check (#548)
Do not check the Raw devfile file name but check if the url ends with .yaml before using the Raw devfile url resolver.
2023-09-06 14:15:11 +03:00
Igor Vinokur ea67092cbc
Fix failing unit tests (#553)
Signed-off-by: Igor <ivinokur@redhat.com>
2023-09-06 12:48:04 +03:00
Igor Vinokur 6edfa3910f
Apply permanetn `ref` query param to the GitLab raw file location request (#545)
A user claims that he couldn't start a workspace form GitLab repository because of the raw file location request doesn't contain the ref query parameter. Rework the way of generating the GitLab raw file location function to permanently add the ref query param.
2023-09-05 12:51:27 +03:00
Igor Vinokur da5174bf17
Duplicate creating a git-credentials secret on token fetch (#551)
Duplicate the git-credentials secret creation step on create personal access token secret. Currently this step is performed on workspace provision step but in this case the PAT secret might be initialised when the provision is finished. In order to synchronise the personal access token secret and git credentials secret creation step duplicate the git credentials secret creation step after the PAT secret creation step.
Refactor the get(scmServerUrl) function in the KubernetesPersonalAccessTokenManager class
2023-09-05 12:49:09 +03:00
Igor Vinokur afd7cad8b8
Set original message and stack trace to a Runtime Exception DTO (#550)
In order to extend the predefined error message in the dashboard, pass original message and stack trace to a Runtime Exception DTO
2023-08-30 09:35:08 +03:00
Igor Vinokur ce6ed7e9c0
Update io.fabric8.kubernetes-client version to latest (#549) 2023-08-29 16:38:31 +03:00
Igor Vinokur 7d0cfb306c
Support SSH urls (#539)
Extend each SCM provider implementation to support SSH urls.
2023-08-27 16:17:13 +03:00
Mykhailo Kuznietsov 8d19ea8046 chore: Bump to 7.74.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-08-23 15:09:29 +02:00
Anatolii Bazko ff90b44018
fix: Improve BitBucket token scope validation (#547)
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-08-22 09:17:54 +02:00
Igor Vinokur f5a70d0f9a
Do not return secret token in the Oauth API (#538)
Remove the personalAccessTokenManager.get() call from the OAuth API getToken() method. The OAuth API must not know anything about PAT secrets. It should get tokens only by requesting an SCM provider OAuth API.
Fix validating the Bitbucket-Server PAT method by requesting user instead of requesting.
This prevents the code execution going to a recursive loop: bitbucketServerApiClient.getPersonalAccessToken() calls oauthApi.getToken() which referred to personalAccessTokenManager.getToken() which validated the token by calling scmPersonalAccessTokenFetcher.getScmUsername() -> bitbucketServerApiClient.getPersonalAccessToken().
2023-08-17 16:29:24 +03:00
Samantha Dawley d96e67252a
22407 - Remove Mattermost notification (#544)
https://github.com/eclipse/che/issues/22407
Comment out the mattermost notification so it doesn't fail the release workflow, but leaving it in the file so I remember to replace it.
2023-08-17 09:28:20 +02:00
Igor Vinokur b2dfdb0c84
Update guava, http-client, squareup.okio to the latest versions (#543)
Update guava, http-client, squareup.okio to the latest versions in order to fix security issues according to the trivy report
2023-08-16 12:45:32 +03:00
Igor Vinokur 73dbac0c44
Do not substring `.git` while parsing Azure DevOps Urls (#541)
Do not substring .git while parsing Azure DevOps Urls. Azure doesn't add the .git suffix neither to the generated clone URLs nor to the browser repository URLs.
2023-08-15 14:37:13 +03:00
che-bot cb5c8aa4d2
chore: Update from ubi8-minimal:8.8-1014 to ubi8-minimal:8.8-1037 (#542)
Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2023-08-14 14:47:03 -07:00
Igor Vinokur 0ea20e687b
Use `login` instead of `name` in the GitHub scopes/username request (#537)
Change user.getName() to user.getLogin() in the GitHub getTokenScopes() API request, in order to fix a bug where NullPointer exception is appeared when a GitHub user request returns a user with null in the name field.
2023-08-01 21:36:14 +03:00
Mykhailo Kuznietsov 29ff3f3e75 chore: Bump to 7.73.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-07-31 10:50:12 +02:00
Igor Vinokur df3fc9965a
Omit scm-username annotation from the PAT secret (#533)
Ignore the che.eclipse.org/scm-username annotation when fetching token from a PAT secret. Instead fetch the username from the isValid(<token>) request.
2023-07-25 18:52:54 +03:00
Igor Vinokur 00675893ff
Update openjdk version from 11 to 17 (#535)
Update openjdk version from 11 to 17 in order to fix the che-server sturtup error
2023-07-25 11:04:22 +03:00
Mykhailo Kuznietsov 2cd1bb2b46 chore: Bump to 7.72.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-07-24 12:10:57 +02:00
Igor Vinokur c5963e0de7
Pass string to ObjectMapper instead of InputStream (#531)
Pass string to ObjectMapper instead of InputStream in order to avoid No content to map due to end-of-input error caused by jdk.internal.net.http.ResponseSubscribers$HttpResponseInputStream.
An error was discovered in our customers environment
2023-07-12 10:33:56 +03:00
Igor Vinokur aee2079322
Use hardcoded string as username for Azure git credentials (#529)
Since Azure git provider do not support username for its user object, use username string as username in the git credentials file if the PAT is related to Azure Devops: https://username:<token>@dev.azure.com
2023-07-06 09:37:33 +03:00
che-bot 21323d1b12
chore: Update from ubi8-minimal:8.8-860 to ubi8-minimal:8.8-1014 (#530)
Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2023-07-04 11:27:14 -03:00
Mykhailo Kuznietsov 454bc7304f chore: Bump to 7.71.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-06-30 09:45:41 +02:00
Igor Vinokur 287b903010
Provision git credentials secrets on workspace start (#527)
On workspace start iterate user PAT secrets. If a PAT secret is not included to the devworkspace-merged-git-credentials secret, create a git credentials secret based on the PAT secret.
Remove the redundant logic of creation an empty workspace-credentials-secret secret.
2023-06-26 17:18:32 +03:00
Igor Vinokur ab83bee400
Omit extracting subfolder from a workspace URL (#523)
sparce-checkoutis no longer available from devfile 2.1, so omit the subfolder mechanism in order to support branch names with a / sign.
2023-06-15 13:41:43 +03:00
Ilya Buziuk fbea05f0cc chore: devfile update 2023-06-15 10:19:20 +02:00
Mykhailo Kuznietsov c23792c7b1 chore: Bump to 7.70.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-06-15 10:18:24 +02:00
Igor Vinokur afedaeed90
Add .vscode/settings.json with java settings (#524) 2023-06-14 10:14:24 +03:00
Anatolii Bazko 7c598014a2
fix: Cloning projects from Azure DevOps (#522)
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-06-08 12:44:06 +03:00
Igor Vinokur 98c2cc79eb
Update devfile to version 2, add extensions.json (#520) 2023-06-07 13:11:46 +03:00
Igor Vinokur 32c67ed032
Return the default resolver if the factory URL refers directly to a devfile (#519)
Check if the factory URL is a raw devfile URL. If so, use the devfile URL resolver, which resolves factories from a direct URL to a devfile content.
2023-06-06 10:38:03 +03:00
Mykhailo Kuznietsov fdb2dbf163 chore: Bump to 7.69.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-06-02 16:13:59 +02:00
Mykhailo Kuznietsov b68fa97aa2
chore: update CODEOWNERS file (#513) 2023-05-31 11:24:24 +03:00
Anatolii Bazko dd873a597b
chore: Use CheServer client factory to handle Kubernetes operation in a user namespace (#516)
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-05-25 17:20:59 +03:00
che-bot ae4f6a33a5
chore: Update from ubi8-minimal:8.7-1107 to ubi8-minimal:8.8-860 (#515)
Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2023-05-25 10:51:18 -03:00
Shmaraiev Oleksandr 3b74041d5d
Create tests to check 'Git zero-config' flow as PR checks (#494)
* Create 'Dockerfile' file to configure ci-operator
* Update 'build-pr-check.yml' github action
* Add tests to check git  flow without PAT setup
* Add tests to check git flow with PAT setup
---------
Co-authored-by: artaleks9 <artaleks9@users.noreply.github.com>
Co-authored-by: Igor Vinokur <ivinokur@redhat.com>
2023-05-22 11:22:03 +03:00
Mykhailo Kuznietsov 559de5a7f1 chore: Bump to 7.68.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-05-18 10:44:15 +02:00
Igor Vinokur cefc638dad
Pass user slug instead of user id when creating a PAT for bitbucket-server (#512)
Pass user neme instead of user id when creating a PAT secret for bitbucket-server in order to fix the generation of thegit-credentials-secret secret which requires the user name: https://<user name>:<token>@<host name>.
2023-05-16 13:53:10 +03:00
Mykhailo Kuznietsov 1fb16e5b63 chore: Bump to 7.67.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-05-10 10:27:11 +02:00
David Kwon eac9cef22b feat: allow che-operator to detect user-profile secret
Signed-off-by: David Kwon <dakwon@redhat.com>
2023-05-09 13:04:42 -04:00
Igor Vinokur 725506d26f
Fix provider name constant in the BitbucketServerUserDataFetcher calss (#511)
Change the OAUTH_PROVIDER_NAME constant from bitbucket to bitbucket-server in order to fix the git user data initialisation flow, when a PAT is initialised in a user namespace.
2023-05-09 16:14:38 +03:00
Mykhailo Kuznietsov 75979a6d6a
chore: che-21993 replace deprecated set-output in actions (#502) 2023-04-27 15:06:41 +03:00
Mykhailo Kuznietsov b333b7bdb9 chore: Bump to 7.66.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-04-21 13:06:43 +02:00
Igor Vinokur aa41ce0c74
Update the `Readme.md` with build and debug instructions (#503)
Update the Readme.md with build and debug instructions.
2023-04-20 10:07:54 +03:00
Mykhailo Kuznietsov d0402f0b8e chore: Bump to 7.65.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-04-19 11:11:56 +02:00
Igor Vinokur 8d0d9ac5d8
Withdraw scm-userid value in PAT secrets and use scm-username instead (#496)
Withdraw the scm-userid annotation from the PAT secret structure.
Rework the PAT validation to check scm-username instead scm-userid.
2023-04-19 09:37:29 +03:00
David Kwon d0549d4fc5 feat: add OpenShift web console dashboard definition
Signed-off-by: David Kwon <dakwon@redhat.com>
2023-04-17 15:37:16 +02:00
Shmaraiev Oleksandr 251a6e1095
Create the 'Dockerfile' to configure ci-operator (#495) 2023-04-13 10:10:00 +03:00
che-bot 16dff88b2e
chore: Update from ubi8-minimal:8.7-1085.1679482090 to ubi8-minimal:8.7-1107 (#492)
Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2023-04-11 10:43:46 -03:00
che-bot c9e8f5eae9
chore: Update from ubi8-minimal:8.7-1085 to ubi8-minimal:8.7-1085.1679482090 (#475)
Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2023-04-04 16:20:09 -07:00
Anatolii Bazko 8dda567e23
fix: Support Azure DevOps repository urls without project (#490)
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-04-04 16:31:00 +03:00
Anatolii Bazko b24e3c7d95
feat: support retrieving Git user data when PAT is configured (#489)
* feat: support retrieving Git user data when PAT is configured

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-04-04 10:14:40 +03:00
Ilya Buziuk 188c722dae chore: Adding @Deprecated annotation to the unused services that will be removed in the future versions
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
2023-04-03 15:40:13 +02:00
Igor Vinokur f5ea114c87
Revert "chore(deps): bump jgroups from 4.1.9.Final to 5.2.13.Final (#427)" (#473)
This reverts commit 4894dfd95b.
2023-03-30 12:35:13 +03:00
dependabot[bot] 4894dfd95b
chore(deps): bump jgroups from 4.1.9.Final to 5.2.13.Final (#427)
* chore(deps): bump jgroups from 4.1.9.Final to 5.2.12.Final

Bumps [jgroups](https://github.com/belaban/JGroups) from 4.1.9.Final to 5.2.12.Final.
- [Release notes](https://github.com/belaban/JGroups/releases)
- [Changelog](https://github.com/belaban/JGroups/blob/master/doc/history.txt)
- [Commits](https://github.com/belaban/JGroups/compare/JGroups-4.1.9.Final...jgroups-5.2.12.Final)

---
updated-dependencies:
- dependency-name: org.jgroups:jgroups
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update pom.xml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Igor Vinokur <ivinokur@redhat.com>
2023-03-30 10:28:53 +03:00
Igor Vinokur 45e9d18d22 Fix vuOAlnerable dependencies
Signed-off-by: Igor Vinokur <ivinokur@redhat.com>
2023-03-29 19:04:50 +02:00
Mykhailo Kuznietsov 63c72d2628 chore: Bump to 7.64.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-03-27 15:40:05 +02:00
Valeriy Svydenko ab04d83427
fix: trim blank chars in PAT (#469)
Signed-off-by: Valerii Svydenko <vsvydenk@redhat.com>
2023-03-20 21:16:38 +02:00
Anatolii Bazko 76445656a9
feat: GitLab support nested repositories (#467)
* feat: GitLab support nested repositories

Signed-off-by: Anatolii Bazko <abazko@redhat.com>

---------

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-03-20 08:32:05 +02:00
Igor Vinokur 5a04496ded
Return empty credentials from bitbucket URL with username (#466)
Override the getCredentials() method in the BitbucketUrl class to intercept bitbucket URL with username e.g. https://user@bitbucket.org/eclipse/che. Return empty credentials for such urls.
2023-03-17 13:24:14 +02:00
Igor Vinokur be757ec5a6
Check the devfile content before creating a factory (#463)
When Che creates a workspace from a repository URL, first we iterate and find a related git provider handler, then we gat a devfile location according to the handler rules. If we pass an unsupported git repository url we will have a default handler which will try find a devfile by the same url as the repository. In that case we will have an html content as a devfile.

We need to check the content before parsing the devfile, and throw a specific error in case if the content is not yaml.
2023-03-14 12:03:39 +02:00
Valeriy Svydenko 54827213f1
fix: extend pattern for BitBacket URL (#461)
Signed-off-by: Valerii Svydenko <vsvydenk@redhat.com>
2023-03-10 10:14:37 +02:00
Anatolii Bazko d9ad2fbd7e Remove scopes from AzureDevOpsApiClient
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-03-09 18:09:31 +01:00
Anatolii Bazko ea1ceb09ac fix: update the way how Azure OAuth2 token is validated
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-03-09 18:09:31 +01:00
Anatolii Bazko 04bf956751
feat: Support git+ssh urls (#458)
* feat: Support git+ssh urls

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-03-09 14:24:49 +02:00
che-bot 709d872d24
chore: Bump to 7.63.0-SNAPSHOT in main (#459)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-03-08 18:05:13 -04:00
che-bot 8d6b8fba98
chore: Update from ubi8-minimal:8.7-1049.1675784874 to ubi8-minimal:8.7-1085 (#453)
Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2023-03-02 14:15:53 -08:00
Anatolii Bazko 5bdea8981e
Merge pull request #456 from eclipse-che/CRW-3927-fix
fix: typo in AzureDevOpsPersonalAccessTokenFetcher
2023-03-02 11:45:15 +02:00
Anatolii Bazko f36a6943fe fixup
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-03-02 11:08:43 +02:00
Anatolii Bazko f22e52e519 fixup
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-03-02 11:03:58 +02:00
Anatolii Bazko bd4c1812fb fixup
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-03-02 10:53:41 +02:00
Anatolii Bazko b0514ce37c fix: typo in AzureDevOpsPersonalAccessTokenFetcher
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-03-02 10:31:05 +02:00
Anatolii Bazko f102475484
Merge pull request #452 from eclipse-che/CRW-3927
feat: Azure DevOps Services OAuth2 support
2023-02-28 17:57:37 +02:00
Anatolii Bazko 49773464e3 Fix remarks
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-02-27 16:32:29 +02:00
Anatolii Bazko a9507244a3 fixes
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-02-27 10:31:38 +02:00
Anatolii Bazko 426718a495 fix
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-02-23 15:20:20 +02:00
Anatolii Bazko 6e7e96873f fix typo
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-02-23 15:20:20 +02:00
Anatolii Bazko 7a84f92aee fix typo
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-02-23 15:20:20 +02:00
Anatolii Bazko 19d13edc7f feat: Azure DevOps Service OAuth2
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2023-02-23 15:20:20 +02:00
Igor Vinokur b9ededf339
Support Basic authentication for devfile factory URL (#451)
Add a parsing rule to detect credentials in factory URLs if it is in a format https://<username>:<pasword>@hostname.
Extract the credentials from factory URLs and pass them to the devfile content request.
2023-02-23 15:05:55 +02:00
Ilya Buziuk dcb0884fe0 refactor: switching to h2 datasource
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
2023-02-22 17:18:23 +01:00
Ilya Buziuk 47184c4953 refactor: Deprecating api/user endpoint. Adding exta GET api/user/id endpoint for easily obtaining user ID
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
2023-02-20 14:34:16 +01:00
Nick Boldt fbf318c0d6
chore: Bump to 7.62.0-SNAPSHOT in main (#447)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-02-16 13:28:52 -04:00
Nick Boldt 6d9f521cee
chore: always pull before push, and use rebase=true to resolve commits (#445)
Change-Id: I255d174a1067375921f567a21e2b933761ff5433

Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-02-15 14:43:46 -04:00
Nick Boldt 3201e3a183
chore: remove ref to .ci/set_tag_version_images.sh script since it was deleted two weeks ago (#443)
Change-Id: Ie770b98d6ebd64deacb3e376f4fee0ec675135a0

Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-02-15 12:07:18 -04:00
Igor Vinokur cb3565dbf8
Support Bitbucket-server oAuth2 factory (#440)
Apply Bitbucket Server oAuth-2 configuration for the factory flow.
2023-02-15 16:43:27 +02:00
che-bot 7bad48cfed
chore: Update from ubi8-minimal:8.7-1049 to ubi8-minimal:8.7-1049.1675784874 (#437)
Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2023-02-09 12:54:18 -04:00
Ilya Buziuk 09e68d34a4 refactor: Removing dependency on UserManager from FactoryService
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
2023-02-09 15:04:38 +01:00
Nick Boldt 7efb085cb7 further simplifications
Change-Id: Ifcd87155e07b88fbacf764d961f445063a770c54
Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-02-07 14:16:46 +01:00
Nick Boldt 752e986a84 Update .github/CODEOWNERS 2023-02-07 14:16:46 +01:00
Nick Boldt 665b063bb7 Update .github/CODEOWNERS 2023-02-07 14:16:46 +01:00
Nick Boldt 3deb00d28a Fionn Kelleher (@osslate) is the replacement for Fabrice, but he doesn't seem to have rights to this repo, so comment this out for now
Change-Id: I67e1758196349544e34fc06f361020f6ea77451d
Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-02-07 14:16:46 +01:00
Nick Boldt 98052dd94c chore: simplify the CODEOWNERS for che-server; remove people who've left; add replacements; remove global owners from subsection (assuming they already have full rights to the repo)
Change-Id: I524aa893c67eacca46cbac71aee38b3098981965
Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-02-07 14:16:46 +01:00
Mykhailo Kuznietsov 3dd20f690a
chore: fix: don't fail release if commit/push is a no-op (for 7.yy.z releases) (#433)
* fix: fix set_tag_version_images.sh for bugfix releases

Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>

* fix: fix set_tag_version_images.sh for bugfix releases

Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>

* fixup! fix: fix set_tag_version_images.sh for bugfix releases

---------

Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-02-02 12:54:56 -04:00
Ilya Buziuk 3b39854685 fix: Simplification of the 'canCreateNamespace' logic
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
2023-02-02 09:42:36 +01:00
Igor Vinokur 7323f4776f
Apply Bitbucket server url validation by testing an API request (#428)
Support factory from public Bitbucket-server repository without any oAuth configuration in the Che side. Add a new check that detects a Bitbucket-server url by testing it by a Bitbucket-server Api request.
2023-01-26 15:25:09 +02:00
Mykhailo Kuznietsov 9a003e2351 chore: Bump to 7.61.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-01-26 11:30:33 +01:00
Igor Vinokur 63517be522
Add "read:user" to the list of github token scopes (#422)
In order to be able to use the generated github token from the workspace pod in the github CLI tool, add the necessary token scope to the list of default scopes.
2023-01-21 13:01:27 +02:00
Igor Vinokur 756342b0c0
Apply Gitlab server url validation by testing an API request (#421)
Support factory from public Gitlab-server repository without any oAuth configuration in the Che side. Add a new check that detects a Gitlab server url by testing it by a Gitlab Api request.
2023-01-19 14:07:50 +02:00
Nick Boldt 5a601bb840
chore: CRW-3811 update deps (for... (#419)
* chore: CRW-3811 update deps (for CVE-2021-0341 ?)

Change-Id: I0e2bbf570acd9808fd1def15dee52ac29651a123
Signed-off-by: Nick Boldt <nboldt@redhat.com>

* unresolveable version, downgrade to previous

Change-Id: I7a1272ed9acda8c7d7adf4616b2c8d6999baf5d6
Signed-off-by: Nick Boldt <nboldt@redhat.com>

* more versions that can't be resolved from maven central

Change-Id: Ib7d96c0c5c6094f4f632f3661ce9d63c690d65c6
Signed-off-by: Nick Boldt <nboldt@redhat.com>

Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-01-17 12:38:14 -04:00
che-bot 457aa84892
chore: Update from ubi8-minimal:8.7-1031 to ubi8-minimal:8.7-1049 (#416)
Signed-off-by: Nick Boldt <nboldt@redhat.com>

Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2023-01-16 11:27:43 -04:00
Ilya Buziuk db249bf877 fixup! adressing review comments
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
2023-01-12 17:28:48 +01:00
Ilya Buziuk a59cc49a7f feat: Removing dependency on the usr, account, profile db tables
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
2023-01-12 17:28:48 +01:00
Nick Boldt 0337316203
chore: CRW-3802 CRW-3803 update to com.fasterxml.jackson 2.14.1 to fix CVEs (#415)
* chore: CRW-3802 CRW-3803 udpate to com.fasterxml.jackson 2.14.1 to fix CVEs

Change-Id: I4b146c16536741751146a9700eea1027064015f0
Signed-off-by: Nick Boldt <nboldt@redhat.com>

* add missing version for junit:junit:jar ==> 4.12

Change-Id: I21c6b53f6df37e684659e9d9604bc15271bc7e3a
Signed-off-by: Nick Boldt <nboldt@redhat.com>

* use eq(DevfileImpl.class); update copyright date; thanks to @vinokurig for the fix!

Change-Id: I436df0c7f9e9557d348fc7faab44379fe510d643
Signed-off-by: Nick Boldt <nboldt@redhat.com>

* fix junit dependency issue

Change-Id: Iec554595866649c7480209463eaa64c12a2f6e96
Signed-off-by: Nick Boldt <nboldt@redhat.com>

* ridiculous pom sorting rules

Change-Id: I6d72fc133bbedb99875051041e221af5892f3323
Signed-off-by: Nick Boldt <nboldt@redhat.com>

* remove junit version

Change-Id: I9bfa72bec71c5b8a009f4a4ac22012aa4b47038d
Signed-off-by: Nick Boldt <nboldt@redhat.com>

Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-01-11 15:04:36 -04:00
Mykhailo Kuznietsov 13a84d2943 chore: Bump to 7.60.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2023-01-09 14:10:06 +01:00
Nick Boldt d112b579f4
chore: #21763 - bump to py 3.9, temurin java... (#413)
* chore: #21763 - bump to py 3.9, temurin java 11 latest

Change-Id: I7e5bd82532ea18eec9468a1d37dfcb1c3e0ab8ae
Signed-off-by: Nick Boldt <nboldt@redhat.com>

* Update .github/workflows/release.yml

* update to latest temurin java 11

Change-Id: Ieb63ecd21768af299065a773f83e3f9d72da4f6c
Signed-off-by: Nick Boldt <nboldt@redhat.com>

Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-01-05 09:10:07 -04:00
Nick Boldt a97e6eec90
chore: update license headers to 2023 because we still use that annoying license header checker for some reason (#412)
To update next year:

  find . -name "*" -exec sed -i -r -e "s@-2023 Red Hat@-2024 Red Hat@g" {} \;

Change-Id: I2167da69ac584e743e61f4bbe699f06296911857
Signed-off-by: Nick Boldt <nboldt@redhat.com>

Signed-off-by: Nick Boldt <nboldt@redhat.com>
2023-01-04 10:33:06 -04:00
che-bot 395a22ec32
chore: Update from ubi8-minimal:8.7-923.1669829893 to ubi8-minimal:8.7-1031 (#409)
Signed-off-by: Nick Boldt <nboldt@redhat.com>

Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2023-01-04 08:04:43 -04:00
Igor Vinokur ef626cd6ee
Fix Delete oauth token API method (#408)
Rework the invalidate token oauth API method to send revoke token request to the git provider. After this request Che authorisation is unsynchronised so user is asked to re apply the authentication on new factory create step.
2023-01-04 10:06:25 +02:00
Piotr Karatkevich dd0e1820c6 feat(tomcat): Increase the maximum size of the request and response HTTP header to 32kb
Tomcat allows to configure the maximum size of the request and response HTTP header. If not specified, this attribute is set to 8192 (8 KB).
In order to avoid request blocking by this limitation, tomcat configuration has been adjusted to set 32768 (32 KB).
2022-12-22 15:53:22 +01:00
Igor Vinokur ab966cf9fe
Retry factory authentication when user rejects git service oauth (#405)
Currently when user rejects the oauth page for GitHub factory, Che tries to continue the factory flow without authentication (possible only for public repo). Apply the logic for the other git authentication providers.
2022-12-21 10:43:36 +02:00
Samantha Dawley 7d6f5f5af5
chore: Update GitHub actions to use Node 16 and Ubuntu to latest (#400)
* Update GitHub actions to use Node 16 and Ubuntu to latest

Signed-off-by: sdawley <sdawley@redhat.com>

* Switching Ubuntu to a set version (22.04). Changed release-action to v1 so it gets updates.

Signed-off-by: sdawley <sdawley@redhat.com>
2022-12-19 13:36:59 -04:00
Nick Boldt a0c25fe332
update integration tests to new root pom... (#402)
* update integration tests to new root pom version

Change-Id: Ic155888a0960ffcd2b26f7bf87373d260f655a2c
Signed-off-by: Nick Boldt <nboldt@redhat.com>

* fix poms that point to obsolete version 7.58.0-SNAPSHOT

Change-Id: I5854752288fec4ea774b27365770558b0d8946db
Signed-off-by: Nick Boldt <nboldt@redhat.com>

Signed-off-by: Nick Boldt <nboldt@redhat.com>
2022-12-16 11:03:12 -04:00
Mykhailo Kuznietsov 23e5b5f891 chore: Bump to 7.59.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2022-12-15 15:50:16 +01:00
Igor Vinokur ea76cda24c
fix: Override bitbucket content provider to use API request (#399)
bitbucket.org doesn't allow to fetch raw file content from private repositories using oAuth token any more. Override the common fetch content flow specifically for bitbucket.
2022-12-09 10:46:01 +02:00
che-bot 3a9a03f9d1
chore: Update from ubi8-minimal:8.7-923 to ubi8-minimal:8.7-923.1669829893 (#395)
Signed-off-by: Nick Boldt <nboldt@redhat.com>

Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2022-12-06 19:32:01 -04:00
Nick Boldt 659066dbf3
chore: clean up CODEOWNERS - remove... (#390)
* chore: clean up CODEOWNERS - remove @skabashnyuk, @metlos, and @MichalMaler; add @ibuziuk and @l0rd as global owners

Change-Id: Idd3c183441e2f394483167d101b9bd859df4b81f
Signed-off-by: Nick Boldt <nboldt@redhat.com>

* Update CODEOWNERS

remove owners who don't have write access to the repo

* Update CODEOWNERS

remove Ihor O per Martha's email

* Update .github/CODEOWNERS

* Update .github/CODEOWNERS

Co-authored-by: Mario Loriedo <mario.loriedo@gmail.com>

Signed-off-by: Nick Boldt <nboldt@redhat.com>
Co-authored-by: Mario Loriedo <mario.loriedo@gmail.com>
2022-12-06 08:59:48 -04:00
Nick Boldt 8f7f4fb28d
chore: update all rpms in dockerfile, not just gnutls (get fresher RPM updates) (#394)
Change-Id: I133e6ed1b1b8b21ce4dc2b6fe36140ff662c1b04
Signed-off-by: Nick Boldt <nboldt@redhat.com>

Signed-off-by: Nick Boldt <nboldt@redhat.com>
2022-12-05 13:02:51 -04:00
Mykhailo Kuznietsov 5e90d07987 chore: Bump to 7.58.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2022-11-24 15:30:55 +01:00
Ilya Buziuk 642732668b chore: Removing deprecated devfile endpoints. Updating the 2.2 schema to the latest version
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
2022-11-22 09:32:32 +01:00
che-bot e897e7b2f2
chore: Update from ubi8-minimal:8.6-994 to ubi8-minimal:8.7-923 (#384)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>

Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2022-11-14 11:51:15 -04:00
Ilya Buziuk 5c8658724f chore: Decommissioning Organization, Resource, Permission, Keycloak, SSH, Activity services
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
2022-11-14 12:53:46 +01:00
Vitaliy Gulyy cf508f009c
fix: Use SHA of the latest commit instead of the branch name when fetching raw file content (#376)
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
2022-11-14 09:20:44 +02:00
Igor Vinokur d11aeaf26b
chore: Add more Git unit tests (#375) 2022-11-08 09:38:27 +02:00
Samantha Dawley 621ad6ba71
chore: #21790 add badges for some actions and a link to downstream 3.x job (#380)
* chore: #21790 add badges for some actions and a link to downstream 3.x job

Signed-off-by: Samantha Dawley <sdawley@redhat.com>

* remove extra braces

* remove che-theia badges from che-server readme

Signed-off-by: Samantha Dawley <sdawley@redhat.com>
Co-authored-by: Nick Boldt <nboldt@redhat.com>
2022-11-07 18:48:41 -04:00
Ilya Buziuk 2400b7e1e5 chore: bumping kubernetes-client to the 5.12.4 version
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
2022-11-07 14:52:24 +01:00
Mykhailo Kuznietsov fb0bdd249f chore: Bump to 7.57.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2022-11-04 15:32:21 +01:00
che-bot e200cd0870
chore: Update from ubi8-minimal:8.6-941 to ubi8-minimal:8.6-994 (#377)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>

Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2022-11-02 07:50:26 -03:00
Andrew Obuchowicz e8ae835df2 fixup! chore: remove che.infra.kubernetes.workspace_start_timeout_min property 2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 687df1a19d fixup! chore: remove che.infra.kubernetes.workspace_start_timeout_min property 2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 640c9b7373 fixup! chore: remove che.workspace.pod.tolerations_json property 2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 2adc95d690 fixup! chore: remove che.workspace.pod.node_selector property 2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 8c7c008831 chore: remove che.workspace.server.ping_success_threshold & che.workspace.server.ping_interval_milliseconds properties
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 2ae602980c chore: remove che.workspace.probe_pool_size property
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 5a932eeba6 chore: remove che.workspace.pool.type, che.workspace.pool.exact_size, che.workspace.pool.cores_multiplier properties
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 9f9dce1bf5 chore: remove che.workspace.auto_start property
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 80d1f4e06d chore: remove che.workspace.pod.tolerations_json property
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 5283270814 chore: remove che.workspace.pod.node_selector property
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 9c6a43c0f9 chore: remove che.workspace.activity_check_scheduler_period_s, che.workspace.activity_check_scheduler_delay_s, che.workspace.activity_cleanup_scheduler_period_s, che.workspace.activity_cleanup_scheduler_initial_delay_s properties
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 454cdd7c6b chore: remove che.workspace.sidecar.image_pull_policy property
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 5360484f28 chore: remove che.infra.kubernetes.workspace_start_timeout_min property
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
2022-11-02 10:38:35 +01:00
Andrew Obuchowicz ee3f2b9911 chore: remove che.workspace.http_proxy, che.workspace.https_proxy, che.workspace.no_proxy properties
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
2022-11-02 10:38:35 +01:00
Andrew Obuchowicz 0c3afb1f22 chore: remove che.workspace.logs.root_dir property
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
2022-11-02 10:38:35 +01:00
Andrew Obuchowicz f3700dba05 chore: remove che.workspace.projects.storage property
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
2022-11-02 10:38:35 +01:00
Igor Vinokur b7f8fea502
fix: Fix gitlab url validation (#372)
Check if a user namespace PAT secret is present, even if the given URL doesn't match the predefined patterns.
Fix the getPatternMatcherByUrl() function as gitlabUrlPatterns.isEmpty() condition is impossible.
Fix the git credentials secret initialisation when a PAT secret is already present.
2022-10-21 09:34:03 +03:00
Igor Vinokur a6faefa953
fix: fix resolving Gitlab raw url (#371)
Partially reverts 5aa763a in order to fix the Gitlab OAuth flow.
The rawFileUrl method uses the API request now. If the request is passed without token it works for public repos, unlike the previous raw file request which fails for private projects, even with the Authorisation header.
2022-10-19 17:59:17 +03:00
Igor Vinokur acc57c7788
chore: Apply maximum allowed expiryDays for the bitbucket server token request (#370)
* chore: Apply maximum allowed expiryDays for the bitbucket server token request

Signed-off-by: Igor Vinokur <ivinokur@redhat.com>

* fixup! chore: Apply maximum allowed expiryDays for the bitbucket server token request

* fixup! chore: Apply maximum allowed expiryDays for the bitbucket server token request

Signed-off-by: Igor Vinokur <ivinokur@redhat.com>
2022-10-14 12:29:58 -03:00
Mykhailo Kuznietsov bc4ec10c23 chore: Bump to 7.56.0-SNAPSHOT in main
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2022-10-12 16:11:49 +02:00
che-bot 304ef32c26
chore: Update from ubi8-minimal:8.6-902.1661794353 to ubi8-minimal:8.6-941 (#367)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>

Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2022-10-12 08:56:33 -03:00
Igor Vinokur f9e002b880
chore: Improve the bitbucket-server Url pattern (#368)
Improve the bitbucket server Url pattern to support url from project repositories and from the bitbucket page that includes branch reference.
2022-10-11 16:35:17 +03:00
Anatolii Bazko d4e29dfe61
Merge pull request #355 from eclipse-che/CRW-3328
feat: Delegate only needed roles to user in his namespace
2022-10-06 11:54:28 +03:00
Anatolii Bazko dfe5b372c2 Fix import
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2022-10-06 09:57:38 +03:00
Igor Vinokur 5aa763aab3
chore: Fix Gitlab raw file location url (#363)
Rework the Gitlab raw file url function to return a public raw file url instead of an API request.
Trim the gitlabEndpoint if it ends with /
2022-10-03 09:52:14 +03:00
che-bot 6350fa9ab4
chore: Bump to 7.55.0-SNAPSHOT in main (#358)
Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>

Signed-off-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
Co-authored-by: Mykhailo Kuznietsov <mkuznets@redhat.com>
2022-09-29 17:06:33 +03:00
Igor Vinokur 2e269aae64
chore: Rework the bitbucket raw file location url (#362)
Rework the rawFileLocation() function to return a file url, which is available for public, without an authentication. This allows to use a factory from a public bitbucket repo without the bitbucket OAuth configuration.
2022-09-28 15:34:39 +03:00
Igor Vinokur 40598a0e8b
fix: Allign the GitHub raw file location Url with subdomain isolation option (#361)
Inject the che.integration.github.disable_subdomain_isolation env variable property to handle the subdomain isolation GitHub option while returning the GitHub raw file location.
2022-09-28 09:59:19 +03:00
Igor Vinokur a8623992b6
chore: Allign the /token/refresh/ factory API method (#359)
Fix the /token/refresh/ factory API method by picking out the hostname from the url parameter and passing it to personalAccessTokenManager.getAndStore(hostname) instead of the entire factory url
2022-09-26 09:05:04 +03:00
Anatolii Bazko 4994821ba9 feat: Delegate only needed roles to user in his namespace
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
2022-09-14 16:56:19 +03:00
828 changed files with 19498 additions and 48582 deletions

View File

@ -0,0 +1,29 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
# Dockerfile to bootstrap build and test in openshift-ci
FROM registry.ci.openshift.org/openshift/release:golang-1.18
# hadolint ignore=DL3002
USER 0
SHELL ["/bin/bash", "-c"]
# Install yq, kubectl, chectl cli used by olm/olm.sh script.
# hadolint ignore=DL3041
# Install yq, kubectl, chectl cli.
RUN yum install --assumeyes -d1 psmisc python3-pip httpd-tools nodejs && \
pip3 install --upgrade setuptools && \
pip3 install yq && \
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
chmod +x ./kubectl && \
mv ./kubectl /usr/local/bin && \
bash <(curl -sL https://che-incubator.github.io/chectl/install.sh) --channel=next

19
.ci/openshift-ci/ca.crt Normal file
View File

@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDDDCCAfSgAwIBAgIBATANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDDBtpbmdy
ZXNzLW9wZXJhdG9yQDE3MDI5MTczMzkwHhcNMjMxMjE4MTYzNTM4WhcNMjUxMjE3
MTYzNTM5WjAmMSQwIgYDVQQDDBtpbmdyZXNzLW9wZXJhdG9yQDE3MDI5MTczMzkw
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDDVfcIyqKLYcrmieDOCvAq
RKFR0PXqjl54DyfhkP7TC/rA4WMaJgYamYNNRcy4rOb+i3P1yepeVlXj+4gka41W
fh1QghqDGPpQTF7I8SDhnz3qdQymgSSkrxBWOGgJZRG3Gd50CNeh+ADdNlOxzZhJ
c1HI9/36Zp0M7RHLNwrYzKf/Scrcl3t/Ps4KHKsNtjNygnPSTjGwza5TTTAvGQ+h
3+c+bKJHZp6VFoEpubmBfCG8x+vJwBNI+YauXwti9EqFutnAbOiQ4aOvqQYINngV
OQTOg3xnifnooaR2iZPOtxPLUDMydHP9sDVNGLICpnKcFN6x5JKq1fAuwOAMRMQr
AgMBAAGjRTBDMA4GA1UdDwEB/wQEAwICpDASBgNVHRMBAf8ECDAGAQH/AgEAMB0G
A1UdDgQWBBRQfZkM6C20GT1YiTiS694vRPP2MDANBgkqhkiG9w0BAQsFAAOCAQEA
qd9ug2Bo2s3CG0qjNtk19WYYAuwkEMZU9L/FbSfmPkkOTbrZB71ofZbVan8Dx9/W
SfbkN1eJQNxd7QIDlExKEW2ufJIMCDe6haLHV8x+z3fISHg3wMUCPtadLG/exafy
agfj8PQgnJ1sbA/fKl0rqcVYuIihZ0DdMe28Yj92BFcs5+TXzVYzjyeIGonUZrCR
LtW2CxV7Ngue9pkWGsqQSlRwzp3knYfZxeQLneZcGlsSV4r9LOKIAA/MhBGgpwVc
zrh7L93jajHD1AD0sRdUQp4VVhysXVmMMSAjaLkqHsvSyJp7yKJOmrts6a274qbU
J1E6cXqtfF0NwRo2D9BouQ==
-----END CERTIFICATE-----

599
.ci/openshift-ci/common.sh Normal file
View File

@ -0,0 +1,599 @@
#!/bin/bash
#
# Copyright (c) 2023-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
set -e
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
PR_IMAGE_TAG="pr-${PULL_NUMBER}"
export CHE_NAMESPACE=${CHE_NAMESPACE:-"eclipse-che"}
export CHE_SERVER_IMAGE=${CHE_SERVER_IMAGE:-"quay.io/eclipse/che-server:${PR_IMAGE_TAG}"}
export ARTIFACTS_DIR=${ARTIFACT_DIR:-"/tmp/artifacts"}
export CHE_FORWARDED_PORT="8081"
export OCP_ADMIN_USER_NAME=${OCP_ADMIN_USER_NAME:-"admin"}
export OCP_NON_ADMIN_USER_NAME=${OCP_NON_ADMIN_USER_NAME:-"user"}
export OCP_LOGIN_PASSWORD=${OCP_LOGIN_PASSWORD:-"passw"}
export ADMIN_CHE_NAMESPACE=${OCP_ADMIN_USER_NAME}"-che"
export USER_CHE_NAMESPACE=${OCP_NON_ADMIN_USER_NAME}"-che"
export GIT_PROVIDER_USERNAME=${GIT_PROVIDER_USERNAME:-"chepullreq1"}
export PUBLIC_REPO_WORKSPACE_NAME=${PUBLIC_REPO_WORKSPACE_NAME:-"public-repo-wksp-testname"}
export PRIVATE_REPO_WORKSPACE_NAME=${PRIVATE_REPO_WORKSPACE_NAME:-"private-repo-wksp-testname"}
export PUBLIC_PROJECT_NAME=${PUBLIC_PROJECT_NAME:-"public-repo"}
export PRIVATE_PROJECT_NAME=${PRIVATE_PROJECT_NAME:-"private-repo"}
export YAML_FILE_NAME=${YAML_FILE_NAME:-"devfile.yaml"}
export CUSTOM_CONFIG_MAP_NAME=${CUSTOM_CONFIG_MAP_NAME:-"custom-ca-certificates"}
export GIT_SSL_CONFIG_MAP_NAME=${GIT_SSL_CONFIG_MAP_NAME:-"che-self-signed-cert"}
provisionOpenShiftOAuthUser() {
echo "------- [INFO] Start provisioning Openshift OAuth user -------"
htpasswd -c -B -b users.htpasswd ${OCP_ADMIN_USER_NAME} ${OCP_LOGIN_PASSWORD}
htpasswd -b users.htpasswd ${OCP_NON_ADMIN_USER_NAME} ${OCP_LOGIN_PASSWORD}
oc create secret generic htpass-secret --from-file=htpasswd="users.htpasswd" -n openshift-config
oc apply -f ".ci/openshift-ci/htpasswdProvider.yaml"
oc adm policy add-cluster-role-to-user cluster-admin ${OCP_ADMIN_USER_NAME}
echo "------- [INFO] Waiting for htpasswd auth to be working up to 5 minutes -------"
CURRENT_TIME=$(date +%s)
ENDTIME=$((CURRENT_TIME + 300))
while [ "$(date +%s)" -lt $ENDTIME ]; do
if oc login -u=${OCP_ADMIN_USER_NAME} -p=${OCP_LOGIN_PASSWORD} --insecure-skip-tls-verify=false; then
echo "======= [INFO] OpenShift OAuth htpasswd is configured. =======
======= [INFO] Login to OCP cluster with admin user credentials is success.======="
return 0
fi
sleep 5
done
echo "####### [ERROR] Error occurred while waiting OpenShift OAuth htpasswd setup. Try to rerun test. #######"
exit 1
}
configureGitSelfSignedCertificate() {
echo "------- [INFO] Configure self-signed certificate for Git provider -------"
oc adm new-project ${CHE_NAMESPACE}
oc project ${CHE_NAMESPACE}
echo "------- [INFO] Create ConfigMap with the required TLS certificate -------"
oc create configmap ${CUSTOM_CONFIG_MAP_NAME} --from-file=.ci/openshift-ci/ca.crt
oc label configmap ${CUSTOM_CONFIG_MAP_NAME} app.kubernetes.io/part-of=che.eclipse.org app.kubernetes.io/component=ca-bundle
echo "------- [INFO] Create ConfigMap to support Git repositories with self-signed certificates -------"
oc create configmap ${GIT_SSL_CONFIG_MAP_NAME} --from-file=.ci/openshift-ci/ca.crt --from-literal=githost=${GIT_PROVIDER_URL}
oc label configmap ${GIT_SSL_CONFIG_MAP_NAME} app.kubernetes.io/part-of=che.eclipse.org
echo "======= [INFO] ConfigMaps are configured ======="
}
createCustomResourcesFile() {
echo "------- [INFO] Create custom resourses file -------"
cat > custom-resources.yaml <<-END
apiVersion: org.eclipse.che/v2
spec:
devEnvironments:
maxNumberOfRunningWorkspacesPerUser: 10000
END
echo "======= [INFO] Generated custom resources file ======="
cat custom-resources.yaml
}
patchCustomResourcesFile() {
echo "------- [INFO] Edit the custom resources file to add 'gitTrustedCertsConfigMapName' -------"
yq -y '.spec.devEnvironments.trustedCerts += {"gitTrustedCertsConfigMapName": "'${GIT_SSL_CONFIG_MAP_NAME}'"}' custom-resources.yaml -i
echo "======= [INFO] Patched custom resources file ======="
cat custom-resources.yaml
}
deployChe() {
echo "------- [INFO] Start installing Eclipse Che -------"
chectl server:deploy --cheimage=$CHE_SERVER_IMAGE \
--che-operator-cr-patch-yaml=custom-resources.yaml \
--platform=openshift \
--telemetry=off \
--batch
waitFinishDeploymentCheServer
echo "======= [INFO] Eclipse Che is successfully installed ======="
}
waitFinishDeploymentCheServer() {
CURRENT_TIME=$(date +%s)
ENDTIME=$((CURRENT_TIME + 60))
while [ "$(date +%s)" -lt $ENDTIME ]; do
podCheServerName=$(oc get pod -n ${CHE_NAMESPACE} -l component=che | grep "che" | awk '{ print $1 }')
echo "Pod Che_Server: $podCheServerName"
count=$(echo "$podCheServerName" | wc -l)
if [ $count -eq 1 ]; then
echo "------- [INFO] Only one Che Server pod is left. -------"
return 0
fi
echo "------- [INFO] Waiting until only one Che Server pod remains. -------"
sleep 5
done
echo "####### [ERROR] Error occurred while waiting for only one Che Server pod. #######"
exit 1
}
# this command starts port forwarding between the local machine and the che-host service in the OpenShift cluster.
forwardPortToService() {
echo "------- [INFO] Start forwarding between the local machine and the che-host service -------"
oc port-forward service/che-host ${CHE_FORWARDED_PORT}:8080 -n ${CHE_NAMESPACE} &
sleep 3s
}
killProcessByPort() {
fuser -k ${CHE_FORWARDED_PORT}/tcp
}
requestFactoryResolverGitRepoUrl() {
GIT_REPO_URL=$1
CLUSTER_ACCESS_TOKEN=$(oc whoami -t)
curl -i -X 'POST' \
http://localhost:${CHE_FORWARDED_PORT}/api/factory/resolver \
-H 'accept: */*' \
-H "Authorization: Bearer ${CLUSTER_ACCESS_TOKEN}" \
-H 'Content-Type: application/json' \
-d '{
"url": "'${GIT_REPO_URL}'"
}'
}
# check that factory resolver returns correct value without any PAT/OAuth setup
testFactoryResolverNoPatOAuth() {
echo "------- [INFO] Check factory resolver for public repository with NO PAT/OAuth setup -------"
testFactoryResolverResponse $1 200
echo "------- [INFO] Check factory resolver for private repository with NO PAT/OAuth setup -------"
testFactoryResolverResponse $2 500
}
# check that raw devfile url factory resolver returns correct value without any PAT/OAuth setup
testFactoryResolverNoPatOAuthRaw() {
echo "------- [INFO] Check factory resolver for public repository with NO PAT/OAuth setup -------"
testFactoryResolverResponse $1 200
echo "------- [INFO] Check factory resolver for private repository with NO PAT/OAuth setup -------"
testFactoryResolverResponse $2 400
}
# check that factory resolver returns correct value with PAT/OAuth setup
testFactoryResolverWithPatOAuth() {
echo "------- [INFO] Check factory resolver for public repository with PAT/OAuth setup -------"
testFactoryResolverResponse $1 200
echo "------- [INFO] Check factory resolver for private repository with PAT/OAuth setup -------"
testFactoryResolverResponse $2 200
}
testFactoryResolverResponse() {
URL=$1
RESPONSE_CODE=$2
if [ "$(requestFactoryResolverGitRepoUrl ${URL} | grep "HTTP/1.1 ${RESPONSE_CODE}")" ]; then
echo "======= [INFO] Factory resolver returned 'HTTP/1.1 ${RESPONSE_CODE}' status code. Expected client side response. ======="
else
echo "####### [ERROR] Factory resolver returned wrong status code. Expected: HTTP/1.1 ${RESPONSE_CODE}. #######
####### Cause possible: PR code regress or service is changed. Need to investigate it. #######"
exit 1
fi
}
requestProvisionNamespace() {
CLUSTER_ACCESS_TOKEN=$(oc whoami -t)
curl -i -X 'POST' \
http://localhost:${CHE_FORWARDED_PORT}/api/kubernetes/namespace/provision \
-H 'accept: application/json' \
-H "Authorization: Bearer ${CLUSTER_ACCESS_TOKEN}" \
-d ''
}
initUserNamespace() {
OCP_USER_NAME=$1
echo "------- [INFO] Initialize user namespace -------"
oc login -u=${OCP_USER_NAME} -p=${OCP_LOGIN_PASSWORD} --insecure-skip-tls-verify=false
request_result=$(requestProvisionNamespace) || true
if [ -z "$request_result" ]; then
echo "####### [ERROR] Cause possible: lost connection to pod, this is an infrastructure problem. Try to rerun the test. #######"
exit 1
elif [ "$(echo "$request_result" | grep "HTTP/1.1 200")" ]; then
echo "======= [INFO] Request provision user namespace returned 'HTTP/1.1 200' status code. User namespace is created. ======="
else
echo "####### [ERROR] Request provision user namespace returned wrong status code. Expected: HTTP/1.1 200. #######
####### User namespace creation failed. Cause possible: PR code regression or service is changed. Need to investigate. #######"
exit 1
fi
}
setupPersonalAccessToken() {
GIT_PROVIDER_TYPE=$1
GIT_PROVIDER_URL=$2
GIT_PROVIDER_PAT=$3
echo "------- [INFO] Setup Personal Access Token Secret -------"
oc project ${USER_CHE_NAMESPACE}
CHE_USER_ID=$(oc get secret user-profile -o jsonpath='{.data.id}' | base64 -d)
ENCODED_PAT=$(echo -n ${GIT_PROVIDER_PAT} | base64)
cat .ci/openshift-ci/pat-secret.yaml > pat-secret.yaml
# patch the pat-secret.yaml file
sed -i "s#che-user-id#${CHE_USER_ID}#g" pat-secret.yaml
sed -i "s#git-provider-name#${GIT_PROVIDER_TYPE}#g" pat-secret.yaml
sed -i "s#git-provider-url#${GIT_PROVIDER_URL}#g" pat-secret.yaml
sed -i "s#encoded-access-token#${ENCODED_PAT}#g" pat-secret.yaml
if [ "${GIT_PROVIDER_TYPE}" == "azure-devops" ]; then
sed -i "s#''#${GIT_PROVIDER_USERNAME}#g" pat-secret.yaml
fi
cat pat-secret.yaml
oc apply -f pat-secret.yaml -n ${USER_CHE_NAMESPACE}
echo "======= [INFO] Personal Access Token is created. ======="
}
setupSSHKeyPairs() {
GIT_PRIVATE_KEY=$1
GIT_PUBLIC_KEY=$2
echo "------- [INFO] Setup SSH Key Pairs Secret "-------
oc project ${USER_CHE_NAMESPACE}
ENCODED_GIT_PRIVATE_KEY=$(echo "${GIT_PRIVATE_KEY}" | base64 -w 0)
ENCODED_GIT_PUBLIC_KEY=$(echo "${GIT_PUBLIC_KEY}" | base64 -w 0)
cat .ci/openshift-ci/ssh-secret.yaml > ssh-secret.yaml
# patch the ssh-secret.yaml file
sed -i "s#ssh_private_key#${ENCODED_GIT_PRIVATE_KEY}#g" ssh-secret.yaml
sed -i "s#ssh_public_key#${ENCODED_GIT_PUBLIC_KEY}#g" ssh-secret.yaml
cat ssh-secret.yaml
oc apply -f ssh-secret.yaml -n ${USER_CHE_NAMESPACE}
echo "======= [INFO] SSH Secret is created. ======="
}
# Only for GitLab server administrator users
createOAuthApplicationGitLabServer() {
ADMIN_ACCESS_TOKEN=$1
CHE_URL=https://$(oc get route -n ${CHE_NAMESPACE} che -o jsonpath='{.spec.host}')
echo "------- [INFO] Create OAuth Application -------"
response=$(curl -k -X POST \
${GIT_PROVIDER_URL}/api/v4/applications \
-H "PRIVATE-TOKEN: ${ADMIN_ACCESS_TOKEN}" \
-d "name=${APPLICATION_NAME}" \
-d "redirect_uri=${CHE_URL}/api/oauth/callback" \
-d "scopes=api write_repository openid")
echo "------- [INFO] Response of the created OAuth Application -------"
OAUTH_ID=$(echo "$response" | jq -r '.id')
APPLICATION_ID=$(echo "$response" | jq -r '.application_id')
APPLICATION_SECRET=$(echo "$response" | jq -r '.secret')
}
# Only for GitLab server administrator users
deleteOAuthApplicationGitLabServer() {
OAUTH_ID=$1
ADMIN_ACCESS_TOKEN=$2
echo "------- [INFO] Delete OAuth Application -------"
curl -i -k -X DELETE \
${GIT_PROVIDER_URL}/api/v4/applications/${OAUTH_ID} \
-H "PRIVATE-TOKEN: ${ADMIN_ACCESS_TOKEN}"
echo "======= [INFO] OAuth Application is deleted ======="
}
# Only for GitLab server
revokeAuthorizedOAuthApplication() {
APPLICATION_ID=$1
APPLICATION_SECRET=$2
echo "------- [INFO] Revoke authorized OAuth application -------"
oc project ${USER_CHE_NAMESPACE}
OAUTH_TOKEN_NAME=$(oc get secret | grep 'personal-access-token'| awk 'NR==1 { print $1 }')
OAUTH_TOKEN=$(oc get secret $OAUTH_TOKEN_NAME -o jsonpath='{.data.token}' | base64 -d)
curl -i -k -X POST \
${GIT_PROVIDER_URL}/oauth/revoke \
-d "client_id=${APPLICATION_ID}" \
-d "client_secret=${APPLICATION_SECRET}" \
-d "token=${OAUTH_TOKEN}"
echo "======= [INFO] Authorized OAuth application is revoked ======="
}
# Only for GitLab server
setupOAuthSecret() {
APPLICATION_ID=$1
APPLICATION_SECRET=$2
echo "------- [INFO] Setup OAuth Secret -------"
oc login -u=${OCP_ADMIN_USER_NAME} -p=${OCP_LOGIN_PASSWORD} --insecure-skip-tls-verify=false
oc project ${CHE_NAMESPACE}
SERVER_POD=$(oc get pod -l component=che | grep "che" | awk 'NR==1 { print $1 }')
ENCODED_APP_ID=$(echo -n "${APPLICATION_ID}" | base64 -w 0)
ENCODED_APP_SECRET=$(echo -n "${APPLICATION_SECRET}" | base64 -w 0)
cat .ci/openshift-ci/oauth-secret.yaml > oauth-secret.yaml
# patch the oauth-secret.yaml file
sed -i "s#git-provider-url#${GIT_PROVIDER_URL}#g" oauth-secret.yaml
sed -i "s#encoded-application-id#${ENCODED_APP_ID}#g" oauth-secret.yaml
sed -i "s#encoded-application-secret#${ENCODED_APP_SECRET}#g" oauth-secret.yaml
cat oauth-secret.yaml
oc apply -f oauth-secret.yaml -n ${CHE_NAMESPACE}
echo "------- [INFO] Wait updating deployment after create OAuth secret -------"
oc wait --for=delete pod/${SERVER_POD} --timeout=120s
}
runTestWorkspaceWithGitRepoUrl() {
WS_NAME=$1
PROJECT_NAME=$2
GIT_REPO_URL=$3
OCP_USER_NAMESPACE=$4
oc project ${OCP_USER_NAMESPACE}
cat .ci/openshift-ci/devworkspace-test.yaml > devworkspace-test.yaml
echo "------- [INFO] Preparing 'devworkspace-test.yaml' and run test workspace -------"
# patch the devworkspace-test.yaml file
sed -i "s#ws-name#${WS_NAME}#g" devworkspace-test.yaml
sed -i "s#project-name#${PROJECT_NAME}#g" devworkspace-test.yaml
sed -i "s#git-repo-url#${GIT_REPO_URL}#g" devworkspace-test.yaml
cat devworkspace-test.yaml
oc apply -f devworkspace-test.yaml -n ${OCP_USER_NAMESPACE}
oc wait -n ${OCP_USER_NAMESPACE} --for=condition=Ready dw ${WS_NAME} --timeout=360s
echo "======= [INFO] Test workspace is run ======="
}
testProjectIsCloned() {
PROJECT_NAME=$1
OCP_USER_NAMESPACE=$2
WORKSPACE_POD_NAME=$(oc get pods -n ${OCP_USER_NAMESPACE} | grep workspace | awk '{print $1}')
if oc exec -it -n ${OCP_USER_NAMESPACE} ${WORKSPACE_POD_NAME} -- test -f /projects/${PROJECT_NAME}/${YAML_FILE_NAME}; then
echo "======= [INFO] Project file /projects/${PROJECT_NAME}/${YAML_FILE_NAME} exists. ======="
else
echo "======= [INFO] Project file /projects/${PROJECT_NAME}/${YAML_FILE_NAME} is absent. ======="
return 1
fi
}
testGitCredentialsData() {
OCP_USER_NAMESPACE=$1
GIT_PROVIDER_PAT=$2
GIT_PROVIDER_URL=$3
echo "------- [INFO] Check the 'git credentials' is in a workspace -------"
hostName="${GIT_PROVIDER_URL#https://}"
if [ "${GIT_PROVIDER_TYPE}" == "azure-devops" ]; then
userName="username"
else
userName=${GIT_PROVIDER_USERNAME}
fi
gitCredentials="https://${userName}:${GIT_PROVIDER_PAT}@${hostName}"
WORKSPACE_POD_NAME=$(oc get pods -n ${OCP_USER_NAMESPACE} | grep workspace | awk '{print $1}')
if oc exec -it -n ${OCP_USER_NAMESPACE} ${WORKSPACE_POD_NAME} -- cat /.git-credentials/credentials | grep -q ${gitCredentials}; then
echo "======= [INFO] Git credentials file '/.git-credentials/credentials' exists and has the expected content. ======="
else
echo "####### [ERROR] Git credentials file '/.git-credentials/credentials' does not exist or has incorrect content. ######
###### Cause possible: PR code regress or service is changed. Need to investigate it. #######"
exit 1
fi
}
deleteTestWorkspace() {
WS_NAME=$1
OCP_USER_NAMESPACE=$2
echo "------- [INFO] Delete test workspace -------"
oc delete dw ${WS_NAME} -n ${OCP_USER_NAMESPACE}
}
startOAuthFactoryTest() {
CHE_URL=https://$(oc get route -n ${CHE_NAMESPACE} che -o jsonpath='{.spec.host}')
# patch oauth-factory-test.yaml
cat .ci/openshift-ci/pod-oauth-factory-test.yaml > oauth-factory-test.yaml
sed -i "s#CHE_URL#${CHE_URL}#g" oauth-factory-test.yaml
sed -i "s#CHE-NAMESPACE#${CHE_NAMESPACE}#g" oauth-factory-test.yaml
sed -i "s#OCP_USER_NAME#${OCP_NON_ADMIN_USER_NAME}#g" oauth-factory-test.yaml
sed -i "s#OCP_USER_PASSWORD#${OCP_LOGIN_PASSWORD}#g" oauth-factory-test.yaml
sed -i "s#FACTORY_REPO_URL#${PRIVATE_REPO_URL}#g" oauth-factory-test.yaml
sed -i "s#GIT_BRANCH#${GIT_REPO_BRANCH}#g" oauth-factory-test.yaml
sed -i "s#GIT_PROVIDER_TYPE#${GIT_PROVIDER_TYPE}#g" oauth-factory-test.yaml
sed -i "s#GIT_PROVIDER_USER_NAME#${GIT_PROVIDER_LOGIN}#g" oauth-factory-test.yaml
sed -i "s#GIT_PROVIDER_USER_PASSWORD#${GIT_PROVIDER_PASSWORD}#g" oauth-factory-test.yaml
echo "------- [INFO] Applying the following patched OAuth Factory Test Pod: -------"
cat oauth-factory-test.yaml
echo "[INFO] --------------------------------------------------"
oc apply -f oauth-factory-test.yaml
# wait for the pod to start
n=0
while [ $n -le 120 ]
do
PHASE=$(oc get pod -n ${CHE_NAMESPACE} ${TEST_POD_NAME} \
--template='{{ .status.phase }}')
if [[ ${PHASE} == "Running" ]]; then
echo "======= [INFO] Factory test started successfully. ======="
return
fi
sleep 5
n=$(( n+1 ))
done
echo "####### [ERROR] Failed to start Factory test. #######
###### Cause possible: an infrastructure problem, pod could not start, try to rerun the test. #######"
exit 1
}
startSmokeTest() {
CHE_URL=https://$(oc get route -n ${CHE_NAMESPACE} che -o jsonpath='{.spec.host}')
# patch che-smoke-test.yaml
cat .ci/openshift-ci/pod-che-smoke-test.yaml > che-smoke-test.yaml
sed -i "s#CHE_URL#${CHE_URL}#g" che-smoke-test.yaml
sed -i "s#CHE-NAMESPACE#${CHE_NAMESPACE}#g" che-smoke-test.yaml
sed -i "s#OCP_USER_NAME#${OCP_NON_ADMIN_USER_NAME}#g" che-smoke-test.yaml
sed -i "s#OCP_USER_PASSWORD#${OCP_LOGIN_PASSWORD}#g" che-smoke-test.yaml
echo "------- [INFO] Applying the following patched Smoke Test Pod: -------"
cat che-smoke-test.yaml
echo "[INFO] --------------------------------------------------"
oc apply -f che-smoke-test.yaml
# wait for the pod to start
n=0
while [ $n -le 120 ]
do
PHASE=$(oc get pod -n ${CHE_NAMESPACE} ${TEST_POD_NAME} \
--template='{{ .status.phase }}')
if [[ ${PHASE} == "Running" ]]; then
echo "======= [INFO] Smoke test started successfully. ======="
return
fi
sleep 5
n=$(( n+1 ))
done
echo "####### [ERROR] Failed to start Smoke test. #######
####### Cause possible: an infrastructure problem, pod could not start, try to rerun the test. #######"
exit 1
}
# Catch the finish of the job and write logs in artifacts.
catchFinish() {
local RESULT=$?
if [ "$RESULT" != "0" ]; then
set +e
collectEclipseCheLogs
set -e
fi
echo "------- [INFO] Terminate the process after finish the test script. -------"
set +e
killProcessByPort
set -e
[[ "${RESULT}" != "0" ]] && echo "####### [ERROR] Job failed. #######" || echo "####### [INFO] Job completed successfully. #######"
exit $RESULT
}
collectEclipseCheLogs() {
mkdir -p ${ARTIFACTS_DIR}/che-logs
# Collect all Eclipse Che logs and cluster CR
oc login -u=${OCP_ADMIN_USER_NAME} -p=${OCP_LOGIN_PASSWORD} --insecure-skip-tls-verify=false
oc get checluster -o yaml -n $CHE_NAMESPACE > "${ARTIFACTS_DIR}/che-cluster.yaml"
chectl server:logs -n $CHE_NAMESPACE --directory ${ARTIFACTS_DIR}/che-logs --telemetry off
}
collectLogs() {
echo "------- [INFO] Waiting until test pod finished. -------"
oc logs -n ${CHE_NAMESPACE} ${TEST_POD_NAME} -c test -f
sleep 3
# Download artifacts
set +e
echo -------" [INFO] Collect all Eclipse Che logs and cluster CR. -------"
collectEclipseCheLogs
echo "------- [INFO] Downloading test report. -------"
mkdir -p ${ARTIFACTS_DIR}/e2e
oc rsync -n ${CHE_NAMESPACE} ${TEST_POD_NAME}:/tmp/e2e/report/ ${ARTIFACTS_DIR}/e2e -c download-reports
oc exec -n ${CHE_NAMESPACE} ${TEST_POD_NAME} -c download-reports -- touch /tmp/done
# Revoke and delete the OAuth application
if [[ ${TEST_POD_NAME} == "oauth-factory-test" ]]; then
revokeAuthorizedOAuthApplication ${APPLICATION_ID} ${APPLICATION_SECRET}
deleteOAuthApplicationGitLabServer ${OAUTH_ID} ${ADMIN_ACCESS_TOKEN}
fi
set -e
EXIT_CODE=$(oc logs -n ${CHE_NAMESPACE} ${TEST_POD_NAME} -c test | grep EXIT_CODE)
if [[ ${EXIT_CODE} != "+ EXIT_CODE=0" ]]; then
echo "####### [ERROR] GUI test failed. Job failed. #######
###### Cause possible: PR code regress or service is changed. Need to investigate it. #######"
exit 1
fi
echo "======= [INFO] Job completed successfully. ======="
}
testCloneGitRepoNoProjectExists() {
WS_NAME=$1
PROJECT_NAME=$2
GIT_REPO_URL=$3
OCP_USER_NAMESPACE=$4
runTestWorkspaceWithGitRepoUrl ${WS_NAME} ${PROJECT_NAME} ${GIT_REPO_URL} ${OCP_USER_NAMESPACE}
echo "------- [INFO] Check the private repository is NOT cloned with NO PAT/OAuth setup. -------"
testProjectIsCloned ${PROJECT_NAME} ${OCP_USER_NAMESPACE} && \
{ echo "####### [ERROR] Project file /projects/${PROJECT_NAME}/${YAML_FILE_NAME} should NOT be present. #######
####### Cause possible: PR code regress or service is changed. Need to investigate it. #######" && exit 1; }
echo "======= [INFO] Project file /projects/${PROJECT_NAME}/${YAML_FILE_NAME} is NOT present. This is EXPECTED. ======="
}
# Test that the repository is cloned when PAT, OAuth or SSH is configured
testCloneGitRepoProjectShouldExists() {
WS_NAME=$1
PROJECT_NAME=$2
GIT_REPO_URL=$3
OCP_USER_NAMESPACE=$4
runTestWorkspaceWithGitRepoUrl ${WS_NAME} ${PROJECT_NAME} ${GIT_REPO_URL} ${OCP_USER_NAMESPACE}
echo "------- [INFO] Check the repository is cloned. -------"
testProjectIsCloned ${PROJECT_NAME} ${OCP_USER_NAMESPACE} || \
{ echo "####### [ERROR] Project file /projects/${PROJECT_NAME}/${YAML_FILE_NAME} should be present. #######
###### Cause possible: PR code regress or service is changed. Need to investigate it. #######" && exit 1; }
}
setupTestEnvironment() {
OCP_USER_NAME=$1
provisionOpenShiftOAuthUser
createCustomResourcesFile
deployChe
forwardPortToService
initUserNamespace ${OCP_USER_NAME}
}
setupTestEnvironmentOAuthFlow() {
ADMIN_ACCESS_TOKEN=$1
APPLICATION_ID=$2
APPLICATION_SECRET=$3
provisionOpenShiftOAuthUser
configureGitSelfSignedCertificate
createCustomResourcesFile
patchCustomResourcesFile
deployChe
createOAuthApplicationGitLabServer ${ADMIN_ACCESS_TOKEN} ${APPLICATION_NAME}
setupOAuthSecret ${APPLICATION_ID} ${APPLICATION_SECRET}
}

View File

@ -0,0 +1,22 @@
kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
name: ws-name
spec:
started: true
routingClass: che
template:
projects:
- name: project-name
git:
remotes:
origin: git-repo-url
contributions:
- name: che-code
uri: https://eclipse-che.github.io/che-plugin-registry/main/v3/plugins/che-incubator/che-code/latest/devfile.yaml
components:
- name: che-code-runtime-description
container:
env:
- name: CODE_HOST
value: 0.0.0.0

View File

@ -0,0 +1,12 @@
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: htpasswd
mappingMethod: claim
type: HTPasswd
htpasswd:
fileData:
name: htpass-secret

View File

@ -0,0 +1,15 @@
kind: Secret
apiVersion: v1
metadata:
name: gitlab-oauth-secret
namespace: eclipse-che
labels:
app.kubernetes.io/part-of: che.eclipse.org
app.kubernetes.io/component: oauth-scm-configuration
annotations:
che.eclipse.org/oauth-scm-server: gitlab
che.eclipse.org/scm-server-endpoint: git-provider-url
type: Opaque
data:
id: encoded-application-id
secret: encoded-application-secret

View File

@ -0,0 +1,15 @@
kind: Secret
apiVersion: v1
metadata:
name: personal-access-token
labels:
app.kubernetes.io/component: scm-personal-access-token
app.kubernetes.io/part-of: che.eclipse.org
annotations:
che.eclipse.org/che-userid: che-user-id
che.eclipse.org/scm-personal-access-token-name: git-provider-name
che.eclipse.org/scm-url: git-provider-url
che.eclipse.org/scm-organization: ''
data:
token: encoded-access-token
type: Opaque

View File

@ -0,0 +1,77 @@
apiVersion: v1
kind: Pod
metadata:
name: che-smoke-test
namespace: CHE-NAMESPACE
spec:
volumes:
- name: test-run-results
- name: ffmpeg-video
- name: dshm
emptyDir:
medium: Memory
containers:
# container containing the tests
- name: test
image: quay.io/eclipse/che-e2e:next
imagePullPolicy: Always
env:
- name: VIDEO_RECORDING
value: "true"
- name: TEST_SUITE
value: "test"
- name: TS_SELENIUM_EDITOR
value: "che-code"
- name: USERSTORY
value: "SmokeTest"
- name: NODE_TLS_REJECT_UNAUTHORIZED
value: "0"
- name: TS_SELENIUM_BASE_URL
value: "CHE_URL"
- name: TS_SELENIUM_LOG_LEVEL
value: "TRACE"
- name: TS_SELENIUM_OCP_USERNAME
value: "OCP_USER_NAME"
- name: TS_SELENIUM_OCP_PASSWORD
value: "OCP_USER_PASSWORD"
- name: TS_SELENIUM_VALUE_OPENSHIFT_OAUTH
value: "true"
- name: TS_OCP_LOGIN_PAGE_PROVIDER_TITLE
value: "htpasswd"
- name: DELETE_WORKSPACE_ON_FAILED_TEST
value: "true"
- name: TS_SELENIUM_START_WORKSPACE_TIMEOUT
value: "360000"
- name: TS_IDE_LOAD_TIMEOUT
value: "40000"
volumeMounts:
- name: test-run-results
mountPath: /tmp/e2e/report/
- name: ffmpeg-video
mountPath: /tmp/ffmpeg_report/
- name: dshm
mountPath: /dev/shm
resources:
requests:
memory: "3Gi"
cpu: "2"
limits:
memory: "4Gi"
cpu: "2"
# Download results
- name: download-reports
image: eeacms/rsync
imagePullPolicy: IfNotPresent
volumeMounts:
- name: test-run-results
mountPath: /tmp/e2e/report/
- name: ffmpeg-video
mountPath: /tmp/ffmpeg_report/
resources:
command: ["sh"]
args:
[
"-c",
"while true; if [[ -f /tmp/done ]]; then exit 0; fi; do sleep 1; done",
]
restartPolicy: Never

View File

@ -0,0 +1,89 @@
apiVersion: v1
kind: Pod
metadata:
name: oauth-factory-test
namespace: CHE-NAMESPACE
spec:
volumes:
- name: test-run-results
- name: ffmpeg-video
- name: dshm
emptyDir:
medium: Memory
containers:
# container containing the tests
- name: test
image: quay.io/eclipse/che-e2e:next
imagePullPolicy: Always
env:
- name: VIDEO_RECORDING
value: "true"
- name: TEST_SUITE
value: "test"
- name: TS_SELENIUM_EDITOR
value: "che-code"
- name: USERSTORY
value: "Factory"
- name: NODE_TLS_REJECT_UNAUTHORIZED
value: "0"
- name: TS_SELENIUM_BASE_URL
value: "CHE_URL"
- name: TS_SELENIUM_LOG_LEVEL
value: "TRACE"
- name: TS_SELENIUM_OCP_USERNAME
value: "OCP_USER_NAME"
- name: TS_SELENIUM_OCP_PASSWORD
value: "OCP_USER_PASSWORD"
- name: TS_SELENIUM_VALUE_OPENSHIFT_OAUTH
value: "true"
- name: TS_SELENIUM_FACTORY_GIT_REPO_URL
value: "FACTORY_REPO_URL"
- name: TS_SELENIUM_FACTORY_GIT_REPO_BRANCH
value: "GIT_BRANCH"
- name: TS_SELENIUM_FACTORY_GIT_PROVIDER
value: "GIT_PROVIDER_TYPE"
- name: TS_SELENIUM_GIT_PROVIDER_OAUTH
value: "true"
- name: TS_SELENIUM_GIT_PROVIDER_USERNAME
value: "GIT_PROVIDER_USER_NAME"
- name: TS_SELENIUM_GIT_PROVIDER_PASSWORD
value: "GIT_PROVIDER_USER_PASSWORD"
- name: TS_OCP_LOGIN_PAGE_PROVIDER_TITLE
value: "htpasswd"
- name: DELETE_WORKSPACE_ON_FAILED_TEST
value: "true"
- name: TS_SELENIUM_START_WORKSPACE_TIMEOUT
value: "360000"
- name: TS_IDE_LOAD_TIMEOUT
value: "40000"
volumeMounts:
- name: test-run-results
mountPath: /tmp/e2e/report/
- name: ffmpeg-video
mountPath: /tmp/ffmpeg_report/
- name: dshm
mountPath: /dev/shm
resources:
requests:
memory: "3Gi"
cpu: "2"
limits:
memory: "4Gi"
cpu: "2"
# Download results
- name: download-reports
image: eeacms/rsync
imagePullPolicy: IfNotPresent
volumeMounts:
- name: test-run-results
mountPath: /tmp/e2e/report/
- name: ffmpeg-video
mountPath: /tmp/ffmpeg_report/
resources:
command: ["sh"]
args:
[
"-c",
"while true; if [[ -f /tmp/done ]]; then exit 0; fi; do sleep 1; done",
]
restartPolicy: Never

View File

@ -0,0 +1,15 @@
apiVersion: v1
kind: Secret
metadata:
name: git-ssh-key
annotations:
controller.devfile.io/mount-as: subpath
controller.devfile.io/mount-path: /etc/ssh/
labels:
controller.devfile.io/mount-to-devworkspace: "true"
controller.devfile.io/watch-secret: "true"
type: Opaque
data:
dwo_ssh_key: ssh_private_key
dwo_ssh_key.pub: ssh_public_key
ssh_config: aG9zdCAqCiAgSWRlbnRpdHlGaWxlIC9ldGMvc3NoL2R3b19zc2hfa2V5CiAgU3RyaWN0SG9zdEtleUNoZWNraW5nID0gbm8K

View File

@ -0,0 +1,38 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_RAW_PATH_URL=${PUBLIC_REPO_RAW_PATH_URL:-"https://dev.azure.com/chepullreq1/che-pr-public/_apis/git/repositories/public-repo/items?path=/devfile.yaml"}
export PRIVATE_REPO_RAW_PATH_URL=${PRIVATE_REPO_URL:-"https://dev.azure.com/chepullreq1/che-pr-private/_apis/git/repositories/private-repo/items?path=/devfile.yaml"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
testFactoryResolverResponse ${PUBLIC_REPO_RAW_PATH_URL} 200
testFactoryResolverResponse ${PRIVATE_REPO_RAW_PATH_URL} 500
testCloneGitRepoNoProjectExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoNoProjectExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,40 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_SSH_URL=${PUBLIC_REPO_SSH_URL:-"git@ssh.dev.azure.com:v3/chepullreq1/che-pr-public/public-repo"}
export PRIVATE_REPO_SSH_URL=${PRIVATE_REPO_SSH_URL:-"git@ssh.dev.azure.com:v3/chepullreq1/che-pr-private/private-repo"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
setupSSHKeyPairs "${AZURE_PRIVATE_KEY}" "${AZURE_PUBLIC_KEY}"
testFactoryResolverResponse ${PUBLIC_REPO_SSH_URL} 200
testFactoryResolverResponse ${PRIVATE_REPO_SSH_URL} 500
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,35 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_URL=${PUBLIC_REPO_URL:-"https://chepullreq1@dev.azure.com/chepullreq1/che-pr-public/_git/public-repo"}
export PRIVATE_REPO_URL=${PRIVATE_REPO_URL:-"https://dev.azure.com/chepullreq1/che-pr-private/_git/private-repo"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
testFactoryResolverNoPatOAuth ${PUBLIC_REPO_URL} ${PRIVATE_REPO_URL}
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoNoProjectExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,59 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_URL=${PUBLIC_REPO_URL:-"https://chepullreq1@dev.azure.com/chepullreq1/che-pr-public/_git/public-repo"}
export PRIVATE_REPO_URL=${PRIVATE_REPO_URL:-"https://dev.azure.com/chepullreq1/che-pr-private/_git/private-repo"}
export GIT_PROVIDER_TYPE=${GIT_PROVIDER_TYPE:-"azure-devops"}
export GIT_PROVIDER_URL=${GIT_PROVIDER_URL:-"https://dev.azure.com"}
export PRIVATE_REPO_SSH_URL=${PRIVATE_REPO_SSH_URL:-"git@ssh.dev.azure.com:v3/chepullreq1/che-pr-private/private-repo"}
export PRIVATE_REPO_RAW_PATH_URL=${PRIVATE_REPO_URL:-"https://dev.azure.com/chepullreq1/che-pr-private/_apis/git/repositories/private-repo/items?path=/devfile.yaml"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
setupPersonalAccessToken ${GIT_PROVIDER_TYPE} ${GIT_PROVIDER_URL} ${AZURE_PAT}
requestProvisionNamespace
testFactoryResolverWithPatOAuth ${PUBLIC_REPO_URL} ${PRIVATE_REPO_URL}
echo "------- [INFO] Check clone public repository with PAT setup -------"
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_URL} ${USER_CHE_NAMESPACE}
testGitCredentialsData ${USER_CHE_NAMESPACE} ${AZURE_PAT} ${GIT_PROVIDER_URL}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
echo "------- [INFO] Check clone private repository with PAT setup -------"
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_URL} ${USER_CHE_NAMESPACE}
testGitCredentialsData ${USER_CHE_NAMESPACE} ${AZURE_PAT} ${GIT_PROVIDER_URL}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
echo "------- [INFO] Check clone private repository by raw devfile URL with PAT setup -------"
testFactoryResolverResponse ${PRIVATE_REPO_RAW_PATH_URL} 200
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
setupSSHKeyPairs "${AZURE_PRIVATE_KEY}" "${AZURE_PUBLIC_KEY}"
echo "------- [INFO] Check clone private repository by SSH URL with PAT setup -------"
testFactoryResolverResponse ${PRIVATE_REPO_SSH_URL} 200
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,37 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_RAW_PATH_URL=${PUBLIC_REPO_RAW_PATH_URL:-"https://bitbucket.org/chepullreq/public-repo/raw/746000bd63a54eaf8ea8aba9dfe6620e5c6c61d7/devfile.yaml"}
export PRIVATE_REPO_RAW_PATH_URL=${PRIVATE_REPO_URL:-"https://bitbucket.org/chepullreq/private-repo/raw/80b183d27c6c533462128b0c092208aad73b2906/devfile.yaml"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
testFactoryResolverNoPatOAuthRaw ${PUBLIC_REPO_RAW_PATH_URL} ${PRIVATE_REPO_RAW_PATH_URL}
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoNoProjectExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,38 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_SSH_URL=${PUBLIC_REPO_SSH_URL:-"git@bitbucket.org:chepullreq/public-repo.git"}
export PRIVATE_REPO_SSH_URL=${PRIVATE_REPO_SSH_URL:-"git@bitbucket.org:chepullreq/private-repo.git"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
setupSSHKeyPairs "${BITBUCKET_PRIVATE_KEY}" "${BITBUCKET_PUBLIC_KEY}"
testFactoryResolverNoPatOAuth ${PUBLIC_REPO_SSH_URL} ${PRIVATE_REPO_SSH_URL}
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,35 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_URL=${PUBLIC_REPO_URL:-"https://chepullreq1@bitbucket.org/chepullreq/public-repo.git"}
export PRIVATE_REPO_URL=${PRIVATE_REPO_URL:-"https://chepullreq1@bitbucket.org/chepullreq/private-repo.git"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
testFactoryResolverNoPatOAuth ${PUBLIC_REPO_URL} ${PRIVATE_REPO_URL}
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoNoProjectExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,32 @@
#!/bin/bash
#
# Copyright (c) 2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export TEST_POD_NAME=${TEST_POD_NAME:-"che-smoke-test"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "collectLogs" EXIT SIGINT
provisionOpenShiftOAuthUser
createCustomResourcesFile
deployChe
startSmokeTest

View File

@ -0,0 +1,45 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_SSH_URL=${PUBLIC_REPO_SSH_URL:-"git@gitea.com:chepullreq1/public-repo.git"}
export PRIVATE_REPO_SSH_URL=${PRIVATE_REPO_SSH_URL:-"git@gitea.com:chepullreq1/private-repo.git"}
export PUBLIC_REPO_RAW_PATH_URL=${PUBLIC_REPO_RAW_PATH_URL:-"https://gitea.com/chepullreq1/public-repo/raw/branch/main/devfile.yaml"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
setupSSHKeyPairs "${GITEA_PRIVATE_KEY}" "${GITEA_PUBLIC_KEY}"
testFactoryResolverResponse ${PUBLIC_REPO_SSH_URL} 200
testFactoryResolverResponse ${PRIVATE_REPO_SSH_URL} 200
testFactoryResolverResponse ${PUBLIC_REPO_RAW_PATH_URL} 200
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoNoProjectExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,33 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PRIVATE_REPO_RAW_PATH_URL=${PRIVATE_REPO_RAW_PATH_URL:-"https://${GITEA_PAT}@gitea.com/chepullreq1/private-repo/raw/branch/main/devfile.yaml"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
testFactoryResolverResponse ${PRIVATE_REPO_RAW_PATH_URL} 200
testCloneGitRepoNoProjectExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,38 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_RAW_PATH_URL=${PUBLIC_REPO_RAW_PATH_URL:-"https://raw.githubusercontent.com/chepullreq1/public-repo/main/devfile.yaml"}
export PRIVATE_REPO_RAW_PATH_URL=${PRIVATE_REPO_URL:-"https://raw.githubusercontent.com/chepullreq1/private-repo/main/devfile.yaml"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
testFactoryResolverNoPatOAuthRaw ${PUBLIC_REPO_RAW_PATH_URL} ${PRIVATE_REPO_RAW_PATH_URL}
testCloneGitRepoNoProjectExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoNoProjectExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,38 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_SSH_URL=${PUBLIC_REPO_SSH_URL:-"git@github.com:chepullreq1/public-repo.git"}
export PRIVATE_REPO_SSH_URL=${PRIVATE_REPO_SSH_URL:-"git@github.com:chepullreq1/private-repo.git"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
setupSSHKeyPairs "${GITHUB_PRIVATE_KEY}" "${GITHUB_PUBLIC_KEY}"
testFactoryResolverNoPatOAuth ${PUBLIC_REPO_SSH_URL} ${PRIVATE_REPO_SSH_URL}
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,35 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_URL=${PUBLIC_REPO_URL:-"https://github.com/chepullreq1/public-repo.git"}
export PRIVATE_REPO_URL=${PRIVATE_REPO_URL:-"https://github.com/chepullreq1/private-repo.git"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
testFactoryResolverNoPatOAuth ${PUBLIC_REPO_URL} ${PRIVATE_REPO_URL}
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoNoProjectExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,59 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_URL=${PUBLIC_REPO_URL:-"https://github.com/chepullreq1/public-repo.git"}
export PRIVATE_REPO_URL=${PRIVATE_REPO_URL:-"https://github.com/chepullreq1/private-repo.git"}
export GIT_PROVIDER_TYPE=${GIT_PROVIDER_TYPE:-"github"}
export GIT_PROVIDER_URL=${GIT_PROVIDER_URL:-"https://github.com"}
export PRIVATE_REPO_RAW_PATH_URL=${PRIVATE_REPO_URL:-"https://raw.githubusercontent.com/chepullreq1/private-repo/main/devfile.yaml"}
export PRIVATE_REPO_SSH_URL=${PRIVATE_REPO_SSH_URL:-"git@github.com:chepullreq1/private-repo.git"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
setupPersonalAccessToken ${GIT_PROVIDER_TYPE} ${GIT_PROVIDER_URL} ${GITHUB_PAT}
requestProvisionNamespace
testFactoryResolverWithPatOAuth ${PUBLIC_REPO_URL} ${PRIVATE_REPO_URL}
echo "------- [INFO] Check clone public repository with PAT setup -------"
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_URL} ${USER_CHE_NAMESPACE}
testGitCredentialsData ${USER_CHE_NAMESPACE} ${GITHUB_PAT} ${GIT_PROVIDER_URL}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
echo "------- [INFO] Check clone private repository with PAT setup -------"
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_URL} ${USER_CHE_NAMESPACE}
testGitCredentialsData ${USER_CHE_NAMESPACE} ${GITHUB_PAT} ${GIT_PROVIDER_URL}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
echo "------- [INFO] Check clone private repository by raw devfile URL with PAT setup -------"
testFactoryResolverResponse ${PRIVATE_REPO_RAW_PATH_URL} 200
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
setupSSHKeyPairs "${GITHUB_PRIVATE_KEY}" "${GITHUB_PUBLIC_KEY}"
echo "------- [INFO] Check clone private repository by SSH URL with PAT setup -------"
testFactoryResolverResponse ${PRIVATE_REPO_SSH_URL} 200
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,37 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_RAW_PATH_URL=${PUBLIC_REPO_RAW_PATH_URL:-"https://gitlab.com/chepullreq1/public-repo/-/raw/main/devfile.yaml"}
export PRIVATE_REPO_RAW_PATH_URL=${PRIVATE_REPO_URL:-"https://gitlab.com/chepullreq1/private-repo/-/raw/main/devfile.yaml"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
testFactoryResolverNoPatOAuthRaw ${PUBLIC_REPO_RAW_PATH_URL} ${PRIVATE_REPO_RAW_PATH_URL}
testCloneGitRepoNoProjectExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoNoProjectExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,39 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_SSH_URL=${PUBLIC_REPO_SSH_URL:-"git@gitlab.com:chepullreq1/public-repo.git"}
export PRIVATE_REPO_SSH_URL=${PRIVATE_REPO_SSH_URL:-"git@gitlab.com:chepullreq1/private-repo.git"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
setupSSHKeyPairs "${GITLAB_PRIVATE_KEY}" "${GITLAB_PUBLIC_KEY}"
testFactoryResolverNoPatOAuth ${PUBLIC_REPO_SSH_URL} ${PRIVATE_REPO_SSH_URL}
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,35 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_URL=${PUBLIC_REPO_URL:-"https://gitlab.com/chepullreq1/public-repo.git"}
export PRIVATE_REPO_URL=${PRIVATE_REPO_URL:-"https://gitlab.com/chepullreq1/private-repo.git"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
testFactoryResolverNoPatOAuth ${PUBLIC_REPO_URL} ${PRIVATE_REPO_URL}
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
testCloneGitRepoNoProjectExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -0,0 +1,39 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export TEST_POD_NAME=${TEST_POD_NAME:-"oauth-factory-test"}
export GIT_PROVIDER_TYPE=${GIT_PROVIDER_TYPE:-"gitlab"}
export GIT_PROVIDER_URL=${GIT_PROVIDER_URL:-"https://gitlab-gitlab-system.apps.git.crw-qe.com"}
export GIT_PROVIDER_LOGIN=${GIT_PROVIDER_LOGIN:-"admin-user"}
export PRIVATE_REPO_URL=${PRIVATE_REPO_URL:-"https://gitlab-gitlab-system.apps.git.crw-qe.com/admin-user/private-repo.git"}
export GIT_REPO_BRANCH=${PRIVATE_REPO_BRANCH:-"main"}
export APPLICATION_NAME=${APPLICATION_NAME:-"TestApp"}
export OAUTH_ID=""
export APPLICATION_ID=""
export APPLICATION_SECRET=""
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "collectLogs" EXIT SIGINT
setupTestEnvironmentOAuthFlow ${ADMIN_ACCESS_TOKEN} ${APPLICATION_NAME} ${APPLICATION_ID} ${APPLICATION_SECRET}
startOAuthFactoryTest

View File

@ -0,0 +1,59 @@
#!/bin/bash
#
# Copyright (c) 2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# exit immediately when a command fails
set -ex
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
echo "======= [INFO] OpenShift CI infrastructure is ready. Running test. ======="
export PUBLIC_REPO_URL=${PUBLIC_REPO_URL:-"https://gitlab.com/chepullreq1/public-repo.git"}
export PRIVATE_REPO_URL=${PRIVATE_REPO_URL:-"https://gitlab.com/chepullreq1/private-repo.git"}
export GIT_PROVIDER_TYPE=${GIT_PROVIDER_TYPE:-"gitlab"}
export GIT_PROVIDER_URL=${GIT_PROVIDER_URL:-"https://gitlab.com"}
export PRIVATE_REPO_SSH_URL=${PRIVATE_REPO_SSH_URL:-"git@gitlab.com:chepullreq1/private-repo.git"}
export PRIVATE_REPO_RAW_PATH_URL=${PRIVATE_REPO_URL:-"https://gitlab.com/chepullreq1/private-repo/-/raw/main/devfile.yaml"}
# import common test functions
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}"/common.sh
trap "catchFinish" EXIT SIGINT
setupTestEnvironment ${OCP_NON_ADMIN_USER_NAME}
setupPersonalAccessToken ${GIT_PROVIDER_TYPE} ${GIT_PROVIDER_URL} ${GITLAB_PAT}
requestProvisionNamespace
testFactoryResolverWithPatOAuth ${PUBLIC_REPO_URL} ${PRIVATE_REPO_URL}
echo "------- [INFO] Check clone public repository with PAT setup -------"
testCloneGitRepoProjectShouldExists ${PUBLIC_REPO_WORKSPACE_NAME} ${PUBLIC_PROJECT_NAME} ${PUBLIC_REPO_URL} ${USER_CHE_NAMESPACE}
testGitCredentialsData ${USER_CHE_NAMESPACE} ${GITLAB_PAT} ${GIT_PROVIDER_URL}
deleteTestWorkspace ${PUBLIC_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
echo "------- [INFO] Check clone private repository with PAT setup -------"
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_URL} ${USER_CHE_NAMESPACE}
testGitCredentialsData ${USER_CHE_NAMESPACE} ${GITLAB_PAT} ${GIT_PROVIDER_URL}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
echo "------- [INFO] Check clone private repository by raw devfile URL with PAT setup -------"
testFactoryResolverResponse ${PRIVATE_REPO_RAW_PATH_URL} 200
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_RAW_PATH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}
setupSSHKeyPairs "${GITLAB_PRIVATE_KEY}" "${GITLAB_PUBLIC_KEY}"
echo "------- [INFO] Check clone private repository by SSH URL with PAT setup -------"
testFactoryResolverResponse ${PRIVATE_REPO_SSH_URL} 200
testCloneGitRepoProjectShouldExists ${PRIVATE_REPO_WORKSPACE_NAME} ${PRIVATE_PROJECT_NAME} ${PRIVATE_REPO_SSH_URL} ${USER_CHE_NAMESPACE}
deleteTestWorkspace ${PRIVATE_REPO_WORKSPACE_NAME} ${USER_CHE_NAMESPACE}

View File

@ -1,20 +0,0 @@
#!/bin/bash
# Copyright (c) 2017-2021 Red Hat, Inc.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
sed_in_place() {
SHORT_UNAME=$(uname -s)
if [ "$(uname)" == "Darwin" ]; then
sed -i '' "$@"
elif [ "${SHORT_UNAME:0:5}" == "Linux" ]; then
sed -i "$@"
fi
}
# only use /latest plugins so updates are smoother (old plugins are deleted from registries with each new release)
plugin_version="latest"
sed_in_place -r -e "s#che.factory.default_editor=eclipse/che-theia/.*#che.factory.default_editor=eclipse/che-theia/$plugin_version#g" ../assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties
sed_in_place -r -e "s#che.workspace.devfile.default_editor=eclipse/che-theia/.*#che.workspace.devfile.default_editor=eclipse/che-theia/$plugin_version#g" ../assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties

41
.github/CODEOWNERS vendored
View File

@ -1,41 +1,8 @@
# Global Owners
* @nickboldt @sparkoo
* @SDawley @ibuziuk @vinokurig @tolusha
# dockerfiles
dockerfiles/** @nickboldt
# assembly
assembly/** @skabashnyuk @nickboldt
assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/** @ibuziuk @nickboldt @themr0c @boczkowska @MichalMaler
# core
core/** @skabashnyuk @nickboldt
# workspace runtime infrastructure implementations
infrastructures/** @skabashnyuk @amisevsk @metlos @nickboldt
# multiuser che
multiuser/api/** @skabashnyuk @nickboldt
multiuser/integration-tests/** @mshaposhnik @skabashnyuk @nickboldt
multiuser/keycloak/** @mshaposhnik @nickboldt
multiuser/machine-auth/** @mshaposhnik @nickboldt
multiuser/permission/** @skabashnyuk @nickboldt
multiuser/personal-account/** @skabashnyuk @nickboldt
multiuser/sql-schema/** @mshaposhnik @nickboldt
# wsmaster
wsmaster/** @skabashnyuk @nickboldt
wsmaster/che-core-api-factory/** @mshaposhnik @nickboldt
wsmaster/che-core-api-factory-shared/** @mshaposhnik @nickboldt
wsmaster/che-core-api-workspace-activity/** @mshaposhnik @nickboldt
wsmaster/che-core-api-workspace/** @skabashnyuk @mshaposhnik @metlos @nickboldt
# che.properties file is quasi-documentation, so in future we might grant access to this
# assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/** @osslate
# deploy
deploy/** @tolusha @nickboldt
deploy/openshift/templates/monitoring/** @skabashnyuk @metlos @nickboldt
# e2e tests
tests/e2e/** @musienko-maxim @Ohrimenko1988 @rhopp @nickboldt @Katka92 @ScrewTSW
# e2e tests infra
tests/.infra/centos-ci/** @musienko-maxim @rhopp @nickboldt
deploy/** @tolusha @dkwon17

View File

@ -11,20 +11,43 @@ name: build-pr-check
on: [push, pull_request]
env:
PR_IMAGE_TAG: pr-${{ github.event.pull_request.number }}
jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check all properties have description
run: ./check_properties_description.sh
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11.0.14'
java-version: '11'
cache: 'maven'
- name: Login to docker.io
if: github.event_name == 'pull_request'
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
registry: docker.io
- name: Login to quay.io
if: github.event_name == 'pull_request'
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io
- name: Build with Maven
run: mvn -B clean install -U -Pintegration
- name: Build images
if: github.event_name == 'pull_request'
run: ./build/build.sh --tag:${{ env.PR_IMAGE_TAG }}
- name: Push images
if: github.event_name == 'pull_request'
run: podman push quay.io/eclipse/che-server:${{ env.PR_IMAGE_TAG }}

View File

@ -21,7 +21,7 @@ on:
jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Execute workflow in Che Docs
id: build

View File

@ -17,50 +17,40 @@ on:
jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11.0.14'
java-version: '11'
cache: 'maven'
- name: Login to docker.io
uses: docker/login-action@v1
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
registry: docker.io
- name: Login to quay.io
uses: docker/login-action@v1
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io
- name: Build with Maven
run: mvn -B clean install -U -Pintegration
- name: Build docker images
- name: Build images
id: build
run: |
SHORT_SHA1=$(git rev-parse --short HEAD)
echo ::set-output name=short_sha1::${SHORT_SHA1}
./dockerfiles/build.sh --tag:next --sha-tag
echo "short_sha1=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
./build/build.sh --tag:next --sha-tag
- name: Push docker images
run: |
docker push quay.io/eclipse/che-endpoint-watcher:next
docker push quay.io/eclipse/che-endpoint-watcher:${{ steps.build.outputs.short_sha1 }}
docker push quay.io/eclipse/che-keycloak:next
docker push quay.io/eclipse/che-keycloak:${{ steps.build.outputs.short_sha1 }}
docker push quay.io/eclipse/che-postgres:next
docker push quay.io/eclipse/che-postgres:${{ steps.build.outputs.short_sha1 }}
docker push quay.io/eclipse/che-server:next
docker push quay.io/eclipse/che-server:${{ steps.build.outputs.short_sha1 }}
podman push quay.io/eclipse/che-server:next
podman push quay.io/eclipse/che-server:${{ steps.build.outputs.short_sha1 }}
- name: Create failure MM message
if: ${{ failure() }}
run: |

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2020 Red Hat, Inc.
# Copyright (c) 2020-2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
@ -43,13 +43,13 @@ on:
jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
path: che-server
fetch-depth: 0
- uses: actions/checkout@v2
- uses: actions/checkout@v3
if: ${{ github.event.inputs.releaseParent == 'true' }}
with:
repository: eclipse/che-parent
@ -63,36 +63,35 @@ jobs:
exit 1
fi
- name: Login to docker.io
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
registry: docker.io
- name: Login to quay.io
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io
- name: Set up Python 3.6
uses: actions/setup-python@v2
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.6
python-version: 3.9
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11.0.14'
java-version: '11'
cache: 'maven'
- name: Set up environment
run: |
sudo apt-get update -y || true
# install more dependencies
sudo apt-get -y -q install wget curl bash git
sudo apt-get -y -q install wget curl bash git
java -version
# want git >=2.24, hub >=2
hub --version # hub reports git version too
git --version
gh --version
# want >=5
bash --version
@ -132,7 +131,7 @@ jobs:
./che-server/make-release.sh
- name: Create GH Release
id: create_release
uses: ncipollo/release-action@v1.8.0
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.CHE_BOT_GITHUB_TOKEN }}
with:
@ -145,17 +144,17 @@ jobs:
prerelease: false
tag: ${{ github.event.inputs.version }}
token: ${{ secrets.CHE_BOT_GITHUB_TOKEN }}
- name: Create failure MM message
if: ${{ failure() }}
run: |
echo "{\"text\":\":no_entry_sign: Che Server ${{ github.event.inputs.version }} release has failed: https://github.com/eclipse-che/che-server/actions/workflows/release.yml\"}" > mattermost.json
- name: Create success MM message
run: |
echo "{\"text\":\":white_check_mark: Che Server ${{ github.event.inputs.version }} has been released: https://quay.io/eclipse/che-server:${{ github.event.inputs.version }}\"}" > mattermost.json
- name: Send MM message
if: ${{ success() }} || ${{ failure() }}
uses: mattermost/action-mattermost-notify@1.1.0
env:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
MATTERMOST_CHANNEL: eclipse-che-releases
MATTERMOST_USERNAME: che-bot
#- name: Create failure MM message
#if: ${{ failure() }}
#run: |
#echo "{\"text\":\":no_entry_sign: Che Server ${{ github.event.inputs.version }} release has failed: https://github.com/eclipse-che/che-server/actions/workflows/release.yml\"}" > mattermost.json
#- name: Create success MM message
#run: |
#echo "{\"text\":\":white_check_mark: Che Server ${{ github.event.inputs.version }} has been released: https://quay.io/eclipse/che-server:${{ github.event.inputs.version }}\"}" > mattermost.json
#- name: Send MM message
#if: ${{ success() }} || ${{ failure() }}
#uses: mattermost/action-mattermost-notify@1.1.0
#env:
#MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
#MATTERMOST_CHANNEL: eclipse-che-releases
#MATTERMOST_USERNAME: che-bot

View File

@ -6,19 +6,19 @@ on:
jobs:
build:
name: Sonar
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11.0.14'
java-version: '11'
cache: 'maven'
- name: Cache SonarCloud packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar

View File

@ -7,7 +7,7 @@ on:
jobs:
add-link:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Web IDE Pull Request Check
uses: redhat-actions/try-in-web-ide@v1

8
.gitignore vendored
View File

@ -1,3 +1,5 @@
.repository/
# Eclipse #
###################
@ -11,10 +13,6 @@ test-output/
maven-eclipse.xml
.factorypath
# Theia #
##################
.theia/
# Idea #
##################
*.iml
@ -48,8 +46,6 @@ maven-eclipse.xml
*.war
*.ear
# Logs and databases #
######################
*.log

9
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,9 @@
{
"recommendations": [
"redhat.java",
"redhat.fabric8-analytics",
"vscjava.vscode-maven",
"vscjava.vscode-java-debug",
"vscjava.vscode-java-test"
]
}

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx6G -Xms100m -Xlog:disable"
}

82
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,82 @@
## Developing with Eclipse Che
This project contains a [devfile v2](https://github.com/eclipse-che/che-server/blob/main/devfile.yaml) located in the project's root directory.
With this devfile you can perform the following tasks:
- Build project sources with maven.
- Build a container image.
- Push your changes to GitHub.
### Starting a Workspace within Eclipse Che
To start a new workspace within Eclipse Che, navigate to the following URL:
```sh
{CHE-HOST}/#https://github.com/eclipse-che/che-server
```
### Running Devfile Tasks for Downloading Dependencies and Building the Project
For VS Code, execute tasks defined in the devfile with these steps:
1. Open the command palette (Ctrl/Cmd + Shift + P).
2. Execute the `Tasks: Run Task` command.
3. Select the `devfile` folder and select the `1. Build sources` task to build the project sources with maven.
4. Follow steps 1 and 2 again, select the `1. Build image` task to build a container image.
5. In the workspace terminal, tag the **che-server** image with your account: `podman tag quay.io/eclipse/che-server:next <docker registry>/<your account>/che-server:next`.
6. Push the **che-server** image to your account: `podman push <docker registry>/<your account>/che-server:next`.
# Local build requirements
- Apache Maven 3.9 or later
- JDK 11
- Podman or Docker (required for running integration tests)
A Che workspace environment allows to build the image internally, using the workspace terminal.
# Start and debug
1. Deploy Che to a [Red Hat OpenShift](https://www.eclipse.org/che/docs/stable/administration-guide/installing-che-on-openshift-using-cli/) or [Minikube](https://www.eclipse.org/che/docs/stable/administration-guide/installing-che-on-minikube/) cluster by using a previously built image: `chectl server:start --platform=<openshift / minikube> --cheimage=<docker registry>/<your account>/che-server:next`.
2. Enable local debugging of the Eclipse Che server: `chectl server:debug`.
3. In your IDE, create a new Remote JVM Debug configuration on `localhost:8000`.
4. Hit a breakpoint in the code and activate the debug configuration.
# Contributing an SCM provider
An SCM provider support has to be provided by adding new maven modules to the wsmaster directory.
## Implementing che-core-api-oauth-<SCM provider name> module
This module is responsible for Oauth requests to the SCM provider and contans next implementations:
1. `<SCM provider name>OAuthAuthenticator` contains specific implementation of Oauth token requestand authentication endpoint.
2. `<SCM provider name>OAuthAuthenticatorProvider` a provider of the `OAuthAuthenticator`.
## Implementing coresponding che-core-api-factory-<SCM provider name> module
This module is responsible for API operations of the specific SCM provider.
1. `<SCM provider name>ApiClient` contains all necessary HTTP API calls like `getUser()`.
2. `<SCM provider name>AuthorisingFileContentProvider` overrides the common `AuthorisingFileContentProvider` to define the specific `isPublicRepository()` function.
3. `<SCM provider name>FactoryParameterResolver` validates SCM URL if it corresponds to the SCM provider. Also Provides specific Factory Parameters resolver for the SCM repository.
4. `<SCM provider name>PersonalAccessTokenFetcher` fetches Personal Access Token from the SCM provider by reqesting the OAuth API of the provider. Validates the token by comparing the token access scopes with the predefined scope list.
5. `<SCM provider name>FileResolver` Implementation of a resolver that can return particular file content from specified SCM repository.
6. `<SCM provider name>URLParser` Parses the string representation of the URL to an SCM specific object
7. `<SCM provider name>UserDataFetcher` Implementation of a resolver that can return particular file content from specified SCM repository.
# CI
There are several [GitHub Actions](https://github.com/eclipse-che/che-server/actions) workflows implemented for this repository:
- [![build-next](https://github.com/eclipse-che/che-server/actions/workflows/next-build.yml/badge.svg)](https://github.com/eclipse-che/che-server/actions/workflows/next-build.yml)
Builds Maven artifacts, builds container images and pushes them to [quay.io](https://quay.io/organization/eclipse) on each commit to [`main`](https://github.com/eclipse-che/che-server/tree/main) branch.
- [![Release Che Server](https://github.com/eclipse-che/che-server/actions/workflows/release.yml/badge.svg)](https://github.com/eclipse-che/che-server/actions/workflows/release.yml)
Builds Maven artifacts and container images. Images are public and pushed to [quay.io](https://quay.io/organization/eclipse). See [RELEASE.md](https://github.com/eclipse-che/che-server/blob/master/RELEASE.md) for more information about this workflow.
- [![Release Changelog](https://github.com/eclipse-che/che-server/actions/workflows/release-changelog.yml/badge.svg)](https://github.com/eclipse-che/che-server/actions/workflows/release-changelog.yml)
Creates a GitHub release which will include a generated changelog.
- [![Update Che docs variables](https://github.com/eclipse-che/che-server/actions/workflows/che-properties-docs-update.yml/badge.svg)](https://github.com/eclipse-che/che-server/actions/workflows/che-properties-docs-update.yml/badge.svg)
Runs on each commit to [`main`](https://github.com/eclipse-che/che-server/tree/main) branch.
- [![build-pr-check](https://github.com/eclipse-che/che-server/actions/workflows/build-pr-check.yml/badge.svg)](https://github.com/eclipse-che/che-server/actions/workflows/build-pr-check.yml)
Builds Maven artifacts and container images. This workflow is used as a check for all pull requests that are submitted to this project.
- [![Sonar](https://github.com/eclipse-che/che-server/actions/workflows/sonar.yaml/badge.svg)](https://github.com/eclipse-che/che-server/actions/workflows/sonar.yaml)
Runs Sonar against the main branch. The result can be seen [here](https://sonarcloud.io/dashboard?id=org.eclipse.che%3Ache-server).
- [![Try in Web IDE](https://github.com/eclipse-che/che-server/actions/workflows/try-in-web-ide.yaml/badge.svg)](https://github.com/eclipse-che/che-server/actions/workflows/try-in-web-ide.yaml)
Used as a check for pull requests that are submitted to this project.
Downstream builds can be found at the link below, which is _internal to Red Hat_. Stable builds can be found by replacing the 3.x with a specific version like 3.2.
- [server_3.x](https://main-jenkins-csb-crwqe.apps.ocp-c1.prod.psi.redhat.com/job/DS_CI/job/server_3.x/)
# Report issues
Issues are tracked on the main Eclipse Che Repository: https://github.com/eclipse/che/issues

View File

@ -1,39 +1,29 @@
[![Next build Status](https://github.com/eclipse-che/che-theia/actions/workflows/next-build.yml/badge.svg)]
[![Release build Status](https://github.com/eclipse-che/che-theia/actions/workflows/release.yml/badge.svg)]
# What is Che server
Che Server is a core component of the [Eclipse Che](https://github.com/eclipse/che/). This component is responsible for creation and managing of Che workspaces, but will some day be replaced by the [Dev Workspace Operator](https://github.com/devfile/devworkspace-operator).
Che Server provides an API for managing Kubernetes namespaces and to retrieve devfile content from repositories,
hosted on GitHub, GitLab, Bitbucket and Microsoft Azure Repos.
# Project structure
Che Server is mostly a Java web application deployed on a Apache Tomcat server in a container.
- ['pom.xml'](https://github.com/eclipse-che/che-server/tree/main/pom.xml) The root Maven module, that lists all dependencies and structure.
- ['assembly'](https://github.com/eclipse-che/che-server/tree/main/assembly) - module for final assemblies of Che web applications
- ['dockerfiles'](https://github.com/eclipse-che/che-server/tree/main/dockerfiles) - directory contains image Dockerfile for Che Server, as well as additional images.
- ['core'](https://github.com/eclipse-che/che-server/tree/main/core) - core and utility modules for Che.
- ['wsmaster'](https://github.com/eclipse-che/che-server/tree/main/wsmaster) - primary modules of the Che Server API.
- ['multiuser'](https://github.com/eclipse-che/che-server/tree/main/multiuser) - modules related to multiuser implementation of Che.
- ['infrastructure'](https://github.com/eclipse-che/che-server/tree/main/infrastructure) - implementations for the underlying infrastructure, on which Che is running (Kubernetes, Openshift, etc.)
- ['deploy'](https://github.com/eclipse-che/che-server/tree/main/deploy) - deployment files for Helm installation.
- ['typescript-dto'](https://github.com/eclipse-che/che-server/tree/main/typescript-dto) module, that provides DTO objects for typescript projects that may depend on Che Server, such as Che Theia.
Che Server is mostly a Java web application deployed on an Apache Tomcat server in a container. Che Server uses the following modules:
### OAuth1 / OAuth2 API implementations
- wsmaster/che-core-api-auth
- wsmaster/che-core-api-azure-devops
- wsmaster/che-core-api-bitbucket
- wsmaster/che-core-api-github
- wsmaster/che-core-api-gitlab
### Factory flow implementations
- wsmaster/che-core-api-factory-azure-devops
- wsmaster/che-core-api-factory-bitbucket
- wsmaster/che-core-api-factory-bitbucket-server
- wsmaster/che-core-api-factory-github
- wsmaster/che-core-api-factory-gitlab
- wsmaster/che-core-api-factory-shared
### Kubernetes namespace provisioning
- infrastructures/kubernetes
- infrastructure/openshift
- infrastructures/infrastructure-factory
# Build requirements
- Apache Maven 3.6.3 or Higher
- JDK Version 11
- Podman or Docker (required for running integration tests)
Other modules are deprecated and will be removed in the future.
# Build and debug
Run `mvn clean install` to build
Activate a faster profile build by adding `-Pfast`
To debug, run `mvn clean install -X` and connect your IDE to the debug port
# CI
There are several [GitHub Actions](https://github.com/eclipse-che/che-server/actions) workflows implemented for this repository:
- [`next`](https://github.com/eclipse-che/che-server/actions/workflows/next-build.yml) - builds Maven artifacts, builds container images and pushes them to [quay.io](https://quay.io/organization/eclipse) on each commit to [`main`](https://github.com/eclipse-che/che-server/tree/main) branch.
- [`release`](https://github.com/eclipse-che/che-server/actions/workflows/release.yml) - builds Maven artifacts and container images. Images are public and pushed to [quay.io](https://quay.io/organization/eclipse). See [RELEASE.md](https://github.com/eclipse-che/che-server/blob/master/RELEASE.md) for more information about this workflow.
- [`release-changelog`](https://github.com/eclipse-che/che-server/actions/workflows/release-changelog.yml) - create GitHub release and generate, which will include a generated changelog
- [`build-pr-check`](https://github.com/eclipse-che/che-server/actions/workflows/build-pr-check.yml) - builds Maven artifacts and container images. This workflow is used as a pull request check for all pull requests, that are submitted to this project
- [`sonar`](https://github.com/eclipse-che/che-server/actions/workflows/sonar.yml) - This check runs Sonar against the main branch. The result can be seen here https://sonarcloud.io/dashboard?id=org.eclipse.che%3Ache-server
# License
- [Eclipse Public License 2.0](LICENSE)
@ -41,8 +31,8 @@ There are several [GitHub Actions](https://github.com/eclipse-che/che-server/act
# Join the community
The Eclipse Che community is globally reachable through public chat rooms, mailing list and weekly calls.
See https://www.eclipse.org/che/docs/che-7/overview/introduction-to-eclipse-che/#_joining_the_community
See the Eclipse Che Documentation about [how you can join our community](https://www.eclipse.org/che/docs/stable/overview/introduction-to-eclipse-che/#_joining_the_community).
## Report issues
## Builds
Issues are tracked on the main Eclipse Che Repository: https://github.com/eclipse/che/issues
* [![release latest stable](https://github.com/eclipse-che/che-server/actions/workflows/release.yml/badge.svg)](https://github.com/eclipse-che/che-server/actions/workflows/release.yml)

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
Copyright (c) 2012-2024 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
@ -17,7 +17,7 @@
<parent>
<artifactId>che-assembly-parent</artifactId>
<groupId>org.eclipse.che</groupId>
<version>7.54.0-SNAPSHOT</version>
<version>7.86.0-SNAPSHOT</version>
</parent>
<artifactId>assembly-che-tomcat</artifactId>
<packaging>jar</packaging>

View File

@ -69,6 +69,7 @@
<Connector port="${port.http:-8080}" protocol="HTTP/1.1"
connectionTimeout="20000"
maxThreads="300"
maxHttpHeaderSize="32768"
compression="on"
compressionMinSize="2048"
noCompressionUserAgents=".*MSIE 6.*"

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
Copyright (c) 2012-2024 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
@ -17,7 +17,7 @@
<parent>
<artifactId>che-assembly-parent</artifactId>
<groupId>org.eclipse.che</groupId>
<version>7.54.0-SNAPSHOT</version>
<version>7.86.0-SNAPSHOT</version>
</parent>
<artifactId>assembly-main</artifactId>
<packaging>pom</packaging>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
Copyright (c) 2012-2024 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
@ -17,7 +17,7 @@
<parent>
<artifactId>che-assembly-parent</artifactId>
<groupId>org.eclipse.che</groupId>
<version>7.54.0-SNAPSHOT</version>
<version>7.86.0-SNAPSHOT</version>
</parent>
<artifactId>assembly-root-war</artifactId>
<packaging>war</packaging>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
Copyright (c) 2012-2024 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
@ -17,7 +17,7 @@
<parent>
<artifactId>che-assembly-parent</artifactId>
<groupId>org.eclipse.che</groupId>
<version>7.54.0-SNAPSHOT</version>
<version>7.86.0-SNAPSHOT</version>
</parent>
<artifactId>assembly-swagger-war</artifactId>
<packaging>war</packaging>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
Copyright (c) 2012-2024 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
@ -17,7 +17,7 @@
<parent>
<artifactId>che-assembly-parent</artifactId>
<groupId>org.eclipse.che</groupId>
<version>7.54.0-SNAPSHOT</version>
<version>7.86.0-SNAPSHOT</version>
</parent>
<artifactId>assembly-wsmaster-war</artifactId>
<packaging>war</packaging>
@ -91,18 +91,22 @@
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-account</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-auth</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-auth-azure-devops</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-auth-bitbucket</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-auth-github</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-auth-gitlab</artifactId>
@ -123,6 +127,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-factory</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-factory-azure-devops</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-factory-bitbucket</artifactId>
@ -131,6 +139,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-factory-bitbucket-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-factory-git-ssh</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-factory-github</artifactId>
@ -143,10 +155,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-logger</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-metrics</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-ssh</artifactId>
@ -183,14 +191,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-schedule</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-db</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-db-vendor-postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-logback</artifactId>
@ -251,18 +251,10 @@
<groupId>org.eclipse.che.multiuser</groupId>
<artifactId>che-multiuser-api-authorization-impl</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.multiuser</groupId>
<artifactId>che-multiuser-api-organization</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.multiuser</groupId>
<artifactId>che-multiuser-api-permission</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.multiuser</groupId>
<artifactId>che-multiuser-api-resource</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.multiuser</groupId>
<artifactId>che-multiuser-api-workspace-activity</artifactId>
@ -275,10 +267,6 @@
<groupId>org.eclipse.che.multiuser</groupId>
<artifactId>che-multiuser-keycloak-token-provider</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.multiuser</groupId>
<artifactId>che-multiuser-keycloak-user-remover</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.multiuser</groupId>
<artifactId>che-multiuser-machine-authentication</artifactId>
@ -347,10 +335,6 @@
<groupId>org.everrest</groupId>
<artifactId>everrest-integration-guice</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
@ -467,6 +451,7 @@
<dep>org.everrest:everrest-core</dep>
<dep>io.jsonwebtoken:jjwt-jackson</dep>
<dep>io.jsonwebtoken:jjwt-impl</dep>
<dep>org.eclipse.che.core:che-core-db-vendor-h2</dep>
</ignoredUnusedDeclaredDependencies>
</configuration>
</execution>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2022 Red Hat, Inc.
* Copyright (c) 2012-2024 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@ -26,7 +26,6 @@ import io.jsonwebtoken.JwtParser;
import io.jsonwebtoken.SigningKeyResolver;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
import org.eclipse.che.api.core.notification.RemoteSubscriptionStorage;
import org.eclipse.che.api.core.rest.CheJsonProvider;
import org.eclipse.che.api.core.rest.MessageBodyAdapter;
@ -36,17 +35,23 @@ import org.eclipse.che.api.factory.server.FactoryAcceptValidator;
import org.eclipse.che.api.factory.server.FactoryCreateValidator;
import org.eclipse.che.api.factory.server.FactoryEditValidator;
import org.eclipse.che.api.factory.server.FactoryParametersResolver;
import org.eclipse.che.api.factory.server.RawDevfileUrlFactoryParameterResolver;
import org.eclipse.che.api.factory.server.ScmFileResolver;
import org.eclipse.che.api.factory.server.ScmService;
import org.eclipse.che.api.factory.server.azure.devops.AzureDevOpsFactoryParametersResolver;
import org.eclipse.che.api.factory.server.azure.devops.AzureDevOpsScmFileResolver;
import org.eclipse.che.api.factory.server.bitbucket.BitbucketFactoryParametersResolver;
import org.eclipse.che.api.factory.server.bitbucket.BitbucketScmFileResolver;
import org.eclipse.che.api.factory.server.bitbucket.BitbucketServerAuthorizingFactoryParametersResolver;
import org.eclipse.che.api.factory.server.bitbucket.BitbucketServerScmFileResolver;
import org.eclipse.che.api.factory.server.git.ssh.GitSshFactoryParametersResolver;
import org.eclipse.che.api.factory.server.git.ssh.GitSshScmFileResolver;
import org.eclipse.che.api.factory.server.github.GithubFactoryParametersResolver;
import org.eclipse.che.api.factory.server.github.GithubFactoryParametersResolverSecond;
import org.eclipse.che.api.factory.server.github.GithubScmFileResolver;
import org.eclipse.che.api.factory.server.github.GithubScmFileResolverSecond;
import org.eclipse.che.api.factory.server.gitlab.GitlabFactoryParametersResolver;
import org.eclipse.che.api.factory.server.gitlab.GitlabScmFileResolver;
import org.eclipse.che.api.metrics.WsMasterMetricsModule;
import org.eclipse.che.api.system.server.ServiceTermination;
import org.eclipse.che.api.system.server.SystemModule;
import org.eclipse.che.api.user.server.NotImplementedTokenValidator;
@ -74,39 +79,28 @@ import org.eclipse.che.api.workspace.server.spi.provision.env.JavaOptsEnvVariabl
import org.eclipse.che.api.workspace.server.spi.provision.env.LegacyEnvVarProvider;
import org.eclipse.che.api.workspace.server.spi.provision.env.MachineTokenEnvVarProvider;
import org.eclipse.che.api.workspace.server.spi.provision.env.MavenOptsEnvVariableProvider;
import org.eclipse.che.api.workspace.server.spi.provision.env.ProjectsRootEnvVariableProvider;
import org.eclipse.che.api.workspace.server.spi.provision.env.WorkspaceIdEnvVarProvider;
import org.eclipse.che.api.workspace.server.spi.provision.env.WorkspaceNameEnvVarProvider;
import org.eclipse.che.api.workspace.server.spi.provision.env.WorkspaceNamespaceNameEnvVarProvider;
import org.eclipse.che.api.workspace.server.wsplugins.ChePluginsApplier;
import org.eclipse.che.commons.observability.deploy.ExecutorWrapperModule;
import org.eclipse.che.core.db.DBTermination;
import org.eclipse.che.core.db.schema.SchemaInitializer;
import org.eclipse.che.core.tracing.metrics.TracingMetricsModule;
import org.eclipse.che.inject.DynaModule;
import org.eclipse.che.multiuser.api.authentication.commons.token.ChainedTokenExtractor;
import org.eclipse.che.multiuser.api.authentication.commons.token.HeaderRequestTokenExtractor;
import org.eclipse.che.multiuser.api.authentication.commons.token.RequestTokenExtractor;
import org.eclipse.che.multiuser.api.permission.server.AdminPermissionInitializer;
import org.eclipse.che.multiuser.api.permission.server.PermissionChecker;
import org.eclipse.che.multiuser.api.permission.server.PermissionCheckerImpl;
import org.eclipse.che.multiuser.api.workspace.activity.MultiUserWorkspaceActivityModule;
import org.eclipse.che.multiuser.keycloak.server.deploy.KeycloakModule;
import org.eclipse.che.multiuser.keycloak.server.deploy.KeycloakUserRemoverModule;
import org.eclipse.che.multiuser.machine.authentication.server.MachineAuthModule;
import org.eclipse.che.multiuser.oidc.OIDCInfo;
import org.eclipse.che.multiuser.oidc.OIDCInfoProvider;
import org.eclipse.che.multiuser.oidc.OIDCJwkProvider;
import org.eclipse.che.multiuser.oidc.OIDCJwtParserProvider;
import org.eclipse.che.multiuser.oidc.OIDCSigningKeyResolver;
import org.eclipse.che.multiuser.organization.api.OrganizationApiModule;
import org.eclipse.che.multiuser.organization.api.OrganizationJpaModule;
import org.eclipse.che.multiuser.permission.user.UserServicePermissionsFilter;
import org.eclipse.che.multiuser.resource.api.ResourceModule;
import org.eclipse.che.security.PBKDF2PasswordEncryptor;
import org.eclipse.che.security.PasswordEncryptor;
import org.eclipse.che.security.oauth.EmbeddedOAuthAPI;
import org.eclipse.che.security.oauth.GitLabModule;
import org.eclipse.che.security.oauth.OAuthAPI;
import org.eclipse.che.security.oauth.OpenShiftOAuthModule;
import org.eclipse.che.workspace.infrastructure.kubernetes.KubernetesClientConfigFactory;
@ -128,7 +122,6 @@ import org.eclipse.che.workspace.infrastructure.openshift.OpenShiftInfrastructur
import org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment;
import org.eclipse.che.workspace.infrastructure.openshift.multiuser.oauth.KeycloakProviderConfigFactory;
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.flywaydb.core.internal.util.PlaceholderReplacer;
/** @author andrew00x */
@DynaModule
@ -144,18 +137,10 @@ public class WsMasterModule extends AbstractModule {
}
// db related components modules
install(new org.eclipse.che.account.api.AccountModule());
install(new org.eclipse.che.api.ssh.server.jpa.SshJpaModule());
install(new org.eclipse.che.api.core.jsonrpc.impl.JsonRpcModule());
install(new org.eclipse.che.api.core.websocket.impl.WebSocketModule());
// db configuration
bind(SchemaInitializer.class)
.to(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer.class);
bind(org.eclipse.che.core.db.DBInitializer.class).asEagerSingleton();
bind(PlaceholderReplacer.class)
.toProvider(org.eclipse.che.core.db.schema.impl.flyway.PlaceholderReplacerProvider.class);
// factory
bind(FactoryAcceptValidator.class)
.to(org.eclipse.che.api.factory.server.impl.FactoryAcceptValidatorImpl.class);
@ -171,27 +156,40 @@ public class WsMasterModule extends AbstractModule {
Multibinder<FactoryParametersResolver> factoryParametersResolverMultibinder =
Multibinder.newSetBinder(binder(), FactoryParametersResolver.class);
factoryParametersResolverMultibinder.addBinding().to(GithubFactoryParametersResolver.class);
factoryParametersResolverMultibinder
.addBinding()
.to(GithubFactoryParametersResolverSecond.class);
factoryParametersResolverMultibinder
.addBinding()
.to(BitbucketServerAuthorizingFactoryParametersResolver.class);
factoryParametersResolverMultibinder.addBinding().to(GitlabFactoryParametersResolver.class);
factoryParametersResolverMultibinder.addBinding().to(BitbucketFactoryParametersResolver.class);
factoryParametersResolverMultibinder
.addBinding()
.to(AzureDevOpsFactoryParametersResolver.class);
factoryParametersResolverMultibinder
.addBinding()
.to(RawDevfileUrlFactoryParameterResolver.class);
factoryParametersResolverMultibinder.addBinding().to(GitSshFactoryParametersResolver.class);
Multibinder<ScmFileResolver> scmFileResolverResolverMultibinder =
Multibinder.newSetBinder(binder(), ScmFileResolver.class);
scmFileResolverResolverMultibinder.addBinding().to(GithubScmFileResolver.class);
scmFileResolverResolverMultibinder.addBinding().to(GithubScmFileResolverSecond.class);
scmFileResolverResolverMultibinder.addBinding().to(BitbucketScmFileResolver.class);
scmFileResolverResolverMultibinder.addBinding().to(GitlabScmFileResolver.class);
scmFileResolverResolverMultibinder.addBinding().to(BitbucketServerScmFileResolver.class);
scmFileResolverResolverMultibinder.addBinding().to(AzureDevOpsScmFileResolver.class);
scmFileResolverResolverMultibinder.addBinding().to(GitSshScmFileResolver.class);
install(new org.eclipse.che.api.factory.server.scm.KubernetesScmModule());
install(new org.eclipse.che.api.factory.server.bitbucket.BitbucketServerModule());
install(new org.eclipse.che.api.factory.server.gitlab.GitlabModule());
install(new org.eclipse.che.api.factory.server.github.GithubModule());
install(new org.eclipse.che.api.factory.server.bitbucket.BitbucketModule());
install(new org.eclipse.che.api.factory.server.azure.devops.AzureDevOpsModule());
bind(org.eclipse.che.api.core.rest.ApiInfoService.class);
bind(org.eclipse.che.api.ssh.server.SshService.class);
bind(org.eclipse.che.api.user.server.UserService.class);
bind(org.eclipse.che.api.user.server.ProfileService.class);
bind(org.eclipse.che.api.user.server.PreferencesService.class);
@ -201,10 +199,9 @@ public class WsMasterModule extends AbstractModule {
install(new DevfileModule());
bind(WorkspaceEntityProvider.class);
bind(org.eclipse.che.api.workspace.server.TemporaryWorkspaceRemover.class);
bind(org.eclipse.che.api.workspace.server.WorkspaceService.class);
bind(org.eclipse.che.api.devfile.server.DevfileService.class);
bind(org.eclipse.che.api.devfile.server.UserDevfileEntityProvider.class);
install(new FactoryModuleBuilder().build(ServersCheckerFactory.class));
Multibinder<InternalEnvironmentProvisioner> internalEnvironmentProvisioners =
@ -221,7 +218,6 @@ public class WsMasterModule extends AbstractModule {
envVarProviders.addBinding().to(WorkspaceIdEnvVarProvider.class);
envVarProviders.addBinding().to(WorkspaceNamespaceNameEnvVarProvider.class);
envVarProviders.addBinding().to(WorkspaceNameEnvVarProvider.class);
envVarProviders.addBinding().to(ProjectsRootEnvVariableProvider.class);
Multibinder<LegacyEnvVarProvider> legacyEnvVarProviderMultibinders =
Multibinder.newSetBinder(binder(), LegacyEnvVarProvider.class);
@ -270,10 +266,6 @@ public class WsMasterModule extends AbstractModule {
terminationMultiBinder
.addBinding()
.to(org.eclipse.che.api.system.server.CronThreadPullTermination.class);
terminationMultiBinder
.addBinding()
.to(org.eclipse.che.api.workspace.server.hc.probe.ProbeSchedulerTermination.class);
bind(DBTermination.class);
final Map<String, String> persistenceProperties = new HashMap<>();
persistenceProperties.put(PersistenceUnitProperties.TARGET_SERVER, "None");
@ -289,7 +281,9 @@ public class WsMasterModule extends AbstractModule {
install(new FactoryModuleBuilder().build(PassThroughProxyProvisionerFactory.class));
installDefaultSecureServerExposer(infrastructure);
install(new org.eclipse.che.security.BitbucketModule());
install(new GitLabModule());
install(new org.eclipse.che.security.oauth.GitLabModule());
install(new org.eclipse.che.security.oauth.AzureDevOpsModule());
install(new org.eclipse.che.security.oauth.GithubModule());
configureMultiUserMode(persistenceProperties, infrastructure);
@ -314,7 +308,6 @@ public class WsMasterModule extends AbstractModule {
}
if (Boolean.valueOf(System.getenv("CHE_METRICS_ENABLED"))) {
install(new org.eclipse.che.core.metrics.MetricsModule());
install(new WsMasterMetricsModule());
install(new InfrastructureMetricsModule());
} else {
install(new org.eclipse.che.core.metrics.NoopMetricsModule());
@ -355,10 +348,7 @@ public class WsMasterModule extends AbstractModule {
persistenceProperties.put(
PersistenceUnitProperties.EXCEPTION_HANDLER_CLASS,
"org.eclipse.che.core.db.postgresql.jpa.eclipselink.PostgreSqlExceptionHandler");
bind(DataSource.class).toProvider(org.eclipse.che.core.db.JndiDataSourceProvider.class);
install(new org.eclipse.che.multiuser.api.permission.server.jpa.SystemPermissionsJpaModule());
install(new org.eclipse.che.multiuser.api.permission.server.PermissionsModule());
install(
new org.eclipse.che.multiuser.permission.workspace.server.WorkspaceApiPermissionsModule());
install(
@ -393,10 +383,6 @@ public class WsMasterModule extends AbstractModule {
org.eclipse.che.multiuser.permission.resource.filters
.FreeResourcesLimitServicePermissionsFilter.class);
install(new ResourceModule());
install(new OrganizationApiModule());
install(new OrganizationJpaModule());
if (Boolean.parseBoolean(System.getenv("CHE_AUTH_NATIVEUSER"))) {
bind(RequestTokenExtractor.class).to(HeaderRequestTokenExtractor.class);
if (KubernetesInfrastructure.NAME.equals(infrastructure)) {
@ -407,14 +393,9 @@ public class WsMasterModule extends AbstractModule {
}
bind(TokenValidator.class).to(NotImplementedTokenValidator.class);
bind(ProfileDao.class).to(JpaProfileDao.class);
bind(OAuthAPI.class).to(EmbeddedOAuthAPI.class);
} else {
install(new KeycloakModule());
install(new KeycloakUserRemoverModule());
bind(RequestTokenExtractor.class).to(ChainedTokenExtractor.class);
bind(OAuthAPI.class).to(EmbeddedOAuthAPI.class).asEagerSingleton();
}
bind(AdminPermissionInitializer.class).asEagerSingleton();
install(new MachineAuthModule());
// User and profile - use profile from keycloak and other stuff is JPA

View File

@ -1,6 +1,6 @@
<!--
Copyright (c) 2012-2021 Red Hat, Inc.
Copyright (c) 2012-2023 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2021 Red Hat, Inc.
Copyright (c) 2012-2023 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
@ -16,5 +16,5 @@
<Resource name="jdbc/che" auth="Container"
type="javax.sql.DataSource"
factory="org.eclipse.che.core.db.postgresql.PostgreSQLJndiDataSourceFactory"/>
factory="org.eclipse.che.core.db.h2.jpa.eclipselink.H2SQLJndiDataSourceFactory"/>
</Context>

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2012-2022 Red Hat, Inc.
# Copyright (c) 2012-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
@ -29,48 +29,6 @@ che.websocket.endpoint=ws://${CHE_HOST}:${CHE_PORT}/api/websocket
# for major WebSocket interactions and messaging.
che.websocket.internal.endpoint=NULL
# Your projects are synchronized from the {prod-short} server into the machine running each
# workspace. This is the directory in the machine where your projects are placed.
che.workspace.projects.storage=/projects
# Defines the directory inside the machine where all the workspace logs are placed.
# Provide this value into the machine, for example, as an environment variable.
# This is to ensure that agent developers can use this directory to back up agent logs.
che.workspace.logs.root_dir=/workspace_logs
# Configures environment variable HTTP_PROXY to a specified value in containers powering workspaces.
che.workspace.http_proxy=
# Configures environment variable HTTPS_PROXY to a specified value in containers powering workspaces.
che.workspace.https_proxy=
# Configures environment variable NO_PROXY to a specified value in containers powering workspaces.
che.workspace.no_proxy=
# By default, when users access a workspace with its URL, the workspace
# automatically starts (if currently stopped). Set this to `false` to disable this behavior.
che.workspace.auto_start=true
# Workspace threads pool configuration. This pool is used for workspace-related
# operations that require asynchronous execution, for example, starting and stopping.
# Possible values are: `fixed` and `cached`.
che.workspace.pool.type=fixed
# This property is ignored when pool type is different from `fixed`.
# It configures the exact size of the pool. When set, the `multiplier` property is ignored.
# If this property is not set (`0`, `<0`, `NULL`), then the pool size equals the number of cores.
# See also `che.workspace.pool.cores_multiplier`.
che.workspace.pool.exact_size=30
# This property is ignored when `che.workspace.pool.exact_size`
# is set and pool type is not set to `fixed`. When set, the pool size is `N_CORES * multiplier`.
che.workspace.pool.cores_multiplier=2
# This property specifies how many threads to use for workspace server liveness probes.
che.workspace.probe_pool_size=10
# HTTP proxy setting for workspace JVM.
che.workspace.http_proxy_java_options=NULL
@ -118,30 +76,6 @@ che.workspace.sidecar.default_cpu_limit_cores=-1
# Specify it either in floating point cores or in integer millicores, for example: `0.125` or `125m`.
che.workspace.sidecar.default_cpu_request_cores=-1
# Defines image pull strategy for sidecars. Possible values are: `Always`,
# `Never`, `IfNotPresent`. For any other value, `Always` is assumed for images
# with the `:latest` tag, or `IfNotPresent` for all other cases.
che.workspace.sidecar.image_pull_policy=Always
# Period of inactive workspaces suspend job execution.
che.workspace.activity_check_scheduler_period_s=60
# Period of cleanup of the activity table. The activity table can contain invalid or stale data
# if an unforeseen error happens, such as a server failure at a particular point in time. The default is set to
# run the cleanup job every hour.
che.workspace.activity_cleanup_scheduler_period_s=3600
# Delay after a server startup to start the first activity cleanup job.
che.workspace.activity_cleanup_scheduler_initial_delay_s=60
# Delay before the first workspace idleness check job is started to avoid
# a mass suspend if {prod-short} server was unavailable for a period close to
# inactivity timeout.
che.workspace.activity_check_scheduler_delay_s=180
# Delay before the first execution of a temporary workspaces cleanup job.
che.workspace.cleanup_temporary_initial_delay_min=5
@ -149,14 +83,6 @@ che.workspace.cleanup_temporary_initial_delay_min=5
# of the next execution of temporary workspaces cleanup job.
che.workspace.cleanup_temporary_period_min=180
# Number of sequential successful pings to a server after which it is treated as available.
# For the {prod-short} Operator, the property is common for all servers, for example: `workspace agent`, `terminal`, and `exec`.
che.workspace.server.ping_success_threshold=1
# Interval (in milliseconds) between successive pings to a workspace server.
che.workspace.server.ping_interval_milliseconds=3000
# List of names of the servers that require liveness probes.
che.workspace.server.liveness_probes=wsagent/http,exec-agent/http,terminal,theia,jupyter,dirigible,cloud-shell,intellij
@ -165,10 +91,6 @@ che.workspace.server.liveness_probes=wsagent/http,exec-agent/http,terminal,theia
# The default is: 10MB=10485760.
che.workspace.startup_debug_log_limit_bytes=10485760
# If set to `true`, 'stop-workspace' role with the edit privileges is granted to the 'che' ServiceAccount if OpenShift OAuth is enabled.
# This configuration is mainly required for workspace idling when the OpenShift OAuth is enabled.
che.workspace.stop.role.enabled=true
# Specifies whether {prod-short} is deployed with DevWorkspaces enabled.
# This property is set by the {prod-short} Operator if it also installed the support for DevWorkspaces.
# This property is used to advertise this fact to the {prod-short} dashboard.
@ -187,24 +109,74 @@ che.auth.access_denied_error_page=/error-oauth
# Reserved user names.
che.auth.reserved_user_names=
# Configuration of the Azure DevOps Service OAuth2 client. Used to obtain personal access tokens.
# Location of the file with Azure DevOps Service Application ID.
che.oauth2.azure.devops.clientid_filepath=NULL
# Location of the file with Azure DevOps Service Client Secret.
che.oauth2.azure.devops.clientsecret_filepath=NULL
# Azure DevOps Service OAuth2 scopes.
# Separate multiple values with comma, for example: scope,scope,scope
# The full list of scopes: https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth?view=azure-devops#scopes
che.integration.azure.devops.application_scopes=vso.code_write
# Azure DevOps Service OAuth2 authorization URI.
che.oauth.azure.devops.authuri=https://app.vssps.visualstudio.com/oauth2/authorize
# Azure DevOps OAuth Service token URI.
che.oauth.azure.devops.tokenuri=https://app.vssps.visualstudio.com/oauth2/token
# Azure DevOps Service API server address.
che.integration.azure.devops.api_endpoint=https://vssps.dev.azure.com
# Azure DevOps SCM API server address.
che.integration.azure.devops.scm.api_endpoint=https://dev.azure.com
# Azure DevOps Service redirect URIs.
# Separate multiple values with comma, for example: URI,URI,URI.
che.oauth.azure.devops.redirecturis=https://${CHE_HOST}/api/oauth/callback
# Configuration of the GitHub OAuth2 client. Used to obtain personal access tokens.
# Location of the file with GitHub client id.
che.oauth2.github.clientid_filepath=NULL
# Configuration of the GitHub OAuth2 client. Used to obtain personal access tokens.
# Location of the file with GitHub client id (The second GitHub instance).
che.oauth2.github.clientid_filepath_2=NULL
# Location of the file with GitHub client secret.
che.oauth2.github.clientsecret_filepath=NULL
# Location of the file with GitHub client secret (The second GitHub instance).
che.oauth2.github.clientsecret_filepath_2=NULL
# GitHub OAuth authorization URI.
che.oauth.github.authuri= https://github.com/login/oauth/authorize
# GitHub OAuth authorization URI (The second GitHub instance).
che.oauth.github.authuri_2= https://github.com/login/oauth/authorize
# GitHub OAuth token URI.
che.oauth.github.tokenuri= https://github.com/login/oauth/access_token
# GitHub OAuth token URI (The second GitHub instance).
che.oauth.github.tokenuri_2= https://github.com/login/oauth/access_token
# GitHub server address.
# Prerequisite: OAuth 2 integration is configured on the GitHub server.
che.integration.github.oauth_endpoint=NULL
# GitHub server address.
# Prerequisite: OAuth 2 integration is configured on the GitHub server (The second GitHub instance).
che.integration.github.oauth_endpoint_2=NULL
# GitHub server disable subdomain isolation flag.
che.integration.github.disable_subdomain_isolation=false
# GitHub server disable subdomain isolation flag (The second GitHub instance).
che.integration.github.disable_subdomain_isolation_2=false
# GitHub OAuth redirect URIs.
# Separate multiple values with comma, for example: URI,URI,URI.
che.oauth.github.redirecturis= http://localhost:${CHE_PORT}/api/oauth/callback
@ -226,7 +198,7 @@ che.oauth1.bitbucket.consumerkeypath=NULL
che.oauth1.bitbucket.privatekeypath=NULL
# Bitbucket Server URL. To work correctly with factories, the same URL
# has to be part of `che.integration.bitbucket.server_endpoints` too.
che.oauth1.bitbucket.endpoint=NULL
che.oauth.bitbucket.endpoint=https://bitbucket.org
# Configuration of Bitbucket OAuth2 client. Used to obtain Personal access tokens.
# Location of the file with Bitbucket client id.
@ -243,7 +215,7 @@ che.oauth.bitbucket.tokenuri= https://bitbucket.org/site/oauth2/access_token
# Bitbucket OAuth redirect URIs.
# Separate multiple values with comma, for example: URI,URI,URI
che.oauth.bitbucket.redirecturis= http://localhost:${CHE_PORT}/api/oauth/callback
che.oauth.bitbucket.redirecturis= https://${CHE_HOST}/api/oauth/callback
### Internal
@ -370,9 +342,6 @@ che.infra.kubernetes.workspace_sa_cluster_roles=NULL
# Cluster roles to assign to user in their namespace.
che.infra.kubernetes.user_cluster_roles=NULL
# Defines wait time that limits the Kubernetes workspace start time.
che.infra.kubernetes.workspace_start_timeout_min=8
# Defines the timeout (in minutes) that limits the period for which {orch-ingress} becomes ready.
che.infra.kubernetes.ingress_start_timeout_min=5
@ -673,16 +642,6 @@ che.workspace.provision.secret.labels=app.kubernetes.io/part-of=che.eclipse.org,
# and supported by the environment.
che.workspace.devfile.async.storage.plugin=eclipse/che-async-pv-plugin/latest
# Optionally configures node selector for workspace pod. The format is comma-separated
# `key=value` pairs, for example: `disktype=ssd,cpu=xlarge,foo=bar`
che.workspace.pod.node_selector=NULL
# Optionally configures tolerations for workspace pod. The format is a string representing a JSON Array of taint tolerations,
# or `NULL` to disable it. The objects contained in the array have to follow the
# link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#toleration-v1-core[toleration v1 core specifications].
# For example: `[{"effect":"NoExecute","key":"aNodeTaint","operator":"Equal","value":"aValue"}]`
che.workspace.pod.tolerations_json=NULL
# Bitbucket endpoints used for factory integrations.
# A comma separated list of Bitbucket server URLs or `NULL` if no integration is expected.
che.integration.bitbucket.server_endpoints=NULL
@ -700,3 +659,16 @@ che.oauth2.gitlab.clientid_filepath=NULL
# Location of the file with GitLab client secret.
che.oauth2.gitlab.clientsecret_filepath=NULL
### Advanced authorization
# Comma separated list of users allowed to access Che.
che.infra.kubernetes.advanced_authorization.allow_users=NULL
# Comma separated list of groups of users allowed to access Che.
che.infra.kubernetes.advanced_authorization.allow_groups=NULL
# Comma separated list of users denied to access Che.
che.infra.kubernetes.advanced_authorization.deny_users=NULL
# Comma separated list of groups of users denied to access Che.
che.infra.kubernetes.advanced_authorization.deny_groups=NULL

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2012-2022 Red Hat, Inc.
# Copyright (c) 2012-2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
@ -64,24 +64,6 @@ che.limits.user.workspaces.count=-1
# stop a running workspace to activate another.
che.limits.user.workspaces.run.count=1
### Organizations workspace limits
# The total amount of RAM that a single organization (team) is allowed to allocate
# to running workspaces. An organization owner can allocate this RAM however they
# see fit across the team's workspaces.
che.limits.organization.workspaces.ram=-1
# The maximum number of workspaces that an organization is allowed to own. The
# organization will be presented with an error message if they try to create
# additional workspaces. This applies to the total number of both running
# and stopped workspaces.
che.limits.organization.workspaces.count=-1
# The maximum number of running workspaces that a single organization is allowed to have.
# If the organization has reached this threshold, and they try to start an
# additional workspace, they will be presented with an error message. The
# organization will need to stop a running workspace to activate another.
che.limits.organization.workspaces.run.count=-1
### Multi-user-specific OpenShift infrastructure configuration
@ -157,22 +139,6 @@ che.keycloak.use_fixed_redirect_urls=false
# Runtime Exception `wii` will be thrown, if this property isn't set properly.
che.oauth.service_mode=delegated
# Configuration for enabling removing user from Keycloak server on removing user from Che database.
# It's disabled by default. You can enable it in special cases when deleting a user in Che database
# should execute removing related-user from Keycloak.
# For it to work correctly, you need to set an administrator username ${che.keycloak.admin_username} and password
# ${che.keycloak.admin_password}.
che.keycloak.cascade_user_removal_enabled=false
# Keycloak administrator username. It will be used for deleting user from Keycloak on removing user
# from Che database. Using it makes sense only if ${che.keycloak.cascade_user_removal_enabled} is
# set to 'true'.
che.keycloak.admin_username=NULL
# Keycloak administrator password. Will be used for deleting user from Keycloak on removing user
# from Che database. Using it makes sense only if ${che.keycloak.cascade_user_removal_enabled} is
# set to 'true'
che.keycloak.admin_password=NULL
# User name adjustment configuration. Che needs to use the usernames as part of Kubernetes object names and labels.
# Therefore there are stricter requirements on their format than the identity providers usually

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2012-2022 Red Hat, Inc.
# Copyright (c) 2012-2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2021 Red Hat, Inc.
* Copyright (c) 2012-2024 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@ -37,6 +37,7 @@ import org.reflections.scanners.FieldAnnotationsScanner;
import org.reflections.scanners.MethodAnnotationsScanner;
import org.reflections.scanners.MethodParameterScanner;
import org.testng.Assert;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;
public class IntegrityConfigurationTest {
@ -125,6 +126,7 @@ public class IntegrityConfigurationTest {
}
@Test
@Ignore
public void shouldNotDeclareUnused() {
Reflections reflections =
new Reflections(

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
Copyright (c) 2012-2024 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
@ -17,7 +17,7 @@
<parent>
<artifactId>che-server</artifactId>
<groupId>org.eclipse.che</groupId>
<version>7.54.0-SNAPSHOT</version>
<version>7.86.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>che-assembly-parent</artifactId>

View File

@ -1,5 +1,6 @@
#!/bin/bash
# Copyright (c) 2017 Red Hat, Inc.
#
# Copyright (c) 2017-2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
@ -14,6 +15,7 @@ IMAGE_ALIASES=${IMAGE_ALIASES:-}
ERROR=${ERROR:-}
DIR=${DIR:-}
SHA_TAG=${SHA_TAG:-}
BUILDER=${BUILDER:-}
skip_tests() {
if [ $SKIP_TESTS = "true" ]; then
@ -48,6 +50,7 @@ init() {
ARGS=""
OPTIONS=""
DOCKERFILE=""
BUILD_COMMAND="build"
BUILD_ARGS=""
while [ $# -gt 0 ]; do
@ -103,6 +106,37 @@ build() {
DIR=$(cd "$(dirname "$0")"; pwd)
fi
BUILD_COMAMAND="build"
if [ -z $BUILDER ]; then
echo "BUILDER is not specified, trying with podman"
BUILDER=$(command -v podman || true)
if [[ ! -x $BUILDER ]]; then
echo "[WARNING] podman is not installed, trying with buildah"
BUILDER=$(command -v buildah || true)
if [[ ! -x $BUILDER ]]; then
echo "[WARNING] buildah is not installed, trying with docker"
BUILDER=$(command -v docker || true)
if [[ ! -x $BUILDER ]]; then
echo "[ERROR] This script requires podman, buildah or docker to be installed. Must abort!"; exit 1
fi
else
BUILD_COMMAND="bud"
fi
fi
else
if [[ ! -x $(command -v "$BUILDER" || true) ]]; then
echo "Builder $BUILDER is missing. Aborting."; exit 1
fi
if [[ $BUILDER =~ "docker" || $BUILDER =~ "podman" ]]; then
if [[ ! $($BUILDER ps) ]]; then
echo "Builder $BUILDER is not functioning. Aborting."; exit 1
fi
fi
if [[ $BUILDER =~ "buildah" ]]; then
BUILD_COMMAND="bud"
fi
fi
# If Dockerfile is empty, build all Dockerfiles
if [ -z ${DOCKERFILE} ]; then
DOCKERFILES_TO_BUILD="$(ls ${DIR}/Dockerfile*)"
@ -137,26 +171,26 @@ build_image() {
-e "s;\${BUILD_PREFIX};${PREFIX};" \
-e "s;\${BUILD_TAG};${TAG};" \
> ${DIR}/.Dockerfile
cd "${DIR}" && docker build -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} .
cd "${DIR}" && "${BUILDER}" "${BUILD_COMMAND}" -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} .
DOCKER_BUILD_STATUS=$?
rm ${DIR}/.Dockerfile
if [ $DOCKER_BUILD_STATUS -eq 0 ]; then
printf "Build of ${BLUE}${IMAGE_NAME} ${GREEN}[OK]${NC}\n"
if [ ! -z "${SHA_TAG}" ]; then
SHA_IMAGE_NAME=${ORGANIZATION}/${PREFIX}-${NAME}:${SHA_TAG}
docker tag ${IMAGE_NAME} ${SHA_IMAGE_NAME}
"${BUILDER}" tag ${IMAGE_NAME} ${SHA_IMAGE_NAME}
DOCKER_TAG_STATUS=$?
if [ $DOCKER_TAG_STATUS -eq 0 ]; then
printf "Re-tagging with SHA based tag ${BLUE}${SHA_IMAGE_NAME} ${GREEN}[OK]${NC}\n"
else
printf "${RED}Failure when tagging docker image ${SHA_IMAGE_NAME}${NC}\n"
exit 1
fi
fi
fi
if [ ! -z "${IMAGE_ALIASES}" ]; then
for TMP_IMAGE_NAME in ${IMAGE_ALIASES}
do
docker tag ${IMAGE_NAME} ${TMP_IMAGE_NAME}:${TAG}
"${BUILDER}" tag ${IMAGE_NAME} ${TMP_IMAGE_NAME}:${TAG}
DOCKER_TAG_STATUS=$?
if [ $DOCKER_TAG_STATUS -eq 0 ]; then
printf " /alias ${BLUE}${TMP_IMAGE_NAME}:${TAG}${NC} ${GREEN}[OK]${NC}\n"
@ -174,32 +208,6 @@ build_image() {
fi
}
check_docker() {
if ! docker ps > /dev/null 2>&1; then
output=$(docker ps)
printf "${RED}Docker not installed properly: ${output}${NC}\n"
exit 1
fi
}
docker_exec() {
if has_docker_for_windows_client; then
MSYS_NO_PATHCONV=1 docker.exe "$@"
else
"$(which docker)" "$@"
fi
}
has_docker_for_windows_client() {
GLOBAL_HOST_ARCH=$(docker version --format {{.Client}})
if [[ "${GLOBAL_HOST_ARCH}" = *"windows"* ]]; then
return 0
else
return 1
fi
}
get_full_path() {
echo "$(cd "$(dirname "${1}")"; pwd)/$(basename "$1")"
}
@ -227,3 +235,27 @@ get_mount_path() {
CLEAN_PATH=$(get_clean_path "${POSIX_PATH}")
echo $CLEAN_PATH
}
# grab assembly
DIR="$(cd "$(dirname "$0")"; pwd)/dockerfiles"
if [ ! -d "${DIR}/../../assembly/assembly-main/target" ]; then
echo "${ERROR}Have you built assembly/assemby-main in ${DIR}/../assembly/assembly-main 'mvn clean install'?"
exit 2
fi
# Use of folder
BUILD_ASSEMBLY_DIR=$(echo "${DIR}"/../../assembly/assembly-main/target/eclipse-che-*/eclipse-che-*/)
LOCAL_ASSEMBLY_DIR="${DIR}"/eclipse-che
if [ -d "${LOCAL_ASSEMBLY_DIR}" ]; then
rm -r "${LOCAL_ASSEMBLY_DIR}"
fi
echo "Copying assembly ${BUILD_ASSEMBLY_DIR} --> ${LOCAL_ASSEMBLY_DIR}"
cp -r "${BUILD_ASSEMBLY_DIR}" "${LOCAL_ASSEMBLY_DIR}"
init --name:server "$@"
build
#cleanUp
rm -rf ${DIR}/eclipse-che

View File

@ -1,4 +1,4 @@
# Copyright (c) 2018-2022 Red Hat, Inc.
# Copyright (c) 2018-2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
@ -10,12 +10,12 @@
#
# https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8-minimal
FROM registry.access.redhat.com/ubi8-minimal:8.6-902.1661794353
FROM registry.access.redhat.com/ubi8-minimal:8.9-1161
USER root
ENV CHE_HOME=/home/user/eclipse-che
ENV JAVA_HOME=/usr/lib/jvm/jre
RUN microdnf install java-11-openjdk-headless tar gzip shadow-utils findutils && \
microdnf update -y gnutls && \
RUN microdnf install java-17-openjdk-headless tar gzip shadow-utils findutils && \
microdnf update -y && \
microdnf -y clean all && rm -rf /var/cache/yum && echo "Installed Packages" && rpm -qa | sort -V && echo "End Of Installed Packages" && \
adduser -G root user && mkdir -p /home/user/eclipse-che
COPY entrypoint.sh /entrypoint.sh

View File

@ -0,0 +1,40 @@
# Copyright (c) 2018-2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8-minimal
FROM ubi8-minimal:8.9-1161
USER root
ENV CHE_HOME=/home/user/devspaces
ENV JAVA_HOME=/usr/lib/jvm/jre
RUN microdnf install java-11-openjdk-headless tar gzip shadow-utils findutils && \
microdnf update -y && \
microdnf -y clean all && rm -rf /var/cache/yum && echo "Installed Packages" && rpm -qa | sort -V && echo "End Of Installed Packages" && \
adduser -G root user && mkdir -p /home/user/devspaces
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
# see fetch-artifacts-pnc.yaml
COPY artifacts/assembly-main.tar.gz /tmp/assembly-main.tar.gz
RUN tar xzf /tmp/assembly-main.tar.gz --strip-components=1 -C /home/user/devspaces; rm -f /tmp/assembly-main.tar.gz
# this should fail if the startup script is not found in correct path /home/user/devspaces/tomcat/bin/catalina.sh
RUN mkdir /logs /data && \
chmod 0777 /logs /data && \
chgrp -R 0 /home/user /logs /data && \
chown -R user /home/user && \
chmod -R g+rwX /home/user && \
find /home/user -type d -exec chmod 777 {} \; && \
java -version && echo -n "Server startup script in: " && \
find /home/user/devspaces -name catalina.sh | grep -z /home/user/devspaces/tomcat/bin/catalina.sh
USER user
# append Brew metadata here

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
Copyright (c) 2012-2024 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
@ -17,7 +17,7 @@
<parent>
<artifactId>che-core-parent</artifactId>
<groupId>org.eclipse.che.core</groupId>
<version>7.54.0-SNAPSHOT</version>
<version>7.86.0-SNAPSHOT</version>
</parent>
<artifactId>che-core-api-core</artifactId>
<packaging>jar</packaging>
@ -116,6 +116,11 @@
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2021 Red Hat, Inc.
* Copyright (c) 2012-2023 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@ -11,7 +11,10 @@
*/
package org.eclipse.che.api.core.rest;
import static com.google.common.base.Strings.isNullOrEmpty;
import static java.lang.String.format;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@ -19,6 +22,7 @@ import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import javax.inject.Singleton;
import org.eclipse.che.api.core.rest.shared.dto.ServiceError;
@ -42,11 +46,18 @@ public class RuntimeExceptionMapper implements ExceptionMapper<RuntimeException>
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
final String utcTime = dateFormat.format(new Date());
final String errorMessage = format("Internal Server Error occurred, error time: %s", utcTime);
String message = exception.getMessage();
final String errorMessage =
isNullOrEmpty(message)
? format("Internal Server Error occurred, error time: %s", utcTime)
: message;
LOG.error(errorMessage, exception);
ServiceError serviceError = DtoFactory.newDto(ServiceError.class).withMessage(errorMessage);
List<String> trace =
stream(exception.getStackTrace()).map(StackTraceElement::toString).collect(toList());
ServiceError serviceError =
DtoFactory.newDto(ServiceError.class).withMessage(errorMessage).withTrace(trace);
return Response.serverError()
.entity(DtoFactory.getInstance().toJson(serviceError))
.type(MediaType.APPLICATION_JSON)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* Copyright (c) 2012-2023 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@ -11,6 +11,7 @@
*/
package org.eclipse.che.api.core.rest.shared.dto;
import java.util.List;
import org.eclipse.che.dto.shared.DTO;
/**
@ -30,8 +31,12 @@ public interface ServiceError {
*/
String getMessage();
List<String> getTrace();
ServiceError withMessage(String message);
ServiceError withTrace(List<String> trace);
/**
* Set error message.
*

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
Copyright (c) 2012-2024 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
@ -17,7 +17,7 @@
<parent>
<artifactId>che-core-parent</artifactId>
<groupId>org.eclipse.che.core</groupId>
<version>7.54.0-SNAPSHOT</version>
<version>7.86.0-SNAPSHOT</version>
</parent>
<artifactId>che-core-api-dto-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
Copyright (c) 2012-2024 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
@ -17,7 +17,7 @@
<parent>
<artifactId>che-core-parent</artifactId>
<groupId>org.eclipse.che.core</groupId>
<version>7.54.0-SNAPSHOT</version>
<version>7.86.0-SNAPSHOT</version>
</parent>
<artifactId>che-core-api-dto</artifactId>
<packaging>jar</packaging>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
Copyright (c) 2012-2024 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
@ -17,7 +17,7 @@
<parent>
<artifactId>che-core-parent</artifactId>
<groupId>org.eclipse.che.core</groupId>
<version>7.54.0-SNAPSHOT</version>
<version>7.86.0-SNAPSHOT</version>
</parent>
<artifactId>che-core-api-model</artifactId>
<packaging>jar</packaging>

View File

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-core-parent</artifactId>
<groupId>org.eclipse.che.core</groupId>
<version>7.54.0-SNAPSHOT</version>
</parent>
<artifactId>che-core-db-vendor-h2</artifactId>
<name>Che Core :: Commons :: DB :: Vendor H2</name>
<dependencies>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-db</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>jakarta.persistence</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,40 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.h2.jpa.eclipselink;
import java.sql.SQLException;
import org.eclipse.che.core.db.jpa.DuplicateKeyException;
import org.eclipse.che.core.db.jpa.IntegrityConstraintViolationException;
import org.eclipse.persistence.exceptions.DatabaseException;
import org.eclipse.persistence.exceptions.ExceptionHandler;
/**
* Rethrows vendor specific exceptions as common exceptions. See <a
* href="http://www.h2database.com/javadoc/org/h2/api/ErrorCode.html">H2 error codes</a>.
*
* @author Yevhenii Voevodin
*/
public class H2ExceptionHandler implements ExceptionHandler {
public Object handleException(RuntimeException exception) {
if (exception instanceof DatabaseException && exception.getCause() instanceof SQLException) {
final SQLException sqlEx = (SQLException) exception.getCause();
switch (sqlEx.getErrorCode()) {
case 23505:
throw new DuplicateKeyException(exception.getMessage(), exception);
case 23506:
throw new IntegrityConstraintViolationException(exception.getMessage(), exception);
}
}
throw exception;
}
}

View File

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-core-parent</artifactId>
<groupId>org.eclipse.che.core</groupId>
<version>7.54.0-SNAPSHOT</version>
</parent>
<artifactId>che-core-db-vendor-mysql</artifactId>
<name>Che Core :: Commons :: DB :: Vendor MySQL</name>
<dependencies>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-db</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>jakarta.persistence</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,40 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.mysql.jpa.eclipselink;
import java.sql.SQLException;
import org.eclipse.che.core.db.jpa.DuplicateKeyException;
import org.eclipse.che.core.db.jpa.IntegrityConstraintViolationException;
import org.eclipse.persistence.exceptions.DatabaseException;
import org.eclipse.persistence.exceptions.ExceptionHandler;
/**
* Rethrows vendor specific exceptions as common exceptions. See <a
* href="https://dev.mysql.com/doc/refman/8.0/en/error-messages-server.html">MySQL error codes</a>.
*
* @author Barry Dresdner
*/
public class MySqlExceptionHandler implements ExceptionHandler {
@Override
public Object handleException(RuntimeException exception) {
if (exception instanceof DatabaseException && exception.getCause() instanceof SQLException) {
final SQLException sqlEx = (SQLException) exception.getCause();
switch (sqlEx.getErrorCode()) {
case 1062:
throw new DuplicateKeyException(exception.getMessage(), exception);
case 1452:
throw new IntegrityConstraintViolationException(exception.getMessage(), exception);
}
}
throw exception;
}
}

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-core-parent</artifactId>
<groupId>org.eclipse.che.core</groupId>
<version>7.54.0-SNAPSHOT</version>
</parent>
<artifactId>che-core-db-vendor-postgresql</artifactId>
<name>Che Core :: Commons :: DB :: Vendor PostgreSQL</name>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-db</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>jakarta.persistence</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.postgresql;
import static com.google.common.base.MoreObjects.firstNonNull;
import org.eclipse.che.core.db.JNDIDataSourceFactory;
/**
* Environment params based JNDI data source factory for Postgres.
*
* @author Sergii Kabashniuk
*/
public class PostgreSQLJndiDataSourceFactory extends JNDIDataSourceFactory {
private static final String DEFAULT_USERNAME = "pgche";
private static final String DEFAULT_PASSWORD = "pgchepassword";
private static final String DEFAULT_URL = "jdbc:postgresql://postgres:5432/dbche";
private static final String DEFAULT_DRIVER__CLASS__NAME = "org.postgresql.Driver";
private static final String DEFAULT_MAX__TOTAL = "20";
private static final String DEFAULT_MAX__IDLE = "2";
private static final String DEFAULT_MAX__WAIT__MILLIS = "-1";
public PostgreSQLJndiDataSourceFactory() throws Exception {
super(
firstNonNull(
nullStringToNullReference(System.getenv("CHE_JDBC_USERNAME")), DEFAULT_USERNAME),
firstNonNull(
nullStringToNullReference(System.getenv("CHE_JDBC_PASSWORD")), DEFAULT_PASSWORD),
firstNonNull(nullStringToNullReference(System.getenv("CHE_JDBC_URL")), DEFAULT_URL),
firstNonNull(
nullStringToNullReference(System.getenv("CHE_JDBC_DRIVER__CLASS__NAME")),
DEFAULT_DRIVER__CLASS__NAME),
firstNonNull(
nullStringToNullReference(System.getenv("CHE_JDBC_MAX__TOTAL")), DEFAULT_MAX__TOTAL),
firstNonNull(
nullStringToNullReference(System.getenv("CHE_JDBC_MAX__IDLE")), DEFAULT_MAX__IDLE),
firstNonNull(
nullStringToNullReference(System.getenv("CHE_JDBC_MAX__WAIT__MILLIS")),
DEFAULT_MAX__WAIT__MILLIS));
}
}

View File

@ -1,41 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.postgresql.jpa.eclipselink;
import java.sql.SQLException;
import org.eclipse.che.core.db.jpa.DuplicateKeyException;
import org.eclipse.che.core.db.jpa.IntegrityConstraintViolationException;
import org.eclipse.persistence.exceptions.DatabaseException;
import org.eclipse.persistence.exceptions.ExceptionHandler;
/**
* Rethrows vendor specific exceptions as common exceptions. See <a
* href="https://www.postgresql.org/docs/9.4/static/errcodes-appendix.html">PostgreSQL error
* codes</a>.
*
* @author Yevhenii Voevodin
* @author Sergii Kabashniuk
*/
public class PostgreSqlExceptionHandler implements ExceptionHandler {
public Object handleException(RuntimeException exception) {
if (exception instanceof DatabaseException && exception.getCause() instanceof SQLException) {
final SQLException sqlEx = (SQLException) exception.getCause();
switch (sqlEx.getSQLState()) {
case "23505":
throw new DuplicateKeyException(exception.getMessage(), exception);
case "23503":
throw new IntegrityConstraintViolationException(exception.getMessage(), exception);
}
}
throw exception;
}
}

View File

@ -1,43 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db;
/**
* Defines common database error codes which should be used throughout the application in preference
* to vendor specific error codes.
*
* @author Yevhenii Voevodin
*/
public enum DBErrorCode {
/** When database error can't be described with one of the other values of this enumeration. */
UNDEFINED(-1),
/**
* When any of the unique constraints is violated e.g. duplicate key or unique index violation.
*/
DUPLICATE_KEY(1),
/** When entity referenced foreign key does not exist */
INTEGRITY_CONSTRAINT_VIOLATION(2);
private final int code;
DBErrorCode(int code) {
this.code = code;
}
/** Returns the code of this error. */
public int getCode() {
return code;
}
}

View File

@ -1,89 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.persistence.EntityManagerFactory;
import org.eclipse.che.core.db.jpa.JpaInitializer;
import org.eclipse.che.core.db.jpa.eclipselink.GuiceEntityListenerInjectionManager;
import org.eclipse.che.core.db.schema.SchemaInitializationException;
import org.eclipse.che.core.db.schema.SchemaInitializer;
import org.eclipse.persistence.internal.sessions.AbstractSession;
/**
* Initializes database components.
*
* <p>Those components which require any persistence operations on their bootstrap have to depend on
* this component. For example:
*
* <pre>
* class StackExistsChecker {
*
* &#064;@Inject
* &#064;SuppressWarnings("unused")
* private DBInitializer dbInitializer;
*
* &#064;PostConstruct
* public void check() {
* ....
* }
* }
* </pre>
*
* In this way it is guaranteed that all database related components will be appropriately
* initialized before {@code check} method is executed.
*
* @author Yevhenii Voevodin
*/
@Singleton
public class DBInitializer {
/**
* when value for this key true, then its mean that db is initialized at first time, otherwise db
* was previously initialized
*/
public static final String BARE_DB_INIT_PROPERTY_NAME = "bare_database_init";
private final Map<String, String> initProperties;
@Inject
public DBInitializer(SchemaInitializer schemaInitializer, JpaInitializer jpaInitializer)
throws SchemaInitializationException {
// schema must be initialized before any other component that may interact with database
initProperties = ImmutableMap.copyOf(schemaInitializer.init());
// jpa initialization goes next
jpaInitializer.init();
}
@Inject
public void setUpInjectionManager(
GuiceEntityListenerInjectionManager injManager, EntityManagerFactory emFactory) {
final AbstractSession session = emFactory.unwrap(AbstractSession.class);
session.setInjectionManager(injManager);
}
/** Returns map of properties which represents state of database while initialization process */
public Map<String, String> getInitProperties() {
return initProperties;
}
/**
* Returns true only if database was initialized at first time otherwise false would be returned
*/
public boolean isBareInit() {
return Boolean.parseBoolean(initProperties.get(BARE_DB_INIT_PROPERTY_NAME));
}
}

View File

@ -1,84 +0,0 @@
/*
* Copyright (c) 2012-2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db;
import com.google.inject.Inject;
import com.google.inject.persist.PersistService;
import java.lang.reflect.Field;
import javax.inject.Singleton;
import javax.persistence.EntityManagerFactory;
import org.eclipse.persistence.internal.sessions.AbstractSession;
import org.eclipse.persistence.internal.sessions.coordination.jgroups.JGroupsRemoteConnection;
import org.eclipse.persistence.sessions.coordination.CommandManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Stops {@link PersistService} when a system is ready to shutdown.
*
* @author Anton Korneta
*/
@Singleton
public class DBTermination {
private static final Logger LOG = LoggerFactory.getLogger(DBTermination.class);
private final PersistService persistService;
private final EntityManagerFactory emFactory;
@Inject
public DBTermination(PersistService persistService, EntityManagerFactory emFactory) {
this.persistService = persistService;
this.emFactory = emFactory;
}
/** Stops {@link PersistService}. Any DB operations are impossible after that. */
public void terminate() {
try {
LOG.info("Stopping persistence service.");
fixJChannelClosing(emFactory);
persistService.stop();
} catch (RuntimeException ex) {
LOG.error("Failed to stop persistent service. Cause: " + ex.getMessage());
}
}
/**
* This method is hack that changes value of {@link JGroupsRemoteConnection#isLocal} to false.
* This is needed to close the JGroups EclipseLinkCommandChannel and as result gracefully stop of
* the system.<br>
* For more details see {@link JGroupsRemoteConnection#closeInternal()}
*
* <p>The corresponding eclipse-link extension issue
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=534148
*/
private void fixJChannelClosing(EntityManagerFactory emFactory) {
try {
final AbstractSession session = emFactory.unwrap(AbstractSession.class);
CommandManager commandManager = session.getCommandManager();
if (commandManager == null) {
// not cluster mode
return;
}
final JGroupsRemoteConnection conn =
(JGroupsRemoteConnection) commandManager.getTransportManager().getConnectionToLocalHost();
final Field isLocal = conn.getClass().getDeclaredField("isLocal");
isLocal.setAccessible(true);
isLocal.set(conn, false);
} catch (IllegalAccessException | NoSuchFieldException ex) {
LOG.error(
"Failed to change JGroupsRemoteConnection#isLocal. This may prevent the graceful stop of "
+ "the system because EclipseLinkCommandChannel will not be closed. Cause: "
+ ex.getMessage());
}
}
}

View File

@ -1,79 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db;
import static org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.createDataSource;
import static org.eclipse.che.core.db.TracingDataSource.wrapWithTracingIfEnabled;
import java.util.Hashtable;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.spi.ObjectFactory;
import javax.sql.DataSource;
import org.apache.tomcat.dbcp.dbcp2.BasicDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Abstract JNDI factory that constructs {@link BasicDataSource} objects from the given params.
* Should not be used directly and must be subclassed to provide instantiation params from needful
* source.
*
* @author Sergii Kabashniuk
*/
public abstract class JNDIDataSourceFactory implements ObjectFactory {
private static final Logger LOG = LoggerFactory.getLogger(JNDIDataSourceFactory.class);
private final DataSource dataSource;
public JNDIDataSourceFactory(
String userName,
String password,
String url,
String driverClassName,
String maxTotal,
String maxIdle,
String maxWaitMillis)
throws Exception {
Properties poolConfigurationProperties = new Properties();
poolConfigurationProperties.setProperty("username", userName);
poolConfigurationProperties.setProperty("password", password);
poolConfigurationProperties.setProperty("url", url);
poolConfigurationProperties.setProperty("driverClassName", driverClassName);
poolConfigurationProperties.setProperty("maxTotal", maxTotal);
poolConfigurationProperties.setProperty("maxIdle", maxIdle);
poolConfigurationProperties.setProperty("maxWaitMillis", maxWaitMillis);
dataSource = wrapWithTracingIfEnabled(createDataSource(poolConfigurationProperties));
}
@Override
public Object getObjectInstance(
Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
LOG.info(
"This={} obj={} name={} Context={} environment={}", this, obj, name, nameCtx, environment);
return dataSource;
}
/**
* Util method to convert string {@code "NULL"} to null reference. Allows to set string {@code
* "NULL"} as a value of the property instead of making sure it is unset as it is done in {@link
* org.eclipse.che.inject.CheBootstrap}
*
* @param value value to transform if needed
* @return null or passed value
*/
protected static String nullStringToNullReference(String value) {
return "NULL".equals(value) ? null : value;
}
}

View File

@ -1,41 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db;
import com.google.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
/**
* Provides data source based on jndi resource name.
*
* @author Yevhenii Voevodin
*/
public class JndiDataSourceProvider implements Provider<DataSource> {
@Inject
@Named("jndi.datasource.name")
private String name;
@Override
public DataSource get() {
try {
final InitialContext context = new InitialContext();
return (DataSource) context.lookup(name);
} catch (NamingException x) {
throw new IllegalStateException(x.getLocalizedMessage(), x);
}
}
}

View File

@ -1,106 +0,0 @@
/*
* Copyright (c) 2012-2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db;
import com.google.common.annotations.Beta;
import io.opentracing.contrib.jdbc.ConnectionInfo;
import io.opentracing.contrib.jdbc.TracingConnection;
import io.opentracing.contrib.jdbc.parser.URLParser;
import io.opentracing.util.GlobalTracer;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;
import javax.sql.DataSource;
import org.slf4j.LoggerFactory;
/**
* Adding tracing support for existing @{@link javax.sql.DataSource}. DbType and DbUser information
* omitted in traces. Traced are made only if active span exists. Prerequisites of using this class
* is that @{@link io.opentracing.Tracer} should be set in @{@link io.opentracing.util.GlobalTracer}
*
* @author Sergii Kabashniuk
*/
@Beta
public class TracingDataSource implements DataSource {
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(TracingDataSource.class);
private final DataSource delegate;
private final ConnectionInfo connectionInfo;
public TracingDataSource(DataSource delegate) {
this.delegate = delegate;
try (Connection connection = delegate.getConnection()) {
connectionInfo = URLParser.parser(connection.getMetaData().getURL());
LOG.debug(
"URL {} connectionInfo {}",
connection.getMetaData().getURL(),
connectionInfo.getPeerService());
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
@Override
public Connection getConnection() throws SQLException {
return new TracingConnection(
delegate.getConnection(), connectionInfo, true, null, GlobalTracer.get());
}
@Override
public Connection getConnection(String username, String password) throws SQLException {
return new TracingConnection(
delegate.getConnection(username, password), connectionInfo, true, null, GlobalTracer.get());
}
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
return delegate.unwrap(iface);
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return delegate.isWrapperFor(iface);
}
@Override
public PrintWriter getLogWriter() throws SQLException {
return delegate.getLogWriter();
}
@Override
public void setLogWriter(PrintWriter out) throws SQLException {
delegate.setLogWriter(out);
}
@Override
public void setLoginTimeout(int seconds) throws SQLException {
delegate.setLoginTimeout(seconds);
}
@Override
public int getLoginTimeout() throws SQLException {
return delegate.getLoginTimeout();
}
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
return delegate.getParentLogger();
}
public static DataSource wrapWithTracingIfEnabled(DataSource dataSource) {
return Boolean.valueOf(System.getenv("CHE_DB_TRACING_ENABLED"))
? new TracingDataSource(dataSource)
: dataSource;
}
}

View File

@ -1,38 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.cascade;
/**
* Context that is used only for sharing the state of the cascading operation among subscribers.
*
* @author Anton Korneta
* @author Sergii Leshchenko
*/
public class CascadeContext {
private Exception cause;
/** Returns the cause which has changed the state of the context. */
public Exception getCause() {
return cause;
}
/** Returns the state of the context. */
public boolean isFailed() {
return cause != null;
}
/** Sets the context into failed state. */
public CascadeContext fail(Exception cause) {
this.cause = cause;
return this;
}
}

View File

@ -1,45 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.cascade;
import org.eclipse.che.api.core.notification.EventSubscriber;
import org.eclipse.che.core.db.cascade.event.CascadeEvent;
/**
* Receives events and puts exceptions in the context to perform rollback operation if it is
* necessary.
*
* @author Anton Korneta
* @author Sergii Leschenko
*/
public abstract class CascadeEventSubscriber<T extends CascadeEvent> implements EventSubscriber<T> {
@Override
public void onEvent(T event) {
if (!event.getContext().isFailed()) {
try {
onCascadeEvent(event);
} catch (Exception ex) {
event.getContext().fail(ex);
}
}
}
/**
* Receives notification about cascade event.
*
* <p>If the method throws an exception it will be set to context to break event publishing and
* rethrow exception. Event is responsible for rethrowing or wrapping original exception.
*
* @see CascadeEvent#propagateException()
*/
public abstract void onCascadeEvent(T event) throws Exception;
}

View File

@ -1,60 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.cascade.event;
import org.eclipse.che.core.db.cascade.CascadeContext;
/**
* Special event type which is needed only for notification in the process which can require cascade
* operation.
*
* <p>Publisher should invoke {@link #propagateException()} to get cause of event canceling.
*
* <p>Rollback of operation must be performed when subscriber throws {@link Exception} during event
* processing.
*
* <p>Usage example:
*
* <pre>
* EventService bus = new EventService();
* bus.subscribe(new CascadeEventSubscriber&lt;MyEvent&gt;() {
* &#64;Override
* public void onCascadeEvent(MyEvent event) throws Exception {
* if (event.getEntityName().startsWith("reserved")) {
* throw new ConflictException("Entity name can't start with `reserved`.");
* }
* }
* });
* bus.publish(new MyEvent(...)).propagateException();
* </pre>
*
* @author Anton Korneta
* @author Sergii Leschenko
*/
public abstract class CascadeEvent {
protected final CascadeContext context = new CascadeContext();
public CascadeContext getContext() {
return context;
}
/**
* Propagates exception if subscriber throws it while event processing otherwise do nothing
*
* @throws Exception when any subscriber throws {@link Exception}
*/
public void propagateException() throws Exception {
if (context.isFailed()) {
throw context.getCause();
}
}
}

View File

@ -1,38 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.cascade.event;
import org.eclipse.che.api.core.ConflictException;
import org.eclipse.che.api.core.ServerException;
/**
* Cascade event about an entity persisting.
*
* <p>{@link ConflictException} or {@link ServerException} can be rethrown during exception
* propagating.
*
* @author Sergii Leschenko
*/
public abstract class PersistEvent extends CascadeEvent {
@Override
public void propagateException() throws ConflictException, ServerException {
if (context.isFailed()) {
try {
throw context.getCause();
} catch (ConflictException | ServerException e) {
throw e;
} catch (Exception e) {
throw new ServerException(e.getLocalizedMessage(), e);
}
}
}
}

View File

@ -1,36 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.cascade.event;
import org.eclipse.che.api.core.ServerException;
/**
* Cascade event about an entity removing.
*
* <p>{@link ServerException} can be rethrown during exception propagating.
*
* @author Sergii Leschenko
*/
public abstract class RemoveEvent extends CascadeEvent {
@Override
public void propagateException() throws ServerException {
if (context.isFailed()) {
try {
throw context.getCause();
} catch (ServerException e) {
throw e;
} catch (Exception e) {
throw new ServerException(e.getLocalizedMessage(), e);
}
}
}
}

View File

@ -1,39 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.cascade.event;
import org.eclipse.che.api.core.ConflictException;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.ServerException;
/**
* Cascade event about an entity updating.
*
* <p>{@link NotFoundException}, {@link ConflictException} or {@link ServerException} can be
* rethrown during exception propagating.
*
* @author Sergii Leschenko
*/
public abstract class UpdateEvent extends CascadeEvent {
@Override
public void propagateException() throws NotFoundException, ConflictException, ServerException {
if (context.isFailed()) {
try {
throw context.getCause();
} catch (NotFoundException | ConflictException | ServerException e) {
throw e;
} catch (Exception e) {
throw new ServerException(e.getLocalizedMessage(), e);
}
}
}
}

View File

@ -1,34 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.jpa;
import javax.persistence.RollbackException;
import org.eclipse.che.core.db.DBErrorCode;
/**
* Extends the standard {@link RollbackException} with an error code from {@link DBErrorCode}.
*
* @author Yevhenii Voevodin
*/
public class DetailedRollbackException extends RollbackException {
private DBErrorCode code;
public DetailedRollbackException(String message, Throwable cause, DBErrorCode code) {
super(message, cause);
this.code = code;
}
public DBErrorCode getCode() {
return code;
}
}

View File

@ -1,27 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.jpa;
import org.eclipse.che.core.db.DBErrorCode;
/**
* Thrown when data couldn't be updated/stored due to unique constrain violation.
*
* @author Yevhenii Voevodin
* @see DBErrorCode#DUPLICATE_KEY
*/
public class DuplicateKeyException extends DetailedRollbackException {
public DuplicateKeyException(String message, Throwable cause) {
super(message, cause, DBErrorCode.DUPLICATE_KEY);
}
}

View File

@ -1,28 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.jpa;
import org.eclipse.che.core.db.DBErrorCode;
/**
* Throws during inserts/updates entity that restricted by referential integrity and given
* insert/update refers to non-existing entity.
*
* @author Anton Korneta
* @see DBErrorCode#INTEGRITY_CONSTRAINT_VIOLATION
*/
public class IntegrityConstraintViolationException extends DetailedRollbackException {
public IntegrityConstraintViolationException(String message, Throwable cause) {
super(message, cause, DBErrorCode.INTEGRITY_CONSTRAINT_VIOLATION);
}
}

View File

@ -1,27 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.jpa;
import com.google.inject.ImplementedBy;
import org.eclipse.che.core.db.jpa.guice.GuiceJpaInitializer;
/**
* Initializes jpa components.
*
* @author Yevhenii Voevodin
*/
@ImplementedBy(GuiceJpaInitializer.class)
public interface JpaInitializer {
/** Initialized jpa components. */
void init();
}

View File

@ -1,69 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.jpa.eclipselink;
import com.google.inject.Inject;
import com.google.inject.Injector;
import javax.naming.NamingException;
import org.eclipse.persistence.internal.sessions.AbstractSession;
import org.eclipse.persistence.internal.sessions.cdi.InjectionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Allows to use dependency injection in entity listeners.
*
* <p>Example:
*
* <pre>
* class WorkspaceEntityListener {
*
* &#064;Inject EventBus bus; <- EventBus will be injected by Guice
*
* &#064;PreRemove
* public void preRemove(Workspace workspace) {
* bus.post(new BeforeWorkspaceRemovedEvent(workspace));
* }
* }
*
* &#064;Entity
* &#064;EntityListeners(WorkspaceEntityListener.class)
* class Workspace {
* // ...
* }
* </pre>
*
* @author Yevhenii Voevodin
*/
public class GuiceEntityListenerInjectionManager implements InjectionManager {
private static final Logger LOG =
LoggerFactory.getLogger(GuiceEntityListenerInjectionManager.class);
@Inject private Injector injector;
@Override
public Object createManagedBeanAndInjectDependencies(Class entityListenerClass)
throws NamingException {
try {
return injector.getInstance(entityListenerClass);
} catch (RuntimeException x) {
LOG.error(x.getLocalizedMessage(), x);
throw new NamingException(x.getLocalizedMessage());
}
}
@Override
public void cleanUp(AbstractSession session) {
// EntityListener objects are managed by Guice, nothing to cleanup
}
}

View File

@ -1,40 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.jpa.guice;
import com.google.inject.persist.PersistService;
import javax.inject.Inject;
import org.eclipse.che.core.db.jpa.JpaInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Should be bound as eager singleton. See <a
* href="https://github.com/google/guice/wiki/JPA">doc</a>
*
* @author Yevhenii Voevodin
* @author Anton Korneta
*/
public class GuiceJpaInitializer implements JpaInitializer {
private static final Logger LOG = LoggerFactory.getLogger(GuiceJpaInitializer.class);
@Inject private PersistService persistService;
public void init() {
try {
persistService.start();
} catch (Exception x) {
LOG.error(x.getLocalizedMessage(), x);
}
}
}

View File

@ -1,28 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.schema;
/**
* Thrown when any schema initialization/migration problem occurs.
*
* @author Yevhenii Voevodin
*/
public class SchemaInitializationException extends Exception {
public SchemaInitializationException(String message, Throwable cause) {
super(message, cause);
}
public SchemaInitializationException(String message) {
super(message);
}
}

View File

@ -1,31 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.schema;
import java.util.Map;
/**
* Initializes database schema or migrates an old version of it to a new one.
*
* @author Yevhenii Voevodin
*/
public interface SchemaInitializer {
/**
* Initializes database schema or migrates an old schema to a new one.
*
* @return initialization properties
* @throws SchemaInitializationException thrown when any error occurs during schema
* initialization/migration
*/
Map<String, String> init() throws SchemaInitializationException;
}

View File

@ -1,210 +0,0 @@
/*
* Copyright (c) 2012-2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.schema.impl.flyway;
import static java.lang.String.format;
import static java.util.stream.Collectors.toList;
import com.google.common.hash.Hashing;
import com.google.common.io.ByteSource;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.flywaydb.core.api.FlywayException;
import org.flywaydb.core.api.MigrationType;
import org.flywaydb.core.api.MigrationVersion;
import org.flywaydb.core.api.resolver.BaseMigrationResolver;
import org.flywaydb.core.api.resolver.ResolvedMigration;
import org.flywaydb.core.internal.dbsupport.DbSupport;
import org.flywaydb.core.internal.resolver.ResolvedMigrationImpl;
import org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor;
import org.flywaydb.core.internal.util.Location;
import org.flywaydb.core.internal.util.PlaceholderReplacer;
import org.flywaydb.core.internal.util.scanner.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Resolves SQL migrations from the configured locations, allows overriding of default scripts with
* vendor specific ones.
*
* <ul>
* Migration scripts must follow the next rules:
* <li>It must be placed in the project dir directory e.g. <i>5.0.1</i>
* <li>Project dir directory must be placed in dedicated directory e.g. <i>resources/sql</i>
* <li>Migration/Initialization script name must start with a number e.g <i>1.init.sql</i>, this
* number indicates the subversion of the database migration, e.g. for dir <i>5.0.0</i> and
* migration script <i>1.init.sql</i> database migration dir will be <i>5.0.0.1</i>
* <li>If a file is not a part of migration it shouldn't end with migration prefix e.g.
* <i>.sql</i> then resolver will ignore it
* </ul>
*
* <p>For the structure:
*
* <pre>
* resources/
* sql/
* 5.0.0/
* 1.init.sql
* 5.0.0-M1/
* 1.rename_fields.sql
* 2.add_workspace_constraint.sql
* postgresql/
* 2.add_workspace_constraint.sql
* 5.0.1/
* 1.stacks_migration.sql
* </pre>
*
* And configuration:
*
* <pre>
* prefix - ""
* suffix - ".sql"
* separator - "."
* locations - "classpath:sql"
* </pre>
*
* <ul>
* 4 database migrations will be resolved
* <li>5.0.0.1 - initialization script based on file <i>sql/5.0.0/1.init.sql</i>
* <li>5.0.0.1.1 - modification script based on file <i>sql/5.0.0-M1/1.rename_fields.sql</i>
* <li>5.0.0.1.2 - modification script(if postgresql is current provider) based on file
* <i>sql/5.0.0-M1/postgresql/2.add_workspace_constraint.sql</i>
* <li>5.0.1.1 - modification script based on file <i>sql/5.0.1/1.stacks_migrations.sql</i>
* </ul>
*
* <p>It is also possible to configure several locations then all of those locations will be
* analyzed for migration scripts existence. For example:
*
* <p>For the structure:
*
* <pre>
* che/
* resources/
* che-schema/
* 5.0.0/
* 1.init.sql
* another-project/
* resources/
* custom-schema/
* 5.0.0/
* 2.init_additional_tables.sql
* </pre>
*
* And configuration:
*
* <pre>
* prefix - ""
* suffix - ".sql"
* separator - "."
* locations - "classpath:che-schema, classpath:custom-schema"
* </pre>
*
* <ul>
* 2 database migrations will be resolved
* <li>5.0.0.1 - initialization script based on file <i>che-schema/5.0.0/1.init.sql</i>
* <li>5.0.0.2 - modification script based on file
* <i>custom-schema/5.0.0/2.init_additional_tables.sql</i>
* </ul>
*
* @author Yevhenii Voevodin
*/
public class CustomSqlMigrationResolver extends BaseMigrationResolver {
private static final Logger LOG = LoggerFactory.getLogger(CustomSqlMigrationResolver.class);
private final String vendorName;
private final ResourcesFinder finder;
private final VersionResolver versionResolver;
private final SqlScriptCreator scriptsCreator;
private final DbSupport dbSupport;
private final PlaceholderReplacer placeholderReplacer;
public CustomSqlMigrationResolver(
String dbProviderName, DbSupport dbSupport, PlaceholderReplacer placeholderReplacer) {
this.vendorName = dbProviderName;
this.dbSupport = dbSupport;
this.placeholderReplacer = placeholderReplacer;
this.finder = new ResourcesFinder();
this.versionResolver = new VersionResolver();
this.scriptsCreator = new SqlScriptCreator();
}
@Override
public Collection<ResolvedMigration> resolveMigrations() {
try {
return resolveSqlMigrations();
} catch (IOException | SQLException x) {
throw new RuntimeException(x.getLocalizedMessage(), x);
}
}
private List<ResolvedMigration> resolveSqlMigrations() throws IOException, SQLException {
LOG.info(
"Searching for SQL scripts in locations {}",
Arrays.toString(flywayConfiguration.getLocations()));
final Map<Location, List<Resource>> allResources = finder.findResources(flywayConfiguration);
LOG.debug("Found scripts: {}", allResources);
final Map<String, Map<String, SqlScript>> scriptsInDir = new HashMap<>();
for (Location location : allResources.keySet()) {
final List<Resource> resources = allResources.get(location);
for (Resource resource : resources) {
final SqlScript newScript = scriptsCreator.createScript(location, resource);
if (!scriptsInDir.containsKey(newScript.dir)) {
scriptsInDir.put(newScript.dir, new HashMap<>(4));
}
final Map<String, SqlScript> existingScripts = scriptsInDir.get(newScript.dir);
final SqlScript existingScript = existingScripts.get(newScript.name);
if (existingScript == null) {
existingScripts.put(newScript.name, newScript);
} else if (Objects.equals(existingScript.vendor, newScript.vendor)) {
throw new FlywayException(
format(
"More than one script with name '%s' is registered for "
+ "database vendor '%s', script '%s' conflicts with '%s'",
newScript.name, existingScript.vendor, newScript, existingScript));
} else if (vendorName.equals(newScript.vendor)) {
existingScripts.put(newScript.name, newScript);
}
}
}
final Map<MigrationVersion, ResolvedMigration> migrations = new HashMap<>();
for (SqlScript script :
scriptsInDir.values().stream()
.flatMap(scripts -> scripts.values().stream())
.collect(toList())) {
final ResolvedMigrationImpl migration = new ResolvedMigrationImpl();
migration.setVersion(versionResolver.resolve(script, flywayConfiguration));
migration.setScript(script.resource.getLocation());
migration.setPhysicalLocation(script.resource.getLocationOnDisk());
migration.setType(MigrationType.SQL);
migration.setDescription(script.name);
migration.setChecksum(
ByteSource.wrap(script.resource.loadAsBytes()).hash(Hashing.crc32()).asInt());
migration.setExecutor(
new SqlMigrationExecutor(
dbSupport, script.resource, placeholderReplacer, flywayConfiguration));
if (migrations.put(migration.getVersion(), migration) != null) {
throw new FlywayException("Two migrations with the same version detected");
}
}
return new ArrayList<>(migrations.values());
}
}

View File

@ -1,122 +0,0 @@
/*
* Copyright (c) 2012-2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.schema.impl.flyway;
import static org.eclipse.che.core.db.DBInitializer.BARE_DB_INIT_PROPERTY_NAME;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
import javax.sql.DataSource;
import org.eclipse.che.core.db.schema.SchemaInitializationException;
import org.eclipse.che.core.db.schema.SchemaInitializer;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.internal.dbsupport.DbSupport;
import org.flywaydb.core.internal.dbsupport.DbSupportFactory;
import org.flywaydb.core.internal.metadatatable.MetaDataTable;
import org.flywaydb.core.internal.metadatatable.MetaDataTableImpl;
import org.flywaydb.core.internal.util.PlaceholderReplacer;
/**
* <a href="https://flywaydb.org/">Flyway</a> based schema initializer.
*
* @author Yevhenii Voevodin
*/
public class FlywaySchemaInitializer implements SchemaInitializer {
private final DataSource dataSource;
private final String[] locations;
private final String scriptsPrefix;
private final String scriptsSuffix;
private final String versionSeparator;
private final boolean baselineOnMigrate;
private final String baselineVersion;
private final PlaceholderReplacer placeholderReplacer;
/**
* Creates a new instance of flyway schema initializer.
*
* @param scriptsLocations the locations where to search migration scripts, if locations is not
* prefixed or prefixed with <i>classpath:</i> then initializer will try to find scripts in
* classpath using {@code Thread.currentThread().}{@link Thread#getContextClassLoader()
* getContextClassLoader()}
* @param scriptsPrefix prefix of migration scripts e.g. 'v' or empty string
* @param scriptsSuffix suffix of migration scripts e.g. '.sql'
* @param versionSeparator separate version from the other part of script name e.g. '.' or '__'
* @param baselineOnMigrate whether to ignore scripts up to the version configured by {@code
* baselineVersion}
* @param baselineVersion up to this version all the scripts ignored, unless schema is initialized
* first time, note that scripts with version equal to baseline version are also ignored
* @param dataSource data source used for migrations
* @param placeholderReplacer used to replace variables in script with configured values
*/
@Inject
public FlywaySchemaInitializer(
@Named("db.schema.flyway.scripts.locations") String[] scriptsLocations,
@Named("db.schema.flyway.scripts.prefix") String scriptsPrefix,
@Named("db.schema.flyway.scripts.suffix") String scriptsSuffix,
@Named("db.schema.flyway.scripts.version_separator") String versionSeparator,
@Named("db.schema.flyway.baseline.enabled") boolean baselineOnMigrate,
@Named("db.schema.flyway.baseline.version") String baselineVersion,
DataSource dataSource,
PlaceholderReplacer placeholderReplacer) {
this.dataSource = dataSource;
this.locations = scriptsLocations;
this.scriptsPrefix = scriptsPrefix;
this.scriptsSuffix = scriptsSuffix;
this.versionSeparator = versionSeparator;
this.baselineOnMigrate = baselineOnMigrate;
this.baselineVersion = baselineVersion;
this.placeholderReplacer = placeholderReplacer;
}
/** Creates a new flyway based initializer with default values. */
public FlywaySchemaInitializer(DataSource dataSource, String... locations) {
this(locations, "", ".sql", "__", false, "", dataSource, PlaceholderReplacer.NO_PLACEHOLDERS);
}
@Override
public Map<String, String> init() throws SchemaInitializationException {
final Map<String, String> initResult = new HashMap<>();
try (final Connection conn = dataSource.getConnection()) {
final Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations(locations);
flyway.setClassLoader(Thread.currentThread().getContextClassLoader());
final DbSupport dbSupport = DbSupportFactory.createDbSupport(conn, true);
final MetaDataTable mt =
new MetaDataTableImpl(
dbSupport,
dbSupport.getOriginalSchema().getTable(flyway.getTable()),
flyway.getInstalledBy());
initResult.put(BARE_DB_INIT_PROPERTY_NAME, String.valueOf(!mt.hasAppliedMigrations()));
final String productName = conn.getMetaData().getDatabaseProductName().toLowerCase();
flyway.setResolvers(
new CustomSqlMigrationResolver(productName, dbSupport, placeholderReplacer));
flyway.setSkipDefaultResolvers(true);
flyway.setBaselineOnMigrate(baselineOnMigrate);
if (baselineOnMigrate) {
flyway.setBaselineVersionAsString(baselineVersion);
}
flyway.setSqlMigrationSeparator(versionSeparator);
flyway.setSqlMigrationSuffix(scriptsSuffix);
flyway.setSqlMigrationPrefix(scriptsPrefix);
flyway.migrate();
} catch (SQLException | RuntimeException x) {
throw new SchemaInitializationException(x.getLocalizedMessage(), x);
}
return initResult;
}
}

View File

@ -1,37 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.schema.impl.flyway;
import javax.inject.Inject;
import javax.inject.Provider;
import org.eclipse.che.inject.ConfigurationProperties;
import org.flywaydb.core.internal.util.PlaceholderReplacer;
/**
* Placeholder replacer that uses configuration properties.
*
* @author Yevhenii Voevodin
*/
public class PlaceholderReplacerProvider implements Provider<PlaceholderReplacer> {
private final PlaceholderReplacer replacer;
@Inject
public PlaceholderReplacerProvider(ConfigurationProperties properties) {
replacer = new PlaceholderReplacer(properties.getProperties(".*"), "${", "}");
}
@Override
public PlaceholderReplacer get() {
return replacer;
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.schema.impl.flyway;
import static com.google.common.collect.Lists.newArrayList;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.flywaydb.core.api.configuration.FlywayConfiguration;
import org.flywaydb.core.internal.util.Location;
import org.flywaydb.core.internal.util.scanner.Resource;
import org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner;
import org.flywaydb.core.internal.util.scanner.filesystem.FileSystemScanner;
/**
* Searches for sql scripts in given places.
*
* @author Yevhenii Voevodin
*/
class ResourcesFinder {
/**
* Finds script resources in configured {@link FlywayConfiguration#getLocations()}.
*
* @param configuration flyway configuration to find scripts
* @return found scripts or an empty list if nothing found
* @throws IOException when any io error occurs during scripts look up
*/
Map<Location, List<Resource>> findResources(FlywayConfiguration configuration)
throws IOException {
final String prefix = configuration.getSqlMigrationPrefix();
final String suffix = configuration.getSqlMigrationSuffix();
final ClassPathScanner cpScanner = new ClassPathScanner(configuration.getClassLoader());
final FileSystemScanner fsScanner = new FileSystemScanner();
final Map<Location, List<Resource>> resources = new HashMap<>();
for (String rawLocation : configuration.getLocations()) {
final Location location = new Location(rawLocation);
if (location.isClassPath()) {
resources.put(location, newArrayList(cpScanner.scanForResources(location, prefix, suffix)));
} else {
resources.put(location, newArrayList(fsScanner.scanForResources(location, prefix, suffix)));
}
}
return resources;
}
}

View File

@ -1,84 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.schema.impl.flyway;
import java.util.Objects;
import org.flywaydb.core.internal.util.Location;
import org.flywaydb.core.internal.util.scanner.Resource;
/**
* Data object for holding information about sql script.
*
* @author Yevhenii Voevodin
*/
class SqlScript {
final Resource resource;
final Location location;
final String dir;
final String vendor;
final String name;
SqlScript(Resource resource, Location location, String dir, String vendor, String name) {
this.resource = resource;
this.location = location;
this.name = name;
this.vendor = vendor;
this.dir = dir;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof SqlScript)) {
return false;
}
final SqlScript that = (SqlScript) obj;
return Objects.equals(resource, that.resource)
&& Objects.equals(location, that.location)
&& Objects.equals(dir, that.dir)
&& Objects.equals(vendor, that.vendor)
&& Objects.equals(name, that.name);
}
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + Objects.hashCode(resource);
hash = 31 * hash + Objects.hashCode(location);
hash = 31 * hash + Objects.hashCode(dir);
hash = 31 * hash + Objects.hashCode(vendor);
hash = 31 * hash + Objects.hashCode(name);
return hash;
}
@Override
public String toString() {
return "SqlScript{"
+ "resource="
+ resource
+ ", location="
+ location
+ ", dir='"
+ dir
+ '\''
+ ", vendor='"
+ vendor
+ '\''
+ ", name='"
+ name
+ '\''
+ '}';
}
}

View File

@ -1,55 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.db.schema.impl.flyway;
import static java.lang.String.format;
import java.io.File;
import org.flywaydb.core.api.FlywayException;
import org.flywaydb.core.internal.util.Location;
import org.flywaydb.core.internal.util.scanner.Resource;
/**
* Creates new {@link SqlScript} instance from given resource.
*
* @author Yevhenii Voevodin
*/
class SqlScriptCreator {
/**
* Create a new instance of script based on location and resource.
*
* @param location root location of the given resource
* @param resource script resource
* @return a new instance of sql script based on location and resource
* @throws FlywayException when script can't be created from the resource
*/
SqlScript createScript(Location location, Resource resource) {
final String separator = location.isClassPath() ? "/" : File.separator;
// '/root-location/5.0.0-M7/v1__init.sql' -> '5.0.0-M7/v1__init.sql'
final String relLocation = resource.getLocation().substring(location.getPath().length() + 1);
final String[] paths = relLocation.split(separator);
// 5.0.0-M1/v1__init.sql
if (paths.length == 2) {
return new SqlScript(resource, location, paths[0], null, paths[1]);
}
// 5.0.0-M1/postgresql/v1__init.sql
if (paths.length == 3) {
return new SqlScript(resource, location, paths[0], paths[1], paths[2]);
}
throw new FlywayException(
format(
"Sql script location must be either in 'location-root/version-dir' "
+ "or in 'location-root/version-dir/provider-name', but script '%s' is not in root '%s'",
resource.getLocation(), location.getPath()));
}
}

Some files were not shown because too many files have changed in this diff Show More