├── .circleci ├── .maven.xml ├── circleci-readme.md └── config.yml ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── CONTRIBUTORS.md ├── Dockerfile ├── LICENSE.txt ├── README.md ├── header.txt ├── headers.sh ├── nexus-repository-helm-it ├── pom.xml └── src │ └── test │ ├── java │ └── org │ │ └── sonatype │ │ └── nexus │ │ └── plugins │ │ └── helm │ │ ├── HelmITConfig.java │ │ ├── internal │ │ ├── HelmClient.java │ │ ├── HelmHostedIT.java │ │ ├── HelmITSupport.java │ │ ├── HelmProxyIT.java │ │ ├── HelmRoutingRuleIT.java │ │ ├── cleanup │ │ │ └── CleanupTaskHelmIT.java │ │ ├── content │ │ │ ├── HelmClient.java │ │ │ ├── HelmContentHostedIT.java │ │ │ ├── HelmContentITSupport.java │ │ │ ├── HelmContentProxyIT.java │ │ │ └── fixtures │ │ │ │ ├── HelmRepoRecipes.groovy │ │ │ │ └── RepositoryRuleHelm.groovy │ │ ├── fixtures │ │ │ ├── HelmRepoRecipes.groovy │ │ │ └── RepositoryRuleHelm.groovy │ │ └── restore │ │ │ └── HelmRestoreBlobIT.java │ │ └── rest │ │ ├── HelmResourceIT.java │ │ └── ResourceITSupport.java │ └── resources │ └── helm │ ├── index.yaml │ ├── mongodb-4.0.4.tgz │ ├── mongodb-6.0.0.tgz │ └── mongodb-7.2.8.tgz ├── nexus-repository-helm ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── sonatype │ │ │ └── repository │ │ │ └── helm │ │ │ ├── HelmAttributes.java │ │ │ ├── HelmRestoreFacet.java │ │ │ ├── HelmUploadHandlerSupport.java │ │ │ ├── api │ │ │ ├── HelmHostedRepositoryApiRequest.java │ │ │ └── HelmProxyRepositoryApiRequest.java │ │ │ ├── internal │ │ │ ├── AssetKind.java │ │ │ ├── HelmFormat.java │ │ │ ├── HelmRecipeSupport.groovy │ │ │ ├── cleanup │ │ │ │ └── HelmCleanupPolicyConfiguration.java │ │ │ ├── content │ │ │ │ ├── HelmContentFacet.java │ │ │ │ ├── HelmUploadHandler.java │ │ │ │ ├── browse │ │ │ │ │ ├── HelmBrowseModule.java │ │ │ │ │ ├── HelmBrowseNodeDAO.java │ │ │ │ │ └── HelmBrowseNodeGenerator.java │ │ │ │ ├── createindex │ │ │ │ │ ├── CreateIndexFacetImpl.java │ │ │ │ │ ├── CreateIndexService.java │ │ │ │ │ └── CreateIndexServiceImpl.java │ │ │ │ ├── metadata │ │ │ │ │ └── IndexYamlAbsoluteUrlRewriter.java │ │ │ │ ├── package-info.java │ │ │ │ ├── recipe │ │ │ │ │ ├── HelmContentFacetImpl.java │ │ │ │ │ ├── HelmHostedFacet.java │ │ │ │ │ ├── HelmHostedFacetImpl.java │ │ │ │ │ ├── HelmHostedRecipe.groovy │ │ │ │ │ ├── HelmProxyFacet.java │ │ │ │ │ ├── HelmProxyRecipe.groovy │ │ │ │ │ └── HostedHandlers.java │ │ │ │ └── store │ │ │ │ │ ├── HelmAssetBlobDAO.java │ │ │ │ │ ├── HelmAssetDAO.java │ │ │ │ │ ├── HelmComponentDAO.java │ │ │ │ │ ├── HelmContentRepositoryDAO.java │ │ │ │ │ └── HelmStoreModule.java │ │ │ ├── createindex │ │ │ │ ├── CreateIndexFacet.java │ │ │ │ └── HelmIndexInvalidationEvent.java │ │ │ ├── database │ │ │ │ └── HelmProperties.java │ │ │ ├── metadata │ │ │ │ ├── ChartEntry.java │ │ │ │ ├── ChartIndex.java │ │ │ │ ├── IndexYamlAbsoluteUrlRewriter.java │ │ │ │ └── IndexYamlAbsoluteUrlRewriterSupport.java │ │ │ ├── orient │ │ │ │ ├── HelmComponentDirector.java │ │ │ │ ├── HelmComponentMaintenanceFacet.java │ │ │ │ ├── HelmFacet.java │ │ │ │ ├── HelmFacetImpl.java │ │ │ │ ├── HelmUploadHandler.java │ │ │ │ ├── createindex │ │ │ │ │ ├── CreateIndexFacetImpl.java │ │ │ │ │ ├── CreateIndexService.java │ │ │ │ │ └── CreateIndexServiceImpl.java │ │ │ │ ├── hosted │ │ │ │ │ ├── HelmHostedFacet.java │ │ │ │ │ ├── HelmHostedFacetImpl.java │ │ │ │ │ ├── HelmHostedRecipe.groovy │ │ │ │ │ ├── HelmHostedWritePolicySelector.java │ │ │ │ │ └── HostedHandlers.java │ │ │ │ ├── metadata │ │ │ │ │ └── IndexYamlBuilder.java │ │ │ │ ├── package-info.java │ │ │ │ ├── proxy │ │ │ │ │ ├── HelmProxyFacetImpl.java │ │ │ │ │ └── HelmProxyRecipe.groovy │ │ │ │ └── restore │ │ │ │ │ └── HelmRestoreFacetImpl.java │ │ │ ├── security │ │ │ │ ├── HelmFormatSecurityContributor.java │ │ │ │ └── HelmSecurityFacet.java │ │ │ ├── ui │ │ │ │ └── UiPluginDescriptorImpl.java │ │ │ └── util │ │ │ │ ├── HelmAttributeParser.java │ │ │ │ ├── HelmPathUtils.java │ │ │ │ ├── ProvenanceParser.java │ │ │ │ ├── TgzParser.java │ │ │ │ └── YamlParser.java │ │ │ └── rest │ │ │ ├── HelmHostedRepositoriesApiResource.java │ │ │ ├── HelmHostedRepositoriesApiResourceBeta.java │ │ │ ├── HelmHostedRepositoriesApiResourceV1.java │ │ │ ├── HelmProxyRepositoriesApiResource.java │ │ │ ├── HelmProxyRepositoriesApiResourceBeta.java │ │ │ └── HelmProxyRepositoriesApiResourceV1.java │ └── resources │ │ └── static │ │ └── rapture │ │ ├── NX │ │ └── helm │ │ │ ├── app │ │ │ ├── PluginConfig.js │ │ │ └── PluginStrings.js │ │ │ ├── controller │ │ │ └── SearchHelm.js │ │ │ ├── util │ │ │ └── HelmRepositoryUrls.js │ │ │ └── view │ │ │ └── repository │ │ │ └── recipe │ │ │ ├── HelmHosted.js │ │ │ └── HelmProxy.js │ │ └── resources │ │ └── nexus-repository-helm-debug.css │ └── test │ ├── java │ └── org │ │ └── sonatype │ │ └── repository │ │ └── helm │ │ └── internal │ │ ├── HelmAssetAttributePopulatorTest.java │ │ ├── HelmFormatTest.java │ │ ├── HelmListTestHelper.java │ │ ├── HelmRecipeTest.java │ │ ├── content │ │ └── createindex │ │ │ └── CreateIndexServiceImplTest.java │ │ ├── metadata │ │ └── ChartIndexTest.java │ │ ├── orient │ │ ├── ComponentDirectorTest.java │ │ ├── createindex │ │ │ └── CreateIndexServiceImplTest.java │ │ └── metadata │ │ │ ├── IndexYamlAbsoluteUrlRewriterTest.java │ │ │ └── IndexYamlBuilderTest.java │ │ ├── security │ │ └── HelmSecurityFacetTest.java │ │ └── util │ │ ├── HelmAttributeParserTest.java │ │ ├── HelmPathUtilsTest.java │ │ ├── ProvenanceParserTest.java │ │ ├── TgzParserTest.java │ │ └── YamlParserTest.java │ └── resources │ └── org │ └── sonatype │ └── repository │ └── helm │ └── internal │ ├── orient │ └── metadata │ │ ├── index.yaml │ │ ├── indexWithCustomUrls.yaml │ │ └── indexWithRelativeUrls.yaml │ └── util │ ├── Chart.yaml │ ├── Chart.yml │ ├── indexresult.yaml │ ├── mongodb-0.4.9.tgz │ ├── mongodb-4.0.4.tgz │ ├── moodle-0.1.4.tgz │ ├── mysql-1.4.0.tgz.prov │ └── mysql_negative-1.4.0.tgz ├── nexus-restore-helm ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── sonatype │ │ └── nexus │ │ └── blobstore │ │ └── restore │ │ └── helm │ │ └── internal │ │ ├── HelmRestoreBlobData.java │ │ └── HelmRestoreBlobStrategy.java │ └── test │ └── java │ └── org │ └── sonatype │ └── nexus │ └── blobstore │ └── restore │ └── helm │ └── internal │ └── HelmRestoreBlobStrategyTest.java └── pom.xml /.circleci/.maven.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | rso 7 | ${env.SONATYPE_USERNAME} 8 | ${env.SONATYPE_PASSWORD} 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.circleci/circleci-readme.md: -------------------------------------------------------------------------------- 1 | CI Debug Notes 2 | ================ 3 | To validate some circleci stuff, I was able to run a “build locally” using the steps below. 4 | The local build runs in a docker container. 5 | 6 | * (Once) Install circleci client (`brew install circleci`) 7 | 8 | * Convert the “real” config.yml into a self contained (non-workspace) config via: 9 | 10 | circleci config process .circleci/config.yml > .circleci/local-config.yml 11 | 12 | * Run a local build with the following command: 13 | 14 | circleci local execute -c .circleci/local-config.yml --job 'github-maven-deploy/build-and-test' 15 | 16 | With the above command, operations that cannot occur during a local build will show an error like this: 17 | 18 | ``` 19 | ... Error: FAILED with error not supported 20 | ``` 21 | 22 | However, the build will proceed and can complete “successfully”, which allows you to verify scripts in your config, etc. 23 | 24 | If the build does complete successfully, you should see a happy yellow `Success!` message. 25 | 26 | Miscellaneous 27 | ------------- 28 | 29 | * Write Key setup 30 | 31 | To allow your CI build to push changes back to github (e.g. release tags, etc), you need to create 32 | a github **Deploy Key** with **write** access. The command below will create such a key. Use an empty password. 33 | See: [CircleCI-Add ssh key](https://circleci.com/docs/2.0/add-ssh-key/#steps) for more details. 34 | 35 | 1. Generate a new ssh key: 36 | 37 | ssh-keygen -m PEM -t rsa -b 4096 -C "community-group@sonatype.com" -f _github_rsa.key 38 | 39 | 2. Copy the public key to your clipboard: 40 | 41 | cat _github_rsa.key.pub | pbcopy 42 | 43 | Paste the public key into a new **write** enabled **GitHub deploy key** with Title: `CircleCI Write ` 44 | 45 | Be sure you check the "Allow write access" option. 46 | Did I mention this key needs write access? (Don't ask how many times I forgot this). 47 | 48 | 3. Copy the private key to your clipboard: 49 | 50 | cat _github_rsa.key | pbcopy 51 | 52 | In the CircleCI Web UI, under Project Settings (top right gear) -> SSH Keys -> Additional SSH Keys -> Add SSH Key, 53 | enter "Hostname": `github.com` 54 | 55 | Paste the private key. 56 | 57 | As a sanity check, the private key should end with `-----END RSA PRIVATE KEY-----`. 58 | 59 | 4. Update the `ssh-fingerprints:` tag in your [config.yml](config.yml) to the fingerprint of the write key. 60 | This fingerprint is visible in the CircleCI web ui after you add the private key. 61 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | orbs: 4 | github-maven-deploy: github-maven-deploy/github-maven-deploy@1.0.5 5 | circleci-maven-release-orb: sonatype-nexus-community/circleci-maven-release-orb@0.0.15 6 | 7 | build-and-test-commands: &build-and-test-commands 8 | mvn-build-test-command: mvn clean verify -PbuildKar -Dit 9 | mvn-collect-artifacts-command: | 10 | mkdir -p ~/project/artifacts/junit/ 11 | find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/project/artifacts/junit/ \; 12 | find . -type f -regex ".*/target/failsafe-reports/.*xml" -exec cp {} ~/project/artifacts/junit/ \; 13 | 14 | release-args: &release-args 15 | mvn-release-perform-command: mvn --batch-mode release:perform -s .circleci/.maven.xml -PbuildKar,circle-ci-release 16 | ssh-fingerprints: "eb:b1:b6:cc:59:57:91:13:4c:b5:11:98:49:d8:1e:ba" 17 | context: rso-base 18 | filters: 19 | branches: 20 | only: master 21 | 22 | workflows: 23 | build-branch: 24 | jobs: 25 | - github-maven-deploy/build-and-test: 26 | <<: *build-and-test-commands 27 | filters: 28 | branches: 29 | ignore: master 30 | 31 | run-release: 32 | jobs: 33 | - approve-release: 34 | type: approval 35 | filters: 36 | branches: 37 | only: master 38 | - circleci-maven-release-orb/run-maven-release: 39 | requires: 40 | - approve-release 41 | <<: *release-args 42 | 43 | release-from-master: 44 | jobs: 45 | - github-maven-deploy/build-and-test: 46 | <<: *build-and-test-commands 47 | filters: 48 | branches: 49 | only: master 50 | - circleci-maven-release-orb/run-maven-release: 51 | requires: 52 | - github-maven-deploy/build-and-test 53 | <<: *release-args 54 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 15 | ## How to be a contributor to this project 16 | 17 | ### Are you submitting a pull request? 18 | 19 | * Use [our codestyle](https://github.com/sonatype/codestyle). If we get a PR that doesn't match it, there will be 20 | much shaming throughout the land. If you use an editor besides Eclipse or IntelliJ, adapt the codestyle and submit a PR 21 | there :) 22 | * Fill out a CLA for us, so we can sort out all the legal parts of contributing. You can get all the information for 23 | this [here](https://help.sonatype.com/display/NXRM3/Bundle+Development#BundleDevelopment-ContributingBundles). You may go, this is for your book, is it 24 | applicable for this repo? Yes, absolutely. Follow the CLA process and email in your form. We are working on a way to 25 | make this simpler, as well. 26 | * Make sure to fill out an issue for your PR, so that we have traceability as to what you are trying to fix, 27 | versus how you fixed it. 28 | * Try to fix one thing per pull request! Many people work on this code, so the more focused your changes are, the less 29 | of a headache other people will have when they merge their work in. 30 | * Make sure to add yourself or your organization to CONTRIBUTORS.md as a part of your PR, if you are new to the project! 31 | * If you're stuck, ask our [gitter channel](https://gitter.im/sonatype/nexus-developers)! There are a number of 32 | experienced programmers who are happy to help with learning and troubleshooting. 33 | 34 | ### Are you new and looking to dive in? 35 | 36 | * Check our issues to see if there is something you can dive in to. 37 | * Come hang out with us at our [gitter channel](https://gitter.im/sonatype/nexus-developers). 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thanks for creating an issue! Please fill out this form so we can be 2 | sure to have all the information we need, and to minimize back and forth. 3 | 4 | * **What are you trying to do?** 5 | 6 | * **What feature or behavior is this required for?** 7 | 8 | * **How could we solve this issue? (Not knowing is okay!)** 9 | 10 | * **Anything else?** 11 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | (brief, plain english overview of your changes here) 2 | 3 | This pull request makes the following changes: 4 | * (your change here) 5 | * (another change here) 6 | * (etc) 7 | 8 | (If there are changes to the UI, please include a screenshot so we 9 | know what to look for!) 10 | 11 | (If there are changes to user behavior in general, please make sure to 12 | update the docs, as well) 13 | 14 | It relates to the following issue #s: 15 | * Fixes #X 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .classpath 3 | .project 4 | .settings/ 5 | 6 | # Maven 7 | target/ 8 | *.ser 9 | *.ec 10 | .mvn/timing.properties 11 | .mvn/extensions.xml 12 | .mvn/maven.config 13 | 14 | # Intellij 15 | *.ipr 16 | *.iml 17 | *.iws 18 | .idea/ 19 | 20 | # OrientDB 21 | .orientdb_history 22 | 23 | # Other 24 | .DS_Store 25 | .clover 26 | *.log 27 | /*.rc 28 | atlassian-ide-plugin.xml 29 | dependency-reduced-pom.xml 30 | out 31 | # ci config for local ci build 32 | /.circleci/local-config.yml 33 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | 15 | A lot of awesome people have contributed to this project! Here they are: 16 | 17 | Sonatype internal people, in alphabetical order by username: 18 | 19 | * [@DarthHater](https://github.com/darthhater/) (Jeffry Hesse) 20 | * [@doddi](https://github.com/doddi/) (Mark Dodgson) 21 | * [@mlukaretkyi](https://github.com/mlukaretkyi) (Maksym Lukaretkyi) 22 | 23 | External contributors: 24 | 25 | ![Possibly You!](http://i.imgur.com/A3eScYul.jpg) 26 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # declaration of NEXUS_VERSION must appear before first FROM command 2 | # see: https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact 3 | ARG NEXUS_VERSION=latest 4 | 5 | FROM maven:3-jdk-8-alpine AS build 6 | 7 | COPY . /nexus-repository-helm/ 8 | RUN cd /nexus-repository-helm/; \ 9 | mvn clean package -PbuildKar; 10 | 11 | FROM sonatype/nexus3:$NEXUS_VERSION 12 | 13 | ARG DEPLOY_DIR=/opt/sonatype/nexus/deploy/ 14 | USER root 15 | COPY --from=build /nexus-repository-helm/nexus-repository-helm/target/nexus-repository-helm-*-bundle.kar ${DEPLOY_DIR} 16 | USER nexus 17 | -------------------------------------------------------------------------------- /header.txt: -------------------------------------------------------------------------------- 1 | Sonatype Nexus (TM) Open Source Version 2 | Copyright (c) ${project.inceptionYear}-present Sonatype, Inc. 3 | All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 4 | 5 | This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 6 | which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 7 | 8 | Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 9 | of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 10 | Eclipse Foundation. All other trademarks are the property of their respective owners. 11 | -------------------------------------------------------------------------------- /headers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | dirname=`dirname $0` 3 | dirname=`cd "$dirname" && pwd` 4 | cd "$dirname" 5 | 6 | op=$1; shift 7 | case "$op" in 8 | 'check' | 'format') 9 | ;; 10 | *) 11 | echo "usage: `basename $0` { check | format } [mvn-options]" 12 | exit 1 13 | esac 14 | 15 | # still depends on profiles defined in https://github.com/sonatype/buildsupport/blob/master/pom.xml 16 | mvn -f ./pom.xml -N -P license-${op} "$@" 17 | -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/java/org/sonatype/nexus/plugins/helm/HelmITConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.nexus.plugins.helm; 14 | 15 | import org.sonatype.nexus.pax.exam.NexusPaxExamSupport; 16 | import org.sonatype.nexus.testsuite.testsupport.NexusITSupport; 17 | 18 | import org.ops4j.pax.exam.Option; 19 | 20 | import static org.ops4j.pax.exam.CoreOptions.systemProperty; 21 | import static org.sonatype.nexus.pax.exam.NexusPaxExamSupport.nexusFeature; 22 | 23 | public class HelmITConfig 24 | { 25 | public static Option[] configureHelmBase() { 26 | return NexusPaxExamSupport.options( 27 | NexusITSupport.configureNexusBase(), 28 | nexusFeature("org.sonatype.nexus.plugins", "nexus-repository-helm"), 29 | systemProperty("nexus-exclude-features").value("nexus-cma-community, nexus-community-feature") 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/java/org/sonatype/nexus/plugins/helm/internal/HelmClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.nexus.plugins.helm.internal; 14 | 15 | import java.io.IOException; 16 | import java.net.URI; 17 | 18 | import org.sonatype.nexus.testsuite.testsupport.FormatClientSupport; 19 | 20 | import org.apache.http.HttpEntity; 21 | import org.apache.http.HttpResponse; 22 | import org.apache.http.client.methods.HttpGet; 23 | import org.apache.http.client.methods.HttpPut; 24 | import org.apache.http.client.protocol.HttpClientContext; 25 | import org.apache.http.impl.client.CloseableHttpClient; 26 | 27 | /** 28 | * A simple test client for Helm repositories. 29 | * 30 | * @since 1.0.0 31 | */ 32 | public class HelmClient 33 | extends FormatClientSupport 34 | { 35 | public HelmClient(final CloseableHttpClient httpClient, 36 | final HttpClientContext httpClientContext, 37 | final URI repositoryBaseUri) 38 | { 39 | super(httpClient, httpClientContext, repositoryBaseUri); 40 | } 41 | 42 | public HttpResponse fetch(final String path, String contentType) throws IOException { 43 | HttpGet request = new HttpGet(resolve(path)); 44 | request.addHeader("Content-Type", contentType); 45 | return execute(request); 46 | } 47 | 48 | public HttpResponse put(String path, HttpEntity entity) throws IOException { 49 | final URI resolve = resolve(path); 50 | final HttpPut put = new HttpPut(resolve); 51 | put.setEntity(entity); 52 | return execute(put); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/java/org/sonatype/nexus/plugins/helm/internal/content/HelmClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.nexus.plugins.helm.internal.content; 14 | 15 | import java.io.IOException; 16 | import java.net.URI; 17 | 18 | import org.sonatype.nexus.content.testsupport.FormatClientSupport; 19 | 20 | import org.apache.http.HttpEntity; 21 | import org.apache.http.HttpResponse; 22 | import org.apache.http.client.methods.HttpGet; 23 | import org.apache.http.client.methods.HttpPut; 24 | import org.apache.http.client.protocol.HttpClientContext; 25 | import org.apache.http.impl.client.CloseableHttpClient; 26 | 27 | /** 28 | * A simple test client for Helm repositories. 29 | */ 30 | public class HelmClient 31 | extends FormatClientSupport 32 | { 33 | public HelmClient(final CloseableHttpClient httpClient, 34 | final HttpClientContext httpClientContext, 35 | final URI repositoryBaseUri) 36 | { 37 | super(httpClient, httpClientContext, repositoryBaseUri); 38 | } 39 | 40 | public HttpResponse fetch(final String path, String contentType) throws IOException { 41 | HttpGet request = new HttpGet(resolve(path)); 42 | request.addHeader("Content-Type", contentType); 43 | return execute(request); 44 | } 45 | 46 | public HttpResponse put(String path, HttpEntity entity) throws IOException { 47 | final URI resolve = resolve(path); 48 | final HttpPut put = new HttpPut(resolve); 49 | put.setEntity(entity); 50 | return execute(put); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/java/org/sonatype/nexus/plugins/helm/internal/content/HelmContentHostedIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.nexus.plugins.helm.internal.content; 14 | 15 | import java.io.IOException; 16 | import java.nio.file.Path; 17 | import java.nio.file.Paths; 18 | import java.util.concurrent.TimeUnit; 19 | 20 | import org.sonatype.nexus.common.app.BaseUrlHolder; 21 | import org.sonatype.nexus.repository.Repository; 22 | import org.sonatype.nexus.repository.http.HttpStatus; 23 | 24 | import com.google.common.io.Files; 25 | import org.apache.http.HttpEntity; 26 | import org.apache.http.HttpResponse; 27 | import org.apache.http.entity.ByteArrayEntity; 28 | import org.junit.Before; 29 | import org.junit.Test; 30 | 31 | import static org.hamcrest.MatcherAssert.assertThat; 32 | import static org.hamcrest.Matchers.is; 33 | import static org.sonatype.nexus.content.testsupport.FormatClientSupport.bytes; 34 | import static org.sonatype.nexus.content.testsupport.FormatClientSupport.status; 35 | 36 | public class HelmContentHostedIT 37 | extends HelmContentITSupport 38 | { 39 | private HelmClient client; 40 | 41 | private Repository repository; 42 | 43 | @Before 44 | public void setup() throws Exception { 45 | BaseUrlHolder.set(this.nexusUrl.toString()); 46 | 47 | repository = repos.createHelmHosted("helm-hosted-test"); 48 | client = helmClient(repository); 49 | uploadPackages(MONGO_PKG_FILE_NAME_600_TGZ, MONGO_PKG_FILE_NAME_728_TGZ); 50 | TimeUnit.SECONDS.sleep(2); 51 | } 52 | 53 | @Test 54 | public void fetchMetaData() throws Exception { 55 | HttpResponse httpResponse = client.fetch(YAML_FILE_NAME, CONTENT_TYPE_YAML); 56 | 57 | assertThat(status(httpResponse), is(HttpStatus.OK)); 58 | } 59 | 60 | @Test 61 | public void fetchTgzPackageFile() throws Exception { 62 | HttpResponse httpResponse = client.fetch(MONGO_PKG_FILE_NAME_600_TGZ, CONTENT_TYPE_TGZ); 63 | 64 | assertThat(status(httpResponse), is(HttpStatus.OK)); 65 | assertThat(bytes(httpResponse), is(Files.toByteArray(testData.resolveFile(MONGO_PKG_FILE_NAME_600_TGZ)))); 66 | } 67 | 68 | private void uploadPackages(String... names) throws IOException { 69 | for (String name : names) { 70 | client.put(name, fileToHttpEntity(name)); 71 | } 72 | } 73 | 74 | private Path getFilePathByName(String fileName) { 75 | return Paths.get(testData.resolveFile(fileName).getAbsolutePath()); 76 | } 77 | 78 | protected HttpEntity fileToHttpEntity(String name) throws IOException { 79 | return new ByteArrayEntity(java.nio.file.Files.readAllBytes(getFilePathByName(name))); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/java/org/sonatype/nexus/plugins/helm/internal/content/HelmContentITSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.nexus.plugins.helm.internal.content; 14 | 15 | import java.net.URL; 16 | 17 | import javax.annotation.Nonnull; 18 | 19 | import org.sonatype.nexus.content.testsupport.NexusITSupport; 20 | import org.sonatype.nexus.pax.exam.NexusPaxExamSupport; 21 | import org.sonatype.nexus.plugins.helm.internal.content.fixtures.RepositoryRuleHelm; 22 | import org.sonatype.nexus.repository.Repository; 23 | 24 | import org.junit.Rule; 25 | import org.ops4j.pax.exam.Configuration; 26 | import org.ops4j.pax.exam.Option; 27 | 28 | import static com.google.common.base.Preconditions.checkNotNull; 29 | import static java.lang.String.format; 30 | import static org.ops4j.pax.exam.CoreOptions.systemProperty; 31 | 32 | public class HelmContentITSupport 33 | extends NexusITSupport 34 | { 35 | public static final String MONGO_PKG_NAME = "mongodb"; 36 | 37 | public static final String YAML_NAME = "index"; 38 | 39 | public static final String MONGO_PKG_VERSION_600 = "6.0.0"; 40 | 41 | public static final String MONGO_PKG_VERSION_728 = "7.2.8"; 42 | 43 | public static final String TGZ_EXT = ".tgz"; 44 | 45 | public static final String YAML_EXT = ".yaml"; 46 | 47 | public static final String MONGO_PKG_FILE_NAME_600_TGZ = format("%s-%s%s", 48 | MONGO_PKG_NAME, MONGO_PKG_VERSION_600, TGZ_EXT); 49 | 50 | public static final String MONGO_PKG_FILE_NAME_728_TGZ = format("%s-%s%s", 51 | MONGO_PKG_NAME, MONGO_PKG_VERSION_728, TGZ_EXT); 52 | 53 | public static final String CONTENT_TYPE_TGZ = "application/x-tgz"; 54 | 55 | public static final String CONTENT_TYPE_YAML = "text/x-yaml"; 56 | 57 | public static final String YAML_FILE_NAME = String.format("%s%s", YAML_NAME, YAML_EXT); 58 | 59 | @Configuration 60 | public static Option[] configureNexus() { 61 | return NexusPaxExamSupport.options( 62 | NexusITSupport.configureNexusBase(), 63 | nexusFeature("org.sonatype.nexus.plugins", "nexus-repository-helm"), 64 | systemProperty("nexus-exclude-features").value("nexus-cma-community, nexus-community-feature") 65 | ); 66 | } 67 | 68 | @Rule 69 | public RepositoryRuleHelm repos = new RepositoryRuleHelm(() -> repositoryManager); 70 | 71 | public HelmContentITSupport() { 72 | testData.addDirectory(NexusPaxExamSupport.resolveBaseFile("target/test-classes/helm")); 73 | } 74 | 75 | @Nonnull 76 | protected URL repositoryBaseUrl(Repository repository) { 77 | return resolveUrl(this.nexusUrl, "/repository/" + repository.getName() + "/"); 78 | } 79 | 80 | @Nonnull 81 | protected HelmClient helmClient(final Repository repository) throws Exception { 82 | checkNotNull(repository); 83 | final URL repositoryUrl = repositoryBaseUrl(repository); 84 | 85 | return new HelmClient( 86 | clientBuilder(repositoryUrl).build(), 87 | clientContext(), 88 | repositoryUrl.toURI() 89 | ); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/java/org/sonatype/nexus/plugins/helm/internal/content/HelmContentProxyIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.nexus.plugins.helm.internal.content; 14 | 15 | import org.sonatype.goodies.httpfixture.server.fluent.Server; 16 | import org.sonatype.nexus.common.app.BaseUrlHolder; 17 | import org.sonatype.nexus.repository.Repository; 18 | import org.sonatype.nexus.repository.http.HttpStatus; 19 | 20 | import com.google.common.io.Files; 21 | import org.apache.http.HttpResponse; 22 | import org.junit.After; 23 | import org.junit.Before; 24 | import org.junit.Test; 25 | 26 | import static org.hamcrest.MatcherAssert.assertThat; 27 | import static org.hamcrest.Matchers.is; 28 | import static org.sonatype.goodies.httpfixture.server.fluent.Behaviours.error; 29 | import static org.sonatype.goodies.httpfixture.server.fluent.Behaviours.file; 30 | import static org.sonatype.nexus.content.testsupport.FormatClientSupport.bytes; 31 | import static org.sonatype.nexus.content.testsupport.FormatClientSupport.status; 32 | 33 | public class HelmContentProxyIT 34 | extends HelmContentITSupport 35 | { 36 | private HelmClient client; 37 | 38 | private Repository repository; 39 | 40 | private Server server; 41 | 42 | @Before 43 | public void setup() throws Exception { 44 | BaseUrlHolder.set(this.nexusUrl.toString()); 45 | server = Server.withPort(0) 46 | .serve("/*").withBehaviours(error(200)) 47 | .serve("/" + MONGO_PKG_FILE_NAME_600_TGZ) 48 | .withBehaviours(file(testData.resolveFile(MONGO_PKG_FILE_NAME_600_TGZ))) 49 | .serve("/" + YAML_FILE_NAME).withBehaviours(file(testData.resolveFile(YAML_FILE_NAME))) 50 | .start(); 51 | repository = repos.createHelmProxy("helm-proxy-test", server.getUrl().toExternalForm()); 52 | client = helmClient(repository); 53 | } 54 | 55 | @After 56 | public void tearDown() throws Exception { 57 | server.stop(); 58 | } 59 | 60 | @Test 61 | public void fetchMetaData() throws Exception { 62 | HttpResponse httpResponse = client.fetch(YAML_FILE_NAME, CONTENT_TYPE_YAML); 63 | 64 | assertThat(status(httpResponse), is(HttpStatus.OK)); 65 | assertThat(bytes(httpResponse), is(Files.toByteArray(testData.resolveFile(YAML_FILE_NAME)))); 66 | } 67 | 68 | @Test 69 | public void fetchTgzPackageFile() throws Exception { 70 | HttpResponse httpResponse = client.fetch(MONGO_PKG_FILE_NAME_600_TGZ, CONTENT_TYPE_TGZ); 71 | 72 | assertThat(status(httpResponse), is(HttpStatus.OK)); 73 | assertThat(bytes(httpResponse), is(Files.toByteArray(testData.resolveFile(MONGO_PKG_FILE_NAME_600_TGZ)))); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/java/org/sonatype/nexus/plugins/helm/internal/content/fixtures/HelmRepoRecipes.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.nexus.plugins.helm.internal.content.fixtures 14 | 15 | import javax.annotation.Nonnull 16 | 17 | import org.sonatype.nexus.repository.Repository 18 | import org.sonatype.nexus.repository.config.Configuration 19 | import org.sonatype.nexus.content.testsupport.fixtures.ConfigurationRecipes 20 | 21 | import groovy.transform.CompileStatic 22 | 23 | /** 24 | * Factory for Helm {@link Repository} {@link Configuration} 25 | */ 26 | @CompileStatic 27 | trait HelmRepoRecipes 28 | extends ConfigurationRecipes 29 | { 30 | @Nonnull 31 | Repository createHelmProxy(final String name, 32 | final String remoteUrl) 33 | { 34 | createRepository(createProxy(name, 'helm-proxy', remoteUrl)) 35 | } 36 | 37 | @Nonnull 38 | Repository createHelmHosted(final String name) 39 | { 40 | createRepository(createHosted(name, 'helm-hosted')) 41 | } 42 | 43 | abstract Repository createRepository(final Configuration configuration) 44 | } 45 | -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/java/org/sonatype/nexus/plugins/helm/internal/content/fixtures/RepositoryRuleHelm.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.nexus.plugins.helm.internal.content.fixtures 14 | 15 | import javax.inject.Provider 16 | 17 | import org.sonatype.nexus.repository.manager.RepositoryManager 18 | import org.sonatype.nexus.content.testsupport.fixtures.RepositoryRule 19 | 20 | class RepositoryRuleHelm 21 | extends RepositoryRule 22 | implements HelmRepoRecipes 23 | { 24 | RepositoryRuleHelm(final Provider repositoryManagerProvider) { 25 | super(repositoryManagerProvider) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/java/org/sonatype/nexus/plugins/helm/internal/fixtures/HelmRepoRecipes.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.nexus.plugins.helm.internal.fixtures 14 | 15 | import javax.annotation.Nonnull 16 | 17 | import org.sonatype.nexus.repository.Repository 18 | import org.sonatype.nexus.repository.config.Configuration 19 | import org.sonatype.nexus.testsuite.testsupport.fixtures.ConfigurationRecipes 20 | 21 | import groovy.transform.CompileStatic 22 | 23 | /** 24 | * Factory for Helm {@link Repository} {@link Configuration} 25 | */ 26 | @CompileStatic 27 | trait HelmRepoRecipes 28 | extends ConfigurationRecipes 29 | { 30 | @Nonnull 31 | Repository createHelmProxy(final String name, 32 | final String remoteUrl) 33 | { 34 | createRepository(createProxy(name, 'helm-proxy', remoteUrl)) 35 | } 36 | 37 | @Nonnull 38 | Repository createHelmHosted(final String name) 39 | { 40 | createRepository(createHosted(name, 'helm-hosted')) 41 | } 42 | 43 | abstract Repository createRepository(final Configuration configuration) 44 | } 45 | -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/java/org/sonatype/nexus/plugins/helm/internal/fixtures/RepositoryRuleHelm.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.nexus.plugins.helm.internal.fixtures 14 | 15 | import javax.inject.Provider 16 | 17 | import org.sonatype.nexus.repository.manager.RepositoryManager 18 | import org.sonatype.nexus.testsuite.testsupport.fixtures.RepositoryRule 19 | 20 | class RepositoryRuleHelm 21 | extends RepositoryRule 22 | implements HelmRepoRecipes 23 | { 24 | RepositoryRuleHelm(final Provider repositoryManagerProvider) { 25 | super(repositoryManagerProvider) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/resources/helm/index.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: '1.0' 2 | entries: 3 | mongodb: 4 | - appVersion: 4.0.10 5 | created: 2019-09-18T12:38:38.917Z 6 | description: NoSQL document-oriented database that stores JSON-like documents 7 | with dynamic schemas, simplifying the integration of data in content-driven 8 | applications. 9 | digest: f2c4dbe8cdd019f97eb9c1843a1748e60d94ef9142c3722121649455c6a21a80 10 | icon: https://bitnami.com/assets/stacks/mongodb/img/mongodb-stack-220x234.png 11 | maintainers: 12 | - email: containers@bitnami.com 13 | name: Bitnami 14 | name: mongodb 15 | sources: 16 | - https://github.com/bitnami/bitnami-docker-mongodb 17 | urls: 18 | - mongodb-6.0.0.tgz 19 | version: 6.0.0 20 | - appVersion: 4.0.12 21 | created: 2019-09-18T10:35:13.855Z 22 | description: NoSQL document-oriented database that stores JSON-like documents 23 | with dynamic schemas, simplifying the integration of data in content-driven 24 | applications. 25 | digest: 5b5550f485c8b489006c8d519d6d6b0799928aaac45ffc9b527a8f9fbb2234a6 26 | icon: https://bitnami.com/assets/stacks/mongodb/img/mongodb-stack-220x234.png 27 | maintainers: 28 | - email: containers@bitnami.com 29 | name: Bitnami 30 | name: mongodb 31 | sources: 32 | - https://github.com/bitnami/bitnami-docker-mongodb 33 | urls: 34 | - mongodb-7.2.8.tgz 35 | version: 7.2.8 36 | generated: 2019-09-18T12:38:50.332Z 37 | -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/resources/helm/mongodb-4.0.4.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonatype-nexus-community/nexus-repository-helm/e9178160b16f5500a1e91b21ee98423a96968f65/nexus-repository-helm-it/src/test/resources/helm/mongodb-4.0.4.tgz -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/resources/helm/mongodb-6.0.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonatype-nexus-community/nexus-repository-helm/e9178160b16f5500a1e91b21ee98423a96968f65/nexus-repository-helm-it/src/test/resources/helm/mongodb-6.0.0.tgz -------------------------------------------------------------------------------- /nexus-repository-helm-it/src/test/resources/helm/mongodb-7.2.8.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonatype-nexus-community/nexus-repository-helm/e9178160b16f5500a1e91b21ee98423a96968f65/nexus-repository-helm-it/src/test/resources/helm/mongodb-7.2.8.tgz -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/HelmAttributes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm; 14 | 15 | import java.util.EnumMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | import java.util.Optional; 19 | 20 | import org.sonatype.nexus.common.collect.NestedAttributesMap; 21 | import org.sonatype.repository.helm.internal.database.HelmProperties; 22 | 23 | /** 24 | * @since 1.0.0 25 | */ 26 | public class HelmAttributes 27 | { 28 | private final Map attributesEnumMap; 29 | 30 | public HelmAttributes() { 31 | attributesEnumMap = new EnumMap<>(HelmProperties.class); 32 | } 33 | 34 | public HelmAttributes(final Map attributesMap) { 35 | attributesEnumMap = new EnumMap<>(HelmProperties.class); 36 | attributesMap.forEach((key, value) -> { 37 | Optional propertyOpt = HelmProperties.findByPropertyName(key); 38 | if (value != null && propertyOpt.isPresent()) { 39 | attributesEnumMap.put(propertyOpt.get(), value); 40 | } 41 | }); 42 | } 43 | 44 | public void populate(final NestedAttributesMap attributesMap) { 45 | attributesEnumMap.forEach((helmProperties, o) -> attributesMap.set(helmProperties.getPropertyName(), o)); 46 | } 47 | 48 | public String getName() { 49 | return getValue(HelmProperties.NAME, String.class); 50 | } 51 | 52 | public String getVersion() { 53 | return getValue(HelmProperties.VERSION, String.class); 54 | } 55 | 56 | public String getAppVersion() { 57 | return getValue(HelmProperties.APP_VERSION, String.class); 58 | } 59 | 60 | public String getDescription() { 61 | return getValue(HelmProperties.DESCRIPTION, String.class); 62 | } 63 | 64 | public String getIcon() { 65 | return getValue(HelmProperties.ICON, String.class); 66 | } 67 | 68 | public String getEngine() { 69 | return getValue(HelmProperties.ENGINE, String.class); 70 | } 71 | 72 | public List getKeywords() { 73 | return getValue(HelmProperties.KEYWORDS, List.class); 74 | } 75 | 76 | 77 | public List> getMaintainers() { 78 | 79 | return getValue(HelmProperties.MAINTAINERS, List.class); 80 | } 81 | 82 | public List getSources() { 83 | return getValue(HelmProperties.SOURCES, List.class); 84 | } 85 | 86 | public void setName(final String name) { 87 | attributesEnumMap.put(HelmProperties.NAME, name); 88 | } 89 | 90 | public void setDescription(final String description) { 91 | attributesEnumMap.put(HelmProperties.DESCRIPTION, description); 92 | } 93 | 94 | public void setVersion(final String version) { 95 | attributesEnumMap.put(HelmProperties.VERSION, version); 96 | } 97 | 98 | public void setIcon(final String icon) { 99 | attributesEnumMap.put(HelmProperties.ICON, icon); 100 | } 101 | 102 | public void setAppVersion(final String appVersion) { 103 | attributesEnumMap.put(HelmProperties.APP_VERSION, appVersion); 104 | } 105 | 106 | public void setEngine(final String engine) { 107 | attributesEnumMap.put(HelmProperties.ENGINE, engine); 108 | } 109 | 110 | public void setKeywords(final List keywords) { 111 | attributesEnumMap.put(HelmProperties.KEYWORDS, keywords); 112 | } 113 | 114 | public void setMaintainers(final List> maintainers) { 115 | attributesEnumMap.put(HelmProperties.MAINTAINERS, maintainers); 116 | } 117 | 118 | private T getValue(HelmProperties property, Class tClass) { 119 | return tClass.cast(attributesEnumMap.get(property)); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/HelmRestoreFacet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm; 14 | 15 | import java.io.IOException; 16 | import java.io.InputStream; 17 | 18 | import org.sonatype.nexus.repository.Facet; 19 | import org.sonatype.nexus.repository.Facet.Exposed; 20 | import org.sonatype.nexus.repository.storage.AssetBlob; 21 | import org.sonatype.nexus.repository.storage.Query; 22 | 23 | /** 24 | * @since 1.0.0 25 | */ 26 | @Exposed 27 | public interface HelmRestoreFacet extends Facet 28 | { 29 | void restore(final AssetBlob assetBlob, final String path) throws IOException; 30 | 31 | boolean assetExists(final String path); 32 | 33 | boolean componentRequired(final String name); 34 | 35 | Query getComponentQuery(final HelmAttributes attributes); 36 | 37 | HelmAttributes extractComponentAttributesFromArchive(final String blobName, final InputStream is) throws IOException; 38 | } 39 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/HelmUploadHandlerSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm; 14 | 15 | import java.util.Set; 16 | 17 | import org.sonatype.nexus.repository.rest.UploadDefinitionExtension; 18 | import org.sonatype.nexus.repository.security.ContentPermissionChecker; 19 | import org.sonatype.nexus.repository.security.VariableResolverAdapter; 20 | import org.sonatype.nexus.repository.upload.UploadDefinition; 21 | import org.sonatype.nexus.repository.upload.UploadHandlerSupport; 22 | import org.sonatype.repository.helm.internal.util.HelmAttributeParser; 23 | 24 | import static org.sonatype.repository.helm.internal.HelmFormat.NAME; 25 | 26 | /** 27 | * @since 1.0.15 28 | */ 29 | public abstract class HelmUploadHandlerSupport 30 | extends UploadHandlerSupport 31 | { 32 | protected final HelmAttributeParser helmPackageParser; 33 | 34 | protected final ContentPermissionChecker contentPermissionChecker; 35 | 36 | protected final VariableResolverAdapter variableResolverAdapter; 37 | 38 | protected UploadDefinition definition; 39 | 40 | public HelmUploadHandlerSupport( 41 | final ContentPermissionChecker contentPermissionChecker, 42 | final HelmAttributeParser helmPackageParser, 43 | final VariableResolverAdapter variableResolverAdapter, 44 | final Set uploadDefinitionExtensions) 45 | { 46 | super(uploadDefinitionExtensions); 47 | this.contentPermissionChecker = contentPermissionChecker; 48 | this.variableResolverAdapter = variableResolverAdapter; 49 | this.helmPackageParser = helmPackageParser; 50 | } 51 | 52 | @Override 53 | public UploadDefinition getDefinition() { 54 | if (definition == null) { 55 | definition = getDefinition(NAME, false); 56 | } 57 | return definition; 58 | } 59 | 60 | @Override 61 | public VariableResolverAdapter getVariableResolverAdapter() { 62 | return variableResolverAdapter; 63 | } 64 | 65 | @Override 66 | public ContentPermissionChecker contentPermissionChecker() { 67 | return contentPermissionChecker; 68 | } 69 | 70 | @Override 71 | public boolean supportsExportImport() { 72 | return true; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/api/HelmHostedRepositoryApiRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.api; 14 | 15 | import org.sonatype.nexus.repository.rest.api.model.CleanupPolicyAttributes; 16 | import org.sonatype.nexus.repository.rest.api.model.HostedRepositoryApiRequest; 17 | import org.sonatype.nexus.repository.rest.api.model.HostedStorageAttributes; 18 | import org.sonatype.repository.helm.internal.HelmFormat; 19 | 20 | import com.fasterxml.jackson.annotation.JsonCreator; 21 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 22 | import com.fasterxml.jackson.annotation.JsonProperty; 23 | 24 | /** 25 | * @since 1.0.0 26 | */ 27 | @JsonIgnoreProperties({"format", "type"}) 28 | public class HelmHostedRepositoryApiRequest 29 | extends HostedRepositoryApiRequest 30 | { 31 | @JsonCreator 32 | public HelmHostedRepositoryApiRequest( 33 | @JsonProperty("name") final String name, 34 | @JsonProperty("online") final Boolean online, 35 | @JsonProperty("storage") final HostedStorageAttributes storage, 36 | @JsonProperty("cleanup") final CleanupPolicyAttributes cleanup) 37 | { 38 | super(name, HelmFormat.NAME, online, storage, cleanup); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/api/HelmProxyRepositoryApiRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.api; 14 | 15 | import org.sonatype.nexus.repository.rest.api.model.CleanupPolicyAttributes; 16 | import org.sonatype.nexus.repository.rest.api.model.HttpClientAttributes; 17 | import org.sonatype.nexus.repository.rest.api.model.NegativeCacheAttributes; 18 | import org.sonatype.nexus.repository.rest.api.model.ProxyAttributes; 19 | import org.sonatype.nexus.repository.rest.api.model.ProxyRepositoryApiRequest; 20 | import org.sonatype.nexus.repository.rest.api.model.StorageAttributes; 21 | import org.sonatype.repository.helm.internal.HelmFormat; 22 | 23 | import com.fasterxml.jackson.annotation.JsonCreator; 24 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 25 | import com.fasterxml.jackson.annotation.JsonProperty; 26 | 27 | /** 28 | * @since 1.0.0 29 | */ 30 | @JsonIgnoreProperties({"format", "type"}) 31 | public class HelmProxyRepositoryApiRequest 32 | extends ProxyRepositoryApiRequest 33 | { 34 | @JsonCreator 35 | public HelmProxyRepositoryApiRequest( 36 | @JsonProperty("name") final String name, 37 | @JsonProperty("online") final Boolean online, 38 | @JsonProperty("storage") final StorageAttributes storage, 39 | @JsonProperty("cleanup") final CleanupPolicyAttributes cleanup, 40 | @JsonProperty("proxy") final ProxyAttributes proxy, 41 | @JsonProperty("negativeCache") final NegativeCacheAttributes negativeCache, 42 | @JsonProperty("httpClient") final HttpClientAttributes httpClient, 43 | @JsonProperty("routingRule") final String routingRule) 44 | { 45 | super(name, HelmFormat.NAME, online, storage, cleanup, proxy, negativeCache, httpClient, routingRule); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/AssetKind.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal; 14 | 15 | import javax.annotation.Nonnull; 16 | 17 | import org.sonatype.nexus.repository.cache.CacheControllerHolder; 18 | import org.sonatype.nexus.repository.cache.CacheControllerHolder.CacheType; 19 | 20 | /** 21 | * Asset kinds for Helm 22 | * 23 | * Examples of all can be found at: https://github.com/kubernetes/helm/blob/master/docs/chart_repository.md#the-chart-repository-structure 24 | * @since 0.0.1 25 | */ 26 | public enum AssetKind 27 | { 28 | HELM_INDEX(CacheControllerHolder.METADATA, ".yaml"), 29 | HELM_PROVENANCE(CacheControllerHolder.CONTENT, ".tgz.prov"), 30 | HELM_PACKAGE(CacheControllerHolder.CONTENT, ".tgz"); 31 | 32 | private final CacheType cacheType; 33 | private final String extension; 34 | 35 | AssetKind(final CacheType cacheType, final String extension) { 36 | this.cacheType = cacheType; 37 | this.extension = extension; 38 | } 39 | 40 | public static AssetKind getAssetKindByFileName(final String name) { 41 | if (name.endsWith(HELM_PACKAGE.getExtension())) { 42 | return AssetKind.HELM_PACKAGE; 43 | } 44 | else if (name.endsWith(HELM_PROVENANCE.getExtension())) { 45 | return AssetKind.HELM_PROVENANCE; 46 | } 47 | return AssetKind.HELM_INDEX; 48 | } 49 | 50 | @Nonnull 51 | public CacheType getCacheType() { 52 | return cacheType; 53 | } 54 | 55 | @Nonnull 56 | public String getExtension() { 57 | return extension; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/HelmFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal; 14 | 15 | import java.util.List; 16 | 17 | import javax.inject.Named; 18 | import javax.inject.Singleton; 19 | 20 | import org.sonatype.nexus.common.hash.HashAlgorithm; 21 | import org.sonatype.nexus.repository.Format; 22 | 23 | import com.google.common.collect.ImmutableList; 24 | 25 | import static org.sonatype.nexus.common.hash.HashAlgorithm.SHA1; 26 | import static org.sonatype.nexus.common.hash.HashAlgorithm.SHA256; 27 | 28 | /** 29 | * Helm repository format. 30 | */ 31 | @Named(HelmFormat.NAME) 32 | @Singleton 33 | public class HelmFormat 34 | extends Format 35 | { 36 | public static final String NAME = "helm"; 37 | 38 | public static final List HASH_ALGORITHMS = ImmutableList.of(SHA1, SHA256); 39 | 40 | public HelmFormat() { 41 | super(NAME); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/cleanup/HelmCleanupPolicyConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.cleanup; 14 | 15 | import java.util.Map; 16 | 17 | import javax.inject.Named; 18 | import javax.inject.Singleton; 19 | 20 | import org.sonatype.nexus.cleanup.config.CleanupPolicyConfiguration; 21 | import org.sonatype.repository.helm.internal.HelmFormat; 22 | 23 | import com.google.common.collect.ImmutableMap; 24 | 25 | import static org.sonatype.nexus.repository.search.DefaultComponentMetadataProducer.IS_PRERELEASE_KEY; 26 | import static org.sonatype.nexus.repository.search.DefaultComponentMetadataProducer.LAST_BLOB_UPDATED_KEY; 27 | import static org.sonatype.nexus.repository.search.DefaultComponentMetadataProducer.LAST_DOWNLOADED_KEY; 28 | import static org.sonatype.nexus.repository.search.DefaultComponentMetadataProducer.REGEX_KEY; 29 | 30 | /** 31 | * Defines which cleanup policy fields to display for Helm. 32 | * 33 | * @since 1.0.0 34 | */ 35 | @Named(HelmFormat.NAME) 36 | @Singleton 37 | public class HelmCleanupPolicyConfiguration 38 | implements CleanupPolicyConfiguration 39 | { 40 | @Override 41 | public Map getConfiguration() { 42 | return ImmutableMap.of(LAST_BLOB_UPDATED_KEY, true, 43 | LAST_DOWNLOADED_KEY, true, 44 | IS_PRERELEASE_KEY, false, 45 | REGEX_KEY, true); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/HelmContentFacet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content; 14 | 15 | import java.io.IOException; 16 | import java.util.Optional; 17 | 18 | import javax.annotation.Nullable; 19 | 20 | import org.sonatype.nexus.repository.Facet; 21 | import org.sonatype.nexus.repository.content.facet.ContentFacet; 22 | import org.sonatype.nexus.repository.content.fluent.FluentAsset; 23 | import org.sonatype.nexus.repository.view.Content; 24 | import org.sonatype.nexus.repository.view.Payload; 25 | import org.sonatype.nexus.repository.view.payloads.TempBlob; 26 | import org.sonatype.repository.helm.HelmAttributes; 27 | import org.sonatype.repository.helm.internal.AssetKind; 28 | 29 | /** 30 | * @since 1.0.11 31 | */ 32 | @Facet.Exposed 33 | public interface HelmContentFacet 34 | extends ContentFacet 35 | { 36 | Iterable browseAssets(); 37 | 38 | Optional getAsset(String path); 39 | 40 | Content putIndex(String path, Content content, AssetKind assetKind); 41 | 42 | Content putComponent(String path, Content content, AssetKind assetKind) throws IOException; 43 | 44 | Content putComponent(String path, TempBlob tempBlob, HelmAttributes helmAttrs, Content content, AssetKind assetKind); 45 | 46 | TempBlob getTempBlob(Payload payload); 47 | 48 | boolean delete(String path); 49 | } 50 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/browse/HelmBrowseModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.browse; 14 | 15 | import javax.inject.Named; 16 | 17 | import org.sonatype.nexus.repository.content.browse.store.FormatBrowseModule; 18 | import org.sonatype.repository.helm.internal.HelmFormat; 19 | 20 | /** 21 | * Configures the browse bindings for the helm format. 22 | * 23 | * @since 1.0.15 24 | */ 25 | @Named(HelmFormat.NAME) 26 | public class HelmBrowseModule 27 | extends FormatBrowseModule 28 | { 29 | } 30 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/browse/HelmBrowseNodeDAO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.browse; 14 | 15 | import org.sonatype.nexus.repository.content.browse.store.BrowseNodeDAO; 16 | 17 | /** 18 | * @since 1.0.15 19 | */ 20 | public interface HelmBrowseNodeDAO 21 | extends BrowseNodeDAO 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/browse/HelmBrowseNodeGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.browse; 14 | 15 | import javax.inject.Named; 16 | import javax.inject.Singleton; 17 | 18 | import org.sonatype.nexus.repository.content.browse.DefaultBrowseNodeGenerator; 19 | import org.sonatype.repository.helm.internal.HelmFormat; 20 | 21 | /** 22 | * Helm places components one level above their assets. 23 | * 24 | * @since 1.0.15 25 | */ 26 | @Singleton 27 | @Named(HelmFormat.NAME) 28 | public class HelmBrowseNodeGenerator 29 | extends DefaultBrowseNodeGenerator 30 | { 31 | } 32 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/createindex/CreateIndexService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.createindex; 14 | 15 | import org.sonatype.nexus.repository.Repository; 16 | import org.sonatype.nexus.repository.view.Content; 17 | 18 | /** 19 | * Build index.yaml file for Helm Hosted 20 | * 21 | * @since 1.0.15 22 | */ 23 | public interface CreateIndexService 24 | { 25 | Content buildIndexYaml(final Repository repository); 26 | } 27 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/metadata/IndexYamlAbsoluteUrlRewriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.metadata; 14 | 15 | import java.io.InputStream; 16 | 17 | import javax.inject.Named; 18 | import javax.inject.Singleton; 19 | 20 | import org.sonatype.nexus.repository.Repository; 21 | import org.sonatype.nexus.repository.view.payloads.TempBlob; 22 | import org.sonatype.nexus.thread.io.StreamCopier; 23 | import org.sonatype.repository.helm.internal.content.HelmContentFacet; 24 | import org.sonatype.repository.helm.internal.metadata.IndexYamlAbsoluteUrlRewriterSupport; 25 | 26 | import static org.sonatype.repository.helm.internal.HelmFormat.HASH_ALGORITHMS; 27 | 28 | /** 29 | * Removes absolute URL entries from index.yaml 30 | * 31 | * @since 1.0.11 32 | */ 33 | @Named 34 | @Singleton 35 | public class IndexYamlAbsoluteUrlRewriter 36 | extends IndexYamlAbsoluteUrlRewriterSupport 37 | { 38 | private static final String contentType = "text/x-yaml"; 39 | 40 | private HelmContentFacet contentFacet; 41 | 42 | public TempBlob removeUrlsFromIndexYamlAndWriteToTempBlob(final TempBlob index, 43 | final Repository repository) 44 | { 45 | contentFacet = repository.facet(HelmContentFacet.class); 46 | return new StreamCopier<>(outputStream -> updateUrls(index.get(), outputStream), this::createTempBlob).read(); 47 | } 48 | 49 | private TempBlob createTempBlob(final InputStream is) { 50 | return contentFacet.blobs().ingest(is, contentType, HASH_ALGORITHMS); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | @FeatureFlag(name = "nexus.datastore.enabled") 14 | package org.sonatype.repository.helm.internal.content; 15 | 16 | import org.sonatype.nexus.common.app.FeatureFlag; 17 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/recipe/HelmHostedFacet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.recipe; 14 | 15 | import java.io.IOException; 16 | 17 | import org.sonatype.nexus.repository.Facet; 18 | import org.sonatype.nexus.repository.Facet.Exposed; 19 | import org.sonatype.nexus.repository.view.Content; 20 | import org.sonatype.nexus.repository.view.Payload; 21 | import org.sonatype.nexus.repository.view.payloads.TempBlob; 22 | import org.sonatype.repository.helm.HelmAttributes; 23 | import org.sonatype.repository.helm.internal.AssetKind; 24 | 25 | /** 26 | * Helm Hosted Facet 27 | * 28 | * @since 1.0.11 29 | */ 30 | @Exposed 31 | public interface HelmHostedFacet 32 | extends Facet 33 | { 34 | Content get(String path); 35 | 36 | void upload(final String path, final Payload payload, final AssetKind assetKind) throws IOException; 37 | 38 | Content upload( 39 | final String path, 40 | final TempBlob tempBlob, 41 | final HelmAttributes helmAttributes, 42 | final Payload payload, 43 | final AssetKind assetKind) throws IOException; 44 | 45 | boolean delete(String path); 46 | } 47 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/recipe/HelmHostedFacetImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.recipe; 14 | 15 | import java.io.IOException; 16 | 17 | import javax.annotation.Nullable; 18 | import javax.inject.Named; 19 | 20 | import org.sonatype.nexus.repository.FacetSupport; 21 | import org.sonatype.nexus.repository.config.Configuration; 22 | import org.sonatype.nexus.repository.view.Content; 23 | import org.sonatype.nexus.repository.view.Payload; 24 | import org.sonatype.nexus.repository.view.payloads.TempBlob; 25 | import org.sonatype.repository.helm.HelmAttributes; 26 | import org.sonatype.repository.helm.internal.AssetKind; 27 | import org.sonatype.repository.helm.internal.content.HelmContentFacet; 28 | 29 | import static com.google.common.base.Preconditions.checkNotNull; 30 | import static org.sonatype.repository.helm.internal.AssetKind.HELM_PACKAGE; 31 | import static org.sonatype.repository.helm.internal.AssetKind.HELM_PROVENANCE; 32 | import org.sonatype.repository.helm.internal.content.HelmContentFacet; 33 | 34 | /** 35 | * {@link HelmHostedFacet implementation} 36 | * 37 | * @since 1.0.11 38 | */ 39 | @Named 40 | public class HelmHostedFacetImpl 41 | extends FacetSupport 42 | implements HelmHostedFacet 43 | { 44 | private HelmContentFacet helmContentFacet; 45 | 46 | @Override 47 | protected void doInit(final Configuration configuration) throws Exception { 48 | super.doInit(configuration); 49 | helmContentFacet = facet(HelmContentFacet.class); 50 | } 51 | 52 | @Nullable 53 | @Override 54 | public Content get(final String path) { 55 | checkNotNull(path); 56 | return helmContentFacet.getAsset(path).orElse(null); 57 | } 58 | 59 | @Override 60 | public void upload( 61 | final String path, 62 | final Payload payload, 63 | final AssetKind assetKind) throws IOException 64 | { 65 | checkNotNull(path); 66 | if (assetKind != HELM_PACKAGE && assetKind != HELM_PROVENANCE) { 67 | throw new IllegalArgumentException("Unsupported assetKind: " + assetKind); 68 | } 69 | helmContentFacet.putComponent(path, new Content(payload), assetKind); 70 | } 71 | 72 | @Override 73 | public Content upload( 74 | final String path, 75 | final TempBlob tempBlob, 76 | final HelmAttributes helmAttributes, 77 | final Payload payload, 78 | final AssetKind assetKind) 79 | { 80 | checkNotNull(path); 81 | if (assetKind != HELM_PACKAGE && assetKind != HELM_PROVENANCE) { 82 | throw new IllegalArgumentException("Unsupported assetKind: " + assetKind); 83 | } 84 | return helmContentFacet.putComponent(path, tempBlob, helmAttributes, new Content(payload), assetKind); 85 | } 86 | 87 | @Override 88 | public boolean delete(final String path) { 89 | checkNotNull(path); 90 | return helmContentFacet.delete(path); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/recipe/HelmProxyFacet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.recipe; 14 | 15 | import java.io.IOException; 16 | 17 | import javax.annotation.Nonnull; 18 | import javax.inject.Inject; 19 | import javax.inject.Named; 20 | 21 | import org.sonatype.nexus.repository.content.facet.ContentProxyFacetSupport; 22 | import org.sonatype.nexus.repository.view.Content; 23 | import org.sonatype.nexus.repository.view.Context; 24 | import org.sonatype.nexus.repository.view.matchers.token.TokenMatcher; 25 | import org.sonatype.repository.helm.internal.AssetKind; 26 | import org.sonatype.repository.helm.internal.content.HelmContentFacet; 27 | import org.sonatype.repository.helm.internal.util.HelmPathUtils; 28 | 29 | import static com.google.common.base.Preconditions.checkNotNull; 30 | 31 | 32 | /** 33 | * @since 1.0.11 34 | */ 35 | @Named 36 | public class HelmProxyFacet 37 | extends ContentProxyFacetSupport 38 | { 39 | private final HelmPathUtils helmPathUtils; 40 | 41 | private static final String INDEX_YAML = "/index.yaml"; 42 | 43 | @Inject 44 | public HelmProxyFacet(final HelmPathUtils helmPathUtils) 45 | { 46 | this.helmPathUtils = checkNotNull(helmPathUtils); 47 | } 48 | 49 | @Override 50 | protected Content getCachedContent(final Context context) throws IOException { 51 | return content().getAsset(getUrl(context)).orElse(null); 52 | } 53 | 54 | @Override 55 | protected Content store(final Context context, final Content content) throws IOException { 56 | AssetKind assetKind = context.getAttributes().require(AssetKind.class); 57 | switch (assetKind) { 58 | case HELM_INDEX: 59 | return content().putIndex(getUrl(context), content, assetKind); 60 | case HELM_PACKAGE: 61 | return content().putComponent(getUrl(context), content, assetKind); 62 | default: 63 | throw new IllegalStateException("Received an invalid AssetKind of type: " + assetKind.name()); 64 | } 65 | } 66 | 67 | 68 | @Override 69 | protected String getUrl(@Nonnull final Context context) { 70 | AssetKind assetKind = context.getAttributes().require(AssetKind.class); 71 | switch (assetKind) { 72 | case HELM_INDEX: 73 | return INDEX_YAML; 74 | case HELM_PACKAGE: 75 | TokenMatcher.State matcherState = helmPathUtils.matcherState(context); 76 | return helmPathUtils.contentFilePath(matcherState); 77 | default: 78 | throw new IllegalStateException("Received an invalid AssetKind of type: " + assetKind.name()); 79 | } 80 | } 81 | 82 | private HelmContentFacet content() { 83 | return getRepository().facet(HelmContentFacet.class); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/recipe/HostedHandlers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.recipe; 14 | 15 | import javax.inject.Inject; 16 | import javax.inject.Named; 17 | import javax.inject.Singleton; 18 | 19 | import org.sonatype.goodies.common.ComponentSupport; 20 | import org.sonatype.nexus.repository.view.Content; 21 | import org.sonatype.nexus.repository.view.Handler; 22 | import org.sonatype.nexus.repository.view.matchers.token.TokenMatcher.State; 23 | import org.sonatype.repository.helm.internal.AssetKind; 24 | import org.sonatype.repository.helm.internal.util.HelmPathUtils; 25 | 26 | import static com.google.common.base.Preconditions.checkNotNull; 27 | import static org.sonatype.nexus.repository.http.HttpResponses.notFound; 28 | import static org.sonatype.nexus.repository.http.HttpResponses.ok; 29 | 30 | /** 31 | * Helm Hosted Handlers 32 | * 33 | * @since 1.0.11 34 | */ 35 | @Named 36 | @Singleton 37 | public class HostedHandlers 38 | extends ComponentSupport 39 | { 40 | private HelmPathUtils helmPathUtils; 41 | 42 | @Inject 43 | public HostedHandlers(final HelmPathUtils helmPathUtils) { 44 | this.helmPathUtils = checkNotNull(helmPathUtils); 45 | } 46 | 47 | public final Handler get = context -> { 48 | AssetKind assetKind = context.getAttributes().require(AssetKind.class); 49 | String path; 50 | if (assetKind == AssetKind.HELM_INDEX) { 51 | path = "/index.yaml"; 52 | } 53 | else { 54 | State state = context.getAttributes().require(State.class); 55 | path = helmPathUtils.contentFilePath(state); 56 | } 57 | Content content = context.getRepository().facet(HelmHostedFacet.class).get(path); 58 | 59 | return (content != null) ? ok(content) : notFound(); 60 | }; 61 | 62 | public final Handler upload = context -> { 63 | State state = context.getAttributes().require(State.class); 64 | String path = helmPathUtils.buildContentAssetPath(state); 65 | AssetKind assetKind = context.getAttributes().require(AssetKind.class); 66 | context.getRepository().facet(HelmHostedFacet.class).upload(path, context.getRequest().getPayload(), assetKind); 67 | return ok(); 68 | }; 69 | 70 | public final Handler delete = context -> { 71 | State state = context.getAttributes().require(State.class); 72 | String path = helmPathUtils.buildContentAssetPath(state); 73 | 74 | boolean deleted = context.getRepository().facet(HelmHostedFacet.class).delete(path); 75 | 76 | return (deleted) ? ok() : notFound(); 77 | }; 78 | } 79 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/store/HelmAssetBlobDAO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.store; 14 | 15 | import org.sonatype.nexus.repository.content.store.AssetBlobDAO; 16 | 17 | /** 18 | * @since 1.0.11 19 | */ 20 | public interface HelmAssetBlobDAO 21 | extends AssetBlobDAO 22 | { 23 | // nothing to add... 24 | } 25 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/store/HelmAssetDAO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.store; 14 | 15 | import org.sonatype.nexus.repository.content.store.AssetDAO; 16 | 17 | /** 18 | * @since 1.0.11 19 | */ 20 | public interface HelmAssetDAO 21 | extends AssetDAO 22 | { 23 | // nothing to add... 24 | } 25 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/store/HelmComponentDAO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.store; 14 | 15 | import org.sonatype.nexus.repository.content.store.ComponentDAO; 16 | 17 | /** 18 | * @since 1.0.11 19 | */ 20 | public interface HelmComponentDAO 21 | extends ComponentDAO 22 | { 23 | // nothing to add... 24 | } 25 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/store/HelmContentRepositoryDAO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.store; 14 | 15 | import org.sonatype.nexus.repository.content.store.ContentRepositoryDAO; 16 | 17 | /** 18 | * @since 1.0.11 19 | */ 20 | public interface HelmContentRepositoryDAO 21 | extends ContentRepositoryDAO 22 | { 23 | // nothing to add... 24 | } 25 | 26 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/content/store/HelmStoreModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.store; 14 | 15 | import javax.inject.Named; 16 | 17 | import org.sonatype.repository.helm.internal.HelmFormat; 18 | import org.sonatype.nexus.repository.content.store.FormatStoreModule; 19 | 20 | /** 21 | * @since 1.0.11 22 | */ 23 | @Named(HelmFormat.NAME) 24 | public class HelmStoreModule 25 | extends FormatStoreModule 29 | { 30 | // nothing to add... 31 | } 32 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/createindex/CreateIndexFacet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.createindex; 14 | 15 | import org.sonatype.nexus.repository.Facet; 16 | import org.sonatype.nexus.repository.Facet.Exposed; 17 | 18 | /** 19 | * Facet interface for rebuilding Helm index.yaml files 20 | * 21 | * @since 0.0.2 22 | */ 23 | @Exposed 24 | public interface CreateIndexFacet 25 | extends Facet 26 | { 27 | /** 28 | * Mark the helm index yaml as invalidated such that it will be rebuilt after waiting for a configured amount of time 29 | * to prevent unnecessary successive rebuilds of the metadata. 30 | */ 31 | void invalidateIndex(); 32 | } 33 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/createindex/HelmIndexInvalidationEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.createindex; 14 | 15 | import static com.google.common.base.Preconditions.checkNotNull; 16 | 17 | /** 18 | * Event class for use when invalidating Helm index.yaml file 19 | * 20 | * @since 0.0.2 21 | */ 22 | public class HelmIndexInvalidationEvent 23 | { 24 | private final String repositoryName; 25 | 26 | private final boolean waitBeforeRebuild; 27 | 28 | public HelmIndexInvalidationEvent(final String repositoryName, 29 | final boolean waitBeforeRebuild) { 30 | this.repositoryName = checkNotNull(repositoryName); 31 | this.waitBeforeRebuild = waitBeforeRebuild; 32 | } 33 | 34 | /** 35 | * The helm repository that requires its index invalidated and rebuilt. 36 | */ 37 | public String getRepositoryName() { 38 | return repositoryName; 39 | } 40 | 41 | /** 42 | * If set then force createIndex to wait before generating to prevent multiple re-writes being scheduled one after 43 | * another 44 | */ 45 | public boolean isWaitBeforeRebuild() { 46 | return waitBeforeRebuild; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/database/HelmProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.database; 14 | 15 | import java.util.Arrays; 16 | import java.util.Optional; 17 | 18 | /** 19 | * Database property names for Helm asset attributes 20 | * 21 | * @since 0.0.2 22 | */ 23 | public enum HelmProperties 24 | { 25 | DESCRIPTION("description"), 26 | ENGINE("engine"), 27 | HOME("home"), 28 | ICON("icon"), 29 | APP_VERSION("appVersion"), 30 | KEYWORDS("keywords"), 31 | MAINTAINERS("maintainers"), 32 | NAME("name"), 33 | SOURCES("sources"), 34 | VERSION("version"); 35 | 36 | private String propertyName; 37 | 38 | HelmProperties(final String type) { 39 | this.propertyName = type; 40 | } 41 | 42 | public String getPropertyName() { 43 | return propertyName; 44 | } 45 | 46 | public static Optional findByPropertyName(String propertyName) { 47 | return Arrays.stream(HelmProperties.values()) 48 | .filter(properties -> propertyName.equals(properties.getPropertyName())) 49 | .findAny(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/metadata/ChartEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.metadata; 14 | 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | import org.joda.time.DateTime; 19 | 20 | /** 21 | * Represents a chart entry in index.yaml 22 | * 23 | * @since 0.0.2 24 | */ 25 | public class ChartEntry 26 | { 27 | private String description; 28 | private String name; 29 | private String version; 30 | private DateTime created; 31 | private String appVersion; 32 | private String digest; 33 | private String icon; 34 | private List urls; 35 | private List sources; 36 | private List> maintainers; 37 | 38 | public String getName() { return this.name; } 39 | 40 | public void setName(final String name) { this.name = name; } 41 | 42 | public String getDescription() { 43 | return description; 44 | } 45 | 46 | public void setDescription(final String description) { 47 | this.description = description; 48 | } 49 | 50 | public String getVersion() { 51 | return version; 52 | } 53 | 54 | public void setVersion(final String version) { 55 | this.version = version; 56 | } 57 | 58 | public DateTime getCreated() { 59 | return created; 60 | } 61 | 62 | public void setCreated(final DateTime created) { 63 | this.created = created; 64 | } 65 | 66 | public String getAppVersion() { 67 | return appVersion; 68 | } 69 | 70 | public void setAppVersion(final String appVersion) { 71 | this.appVersion = appVersion; 72 | } 73 | 74 | public String getDigest() { 75 | return digest; 76 | } 77 | 78 | public void setDigest(final String digest) { 79 | this.digest = digest; 80 | } 81 | 82 | public String getIcon() { 83 | return icon; 84 | } 85 | 86 | public void setIcon(final String icon) { 87 | this.icon = icon; 88 | } 89 | 90 | public List getUrls() { 91 | return urls; 92 | } 93 | 94 | public void setUrls(final List urls) { 95 | this.urls = urls; 96 | } 97 | 98 | public List getSources() { 99 | return sources; 100 | } 101 | 102 | public void setSources(final List sources) { 103 | this.sources = sources; 104 | } 105 | 106 | public List> getMaintainers() { 107 | return maintainers; 108 | } 109 | 110 | public void setMaintainers(final List> maintainers) { 111 | this.maintainers = maintainers; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/metadata/ChartIndex.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.metadata; 14 | 15 | import java.util.ArrayList; 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | import org.joda.time.DateTime; 21 | 22 | /** 23 | * Object for storing attributes in a Helm index.yaml file 24 | * 25 | * @since 0.0.2 26 | */ 27 | public final class ChartIndex 28 | { 29 | private String apiVersion; 30 | private Map> entries; 31 | private DateTime generated; 32 | 33 | public ChartIndex() { 34 | this.entries = new HashMap<>(); 35 | } 36 | 37 | public String getApiVersion() { 38 | return this.apiVersion; 39 | } 40 | 41 | public void setApiVersion(final String apiVersion) { 42 | this.apiVersion = apiVersion; 43 | } 44 | 45 | public Map> getEntries() { 46 | return this.entries; 47 | } 48 | 49 | public void addEntry(final ChartEntry chartEntry) { 50 | this.entries.computeIfAbsent(chartEntry.getName(), k -> new ArrayList<>()).add(chartEntry); 51 | } 52 | 53 | public void setEntries(final Map> entries) { 54 | this.entries = entries; 55 | } 56 | 57 | public DateTime getGenerated() { return this.generated; } 58 | 59 | public void setGenerated(final DateTime generated) { 60 | this.generated = generated; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/metadata/IndexYamlAbsoluteUrlRewriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.metadata; 14 | 15 | import java.io.InputStream; 16 | 17 | import javax.inject.Named; 18 | import javax.inject.Singleton; 19 | 20 | import org.sonatype.nexus.repository.Repository; 21 | import org.sonatype.nexus.repository.storage.StorageFacet; 22 | import org.sonatype.nexus.repository.storage.TempBlob; 23 | import org.sonatype.nexus.thread.io.StreamCopier; 24 | import org.sonatype.repository.helm.internal.metadata.IndexYamlAbsoluteUrlRewriterSupport; 25 | 26 | import static org.sonatype.repository.helm.internal.HelmFormat.HASH_ALGORITHMS; 27 | 28 | /** 29 | * Removes absolute URL entries from index.yaml 30 | * 31 | * @since 0.0.1 32 | */ 33 | @Named 34 | @Singleton 35 | public class IndexYamlAbsoluteUrlRewriter 36 | extends IndexYamlAbsoluteUrlRewriterSupport 37 | { 38 | private StorageFacet storageFacet; 39 | 40 | public TempBlob removeUrlsFromIndexYamlAndWriteToTempBlob(final TempBlob index, 41 | final Repository repository) 42 | { 43 | storageFacet = repository.facet(StorageFacet.class); 44 | 45 | return new StreamCopier<>(outputStream -> updateUrls(index.get(), outputStream), 46 | this::createTempBlob).read(); 47 | } 48 | 49 | private TempBlob createTempBlob(final InputStream is) { 50 | return storageFacet.createTempBlob(is, HASH_ALGORITHMS); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/metadata/IndexYamlAbsoluteUrlRewriterSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.metadata; 14 | 15 | import java.io.IOException; 16 | import java.io.InputStream; 17 | import java.io.InputStreamReader; 18 | import java.io.OutputStream; 19 | import java.io.OutputStreamWriter; 20 | import java.io.Reader; 21 | import java.io.Writer; 22 | import java.net.URI; 23 | import java.net.URISyntaxException; 24 | import java.nio.file.Paths; 25 | 26 | import org.sonatype.goodies.common.ComponentSupport; 27 | 28 | import org.apache.http.client.utils.URIBuilder; 29 | import org.yaml.snakeyaml.DumperOptions; 30 | import org.yaml.snakeyaml.Yaml; 31 | import org.yaml.snakeyaml.constructor.SafeConstructor; 32 | import org.yaml.snakeyaml.emitter.Emitter; 33 | import org.yaml.snakeyaml.events.CollectionEndEvent; 34 | import org.yaml.snakeyaml.events.CollectionStartEvent; 35 | import org.yaml.snakeyaml.events.Event; 36 | import org.yaml.snakeyaml.events.ScalarEvent; 37 | 38 | /** 39 | * Removes absolute URL entries from index.yaml 40 | * 41 | * @since 1.0.11 42 | */ 43 | public class IndexYamlAbsoluteUrlRewriterSupport 44 | extends ComponentSupport 45 | { 46 | private static final String URLS = "urls"; 47 | 48 | protected void updateUrls(final InputStream is, 49 | final OutputStream os) 50 | { 51 | try (Reader reader = new InputStreamReader(is); 52 | Writer writer = new OutputStreamWriter(os)) { 53 | Yaml yaml = new Yaml(new SafeConstructor()); 54 | Emitter emitter = new Emitter(writer, new DumperOptions()); 55 | boolean rewrite = false; 56 | for (Event event : yaml.parse(reader)) { 57 | if (event instanceof ScalarEvent) { 58 | ScalarEvent scalarEvent = (ScalarEvent) event; 59 | if (rewrite) { 60 | event = maybeSetAbsoluteUrlAsRelative(scalarEvent); 61 | } 62 | else if (URLS.equals(scalarEvent.getValue())) { 63 | rewrite = true; 64 | } 65 | } 66 | else if (event instanceof CollectionStartEvent) { 67 | // NOOP 68 | } 69 | else if (event instanceof CollectionEndEvent) { 70 | rewrite = false; 71 | } 72 | emitter.emit(event); 73 | } 74 | } 75 | catch (IOException ex) { 76 | log.error("Error rewriting urls in index.yaml", ex); 77 | } 78 | } 79 | 80 | protected Event maybeSetAbsoluteUrlAsRelative(ScalarEvent scalarEvent) { 81 | String oldUrl = scalarEvent.getValue(); 82 | try { 83 | URI uri = new URIBuilder(oldUrl).build(); 84 | if (uri.isAbsolute()) { 85 | String fileName = uri.getPath(); 86 | // Rewrite absolute paths to relative 87 | if (!fileName.isEmpty()) { 88 | fileName = Paths.get(fileName).getFileName().toString(); 89 | } 90 | scalarEvent = new ScalarEvent(scalarEvent.getAnchor(), scalarEvent.getTag(), 91 | scalarEvent.getImplicit(), fileName, scalarEvent.getStartMark(), 92 | scalarEvent.getEndMark(), scalarEvent.getStyle()); 93 | } 94 | } 95 | catch (URISyntaxException ex) { 96 | log.error("Invalid URI in index.yaml", ex); 97 | } 98 | return scalarEvent; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/orient/HelmComponentDirector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.orient; 14 | 15 | import java.util.Optional; 16 | 17 | import javax.inject.Inject; 18 | import javax.inject.Named; 19 | import javax.inject.Singleton; 20 | 21 | import org.sonatype.goodies.common.ComponentSupport; 22 | import org.sonatype.nexus.repository.Repository; 23 | import org.sonatype.nexus.repository.manager.RepositoryManager; 24 | import org.sonatype.nexus.repository.storage.Bucket; 25 | import org.sonatype.nexus.repository.storage.BucketStore; 26 | import org.sonatype.nexus.repository.storage.Component; 27 | import org.sonatype.nexus.repository.storage.ComponentDirector; 28 | import org.sonatype.repository.helm.internal.HelmFormat; 29 | 30 | import static com.google.common.base.Preconditions.checkNotNull; 31 | 32 | /** 33 | * @since 1.0.0 34 | */ 35 | @Named(HelmFormat.NAME) 36 | @Singleton 37 | public class HelmComponentDirector 38 | extends ComponentSupport 39 | implements ComponentDirector 40 | { 41 | private final BucketStore bucketStore; 42 | 43 | private final RepositoryManager repositoryManager; 44 | 45 | @Inject 46 | public HelmComponentDirector( 47 | final BucketStore bucketStore, 48 | final RepositoryManager repositoryManager) 49 | { 50 | this.bucketStore = checkNotNull(bucketStore); 51 | this.repositoryManager = checkNotNull(repositoryManager); 52 | } 53 | 54 | @Override 55 | public boolean allowMoveTo(final Repository destination) { 56 | return true; 57 | } 58 | 59 | @Override 60 | public boolean allowMoveTo(final Component component, final Repository destination) { 61 | return repositoryFor(component).isPresent(); 62 | } 63 | 64 | @Override 65 | public boolean allowMoveFrom(final Repository source) { 66 | return true; 67 | } 68 | 69 | private Optional repositoryFor(final Component component) { 70 | return Optional.of(component) 71 | .map(Component::bucketId) 72 | .map(bucketStore::getById) 73 | .map(Bucket::getRepositoryName) 74 | .map(repositoryManager::get); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/orient/HelmComponentMaintenanceFacet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.orient; 14 | 15 | import java.util.Collections; 16 | import java.util.Set; 17 | 18 | import javax.inject.Named; 19 | 20 | import org.sonatype.nexus.common.entity.EntityId; 21 | import org.sonatype.nexus.repository.storage.Asset; 22 | import org.sonatype.nexus.repository.storage.Bucket; 23 | import org.sonatype.nexus.repository.storage.Component; 24 | import org.sonatype.nexus.repository.storage.DefaultComponentMaintenanceImpl; 25 | import org.sonatype.nexus.repository.storage.StorageTx; 26 | import org.sonatype.nexus.transaction.Transactional; 27 | import org.sonatype.nexus.transaction.UnitOfWork; 28 | 29 | import com.orientechnologies.common.concur.ONeedRetryException; 30 | 31 | /** 32 | * @since 1.0.0 33 | */ 34 | @Named 35 | public class HelmComponentMaintenanceFacet 36 | extends DefaultComponentMaintenanceImpl 37 | { 38 | @Transactional(retryOn = ONeedRetryException.class) 39 | @Override 40 | protected Set deleteAssetTx(final EntityId assetId, final boolean deleteBlobs) { 41 | StorageTx tx = UnitOfWork.currentTx(); 42 | Bucket bucket = tx.findBucket(getRepository()); 43 | Asset asset = tx.findAsset(assetId, bucket); 44 | 45 | if (asset == null) { 46 | return Collections.emptySet(); 47 | } 48 | 49 | tx.deleteAsset(asset, deleteBlobs); 50 | 51 | if (asset.componentId() != null) { 52 | Component component = tx.findComponentInBucket(asset.componentId(), bucket); 53 | 54 | if (!tx.browseAssets(component).iterator().hasNext()) { 55 | log.debug("Deleting component: {}", component); 56 | tx.deleteComponent(component, deleteBlobs); 57 | } 58 | } 59 | return Collections.singleton(asset.name()); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/orient/HelmFacet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.orient; 14 | 15 | import java.io.IOException; 16 | import java.io.InputStream; 17 | import java.util.Optional; 18 | 19 | import javax.annotation.Nullable; 20 | 21 | import org.sonatype.nexus.blobstore.api.Blob; 22 | import org.sonatype.nexus.common.collect.AttributesMap; 23 | import org.sonatype.nexus.repository.Facet; 24 | import org.sonatype.nexus.repository.storage.Asset; 25 | import org.sonatype.nexus.repository.storage.StorageTx; 26 | import org.sonatype.nexus.repository.view.Content; 27 | import org.sonatype.nexus.repository.view.Payload; 28 | import org.sonatype.repository.helm.HelmAttributes; 29 | import org.sonatype.repository.helm.internal.AssetKind; 30 | 31 | import com.google.common.base.Supplier; 32 | 33 | /** 34 | * @since 1.0.0 35 | */ 36 | @Facet.Exposed 37 | public interface HelmFacet 38 | extends Facet 39 | { 40 | Iterable browseComponentAssets(final StorageTx tx, @Nullable final AssetKind assetKind); 41 | 42 | Optional findAsset(final StorageTx tx, final String assetName); 43 | 44 | Asset findOrCreateAsset(final StorageTx tx, 45 | final String assetPath, 46 | final AssetKind assetKind, 47 | final HelmAttributes helmAttributes); 48 | 49 | Content saveAsset(final StorageTx tx, 50 | final Asset asset, 51 | final Supplier contentSupplier, 52 | final Payload payload); 53 | 54 | Content saveAsset(final StorageTx tx, 55 | final Asset asset, 56 | final Supplier contentSupplier, 57 | @Nullable final String contentType, 58 | @Nullable final AttributesMap contentAttributes) throws IOException; 59 | 60 | Content toContent(final Asset asset, final Blob blob); 61 | } 62 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/orient/createindex/CreateIndexService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.orient.createindex; 14 | 15 | import org.sonatype.nexus.repository.Repository; 16 | import org.sonatype.nexus.repository.storage.TempBlob; 17 | 18 | /** 19 | * Build index.yaml file for Helm Hosted 20 | * 21 | * @since 0.0.2 22 | */ 23 | public interface CreateIndexService 24 | { 25 | TempBlob buildIndexYaml(final Repository repository); 26 | } 27 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/orient/hosted/HelmHostedFacet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.orient.hosted; 14 | 15 | import java.io.IOException; 16 | 17 | import org.sonatype.nexus.repository.Facet; 18 | import org.sonatype.nexus.repository.Facet.Exposed; 19 | import org.sonatype.nexus.repository.storage.Asset; 20 | import org.sonatype.nexus.repository.view.Content; 21 | import org.sonatype.nexus.repository.view.Payload; 22 | import org.sonatype.nexus.repository.storage.TempBlob; 23 | import org.sonatype.repository.helm.internal.AssetKind; 24 | 25 | /** 26 | * Helm Hosted Facet 27 | * 28 | * @since 0.0.2 29 | */ 30 | @Exposed 31 | public interface HelmHostedFacet 32 | extends Facet 33 | { 34 | Content get(String path); 35 | 36 | void upload(final String path, final Payload payload, final AssetKind assetKind) throws IOException; 37 | 38 | Asset upload(final String path, final TempBlob tempBlob, final Payload payload, final AssetKind assetKind) throws IOException; 39 | 40 | boolean delete(String path); 41 | } 42 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/orient/hosted/HelmHostedWritePolicySelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.orient.hosted; 14 | 15 | import java.util.Objects; 16 | 17 | import org.sonatype.nexus.repository.storage.Asset; 18 | import org.sonatype.nexus.repository.storage.WritePolicy; 19 | import org.sonatype.nexus.repository.storage.WritePolicySelector; 20 | 21 | import static org.sonatype.nexus.repository.storage.AssetEntityAdapter.P_ASSET_KIND; 22 | import static org.sonatype.nexus.repository.storage.WritePolicy.ALLOW_ONCE; 23 | import static org.sonatype.repository.helm.internal.AssetKind.HELM_PACKAGE; 24 | 25 | /** 26 | * @since 0.0.2 27 | */ 28 | public class HelmHostedWritePolicySelector 29 | implements WritePolicySelector 30 | { 31 | @Override 32 | public WritePolicy select(final Asset asset, final WritePolicy configured) { 33 | if (ALLOW_ONCE == configured) { 34 | final String assetKind = asset.formatAttributes().get(P_ASSET_KIND, String.class); 35 | if (!Objects.equals(HELM_PACKAGE.name(), assetKind)) { 36 | return WritePolicy.ALLOW; 37 | } 38 | } 39 | return configured; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/orient/hosted/HostedHandlers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.orient.hosted; 14 | 15 | import javax.inject.Inject; 16 | import javax.inject.Named; 17 | import javax.inject.Singleton; 18 | 19 | import org.sonatype.goodies.common.ComponentSupport; 20 | import org.sonatype.nexus.repository.view.Content; 21 | import org.sonatype.nexus.repository.view.Handler; 22 | import org.sonatype.nexus.repository.view.matchers.token.TokenMatcher; 23 | import org.sonatype.nexus.repository.view.matchers.token.TokenMatcher.State; 24 | import org.sonatype.repository.helm.internal.AssetKind; 25 | import org.sonatype.repository.helm.internal.util.HelmPathUtils; 26 | 27 | import static com.google.common.base.Preconditions.checkNotNull; 28 | import static org.sonatype.nexus.repository.http.HttpResponses.notFound; 29 | import static org.sonatype.nexus.repository.http.HttpResponses.ok; 30 | 31 | /** 32 | * Helm Hosted Handlers 33 | * 34 | * @since 0.0.2 35 | */ 36 | @Named 37 | @Singleton 38 | public class HostedHandlers 39 | extends ComponentSupport 40 | { 41 | private HelmPathUtils helmPathUtils; 42 | 43 | @Inject 44 | public HostedHandlers(final HelmPathUtils helmPathUtils) { 45 | this.helmPathUtils = checkNotNull(helmPathUtils); 46 | } 47 | 48 | public final Handler get = context -> { 49 | AssetKind assetKind = context.getAttributes().require(AssetKind.class); 50 | String path; 51 | if (assetKind == AssetKind.HELM_INDEX) { 52 | path = "index.yaml"; 53 | } 54 | else { 55 | State state = context.getAttributes().require(TokenMatcher.State.class); 56 | path = helmPathUtils.filename(state); 57 | } 58 | Content content = context.getRepository().facet(HelmHostedFacet.class).get(path); 59 | 60 | return (content != null) ? ok(content) : notFound(); 61 | }; 62 | 63 | public final Handler upload = context -> { 64 | State state = context.getAttributes().require(TokenMatcher.State.class); 65 | String path = helmPathUtils.buildAssetPath(state); 66 | AssetKind assetKind = context.getAttributes().require(AssetKind.class); 67 | context.getRepository().facet(HelmHostedFacet.class).upload(path, context.getRequest().getPayload(), assetKind); 68 | return ok(); 69 | }; 70 | 71 | public final Handler delete = context -> { 72 | State state = context.getAttributes().require(TokenMatcher.State.class); 73 | String path = helmPathUtils.buildAssetPath(state); 74 | 75 | boolean deleted = context.getRepository().facet(HelmHostedFacet.class).delete(path); 76 | 77 | return (deleted) ? ok() : notFound(); 78 | }; 79 | } 80 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/orient/metadata/IndexYamlBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.orient.metadata; 14 | 15 | import java.io.InputStream; 16 | import java.io.OutputStream; 17 | 18 | import javax.inject.Inject; 19 | import javax.inject.Named; 20 | 21 | import org.sonatype.nexus.repository.storage.StorageFacet; 22 | import org.sonatype.nexus.repository.storage.TempBlob; 23 | import org.sonatype.nexus.thread.io.StreamCopier; 24 | import org.sonatype.repository.helm.internal.HelmFormat; 25 | import org.sonatype.repository.helm.internal.metadata.ChartIndex; 26 | import org.sonatype.repository.helm.internal.util.YamlParser; 27 | 28 | import static com.google.common.base.Preconditions.checkNotNull; 29 | 30 | /** 31 | * @since 0.0.2 32 | */ 33 | @Named 34 | public class IndexYamlBuilder 35 | { 36 | private final YamlParser yamlParser; 37 | 38 | @Inject 39 | public IndexYamlBuilder(final YamlParser yamlParser) { 40 | this.yamlParser = checkNotNull(yamlParser); 41 | } 42 | 43 | public TempBlob build(final ChartIndex index, final StorageFacet storageFacet) { 44 | return new StreamCopier<>(os -> readIntoYaml(os, index), is -> createTempBlob(is, storageFacet)).read(); 45 | } 46 | 47 | private void readIntoYaml(final OutputStream os, final ChartIndex index) { 48 | yamlParser.write(os, index); 49 | } 50 | 51 | private TempBlob createTempBlob(final InputStream inputStream, final StorageFacet storageFacet) { 52 | return storageFacet.createTempBlob(inputStream, HelmFormat.HASH_ALGORITHMS); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/orient/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | @FeatureFlag(name = "nexus.orient.store.content") 14 | package org.sonatype.repository.helm.internal.orient; 15 | 16 | import org.sonatype.nexus.common.app.FeatureFlag; 17 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/orient/restore/HelmRestoreFacetImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.orient.restore; 14 | 15 | import java.io.IOException; 16 | import java.io.InputStream; 17 | 18 | import javax.inject.Inject; 19 | import javax.inject.Named; 20 | 21 | import org.sonatype.nexus.common.collect.AttributesMap; 22 | import org.sonatype.nexus.repository.FacetSupport; 23 | import org.sonatype.nexus.repository.config.Configuration; 24 | import org.sonatype.nexus.repository.storage.Asset; 25 | import org.sonatype.nexus.repository.storage.AssetBlob; 26 | import org.sonatype.nexus.repository.storage.Query; 27 | import org.sonatype.nexus.repository.storage.StorageTx; 28 | import org.sonatype.nexus.repository.transaction.TransactionalTouchBlob; 29 | import org.sonatype.nexus.repository.view.Content; 30 | import org.sonatype.nexus.transaction.UnitOfWork; 31 | import org.sonatype.repository.helm.HelmAttributes; 32 | import org.sonatype.repository.helm.internal.orient.HelmFacet; 33 | import org.sonatype.repository.helm.HelmRestoreFacet; 34 | import org.sonatype.repository.helm.internal.AssetKind; 35 | import org.sonatype.repository.helm.internal.util.HelmAttributeParser; 36 | 37 | import static org.sonatype.nexus.repository.storage.ComponentEntityAdapter.P_VERSION; 38 | import static org.sonatype.nexus.repository.storage.MetadataNodeEntityAdapter.P_NAME; 39 | 40 | /** 41 | * @since 1.0.0 42 | */ 43 | @Named 44 | public class HelmRestoreFacetImpl 45 | extends FacetSupport 46 | implements HelmRestoreFacet 47 | { 48 | private HelmFacet helmFacet; 49 | 50 | private final HelmAttributeParser helmAttributeParser; 51 | 52 | @Inject 53 | public HelmRestoreFacetImpl(final HelmAttributeParser helmAttributeParser) 54 | { 55 | this.helmAttributeParser = helmAttributeParser; 56 | } 57 | 58 | @Override 59 | protected void doInit(final Configuration configuration) throws Exception { 60 | super.doInit(configuration); 61 | helmFacet = facet(HelmFacet.class); 62 | } 63 | 64 | @Override 65 | @TransactionalTouchBlob 66 | public void restore(final AssetBlob assetBlob, final String path) throws IOException { 67 | StorageTx tx = UnitOfWork.currentTx(); 68 | AssetKind assetKind = AssetKind.getAssetKindByFileName(path); 69 | HelmAttributes attributes = helmAttributeParser.getAttributes(assetKind, assetBlob.getBlob().getInputStream()); 70 | Asset asset = helmFacet.findOrCreateAsset(tx, path, assetKind, attributes); 71 | tx.attachBlob(asset, assetBlob); 72 | Content.applyToAsset(asset, Content.maintainLastModified(asset, new AttributesMap())); 73 | tx.saveAsset(asset); 74 | } 75 | 76 | @Override 77 | @TransactionalTouchBlob 78 | public boolean assetExists(final String path) { 79 | final StorageTx tx = UnitOfWork.currentTx(); 80 | return tx.findAssetWithProperty(P_NAME, path, tx.findBucket(getRepository())) != null; 81 | } 82 | 83 | @Override 84 | public boolean componentRequired(final String name) { 85 | return AssetKind.getAssetKindByFileName(name) != AssetKind.HELM_INDEX; 86 | } 87 | 88 | @Override 89 | public Query getComponentQuery(final HelmAttributes attributes) { 90 | return Query.builder().where(P_NAME).eq(attributes.getName()) 91 | .and(P_VERSION).eq(attributes.getVersion()).build(); 92 | } 93 | 94 | @Override 95 | public HelmAttributes extractComponentAttributesFromArchive(final String blobName, final InputStream is) throws IOException { 96 | AssetKind assetKind = AssetKind.getAssetKindByFileName((blobName)); 97 | return helmAttributeParser.getAttributes(assetKind, is); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/security/HelmFormatSecurityContributor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.security; 14 | 15 | import javax.inject.Inject; 16 | import javax.inject.Named; 17 | import javax.inject.Singleton; 18 | 19 | import org.sonatype.nexus.repository.Format; 20 | import org.sonatype.nexus.repository.security.RepositoryFormatSecurityContributor; 21 | import org.sonatype.repository.helm.internal.HelmFormat; 22 | 23 | /** 24 | * Helm format security resource. 25 | */ 26 | @Named 27 | @Singleton 28 | public class HelmFormatSecurityContributor 29 | extends RepositoryFormatSecurityContributor 30 | { 31 | @Inject 32 | public HelmFormatSecurityContributor(@Named(HelmFormat.NAME) final Format format) { 33 | super(format); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/security/HelmSecurityFacet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.security; 14 | 15 | import javax.inject.Inject; 16 | import javax.inject.Named; 17 | 18 | import org.sonatype.nexus.repository.config.Configuration; 19 | import org.sonatype.nexus.repository.security.ContentPermissionChecker; 20 | import org.sonatype.nexus.repository.security.SecurityFacetSupport; 21 | import org.sonatype.nexus.repository.security.VariableResolverAdapter; 22 | 23 | /** 24 | * Helm format security facet. 25 | */ 26 | @Named 27 | public class HelmSecurityFacet 28 | extends SecurityFacetSupport 29 | { 30 | @Inject 31 | public HelmSecurityFacet( 32 | final HelmFormatSecurityContributor securityResource, 33 | @Named("simple") final VariableResolverAdapter variableResolverAdapter, 34 | final ContentPermissionChecker contentPermissionChecker) 35 | { 36 | super(securityResource, variableResolverAdapter, contentPermissionChecker); 37 | } 38 | 39 | @Override 40 | protected void doValidate(final Configuration configuration) throws Exception { 41 | super.doValidate(configuration); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/ui/UiPluginDescriptorImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.ui; 14 | 15 | import javax.annotation.Priority; 16 | import javax.inject.Named; 17 | import javax.inject.Singleton; 18 | 19 | import org.sonatype.nexus.rapture.UiPluginDescriptorSupport; 20 | 21 | @Named 22 | @Singleton 23 | @Priority(Integer.MAX_VALUE - 200) 24 | public class UiPluginDescriptorImpl 25 | extends UiPluginDescriptorSupport 26 | { 27 | public UiPluginDescriptorImpl() { 28 | super("nexus-repository-helm"); 29 | setNamespace("NX.helm"); 30 | setConfigClassName("NX.helm.app.PluginConfig"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/util/HelmAttributeParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.util; 14 | 15 | import java.io.IOException; 16 | import java.io.InputStream; 17 | 18 | import javax.inject.Inject; 19 | import javax.inject.Named; 20 | import javax.inject.Singleton; 21 | 22 | import org.sonatype.repository.helm.HelmAttributes; 23 | import org.sonatype.repository.helm.internal.AssetKind; 24 | 25 | import static com.google.common.base.Preconditions.checkNotNull; 26 | 27 | /** 28 | * @since 0.0.2 29 | */ 30 | @Named 31 | @Singleton 32 | public class HelmAttributeParser 33 | { 34 | private TgzParser tgzParser; 35 | private YamlParser yamlParser; 36 | private ProvenanceParser provenanceParser; 37 | 38 | @Inject 39 | public HelmAttributeParser(final TgzParser tgzParser, 40 | final YamlParser yamlParser, 41 | final ProvenanceParser provenanceParser) { 42 | this.tgzParser = checkNotNull(tgzParser); 43 | this.yamlParser = checkNotNull(yamlParser); 44 | this.provenanceParser = checkNotNull(provenanceParser); 45 | } 46 | 47 | public HelmAttributes getAttributes(final AssetKind assetKind, final InputStream inputStream) throws IOException { 48 | switch (assetKind) { 49 | case HELM_PACKAGE: 50 | return getAttributesFromInputStream(inputStream); 51 | case HELM_PROVENANCE: 52 | return getAttributesProvenanceFromInputStream(inputStream); 53 | default: 54 | return new HelmAttributes(); 55 | } 56 | } 57 | 58 | private HelmAttributes getAttributesProvenanceFromInputStream(final InputStream inputStream) throws IOException { 59 | return provenanceParser.parse(inputStream); 60 | } 61 | 62 | private HelmAttributes getAttributesFromInputStream(final InputStream inputStream) throws IOException { 63 | try (InputStream is = tgzParser.getChartFromInputStream(inputStream)) { 64 | return new HelmAttributes(yamlParser.load(is)); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/util/HelmPathUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.util; 14 | 15 | import javax.inject.Named; 16 | import javax.inject.Singleton; 17 | 18 | import org.sonatype.nexus.repository.view.Context; 19 | import org.sonatype.nexus.repository.view.matchers.token.TokenMatcher; 20 | 21 | import static com.google.common.base.Preconditions.checkNotNull; 22 | 23 | /** 24 | * Utility methods for working with Helm routes and paths. 25 | * 26 | * @since 0.0.1 27 | */ 28 | @Named 29 | @Singleton 30 | public class HelmPathUtils 31 | { 32 | /** 33 | * Returns the filename from a {@link TokenMatcher.State}. 34 | */ 35 | public String filename(final TokenMatcher.State state) { 36 | return match(state, "filename"); 37 | } 38 | 39 | public String contentFilePath(final TokenMatcher.State state) { 40 | return String.format("/%s",filename(state)); 41 | } 42 | 43 | public String extension(final TokenMatcher.State state) { 44 | return match(state, "extension"); 45 | } 46 | 47 | /** 48 | * Utility method encapsulating getting a particular token by name from a matcher, including preconditions. 49 | */ 50 | private String match(final TokenMatcher.State state, final String name) { 51 | checkNotNull(state); 52 | String result = state.getTokens().get(name); 53 | checkNotNull(result); 54 | return result; 55 | } 56 | 57 | /** 58 | * Returns the {@link TokenMatcher.State} for the content. 59 | */ 60 | public TokenMatcher.State matcherState(final Context context) { 61 | return context.getAttributes().require(TokenMatcher.State.class); 62 | } 63 | 64 | public String buildAssetPath(final TokenMatcher.State matcherState) { 65 | String filename = filename(matcherState); 66 | String extension = extension(matcherState); 67 | return filename + "." + extension; 68 | } 69 | 70 | public String buildContentAssetPath(final TokenMatcher.State matcherState) { 71 | return String.format("/%s", buildAssetPath(matcherState)); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/util/ProvenanceParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.util; 14 | 15 | import java.io.BufferedReader; 16 | import java.io.IOException; 17 | import java.io.InputStream; 18 | import java.io.InputStreamReader; 19 | 20 | import javax.inject.Named; 21 | import javax.inject.Singleton; 22 | 23 | import org.sonatype.repository.helm.HelmAttributes; 24 | import org.sonatype.repository.helm.internal.database.HelmProperties; 25 | 26 | /** 27 | * @since 1.0.0 28 | */ 29 | @Named 30 | @Singleton 31 | public class ProvenanceParser 32 | { 33 | public HelmAttributes parse(final InputStream inputStream) throws IOException { 34 | HelmAttributes attributes = new HelmAttributes(); 35 | try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) { 36 | String line; 37 | while ((line = bufferedReader.readLine()) != null) { 38 | if (line.startsWith(HelmProperties.NAME.getPropertyName())) { 39 | attributes.setName(getValue(line)); 40 | } 41 | if (line.startsWith(HelmProperties.DESCRIPTION.getPropertyName())) { 42 | attributes.setDescription(getValue(line)); 43 | } 44 | if (line.startsWith(HelmProperties.VERSION.getPropertyName())) { 45 | attributes.setVersion(getValue(line)); 46 | } 47 | if (line.startsWith(HelmProperties.ICON.getPropertyName())) { 48 | attributes.setIcon(getValue(line)); 49 | } 50 | if (line.startsWith(HelmProperties.APP_VERSION.getPropertyName())) { 51 | attributes.setAppVersion(getValue(line)); 52 | } 53 | } 54 | } 55 | return attributes; 56 | } 57 | 58 | private String getValue(String string) { 59 | return string.substring(string.indexOf(":") + 1).trim(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/internal/util/TgzParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.util; 14 | 15 | import java.io.ByteArrayInputStream; 16 | import java.io.IOException; 17 | import java.io.InputStream; 18 | 19 | import javax.inject.Named; 20 | import javax.inject.Singleton; 21 | 22 | import org.apache.commons.compress.archivers.ArchiveEntry; 23 | import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; 24 | import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; 25 | 26 | /** 27 | * Utility methods for working with tgz files 28 | * 29 | * @since 0.0.1 30 | */ 31 | @Named 32 | @Singleton 33 | public class TgzParser 34 | { 35 | private static final String CHART_NAME = "Chart.yaml"; 36 | 37 | public InputStream getChartFromInputStream(final InputStream is) throws IOException { 38 | try (GzipCompressorInputStream gzis = new GzipCompressorInputStream(is)) { 39 | try (TarArchiveInputStream tais = new TarArchiveInputStream(gzis)) { 40 | ArchiveEntry currentEntry; 41 | while ((currentEntry = tais.getNextEntry()) != null) { 42 | if (currentEntry.getName().endsWith(CHART_NAME)) { 43 | byte[] buf = new byte[(int) currentEntry.getSize()]; 44 | tais.read(buf, 0, buf.length); 45 | return new ByteArrayInputStream(buf); 46 | } 47 | } 48 | } 49 | } 50 | throw new IllegalArgumentException(String.format("%s not found", CHART_NAME)); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/rest/HelmHostedRepositoriesApiResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.rest; 14 | 15 | import javax.ws.rs.POST; 16 | import javax.ws.rs.PUT; 17 | import javax.ws.rs.Path; 18 | import javax.ws.rs.PathParam; 19 | import javax.ws.rs.core.Response; 20 | 21 | import org.sonatype.nexus.repository.rest.api.AbstractRepositoriesApiResource; 22 | import org.sonatype.nexus.validation.Validate; 23 | import org.sonatype.repository.helm.api.HelmHostedRepositoryApiRequest; 24 | 25 | import io.swagger.annotations.Api; 26 | import io.swagger.annotations.ApiOperation; 27 | import io.swagger.annotations.ApiParam; 28 | import io.swagger.annotations.ApiResponse; 29 | import io.swagger.annotations.ApiResponses; 30 | import org.apache.shiro.authz.annotation.RequiresAuthentication; 31 | 32 | import static org.sonatype.nexus.rest.ApiDocConstants.API_REPOSITORY_MANAGEMENT; 33 | import static org.sonatype.nexus.rest.ApiDocConstants.AUTHENTICATION_REQUIRED; 34 | import static org.sonatype.nexus.rest.ApiDocConstants.INSUFFICIENT_PERMISSIONS; 35 | import static org.sonatype.nexus.rest.ApiDocConstants.REPOSITORY_CREATED; 36 | import static org.sonatype.nexus.rest.ApiDocConstants.REPOSITORY_UPDATED; 37 | 38 | /** 39 | * @since 1.0.0 40 | */ 41 | @Api(value = API_REPOSITORY_MANAGEMENT) 42 | 43 | public abstract class HelmHostedRepositoriesApiResource 44 | extends AbstractRepositoriesApiResource 45 | { 46 | @ApiOperation("Create Helm hosted repository") 47 | @ApiResponses(value = { 48 | @ApiResponse(code = 201, message = REPOSITORY_CREATED), 49 | @ApiResponse(code = 401, message = AUTHENTICATION_REQUIRED), 50 | @ApiResponse(code = 403, message = INSUFFICIENT_PERMISSIONS) 51 | }) 52 | @POST 53 | @RequiresAuthentication 54 | @Validate 55 | @Override 56 | public Response createRepository(final HelmHostedRepositoryApiRequest request) { 57 | return super.createRepository(request); 58 | } 59 | 60 | @ApiOperation("Update Helm hosted repository") 61 | @ApiResponses(value = { 62 | @ApiResponse(code = 204, message = REPOSITORY_UPDATED), 63 | @ApiResponse(code = 401, message = AUTHENTICATION_REQUIRED), 64 | @ApiResponse(code = 403, message = INSUFFICIENT_PERMISSIONS) 65 | }) 66 | @PUT 67 | @Path("/{repositoryName}") 68 | @RequiresAuthentication 69 | @Validate 70 | @Override 71 | public Response updateRepository( 72 | final HelmHostedRepositoryApiRequest request, 73 | @ApiParam(value = "Name of the repository to update") @PathParam("repositoryName") final String repositoryName) 74 | { 75 | return super.updateRepository(request, repositoryName); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/rest/HelmHostedRepositoriesApiResourceBeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.rest; 14 | 15 | import javax.inject.Named; 16 | import javax.inject.Singleton; 17 | import javax.ws.rs.Path; 18 | 19 | import org.sonatype.nexus.repository.rest.api.RepositoriesApiResourceBeta; 20 | 21 | import io.swagger.annotations.Api; 22 | 23 | @Named 24 | @Singleton 25 | @Path(RepositoriesApiResourceBeta.RESOURCE_URI + "/helm/hosted") 26 | @Api(hidden = true) 27 | @Deprecated 28 | public class HelmHostedRepositoriesApiResourceBeta 29 | extends HelmHostedRepositoriesApiResource 30 | { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/rest/HelmHostedRepositoriesApiResourceV1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.rest; 14 | 15 | import javax.inject.Named; 16 | import javax.inject.Singleton; 17 | import javax.ws.rs.Path; 18 | 19 | import org.sonatype.nexus.repository.rest.api.RepositoriesApiResourceV1; 20 | 21 | @Named 22 | @Singleton 23 | @Path(RepositoriesApiResourceV1.RESOURCE_URI + "/helm/hosted") 24 | public class HelmHostedRepositoriesApiResourceV1 25 | extends HelmHostedRepositoriesApiResource 26 | { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/rest/HelmProxyRepositoriesApiResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.rest; 14 | 15 | import javax.ws.rs.POST; 16 | import javax.ws.rs.PUT; 17 | import javax.ws.rs.Path; 18 | import javax.ws.rs.PathParam; 19 | import javax.ws.rs.core.Response; 20 | 21 | import org.sonatype.nexus.repository.rest.api.AbstractRepositoriesApiResource; 22 | import org.sonatype.nexus.validation.Validate; 23 | import org.sonatype.repository.helm.api.HelmProxyRepositoryApiRequest; 24 | 25 | import io.swagger.annotations.Api; 26 | import io.swagger.annotations.ApiOperation; 27 | import io.swagger.annotations.ApiParam; 28 | import io.swagger.annotations.ApiResponse; 29 | import io.swagger.annotations.ApiResponses; 30 | import org.apache.shiro.authz.annotation.RequiresAuthentication; 31 | 32 | import static org.sonatype.nexus.rest.ApiDocConstants.API_REPOSITORY_MANAGEMENT; 33 | import static org.sonatype.nexus.rest.ApiDocConstants.AUTHENTICATION_REQUIRED; 34 | import static org.sonatype.nexus.rest.ApiDocConstants.INSUFFICIENT_PERMISSIONS; 35 | import static org.sonatype.nexus.rest.ApiDocConstants.REPOSITORY_CREATED; 36 | import static org.sonatype.nexus.rest.ApiDocConstants.REPOSITORY_UPDATED; 37 | 38 | /** 39 | * @since 1.0.0 40 | */ 41 | @Api(value = API_REPOSITORY_MANAGEMENT) 42 | public abstract class HelmProxyRepositoriesApiResource 43 | extends AbstractRepositoriesApiResource 44 | { 45 | @ApiOperation("Create Helm proxy repository") 46 | @ApiResponses(value = { 47 | @ApiResponse(code = 201, message = REPOSITORY_CREATED), 48 | @ApiResponse(code = 401, message = AUTHENTICATION_REQUIRED), 49 | @ApiResponse(code = 403, message = INSUFFICIENT_PERMISSIONS) 50 | }) 51 | @POST 52 | @RequiresAuthentication 53 | @Validate 54 | @Override 55 | public Response createRepository(final HelmProxyRepositoryApiRequest request) { 56 | return super.createRepository(request); 57 | } 58 | 59 | @ApiOperation("Update Helm proxy repository") 60 | @ApiResponses(value = { 61 | @ApiResponse(code = 204, message = REPOSITORY_UPDATED), 62 | @ApiResponse(code = 401, message = AUTHENTICATION_REQUIRED), 63 | @ApiResponse(code = 403, message = INSUFFICIENT_PERMISSIONS) 64 | }) 65 | @PUT 66 | @Path("/{repositoryName}") 67 | @RequiresAuthentication 68 | @Validate 69 | @Override 70 | public Response updateRepository( 71 | final HelmProxyRepositoryApiRequest request, 72 | @ApiParam(value = "Name of the repository to update") @PathParam("repositoryName") final String repositoryName) 73 | { 74 | return super.updateRepository(request, repositoryName); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/rest/HelmProxyRepositoriesApiResourceBeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.rest; 14 | 15 | import javax.inject.Named; 16 | import javax.inject.Singleton; 17 | import javax.ws.rs.Path; 18 | 19 | import org.sonatype.nexus.repository.rest.api.RepositoriesApiResourceBeta; 20 | 21 | import io.swagger.annotations.Api; 22 | 23 | @Named 24 | @Singleton 25 | @Path(RepositoriesApiResourceBeta.RESOURCE_URI + "/helm/proxy") 26 | @Api(hidden = true) 27 | @Deprecated 28 | public class HelmProxyRepositoriesApiResourceBeta 29 | extends HelmProxyRepositoriesApiResource 30 | { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/java/org/sonatype/repository/helm/rest/HelmProxyRepositoriesApiResourceV1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.rest; 14 | 15 | import javax.inject.Named; 16 | import javax.inject.Singleton; 17 | import javax.ws.rs.Path; 18 | 19 | import org.sonatype.nexus.repository.rest.api.RepositoriesApiResourceV1; 20 | 21 | @Named 22 | @Singleton 23 | @Path(RepositoriesApiResourceV1.RESOURCE_URI + "/helm/proxy") 24 | public class HelmProxyRepositoriesApiResourceV1 25 | extends HelmProxyRepositoriesApiResource 26 | { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/resources/static/rapture/NX/helm/app/PluginConfig.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | Ext.define('NX.helm.app.PluginConfig', { 14 | '@aggregate_priority': 100, 15 | 16 | requires: [ 17 | 'NX.helm.app.PluginStrings', 18 | 'NX.helm.util.HelmRepositoryUrls' 19 | ], 20 | controllers: [{ 21 | id: 'NX.helm.controller.SearchHelm', 22 | active: function() { 23 | return NX.app.Application.bundleActive('org.sonatype.nexus.plugins.nexus-repository-helm'); 24 | } 25 | } 26 | ] 27 | }); 28 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/resources/static/rapture/NX/helm/app/PluginStrings.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | 14 | /*global Ext, NX*/ 15 | 16 | /** 17 | * Helm plugin strings. 18 | */ 19 | Ext.define('NX.helm.app.PluginStrings', { 20 | '@aggregate_priority': 90, 21 | 22 | singleton: true, 23 | requires: [ 24 | 'NX.I18n' 25 | ], 26 | 27 | keys: { 28 | Repository_Facet_HelmFacet_Title: 'Helm Settings', 29 | SearchHelm_Group: 'Helm Repositories', 30 | SearchHelm_License_FieldLabel: 'License', 31 | SearchHelm_Text: 'Helm', 32 | SearchHelm_Description: 'Search for components in Helm repositories' 33 | } 34 | }, function(self) { 35 | NX.I18n.register(self); 36 | }); 37 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/resources/static/rapture/NX/helm/controller/SearchHelm.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | /** 14 | * @since 1.0.0 15 | */ 16 | Ext.define('NX.helm.controller.SearchHelm', { 17 | extend: 'NX.app.Controller', 18 | requires: [ 19 | 'NX.I18n' 20 | ], 21 | 22 | /** 23 | * @override 24 | */ 25 | init: function() { 26 | var me = this, 27 | search = me.getController('NX.coreui.controller.Search'); 28 | 29 | search.registerFilter({ 30 | id: 'helm', 31 | name: 'helm', 32 | text: NX.I18n.get('SearchHelm_Text'), 33 | description: NX.I18n.get('SearchHelm_Description'), 34 | readOnly: true, 35 | criterias: [ 36 | {id: 'format', value: 'helm', hidden: true}, 37 | {id: 'name.raw'}, 38 | {id: 'version'} 39 | ] 40 | }, me); 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/resources/static/rapture/NX/helm/util/HelmRepositoryUrls.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | Ext.define('NX.helm.util.HelmRepositoryUrls', { 14 | '@aggregate_priority': 90, 15 | 16 | singleton: true, 17 | requires: [ 18 | 'NX.coreui.util.RepositoryUrls', 19 | 'NX.util.Url' 20 | ] 21 | }, function(self) { 22 | NX.coreui.util.RepositoryUrls.addRepositoryUrlStrategy('helm', function (assetModel) { 23 | var repositoryName = assetModel.get('repositoryName'), assetName = assetModel.get('name'); 24 | return NX.util.Url.asLink(NX.util.Url.baseUrl + '/repository/' + repositoryName + '/' + assetName, assetName); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/resources/static/rapture/NX/helm/view/repository/recipe/HelmHosted.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | /*global Ext, NX*/ 14 | 15 | /** 16 | * Repository "Settings" form for a helm Hosted repository. 17 | * 18 | * @since 0.0.2 19 | */ 20 | Ext.define('NX.coreui.view.repository.recipe.HelmHosted', { 21 | extend: 'NX.coreui.view.repository.RepositorySettingsForm', 22 | alias: 'widget.nx-coreui-repository-helm-hosted', 23 | requires: [ 24 | 'NX.coreui.view.repository.facet.StorageFacet', 25 | 'NX.coreui.view.repository.facet.StorageFacetHosted', 26 | 'NX.coreui.view.repository.facet.CleanupPolicyFacet' 27 | ], 28 | 29 | /** 30 | * @override 31 | */ 32 | initComponent: function() { 33 | var me = this; 34 | 35 | me.items = [ 36 | {xtype: 'nx-coreui-repository-storage-facet'}, 37 | {xtype: 'nx-coreui-repository-storage-hosted-facet'}, 38 | {xtype: 'nx-coreui-repository-cleanup-policy-facet'} 39 | ]; 40 | 41 | me.callParent(); 42 | } 43 | }); 44 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/resources/static/rapture/NX/helm/view/repository/recipe/HelmProxy.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | /*global Ext, NX*/ 14 | 15 | /** 16 | * Repository "Settings" form for a Helm Proxy repository 17 | */ 18 | Ext.define('NX.helm.view.repository.recipe.HelmProxy', { 19 | extend: 'NX.coreui.view.repository.RepositorySettingsForm', 20 | alias: 'widget.nx-coreui-repository-helm-proxy', 21 | requires: [ 22 | 'NX.coreui.view.repository.facet.ProxyFacet', 23 | 'NX.coreui.view.repository.facet.StorageFacet', 24 | 'NX.coreui.view.repository.facet.RoutingRuleFacet', 25 | 'NX.coreui.view.repository.facet.HttpClientFacet', 26 | 'NX.coreui.view.repository.facet.NegativeCacheFacet', 27 | 'NX.coreui.view.repository.facet.CleanupPolicyFacet' 28 | ], 29 | 30 | /** 31 | * @override 32 | */ 33 | initComponent: function () { 34 | var me = this; 35 | 36 | me.items = [ 37 | {xtype: 'nx-coreui-repository-proxy-facet'}, 38 | {xtype: 'nx-coreui-repository-storage-facet'}, 39 | {xtype: 'nx-coreui-repository-routing-rule-facet'}, 40 | {xtype: 'nx-coreui-repository-negativecache-facet'}, 41 | {xtype: 'nx-coreui-repository-httpclient-facet'}, 42 | {xtype: 'nx-coreui-repository-cleanup-policy-facet'} 43 | ]; 44 | 45 | me.callParent(); 46 | } 47 | }); 48 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/main/resources/static/rapture/resources/nexus-repository-helm-debug.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | /* placeholder */ 14 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/HelmAssetAttributePopulatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal; 14 | 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | import org.sonatype.goodies.testsupport.TestSupport; 19 | import org.sonatype.nexus.common.collect.NestedAttributesMap; 20 | import org.sonatype.repository.helm.HelmAttributes; 21 | import org.sonatype.repository.helm.internal.database.HelmProperties; 22 | 23 | import org.junit.Test; 24 | 25 | import static org.hamcrest.CoreMatchers.equalTo; 26 | import static org.hamcrest.CoreMatchers.is; 27 | import static org.hamcrest.CoreMatchers.notNullValue; 28 | import static org.hamcrest.MatcherAssert.assertThat; 29 | import static org.sonatype.nexus.repository.storage.MetadataNodeEntityAdapter.P_ATTRIBUTES; 30 | 31 | public class HelmAssetAttributePopulatorTest 32 | extends TestSupport 33 | { 34 | @Test 35 | public void testPopulateNestedAttributesMapFromHelmAttributes() throws Exception { 36 | NestedAttributesMap nestedAttributesMap = new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>()); 37 | 38 | setUpHelmAttributes().populate(nestedAttributesMap); 39 | 40 | assertThat(nestedAttributesMap.get(HelmProperties.ICON.getPropertyName()), is(equalTo("icon"))); 41 | assertThat(nestedAttributesMap.get(HelmProperties.DESCRIPTION.getPropertyName()), is(equalTo("description"))); 42 | assertThat(nestedAttributesMap.get(HelmProperties.NAME.getPropertyName()), is(equalTo("name"))); 43 | assertThat(nestedAttributesMap.get(HelmProperties.VERSION.getPropertyName()), is(equalTo("1.0.0"))); 44 | assertThat(nestedAttributesMap.get(HelmProperties.APP_VERSION.getPropertyName()), is(equalTo("0.0.1"))); 45 | assertThat(nestedAttributesMap.get(HelmProperties.MAINTAINERS.getPropertyName()), is(notNullValue())); 46 | assertThat(nestedAttributesMap.get(HelmProperties.SOURCES.getPropertyName()), is(notNullValue())); 47 | } 48 | 49 | private HelmAttributes setUpHelmAttributes() { 50 | Map properties = new HashMap<>(); 51 | properties.put(HelmProperties.DESCRIPTION.getPropertyName(), "description"); 52 | properties.put(HelmProperties.ICON.getPropertyName(), "icon"); 53 | properties.put(HelmProperties.NAME.getPropertyName(), "name"); 54 | properties.put(HelmProperties.VERSION.getPropertyName(), "1.0.0"); 55 | properties.put(HelmProperties.APP_VERSION.getPropertyName(), "0.0.1"); 56 | properties.put(HelmProperties.SOURCES.getPropertyName(), HelmListTestHelper.getSourcesList()); 57 | properties.put(HelmProperties.MAINTAINERS.getPropertyName(), HelmListTestHelper.getMaintainersList()); 58 | 59 | return new HelmAttributes(properties); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/HelmFormatTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal; 14 | 15 | import org.junit.Test; 16 | 17 | import static org.hamcrest.CoreMatchers.equalTo; 18 | import static org.hamcrest.CoreMatchers.is; 19 | import static org.hamcrest.MatcherAssert.assertThat; 20 | 21 | public class HelmFormatTest 22 | { 23 | private HelmFormat underTest; 24 | 25 | @Test 26 | public void checkFormatNameIsCorrect() { 27 | underTest = new HelmFormat(); 28 | 29 | assertThat(underTest.getValue(), is(equalTo("helm"))); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/HelmListTestHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal; 14 | 15 | import java.util.ArrayList; 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | public class HelmListTestHelper 21 | { 22 | public static List> getMaintainersList() { 23 | List> maintainers = new ArrayList<>(); 24 | Map map = new HashMap<>(); 25 | 26 | map.put("email", "containers@bitnami.com"); 27 | map.put("name", "Bitnami"); 28 | 29 | maintainers.add(map); 30 | 31 | return maintainers; 32 | } 33 | 34 | public static List getUrlList() { 35 | List list = new ArrayList<>(); 36 | 37 | list.add("mongodb-0.5.2.tgz"); 38 | 39 | return list; 40 | } 41 | 42 | public static List getSourcesList() { 43 | List list = new ArrayList<>(); 44 | 45 | list.add("https://github.com/bitnami/bitnami-docker-mongodb"); 46 | 47 | return list; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/HelmRecipeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal; 14 | 15 | import org.sonatype.goodies.testsupport.TestSupport; 16 | import org.sonatype.nexus.repository.types.HostedType; 17 | import org.sonatype.nexus.repository.types.ProxyType; 18 | import org.sonatype.nexus.repository.view.handlers.HighAvailabilitySupportChecker; 19 | import org.sonatype.repository.helm.internal.orient.hosted.HelmHostedRecipe; 20 | import org.sonatype.repository.helm.internal.orient.proxy.HelmProxyRecipe; 21 | 22 | import org.junit.Before; 23 | import org.junit.Test; 24 | import org.mockito.Mock; 25 | 26 | import static org.hamcrest.CoreMatchers.equalTo; 27 | import static org.hamcrest.CoreMatchers.is; 28 | import static org.hamcrest.MatcherAssert.assertThat; 29 | import static org.mockito.Mockito.verify; 30 | import static org.mockito.Mockito.when; 31 | 32 | public class HelmRecipeTest 33 | extends TestSupport 34 | { 35 | 36 | @Mock 37 | private HelmFormat helmFormat; 38 | 39 | @Mock 40 | private HighAvailabilitySupportChecker highAvailabilitySupportChecker; 41 | 42 | private HelmProxyRecipe helmProxyRecipe; 43 | 44 | private HelmHostedRecipe helmHostedRecipe; 45 | 46 | @Before 47 | public void setUp() { 48 | when(helmFormat.getValue()).thenReturn(HelmFormat.NAME); 49 | helmProxyRecipe = new HelmProxyRecipe(new ProxyType(), helmFormat); 50 | helmHostedRecipe = new HelmHostedRecipe(new HostedType(), helmFormat); 51 | helmProxyRecipe.setHighAvailabilitySupportChecker(highAvailabilitySupportChecker); 52 | helmHostedRecipe.setHighAvailabilitySupportChecker(highAvailabilitySupportChecker); 53 | } 54 | 55 | @Test 56 | public void haEnabledHostedRepository() { 57 | when(highAvailabilitySupportChecker.isSupported(HelmFormat.NAME)).thenReturn(true); 58 | assertThat(helmHostedRecipe.isFeatureEnabled(), is(equalTo(true))); 59 | verify(highAvailabilitySupportChecker).isSupported(HelmFormat.NAME); 60 | } 61 | 62 | @Test 63 | public void haDisabledHostedRepository() { 64 | when(highAvailabilitySupportChecker.isSupported(HelmFormat.NAME)).thenReturn(false); 65 | assertThat(helmHostedRecipe.isFeatureEnabled(), is(equalTo(false))); 66 | verify(highAvailabilitySupportChecker).isSupported(HelmFormat.NAME); 67 | } 68 | 69 | @Test 70 | public void haEnabledProxyRepository() { 71 | when(highAvailabilitySupportChecker.isSupported(HelmFormat.NAME)).thenReturn(true); 72 | assertThat(helmProxyRecipe.isFeatureEnabled(), is(equalTo(true))); 73 | verify(highAvailabilitySupportChecker).isSupported(HelmFormat.NAME); 74 | } 75 | 76 | @Test 77 | public void haDisabledProxyRepository() { 78 | when(highAvailabilitySupportChecker.isSupported(HelmFormat.NAME)).thenReturn(false); 79 | assertThat(helmProxyRecipe.isFeatureEnabled(), is(equalTo(false))); 80 | verify(highAvailabilitySupportChecker).isSupported(HelmFormat.NAME); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/content/createindex/CreateIndexServiceImplTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.content.createindex; 14 | 15 | import java.util.Arrays; 16 | import java.util.Collections; 17 | import java.util.HashMap; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | import org.sonatype.goodies.testsupport.TestSupport; 23 | import org.sonatype.nexus.common.collect.NestedAttributesMap; 24 | import org.sonatype.nexus.repository.Repository; 25 | import org.sonatype.nexus.repository.content.Asset; 26 | import org.sonatype.nexus.repository.content.AssetBlob; 27 | import org.sonatype.nexus.repository.content.fluent.FluentAsset; 28 | import org.sonatype.nexus.repository.view.Content; 29 | import org.sonatype.repository.helm.internal.AssetKind; 30 | import org.sonatype.repository.helm.internal.content.HelmContentFacet; 31 | import org.sonatype.repository.helm.internal.util.YamlParser; 32 | 33 | import com.google.inject.AbstractModule; 34 | import com.google.inject.Guice; 35 | import org.junit.Before; 36 | import org.junit.Test; 37 | import org.mockito.Mock; 38 | 39 | import static org.hamcrest.CoreMatchers.is; 40 | import static org.hamcrest.CoreMatchers.notNullValue; 41 | import static org.hamcrest.MatcherAssert.assertThat; 42 | import static org.mockito.Matchers.anyObject; 43 | import static org.powermock.api.mockito.PowerMockito.when; 44 | 45 | public class CreateIndexServiceImplTest 46 | extends TestSupport 47 | { 48 | private CreateIndexServiceImpl underTest; 49 | 50 | @Mock 51 | private YamlParser yamlParser; 52 | 53 | @Mock 54 | private AssetBlob assetBlob; 55 | 56 | @Mock 57 | private Iterable assets; 58 | 59 | @Mock 60 | private Iterator assetIterator; 61 | 62 | @Mock 63 | private HelmContentFacet helmFacet; 64 | 65 | @Mock 66 | private Repository repository; 67 | 68 | @Mock 69 | private FluentAsset asset; 70 | 71 | @Mock 72 | private NestedAttributesMap formatAttributes; 73 | 74 | @Before 75 | public void setUp() { 76 | when(repository.facet(HelmContentFacet.class)).thenReturn(helmFacet); 77 | initializeSystemUnderTest(); 78 | } 79 | 80 | @Test 81 | public void testBuildIndexYaml() { 82 | List list = Arrays.asList(asset); 83 | when(asset.attributes()).thenReturn(formatAttributes); 84 | Map shaMap = new HashMap<>(); 85 | shaMap.put("sha256", "12345"); 86 | 87 | when(assetBlob.checksums()).thenReturn(shaMap); 88 | when(helmFacet.browseAssets()).thenReturn(list); 89 | when(yamlParser.getYamlContent(anyObject())).thenReturn("index.yaml"); 90 | 91 | Content result = underTest.buildIndexYaml(repository); 92 | 93 | assertThat(result, is(notNullValue())); 94 | } 95 | 96 | @Test 97 | public void testIndexYamlBuiltEvenWhenNoAssets() { 98 | when(assets.iterator()).thenReturn(assetIterator); 99 | when(assetIterator.next()).thenReturn(asset); 100 | when(helmFacet.browseAssets()).thenReturn(Collections.emptyList()); 101 | when(yamlParser.getYamlContent(anyObject())).thenReturn("index.yaml"); 102 | 103 | Content result = underTest.buildIndexYaml(repository); 104 | 105 | assertThat(result, is(notNullValue())); 106 | } 107 | 108 | private void initializeSystemUnderTest() { 109 | underTest = Guice.createInjector(new AbstractModule() 110 | { 111 | @Override 112 | protected void configure() { 113 | bind(YamlParser.class).toInstance(yamlParser); 114 | } 115 | }).getInstance(CreateIndexServiceImpl.class); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/metadata/ChartIndexTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.metadata; 14 | 15 | import org.sonatype.goodies.testsupport.TestSupport; 16 | 17 | import org.junit.Before; 18 | import org.junit.Test; 19 | 20 | import static org.hamcrest.MatcherAssert.assertThat; 21 | import static org.hamcrest.core.Is.is; 22 | 23 | public class ChartIndexTest 24 | extends TestSupport 25 | { 26 | private ChartIndex underTest; 27 | 28 | @Before 29 | public void setUp() throws Exception { 30 | underTest = new ChartIndex(); 31 | } 32 | 33 | @Test 34 | public void addChartEntry() { 35 | ChartEntry chartEntry = new ChartEntry(); 36 | underTest.addEntry(chartEntry); 37 | 38 | assertThat(underTest.getEntries().size(), is(1)); 39 | } 40 | 41 | @Test 42 | public void addMultipleChartEntries() throws Exception { 43 | ChartEntry chartEntry = new ChartEntry(); 44 | ChartEntry chartEntrySameName = new ChartEntry(); 45 | ChartEntry chartEntryDifferentName = new ChartEntry(); 46 | 47 | chartEntry.setName("test"); 48 | chartEntrySameName.setName("test"); 49 | chartEntryDifferentName.setName("different name"); 50 | 51 | underTest.addEntry(chartEntry); 52 | underTest.addEntry(chartEntrySameName); 53 | 54 | assertThat(underTest.getEntries().size(), is(1)); 55 | 56 | underTest.addEntry(chartEntryDifferentName); 57 | 58 | assertThat(underTest.getEntries().size(), is(2)); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/orient/ComponentDirectorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.orient; 14 | 15 | import org.sonatype.goodies.testsupport.TestSupport; 16 | import org.sonatype.nexus.common.entity.EntityId; 17 | import org.sonatype.nexus.repository.Repository; 18 | import org.sonatype.nexus.repository.manager.RepositoryManager; 19 | import org.sonatype.nexus.repository.storage.Bucket; 20 | import org.sonatype.nexus.repository.storage.BucketStore; 21 | import org.sonatype.nexus.repository.storage.Component; 22 | 23 | import org.junit.Test; 24 | import org.mockito.Mock; 25 | 26 | import static org.junit.Assert.assertTrue; 27 | import static org.mockito.Mockito.mock; 28 | import static org.mockito.Mockito.when; 29 | 30 | public class ComponentDirectorTest 31 | extends TestSupport 32 | { 33 | @Mock 34 | private BucketStore bucketStore; 35 | 36 | @Mock 37 | private RepositoryManager repositoryManager; 38 | 39 | @Mock 40 | private Component component; 41 | 42 | @Mock 43 | private Repository source; 44 | 45 | @Mock 46 | private Repository destination; 47 | 48 | @Test 49 | public void allowMoveTest() { 50 | HelmComponentDirector director = new HelmComponentDirector(bucketStore, repositoryManager); 51 | assertTrue(director.allowMoveTo(destination)); 52 | assertTrue(director.allowMoveFrom(source)); 53 | 54 | EntityId bucketId = mock(EntityId.class); 55 | when(component.bucketId()).thenReturn(bucketId); 56 | Bucket bucket = mock(Bucket.class); 57 | when(bucketStore.getById(bucketId)).thenReturn(bucket); 58 | when(bucket.getRepositoryName()).thenReturn("repo"); 59 | when(repositoryManager.get("repo")).thenReturn(source); 60 | 61 | assertTrue(director.allowMoveTo(component, destination)); 62 | 63 | assertTrue(director.allowMoveTo(destination)); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/orient/metadata/IndexYamlBuilderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.orient.metadata; 14 | 15 | import java.io.ByteArrayInputStream; 16 | import java.io.InputStream; 17 | import java.io.OutputStream; 18 | 19 | import org.sonatype.goodies.testsupport.TestSupport; 20 | import org.sonatype.nexus.repository.storage.StorageFacet; 21 | import org.sonatype.nexus.repository.storage.TempBlob; 22 | import org.sonatype.repository.helm.internal.metadata.ChartIndex; 23 | import org.sonatype.repository.helm.internal.util.YamlParser; 24 | 25 | import org.apache.commons.io.IOUtils; 26 | import org.junit.Before; 27 | import org.junit.Test; 28 | import org.mockito.ArgumentCaptor; 29 | import org.mockito.Mock; 30 | 31 | import static org.junit.Assert.assertEquals; 32 | import static org.mockito.Matchers.any; 33 | import static org.mockito.Matchers.eq; 34 | import static org.mockito.Mockito.verify; 35 | import static org.mockito.Mockito.when; 36 | import static org.sonatype.repository.helm.internal.HelmFormat.HASH_ALGORITHMS; 37 | 38 | public class IndexYamlBuilderTest 39 | extends TestSupport 40 | { 41 | @Mock 42 | YamlParser yamlParser; 43 | 44 | @Mock 45 | StorageFacet storageFacet; 46 | 47 | @Mock 48 | TempBlob tempBlob; 49 | 50 | private IndexYamlBuilder underTest; 51 | 52 | private ChartIndex index; 53 | 54 | @Before 55 | public void setUp() throws Exception { 56 | underTest = new IndexYamlBuilder(this.yamlParser); 57 | index = new ChartIndex(); 58 | } 59 | 60 | @Test 61 | public void testChartIndexPassedCorrectly() throws Exception { 62 | setupRepositoryMock(); 63 | ArgumentCaptor captorStorage = ArgumentCaptor.forClass(InputStream.class); 64 | ArgumentCaptor captor = ArgumentCaptor.forClass(ChartIndex.class); 65 | 66 | TempBlob tempBlob = underTest.build(index, storageFacet); 67 | 68 | verify(storageFacet).createTempBlob(captorStorage.capture(), eq(HASH_ALGORITHMS)); 69 | verify(yamlParser).write(any(OutputStream.class), captor.capture()); 70 | 71 | assertEquals(index, captor.getValue()); 72 | } 73 | 74 | @Test 75 | public void testTempBlobReturned() throws Exception { 76 | initializeStorageFacet(); 77 | TempBlob result = underTest.build(index, storageFacet); 78 | 79 | assertEquals(result, tempBlob); 80 | } 81 | 82 | private void initializeStorageFacet() { 83 | when(storageFacet.createTempBlob(any(InputStream.class), eq(HASH_ALGORITHMS))).thenReturn(tempBlob); 84 | } 85 | 86 | private void setupRepositoryMock() { 87 | when(storageFacet.createTempBlob(any(InputStream.class), any(Iterable.class))).thenAnswer(args -> { 88 | InputStream inputStream = (InputStream) args.getArguments()[0]; 89 | byte[] bytes = IOUtils.toByteArray(inputStream); 90 | when(tempBlob.get()).thenReturn(new ByteArrayInputStream(bytes)); 91 | return tempBlob; 92 | }); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/security/HelmSecurityFacetTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.security; 14 | 15 | import org.sonatype.goodies.testsupport.TestSupport; 16 | import org.sonatype.nexus.repository.Format; 17 | import org.sonatype.nexus.repository.Repository; 18 | import org.sonatype.nexus.repository.http.HttpMethods; 19 | import org.sonatype.nexus.repository.security.ContentPermissionChecker; 20 | import org.sonatype.nexus.repository.security.VariableResolverAdapter; 21 | import org.sonatype.nexus.repository.view.Request; 22 | 23 | import org.apache.shiro.authz.AuthorizationException; 24 | import org.junit.Before; 25 | import org.junit.Test; 26 | import org.mockito.Mock; 27 | 28 | import static org.junit.Assert.fail; 29 | import static org.mockito.Matchers.any; 30 | import static org.mockito.Matchers.eq; 31 | import static org.mockito.Mockito.verify; 32 | import static org.mockito.Mockito.when; 33 | import static org.sonatype.nexus.security.BreadActions.READ; 34 | 35 | public class HelmSecurityFacetTest 36 | extends TestSupport 37 | { 38 | @Mock 39 | Request request; 40 | 41 | @Mock 42 | Repository repository; 43 | 44 | @Mock 45 | ContentPermissionChecker contentPermissionChecker; 46 | 47 | @Mock 48 | VariableResolverAdapter variableResolverAdapter; 49 | 50 | @Mock 51 | HelmFormatSecurityContributor securityContributor; 52 | 53 | HelmSecurityFacet helmSecurityFacet; 54 | 55 | @Before 56 | public void setupConfig() throws Exception { 57 | when(request.getPath()).thenReturn("/some/path.txt"); 58 | when(request.getAction()).thenReturn(HttpMethods.GET); 59 | 60 | when(repository.getFormat()).thenReturn(new Format("helm") { }); 61 | when(repository.getName()).thenReturn("HelmSecurityFacetTest"); 62 | 63 | helmSecurityFacet = new HelmSecurityFacet(securityContributor, 64 | variableResolverAdapter, contentPermissionChecker); 65 | 66 | helmSecurityFacet.attach(repository); 67 | } 68 | 69 | @Test 70 | public void testEnsurePermitted_permitted() throws Exception { 71 | when(contentPermissionChecker.isPermitted(eq("HelmSecurityFacetTest"), eq("helm"), eq(READ), any())) 72 | .thenReturn(true); 73 | helmSecurityFacet.ensurePermitted(request); 74 | } 75 | 76 | @Test 77 | public void testEnsurePermitted_notPermitted() throws Exception { 78 | when(contentPermissionChecker.isPermitted(eq("HelmSecurityFacetTest"), eq("helm"), eq(READ), any())) 79 | .thenReturn(false); 80 | try { 81 | helmSecurityFacet.ensurePermitted(request); 82 | fail("AuthorizationException should have been thrown"); 83 | } 84 | catch (AuthorizationException e) { 85 | //expected 86 | } 87 | 88 | verify(contentPermissionChecker).isPermitted(eq("HelmSecurityFacetTest"), eq("helm"), eq(READ), any()); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/util/HelmAttributeParserTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.util; 14 | 15 | import java.io.InputStream; 16 | import java.util.Collections; 17 | import java.util.LinkedHashMap; 18 | import java.util.Map; 19 | 20 | import org.sonatype.goodies.testsupport.TestSupport; 21 | import org.sonatype.repository.helm.HelmAttributes; 22 | import org.sonatype.repository.helm.internal.AssetKind; 23 | 24 | import org.junit.Before; 25 | import org.junit.Test; 26 | 27 | import static org.hamcrest.MatcherAssert.assertThat; 28 | import static org.hamcrest.Matchers.is; 29 | 30 | public class HelmAttributeParserTest 31 | extends TestSupport 32 | { 33 | private YamlParser yamlParser; 34 | 35 | private TgzParser tgzParser; 36 | 37 | private ProvenanceParser provenanceParser; 38 | 39 | private HelmAttributeParser underTest; 40 | 41 | @Before 42 | public void setUp() { 43 | yamlParser = new YamlParser(); 44 | tgzParser = new TgzParser(); 45 | provenanceParser = new ProvenanceParser(); 46 | underTest = new HelmAttributeParser(tgzParser, yamlParser, provenanceParser); 47 | } 48 | 49 | @Test 50 | public void testGetAttributesFromChart() throws Exception { 51 | String name = "mongodb-0.4.9.tgz"; 52 | InputStream chart = getClass().getResourceAsStream(name); 53 | AssetKind assetKind = AssetKind.getAssetKindByFileName(name); 54 | HelmAttributes result = underTest.getAttributes(assetKind, chart); 55 | 56 | assertThat(result.getName(), is("mongodb")); 57 | assertThat(result.getVersion(), is("0.4.9")); 58 | assertThat(result.getDescription(), 59 | is("NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications.")); 60 | assertThat(result.getIcon(), is("https://bitnami.com/assets/stacks/mongodb/img/mongodb-stack-220x234.png")); 61 | 62 | Map maintainers = new LinkedHashMap() 63 | {{ 64 | put("email", "containers@bitnami.com"); 65 | put("name", "Bitnami"); 66 | }}; 67 | assertThat(result.getMaintainers(), is(Collections.singletonList(maintainers))); 68 | assertThat(result.getSources(), is(Collections.singletonList("https://github.com/bitnami/bitnami-docker-mongodb"))); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/util/HelmPathUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.util; 14 | 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | import org.sonatype.goodies.testsupport.TestSupport; 19 | import org.sonatype.nexus.repository.view.matchers.token.TokenMatcher; 20 | 21 | import org.junit.Before; 22 | import org.junit.Test; 23 | import org.mockito.Mock; 24 | 25 | import static org.hamcrest.CoreMatchers.equalTo; 26 | import static org.hamcrest.core.Is.is; 27 | import static org.mockito.Mockito.when; 28 | import static org.hamcrest.MatcherAssert.assertThat; 29 | 30 | public class HelmPathUtilsTest 31 | extends TestSupport 32 | { 33 | private static final String FILENAME = "mongodb-0.4.9.tgz"; 34 | 35 | private HelmPathUtils underTest; 36 | 37 | @Mock 38 | private TokenMatcher.State state; 39 | 40 | @Before 41 | public void setUp() throws Exception { 42 | underTest = new HelmPathUtils(); 43 | } 44 | 45 | @Test 46 | public void filename() throws Exception { 47 | Map map = new HashMap<>(); 48 | map.put("filename", FILENAME); 49 | when(state.getTokens()).thenReturn(map); 50 | String result = underTest.filename(state); 51 | assertThat(result, is(equalTo(FILENAME))); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/util/ProvenanceParserTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.util; 14 | 15 | import java.io.InputStream; 16 | 17 | import org.sonatype.goodies.testsupport.TestSupport; 18 | import org.sonatype.repository.helm.HelmAttributes; 19 | 20 | import org.junit.Before; 21 | import org.junit.Test; 22 | 23 | import static org.hamcrest.CoreMatchers.equalTo; 24 | import static org.hamcrest.MatcherAssert.assertThat; 25 | import static org.hamcrest.core.Is.is; 26 | 27 | public class ProvenanceParserTest 28 | extends TestSupport 29 | { 30 | private ProvenanceParser provenanceParser; 31 | 32 | @Before 33 | public void setUp() { 34 | this.provenanceParser = new ProvenanceParser(); 35 | } 36 | 37 | @Test 38 | public void parseProv() throws Exception { 39 | InputStream is = getClass().getResourceAsStream("mysql-1.4.0.tgz.prov"); 40 | HelmAttributes attributes = provenanceParser.parse(is); 41 | 42 | assertThat(attributes.getName(), is(equalTo("mysql"))); 43 | assertThat(attributes.getDescription(), is(equalTo("Fast, reliable, scalable, and easy to use open-source relational database system."))); 44 | assertThat(attributes.getVersion(), is(equalTo("1.4.0"))); 45 | assertThat(attributes.getIcon(), is(equalTo("https://www.mysql.com/common/logos/logo-mysql-170x115.png"))); 46 | assertThat(attributes.getAppVersion(), is(equalTo("5.7.27"))); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/java/org/sonatype/repository/helm/internal/util/TgzParserTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.repository.helm.internal.util; 14 | 15 | import java.io.InputStream; 16 | import java.io.InputStreamReader; 17 | 18 | import org.sonatype.goodies.testsupport.TestSupport; 19 | 20 | import org.apache.commons.io.IOUtils; 21 | import org.junit.Before; 22 | import org.junit.Test; 23 | 24 | import static org.hamcrest.MatcherAssert.assertThat; 25 | import static org.hamcrest.core.Is.is; 26 | 27 | public class TgzParserTest 28 | extends TestSupport 29 | { 30 | private TgzParser underTest; 31 | 32 | @Before 33 | public void setUp() { 34 | this.underTest = new TgzParser(); 35 | } 36 | 37 | @Test 38 | public void getYamlFromTgzTestCustomArchive() throws Exception { 39 | InputStream is = getClass().getResourceAsStream("mongodb-4.0.4.tgz"); 40 | InputStream chartFromInputStream = underTest.getChartFromInputStream(is); 41 | String fileContent = IOUtils.toString(new InputStreamReader(chartFromInputStream)); 42 | 43 | String expected = "appVersion: 3.6.6\n" 44 | + "description: NoSQL document-oriented database that stores JSON-like documents with\n" 45 | + " dynamic schemas, simplifying the integration of data in content-driven applications.\n" 46 | + "engine: gotpl\n" 47 | + "home: https://mongodb.org\n" 48 | + "icon: https://bitnami.com/assets/stacks/mongodb/img/mongodb-stack-220x234.png\n" 49 | + "keywords:\n" 50 | + "- mongodb\n" 51 | + "- database\n" 52 | + "- nosql\n" 53 | + "- cluster\n" 54 | + "- replicaset\n" 55 | + "- replication\n" 56 | + "maintainers:\n" 57 | + "- email: containers@bitnami.com\n" 58 | + " name: Bitnami\n" 59 | + "name: mongodb\n" 60 | + "sources:\n" 61 | + "- https://github.com/bitnami/bitnami-docker-mongodb\n" 62 | + "version: 4.0.4\n"; 63 | assertThat(fileContent, is(expected)); 64 | } 65 | 66 | @Test(expected = IllegalArgumentException.class) 67 | public void chartNotFound() throws Exception { 68 | InputStream is = getClass().getResourceAsStream("mysql_negative-1.4.0.tgz"); 69 | underTest.getChartFromInputStream(is); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/orient/metadata/indexWithCustomUrls.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | entries: 3 | acs-engine-autoscaler: 4 | - apiVersion: v1 5 | appVersion: 2.1.1 6 | created: '2019-11-06T16:57:53.298448000Z' 7 | deprecated: true 8 | description: DEPRECATED Scales worker nodes within agent pools 9 | digest: 93f924d4498d588bcdda88c7401e27c6fa0f50ff0601e78885eca13eb683c1e2 10 | home: https://github.com/wbuchwalter/Kubernetes-acs-engine-autoscaler 11 | icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png 12 | name: acs-engine-autoscaler 13 | sources: 14 | - https://github.com/wbuchwalter/Kubernetes-acs-engine-autoscaler 15 | urls: 16 | - https://burdenbear.github.io/kube-charts-mirror/acs-engine-autoscaler-2.2.2.tgz 17 | version: 2.2.2 18 | - apiVersion: v1 19 | appVersion: 2.1.1 20 | created: '2018-12-11T02:55:17.969867000Z' 21 | description: Scales worker nodes within agent pools 22 | digest: 3232999ebabc42cd7c5475251b5cd2e0c6bf4363551cff13ebe3a78cee1dfba6 23 | home: https://github.com/wbuchwalter/Kubernetes-acs-engine-autoscaler 24 | icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png 25 | maintainers: 26 | - email: ritazh@microsoft.com 27 | name: ritazh 28 | - email: wibuch@microsoft.com 29 | name: wbuchwalter 30 | name: acs-engine-autoscaler 31 | sources: 32 | - https://github.com/wbuchwalter/Kubernetes-acs-engine-autoscaler 33 | urls: 34 | - https://burdenbear.github.io/kube-charts-mirror/acs-engine-autoscaler-2.2.1.tgz 35 | version: 2.2.1 36 | - apiVersion: v1 37 | appVersion: 2.1.1 38 | created: '2018-11-28T23:56:19.641278000Z' 39 | description: Scales worker nodes within agent pools 40 | digest: 5904caae456eecd1fed0a5d58f4a6f46e1fe97f954c4467e49fc80f91d912a10 41 | home: https://github.com/wbuchwalter/Kubernetes-acs-engine-autoscaler 42 | icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png 43 | maintainers: 44 | - email: ritazh@microsoft.com 45 | name: ritazh 46 | - email: wibuch@microsoft.com 47 | name: wbuchwalter 48 | name: acs-engine-autoscaler 49 | sources: 50 | - https://github.com/wbuchwalter/Kubernetes-acs-engine-autoscaler 51 | urls: 52 | - https://burdenbear.github.io/kube-charts-mirror/acs-engine-autoscaler-2.2.0.tgz 53 | version: 2.2.0 54 | generated: '2019-11-06T16:57:53.297933000Z' 55 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/orient/metadata/indexWithRelativeUrls.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | entries: 3 | acs-engine-autoscaler: 4 | - apiVersion: v1 5 | appVersion: 2.1.1 6 | created: 2018-03-27T20:26:09.598691403Z 7 | description: Scales worker nodes within agent pools 8 | digest: 5c016fefd8942b008abf41f282906d055f4a61f650ad125746843e62efc01bd0 9 | icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png 10 | maintainers: 11 | - email: ritazh@microsoft.com 12 | name: ritazh 13 | - email: wibuch@microsoft.com 14 | name: wbuchwalter 15 | name: acs-engine-autoscaler 16 | sources: 17 | - https://github.com/wbuchwalter/Kubernetes-acs-engine-autoscaler 18 | urls: 19 | - https://kubernetes-charts.storage.googleapis.com/acs-engine-autoscaler-2.1.3.tgz 20 | version: 2.1.3 21 | - apiVersion: v1 22 | appVersion: 2.1.1 23 | created: 2018-02-28T19:04:23.819056988Z 24 | description: Scales worker nodes within agent pools 25 | digest: c3d0aa9f61913913735a0904577681328ae9374ff30d2bfa0ee33348b069cb7d 26 | icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png 27 | maintainers: 28 | - email: ritazh@microsoft.com 29 | name: ritazh 30 | - email: wibuch@microsoft.com 31 | name: wbuchwalter 32 | name: acs-engine-autoscaler 33 | sources: 34 | - https://github.com/wbuchwalter/Kubernetes-acs-engine-autoscaler 35 | urls: 36 | - charts/acs-engine-autoscaler-2.1.2.tgz 37 | version: 2.1.2 38 | - apiVersion: v1 39 | appVersion: 2.1.1 40 | created: 2018-02-13T23:19:19.729122896Z 41 | description: Scales worker nodes within agent pools 42 | digest: 39e66eb53c310529bd9dd19776f8ba662e063a4ebd51fc5ec9f2267e2e073e3e 43 | icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png 44 | maintainers: 45 | - email: ritazh@microsoft.com 46 | name: ritazh 47 | - email: wibuch@microsoft.com 48 | name: wbuchwalter 49 | name: acs-engine-autoscaler 50 | sources: 51 | - https://github.com/wbuchwalter/Kubernetes-acs-engine-autoscaler 52 | urls: 53 | - acs-engine-autoscaler-2.1.1.tgz 54 | version: 2.1.1 55 | generated: 2018-03-27T20:26:09.598062444Z 56 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/util/Chart.yaml: -------------------------------------------------------------------------------- 1 | description: NoSQL document-oriented database that stores JSON-like documents with 2 | dynamic schemas, simplifying the integration of data in content-driven applications. 3 | engine: gotpl 4 | home: https://mongodb.org 5 | icon: https://bitnami.com/assets/stacks/mongodb/img/mongodb-stack-220x234.png 6 | keywords: 7 | - mongodb 8 | - database 9 | - nosql 10 | maintainers: 11 | - email: containers@bitnami.com 12 | name: Bitnami 13 | name: mongodb 14 | sources: 15 | - https://github.com/bitnami/bitnami-docker-mongodb 16 | version: 0.4.9 17 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/util/Chart.yml: -------------------------------------------------------------------------------- 1 | description: NoSQL document-oriented database that stores JSON-like documents with 2 | dynamic schemas, simplifying the integration of data in content-driven applications. 3 | engine: gotpl 4 | home: https://mongodb.org 5 | icon: https://bitnami.com/assets/stacks/mongodb/img/mongodb-stack-220x234.png 6 | keywords: 7 | - mongodb 8 | - database 9 | - nosql 10 | maintainers: 11 | - email: containers@bitnami.com 12 | name: Bitnami 13 | name: mongodb 14 | sources: 15 | - https://github.com/bitnami/bitnami-docker-mongodb 16 | version: 0.4.9 17 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/util/indexresult.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: '1.0' 2 | entries: 3 | notmongdb: 4 | - appVersion: 0.0.1 5 | created: 2018-08-13T22:05:33.023Z 6 | description: |- 7 | NoSQL document-oriented database that stores JSON-like documents with 8 | dynamic schemas, simplifying the integration of data in content-driven applications. 9 | digest: '12345' 10 | icon: https://bitnami.com/assets/stacks/mongodb/img/mongodb-stack-220x234.png 11 | maintainers: 12 | - name: Bitnami 13 | email: containers@bitnami.com 14 | name: notmongdb 15 | sources: 16 | - https://github.com/bitnami/bitnami-docker-mongodb 17 | urls: 18 | - mongodb-0.5.2.tgz 19 | version: 1.0.0 20 | mongodb: 21 | - appVersion: 0.0.1 22 | created: 2018-08-13T22:05:33.023Z 23 | description: |- 24 | NoSQL document-oriented database that stores JSON-like documents with 25 | dynamic schemas, simplifying the integration of data in content-driven applications. 26 | digest: '12345' 27 | icon: https://bitnami.com/assets/stacks/mongodb/img/mongodb-stack-220x234.png 28 | maintainers: 29 | - name: Bitnami 30 | email: containers@bitnami.com 31 | name: mongodb 32 | sources: 33 | - https://github.com/bitnami/bitnami-docker-mongodb 34 | urls: 35 | - mongodb-0.5.2.tgz 36 | version: 0.4.9 37 | - appVersion: 0.0.2 38 | created: 2018-08-13T22:05:33.023Z 39 | description: |- 40 | NoSQL document-oriented database that stores JSON-like documents with 41 | dynamic schemas, simplifying the integration of data in content-driven applications. 42 | digest: '12345' 43 | icon: https://bitnami.com/assets/stacks/mongodb/img/mongodb-stack-220x234.png 44 | maintainers: 45 | - name: Bitnami 46 | email: containers@bitnami.com 47 | name: mongodb 48 | sources: 49 | - https://github.com/bitnami/bitnami-docker-mongodb 50 | urls: 51 | - mongodb-0.5.2.tgz 52 | version: 0.4.8 53 | -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/util/mongodb-0.4.9.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonatype-nexus-community/nexus-repository-helm/e9178160b16f5500a1e91b21ee98423a96968f65/nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/util/mongodb-0.4.9.tgz -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/util/mongodb-4.0.4.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonatype-nexus-community/nexus-repository-helm/e9178160b16f5500a1e91b21ee98423a96968f65/nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/util/mongodb-4.0.4.tgz -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/util/moodle-0.1.4.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonatype-nexus-community/nexus-repository-helm/e9178160b16f5500a1e91b21ee98423a96968f65/nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/util/moodle-0.1.4.tgz -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/util/mysql-1.4.0.tgz.prov: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNED MESSAGE----- 2 | Hash: SHA512 3 | 4 | apiVersion: v1 5 | appVersion: 5.7.27 6 | description: Fast, reliable, scalable, and easy to use open-source relational database system. 7 | engine: gotpl 8 | home: https://www.mysql.com/ 9 | icon: https://www.mysql.com/common/logos/logo-mysql-170x115.png 10 | keywords: 11 | - - mysql 12 | - - database 13 | - - sql 14 | maintainers: 15 | - - email: o.with@sportradar.com 16 | name: olemarkus 17 | - - email: viglesias@google.com 18 | name: viglesiasce 19 | name: mysql 20 | sources: 21 | - - https://github.com/kubernetes/charts 22 | - - https://github.com/docker-library/mysql 23 | version: 1.4.0 24 | 25 | ... 26 | files: 27 | mysql-1.4.0.tgz: sha256:a2136b01250a14692974c4217876f655196f4b7941d273abd710fa1929d1fad4 28 | -----BEGIN PGP SIGNATURE----- 29 | 30 | wsFcBAEBCgAQBQJduX16CRD+ZxIilY7rVAAAnywQAIQIa2OVJ+3ue+VCkmDRGyxT 31 | OTsCxqOjBSHQt2TH8qNyLInCSeIKsryWDDm/i2lrS6dJZknUYWvV67DGK4rDrTvm 32 | Lc4kH3MiE9UMDK2BEvY9h65svFHFId7l+UTuJ8x78pC4HvqcdWxOFrJ13rhuMu+b 33 | hmVFgNyTzbURKt8rU1foIGZ13kwi8iY0uQGzKnbDNzeoG71xSn2DR5MDBdspzFRI 34 | s/xBzGx0zbOWiKz1pf//mF1kHyVeWGdT8tARJcrDSIzt5144zFLye3tVA5l0k7al 35 | /bg45miDgdatYtc987yfI7NI8WV3+6XFoTKLhLJneNZIIOy6lh4RUs8WgIUItSZl 36 | vJEAiMxF56iwgUfhbljwmCoqt+WtnR1ggozCsKxeXzSJiuqspfgv80Pjp51h9pdE 37 | 9YJTcLEOAlfppIGQzQ2+vCvGt4iQeFalqC0J7O7rQ+NbqjD2WNTPSwESfIEAtQ2o 38 | xBp8AeR1uDQKMIGrYw3HQPDQ1raEoK5dprVZC/Y5Y3+5IRS0Wmogq5+1oj7dNQdp 39 | 0L8qlH1dHiyv+BYjuZ4IMG8ybK/kJBTHLPQkaY6o4YGse+qFEVKF6qP/0njgWmMv 40 | l6heGt9iC0SCNLrbz/A1ZApb7GjYeF5830yD4oF3q0aHEPMn+fKmnMJoP6P6Acyd 41 | RvLnDjCdc62R7o52fy/f 42 | =0Lcc 43 | -----END PGP SIGNATURE----- -------------------------------------------------------------------------------- /nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/util/mysql_negative-1.4.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonatype-nexus-community/nexus-repository-helm/e9178160b16f5500a1e91b21ee98423a96968f65/nexus-repository-helm/src/test/resources/org/sonatype/repository/helm/internal/util/mysql_negative-1.4.0.tgz -------------------------------------------------------------------------------- /nexus-restore-helm/src/main/java/org/sonatype/nexus/blobstore/restore/helm/internal/HelmRestoreBlobData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sonatype Nexus (TM) Open Source Version 3 | * Copyright (c) 2018-present Sonatype, Inc. 4 | * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. 5 | * 6 | * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, 7 | * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. 8 | * 9 | * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks 10 | * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the 11 | * Eclipse Foundation. All other trademarks are the property of their respective owners. 12 | */ 13 | package org.sonatype.nexus.blobstore.restore.helm.internal; 14 | 15 | import org.sonatype.nexus.blobstore.restore.RestoreBlobData; 16 | import org.sonatype.nexus.blobstore.restore.RestoreBlobDataSupport; 17 | 18 | /** 19 | * @since 1.0.next 20 | */ 21 | class HelmRestoreBlobData extends RestoreBlobDataSupport 22 | { 23 | HelmRestoreBlobData(final RestoreBlobData blobData) { 24 | super(blobData); 25 | } 26 | } 27 | --------------------------------------------------------------------------------