Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(rest.packages.provider): add endpoint for Package Descriptor retrieval #4934

Merged

Conversation

mattdibi
Copy link
Contributor

@mattdibi mattdibi commented Oct 30, 2023

This PR follows #4894 and adds the endpoint for Eclipse Marketplace's Package Descriptor retrieval.

Can be tested using:

export ADDRESS=<addr>
export USERNAME=<user>
export PASSWORD=<pass>

and then:

curl -X PUT -k -u $USERNAME:$PASSWORD \
       -H 'Content-Type: application/json' \
       -d '{ "url": "http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=5514714" }' \
       https://$ADDRESS/services/deploy/v2/_packageDescriptor

Roadmap:

Changelog

I mainly repurposed the code in:

Creating a new POJO (i.e. MarketplacePackageDescriptor) for representing the info contained in the downloaded descriptor and basically using everything in the rest.packages.provider.

@mattdibi
Copy link
Contributor Author

Setting this as ready for review since the only thing missing are tests at this point

@mattdibi mattdibi marked this pull request as ready for review October 31, 2023 13:58
@mattdibi mattdibi force-pushed the refactor/deployment_packages_download branch from e89e70e to 4988ad4 Compare October 31, 2023 13:59
@mattdibi mattdibi requested a review from nicolatimeus October 31, 2023 15:34
@mattdibi

This comment was marked as outdated.

@nicolatimeus
Copy link
Contributor


mpUrl = new URL(String.format(MARKETPLACE_URL, nodeId));
connection = (HttpsURLConnection) mpUrl.openConnection();
connection.setSSLSocketFactory(this.sslManagerService.getSSLSocketFactory());
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently the console has a configuration property that allows to specify the SslManagerService that is used to fetch deployment packages from the marketlplace, this change would make it use the SslManagerService configured in the deployment agent instead.. We could add another getMarketplacePackageDescriptor(String, SslManagerService) to the DeploymentAgent that allows to specify the SslManagerService to restore the old behaviour

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 08eca41

@nicolatimeus
Copy link
Contributor

Please also update copyright headers in all changed files

@nicolatimeus
Copy link
Contributor

Please update the exported package version to 1.1.0 here https://github.com/mattdibi/kura/blob/73adee3550e2d4febf49bfe16abe7207aa4078dc/kura/org.eclipse.kura.deployment.agent/META-INF/MANIFEST.MF#L9

We should also update the import declarations of this package to use version range [1.1,2.0) in the bundles that use the new methods (console)

@mattdibi
Copy link
Contributor Author

Please update the exported package version to 1.1.0 here https://github.com/mattdibi/kura/blob/73adee3550e2d4febf49bfe16abe7207aa4078dc/kura/org.eclipse.kura.deployment.agent/META-INF/MANIFEST.MF#L9

Addressed in d0dee4c

We should also update the import declarations of this package to use version range [1.1,2.0) in the bundles that use the new methods (console)

Addressed in d0dee4c

Please also update copyright headers in all changed files

Addressed in 98cbbaa

@mattdibi mattdibi force-pushed the refactor/deployment_packages_download branch from e2ccf4e to 91545f5 Compare November 10, 2023 11:22
@mattdibi
Copy link
Contributor Author

Update to mockserver v 5.15.0. Newly added dependency is ✅

echo "maven/mavencentral/org.mock-server/mockserver-netty-no-dependencies/5.15.0" | java -jar ~/Downloads/org.eclipse.dash.licenses-1.0.3-20231111.065112-172.jar -
[main] INFO Querying Eclipse Foundation for license data for 1 items.
[main] INFO Found 1 items.
[main] INFO Vetted license information was found for all content. No further investigation is required.
echo "maven/mavencentral/org.mock-server/mockserver-client-java-no-dependencies/5.15.0" | java -jar ~/Downloads/org.eclipse.dash.licenses-1.0.3-20231111.065112-172.jar -
[main] INFO Querying Eclipse Foundation for license data for 1 items.
[main] INFO Found 1 items.
[main] INFO Vetted license information was found for all content. No further investigation is required.
maven/mavencentral/org.mock-server/mockserver-client-java-no-dependencies/5.15.0, Apache-2.0 AND LGPL-3.0-only, approved, #11514
maven/mavencentral/org.mock-server/mockserver-netty-no-dependencies/5.15.0, Apache-2.0 AND LGPL-3.0-only AND OFL-1.1 AND (BSD-3-Clause AND MIT), approved, #11515

See:

@mattdibi mattdibi merged commit 5b7b71c into eclipse-kura:develop Nov 13, 2023
@mattdibi mattdibi deleted the refactor/deployment_packages_download branch November 13, 2023 10:04
Copy link
Contributor

The backport to release-5.4.0 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-release-5.4.0 release-5.4.0
# Navigate to the new working tree
cd .worktrees/backport-release-5.4.0
# Create a new branch
git switch --create backport-4934-to-release-5.4.0
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 5b7b71cd83bbfb37209e39998bde732916586fe3
# Push it to GitHub
git push --set-upstream origin backport-4934-to-release-5.4.0
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-release-5.4.0

