Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Commit

Permalink
Public export of Nexus Repository - Helm Plugin:
Browse files Browse the repository at this point in the history
  - 3a0595cf279ec692b2e9999b2cf70ee029ed8eca by Jeffry Hesse <jeffryxtron@gmail.com>

GitOrigin-RevId: 3a0595cf279ec692b2e9999b2cf70ee029ed8eca
  • Loading branch information
DarthHater committed Aug 16, 2018
1 parent 8911909 commit 5517c8e
Show file tree
Hide file tree
Showing 38 changed files with 2,156 additions and 78 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ RUN cd /nexus-repository-helm/; sed -i "s/3.10.0-04/${NEXUS_VERSION}-${NEXUS_BUI
FROM sonatype/nexus3:$NEXUS_VERSION
ARG NEXUS_VERSION=3.10.0
ARG NEXUS_BUILD=04
ARG HELM_VERSION=0.0.1
ARG HELM_VERSION=0.0.2
ARG TARGET_DIR=/opt/sonatype/nexus/system/org/sonatype/nexus/plugins/nexus-repository-helm/${HELM_VERSION}/
USER root
RUN mkdir -p ${TARGET_DIR}; \
sed -i 's@nexus-repository-maven</feature>@nexus-repository-maven</feature>\n <feature prerequisite="false" dependency="false">nexus-repository-helm</feature>@g' /opt/sonatype/nexus/system/org/sonatype/nexus/assemblies/nexus-core-feature/${NEXUS_VERSION}-${NEXUS_BUILD}/nexus-core-feature-${NEXUS_VERSION}-${NEXUS_BUILD}-features.xml; \
sed -i 's@<feature name="nexus-repository-maven"@<feature name="nexus-repository-helm" description="org.sonatype.nexus.plugins:nexus-repository-helm" version="0.0.1">\n <details>org.sonatype.nexus.plugins:nexus-repository-helm</details>\n <bundle>mvn:org.sonatype.nexus.plugins/nexus-repository-helm/0.0.1</bundle>\n <bundle>mvn:org.apache.commons/commons-compress/1.11</bundle>\n </feature>\n <feature name="nexus-repository-maven"@g' /opt/sonatype/nexus/system/org/sonatype/nexus/assemblies/nexus-core-feature/${NEXUS_VERSION}-${NEXUS_BUILD}/nexus-core-feature-${NEXUS_VERSION}-${NEXUS_BUILD}-features.xml;
sed -i 's@<feature name="nexus-repository-maven"@<feature name="nexus-repository-helm" description="org.sonatype.nexus.plugins:nexus-repository-helm" version="0.0.2">\n <details>org.sonatype.nexus.plugins:nexus-repository-helm</details>\n <bundle>mvn:org.sonatype.nexus.plugins/nexus-repository-helm/0.0.2</bundle>\n <bundle>mvn:org.apache.commons/commons-compress/1.11</bundle>\n </feature>\n <feature name="nexus-repository-maven"@g' /opt/sonatype/nexus/system/org/sonatype/nexus/assemblies/nexus-core-feature/${NEXUS_VERSION}-${NEXUS_BUILD}/nexus-core-feature-${NEXUS_VERSION}-${NEXUS_BUILD}-features.xml;
COPY --from=build /nexus-repository-helm/target/nexus-repository-helm-${HELM_VERSION}.jar ${TARGET_DIR}
USER nexus
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ If everything checks out, the bundle for Helm should be available in the `target

#### Build with Docker

`docker build -t nexus-repository-helm:0.0.1 .`
`docker build -t nexus-repository-helm:0.0.2 .`

#### Run as a Docker container

`docker run -d -p 8081:8081 --name nexus nexus-repository-helm:0.0.1`
`docker run -d -p 8081:8081 --name nexus nexus-repository-helm:0.0.2`

For further information like how to persist volumes check out [the GitHub repo for our official image](https://github.com/sonatype/docker-nexus3).

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<parent>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>nexus-plugins</artifactId>
<version>3.10.0-04</version>
<version>3.13.0-01</version>
</parent>
<groupId>org.sonatype.repository</groupId>
<artifactId>nexus-repository-helm</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<version>0.0.1</version>
<version>0.0.2</version>
<inceptionYear>2018</inceptionYear>
<packaging>bundle</packaging>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Sonatype Nexus (TM) Open Source Version
* Copyright (c) 2018-present Sonatype, Inc.
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
package org.sonatype.repository.helm.internal;

import java.time.LocalDateTime;
import java.util.Date;

import javax.inject.Named;
import javax.inject.Singleton;

import org.sonatype.goodies.common.ComponentSupport;
import org.sonatype.nexus.common.collect.NestedAttributesMap;
import org.sonatype.repository.helm.internal.metadata.HelmAttributes;

import static org.sonatype.repository.helm.internal.database.HelmProperties.*;

/**
* @since 0.0.2
*/
@Named
@Singleton
public class HelmAssetAttributePopulator
extends ComponentSupport
{
public void populate(final NestedAttributesMap attributes, final HelmAttributes helmAttributes) {
attributes.set(NAME, helmAttributes.getName());
attributes.set(DESCRIPTION, helmAttributes.getDescription());
attributes.set(VERSION, helmAttributes.getVersion());
attributes.set(ICON, helmAttributes.getIcon());
attributes.set(SOURCES, helmAttributes.getSources());
attributes.set(MAINTAINERS, helmAttributes.getMaintainers());
attributes.set(APP_VERSION, helmAttributes.getAppVersion());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ package org.sonatype.repository.helm.internal
import javax.inject.Inject
import javax.inject.Provider

import org.sonatype.nexus.repository.view.Context
import org.sonatype.nexus.repository.view.Matcher
import org.sonatype.nexus.repository.view.matchers.ActionMatcher
import org.sonatype.nexus.repository.view.matchers.LiteralMatcher
import org.sonatype.nexus.repository.view.matchers.logic.LogicMatchers
import org.sonatype.nexus.repository.view.matchers.token.TokenMatcher
import org.sonatype.repository.helm.internal.security.HelmSecurityFacet

import org.sonatype.nexus.repository.Format
Expand All @@ -39,6 +45,11 @@ import org.sonatype.nexus.repository.view.handlers.ExceptionHandler
import org.sonatype.nexus.repository.view.handlers.HandlerContributor
import org.sonatype.nexus.repository.view.handlers.TimingHandler

import static org.sonatype.nexus.repository.http.HttpMethods.GET
import static org.sonatype.nexus.repository.http.HttpMethods.HEAD
import static org.sonatype.repository.helm.internal.AssetKind.HELM_INDEX
import static org.sonatype.repository.helm.internal.AssetKind.HELM_PACKAGE

/**
* Support for Helm recipes.
*/
Expand Down Expand Up @@ -105,4 +116,38 @@ abstract class HelmRecipeSupport
protected HelmRecipeSupport(final Type type, final Format format) {
super(type, format)
}

/**
* Matcher for index.yaml
*/
static Matcher indexMatcher() {
LogicMatchers.and(
new ActionMatcher(GET, HEAD),
new LiteralMatcher('/index.yaml'),
new Matcher() {
@Override
boolean matches(final Context context) {
context.attributes.set(AssetKind.class, HELM_INDEX)
return true
}
}
)
}

/**
* Matcher for package mapping.
*/
static Matcher packageMatcher() {
LogicMatchers.and(
new ActionMatcher(GET, HEAD),
new TokenMatcher('/{filename:.+}'),
new Matcher() {
@Override
boolean matches(final Context context) {
context.attributes.set(AssetKind.class, HELM_PACKAGE)
return true
}
}
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Sonatype Nexus (TM) Open Source Version
* Copyright (c) 2018-present Sonatype, Inc.
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
package org.sonatype.repository.helm.internal.createindex;

import org.sonatype.nexus.repository.Facet;
import org.sonatype.nexus.repository.Facet.Exposed;

/**
* Facet interface for rebuilding Helm index.yaml files
*
* @since 0.0.2
*/
@Exposed
public interface CreateIndexFacet
extends Facet
{
/**
* Mark the helm index yaml as invalidated such that it will be rebuilt after waiting for a configured amount of time
* to prevent unnecessary successive rebuilds of the metadata.
*/
void invalidateIndex();
}
Loading

0 comments on commit 5517c8e

Please sign in to comment.