Then, create a pull request where the base branch is release-5.4.0 and the compare/head branch is backport-4934-to-release-5.4.0.

mattdibi added a commit that referenced this pull request Nov 13, 2023
…rieval (#4934)

* feat: add MarketplacePackageDescriptor.java

* feat: add barebone getMarketplacePackageDescriptor method implementation

WIP

* feat: add getMarketplacePackageDescriptor to DeploymentAgentService interface

* feat: add isEclipseMarketplaceUrl check

WIP

* style: fix variable name

* feat: add quick&dirty descriptor check endpoint

STILL WIP: we should at least have a dedicated request type instead of
recycling InstallRequest

* feat: return json object

* debug: add debugging log

* feat: actually perform check on input url

* feat: add proper Kura version retrival

* refactor: move instantiation

* refactor: use proper exceptions

* style: add copyright header

* feat: use QueryParam for passing the URL to be checked

* feat: provide equals and hashCode overrides

* fix: do not log user-controlled data

* fix: replace character class by the character itself

* test: add unit tests for MarketplacePackageDescriptor

* style: add copyright header

* style: refactor into gerkhin style

* refactor: move given/when/then methods in their sections

* refactor: use the builder for gods sake

* style: add forgotten about files

* test: add DeploymentRestServiceUnitTest for marketplace descriptor

* refactor: move URL checks outside DeploymentAgentService to allow for testing

* test: update unit tests

* refactor: move method into its section

* test: add integration tests

* fix: remove commented out code

* test: add some more tests

* test: add test case for failing getMarketplacePackageDescriptor call

* docs: add Javadocs for DeploymentRestService

* docs: add javadocs for DeploymentAgentService

* test: add DeploymentAgentTest:getMarketplacePackageDescriptor tests (#11)

* ci(debug): set envvar to run testcontainers with podman

* refactor: user raw Mockserver instead of going through Testcontainers

* refactor: remove unnecessary dependencies

* ci: roll-back changes

* test: use random free port

* test: add null URL test

* test: reset MockServer status after each test

* feat: GET -> PUT

* test: GET -> PUT

* refactor(web2): modify UI so that it uses the newly introduced method

* build: downgrade mockserver 5.15.0 -> 5.14.0

* build: I'm a dum dum

* docs: add "since" annotation for newly introduced method

* style: update copyright headers

* chore: deployment agent service version bump to 1.1.0

* feat: add method for overriding SslManagerService used to establish connection

* style: restore formatting

* style: update copyright headers

* style: update copyright header

* build: switched to mockserver v 5.15.0

* docs: remove newly added test deps from NOTICE file
mattdibi added a commit that referenced this pull request Nov 13, 2023
…rieval [backport release-5.4.0] (#4968)

feat(rest.packages.provider): add endpoint for Package Descriptor retrieval (#4934)

* feat: add MarketplacePackageDescriptor.java

* feat: add barebone getMarketplacePackageDescriptor method implementation

WIP

* feat: add getMarketplacePackageDescriptor to DeploymentAgentService interface

* feat: add isEclipseMarketplaceUrl check

WIP

* style: fix variable name

* feat: add quick&dirty descriptor check endpoint

STILL WIP: we should at least have a dedicated request type instead of
recycling InstallRequest

* feat: return json object

* debug: add debugging log

* feat: actually perform check on input url

* feat: add proper Kura version retrival

* refactor: move instantiation

* refactor: use proper exceptions

* style: add copyright header

* feat: use QueryParam for passing the URL to be checked

* feat: provide equals and hashCode overrides

* fix: do not log user-controlled data

* fix: replace character class by the character itself

* test: add unit tests for MarketplacePackageDescriptor

* style: add copyright header

* style: refactor into gerkhin style

* refactor: move given/when/then methods in their sections

* refactor: use the builder for gods sake

* style: add forgotten about files

* test: add DeploymentRestServiceUnitTest for marketplace descriptor

* refactor: move URL checks outside DeploymentAgentService to allow for testing

* test: update unit tests

* refactor: move method into its section

* test: add integration tests

* fix: remove commented out code

* test: add some more tests

* test: add test case for failing getMarketplacePackageDescriptor call

* docs: add Javadocs for DeploymentRestService

* docs: add javadocs for DeploymentAgentService

* test: add DeploymentAgentTest:getMarketplacePackageDescriptor tests (#11)

* ci(debug): set envvar to run testcontainers with podman

* refactor: user raw Mockserver instead of going through Testcontainers

* refactor: remove unnecessary dependencies

* ci: roll-back changes

* test: use random free port

* test: add null URL test

* test: reset MockServer status after each test

* feat: GET -> PUT

* test: GET -> PUT

* refactor(web2): modify UI so that it uses the newly introduced method

* build: downgrade mockserver 5.15.0 -> 5.14.0

* build: I'm a dum dum

* docs: add "since" annotation for newly introduced method

* style: update copyright headers

* chore: deployment agent service version bump to 1.1.0

* feat: add method for overriding SslManagerService used to establish connection

* style: restore formatting

* style: update copyright headers

* style: update copyright header

* build: switched to mockserver v 5.15.0

* docs: remove newly added test deps from NOTICE file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants