-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sonatype-nexus-community/proxy-poc
Proxy POC
- Loading branch information
Showing
21 changed files
with
1,681 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!-- | ||
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. | ||
--> | ||
## Puppet Repositories | ||
|
||
### Introduction | ||
|
||
[Puppet](https://www.puppet.com/) is a application management format used to help automate and run an organizations | ||
infrastructure, using Puppet Modules, which are effectively recipes for running an application. | ||
|
||
### Proxying The Puppet Forge | ||
|
||
You can set up a Puppet proxy repository to access a remote repository location, for example to proxy the stable Puppet | ||
Modules at [the Puppet Forge](https://forge.puppet.com/) | ||
|
||
To proxy a Puppet repository, you simply create a new 'puppet (proxy)' as documented in | ||
[Repository Management](https://help.sonatype.com/repomanager3/configuration/repository-management) in | ||
detail. Minimal configuration steps are: | ||
|
||
- Define 'Name' | ||
- Define URL for 'Remote storage' e.g. [https://forgeapi.puppet.com/](https://forgeapi.puppet.com/) | ||
- Select a 'Blob store' for 'Storage' | ||
|
||
### Configuring Puppet | ||
|
||
There are relatively few steps for configuring Puppet to use Nexus Repository: | ||
|
||
You'll need to have Puppet installed, for interaction with the Puppet Forge. | ||
|
||
NOTE: These instructions are Linux/OS X specific. | ||
|
||
Once you have Puppet up and running you'll want to run commands similar to the following: | ||
|
||
You'll need to create a `puppet.conf` file at the following location if it does not exist: | ||
|
||
`~/.puppet/puppet.conf` | ||
|
||
In this file you'll need to add: | ||
|
||
`module_repository = 'http://nexushostname:nexusport/repository/puppet-proxy-name'` | ||
|
||
Once you've done this, you should be ready to install Puppet modules via `puppet install module`! | ||
|
||
### Browsing Puppet Repository Packages | ||
|
||
You can browse Puppet repositories in the user interface inspecting the components and assets and their details, as | ||
described in [Browsing Repositories and Repository Groups](https://help.sonatype.com/display/NXRM3/Browsing+Repositories+and+Repository+Groups). |
43 changes: 43 additions & 0 deletions
43
src/main/java/org/sonatype/nexus/repository/puppet/internal/AssetKind.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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.nexus.repository.puppet.internal; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import org.sonatype.nexus.repository.cache.CacheControllerHolder.CacheType; | ||
|
||
import static org.sonatype.nexus.repository.cache.CacheControllerHolder.*; | ||
|
||
/** | ||
* Asset kinds for Puppet | ||
* | ||
* Examples of all can be found at: https://forgeapi.puppetlabs.com/#interactive-demonstration | ||
* @since 0.0.1 | ||
*/ | ||
public enum AssetKind | ||
{ | ||
MODULE_RELEASES_BY_NAME(METADATA), | ||
MODULE_RELEASE_BY_NAME_AND_VERSION(METADATA), | ||
MODULE_DOWNLOAD(CONTENT); | ||
|
||
private final CacheType cacheType; | ||
|
||
AssetKind(final CacheType cacheType) { | ||
this.cacheType = cacheType; | ||
} | ||
|
||
@Nonnull | ||
public CacheType getCacheType() { | ||
return cacheType; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/main/java/org/sonatype/nexus/repository/puppet/internal/PuppetContentValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* 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.nexus.repository.puppet.internal; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
import org.sonatype.goodies.common.ComponentSupport; | ||
import org.sonatype.nexus.mime.MimeRulesSource; | ||
import org.sonatype.nexus.repository.storage.ContentValidator; | ||
import org.sonatype.nexus.repository.storage.DefaultContentValidator; | ||
|
||
import com.google.common.base.Supplier; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
/** | ||
* @since 0.0.1 | ||
*/ | ||
@Named(PuppetFormat.NAME) | ||
@Singleton | ||
public class PuppetContentValidator | ||
extends ComponentSupport | ||
implements ContentValidator | ||
{ | ||
private final DefaultContentValidator defaultContentValidator; | ||
|
||
@Inject | ||
public PuppetContentValidator(final DefaultContentValidator defaultContentValidator) { | ||
this.defaultContentValidator = checkNotNull(defaultContentValidator); | ||
} | ||
|
||
@Override | ||
public String determineContentType(final boolean strictContentTypeValidation, | ||
final Supplier<InputStream> contentSupplier, | ||
final @Nullable MimeRulesSource mimeRulesSource, | ||
final @Nullable String contentName, | ||
final @Nullable String declaredContentType) throws IOException | ||
{ | ||
if (contentName != null) { | ||
if (!contentName.endsWith(".tar.gz")) { | ||
// Note: Tika thinks the puppet json responses are text/plain since we aren't getting them as .json files | ||
return defaultContentValidator.determineContentType( | ||
false, | ||
contentSupplier, | ||
mimeRulesSource, | ||
contentName + ".json", | ||
declaredContentType); | ||
} | ||
} | ||
return defaultContentValidator.determineContentType( | ||
strictContentTypeValidation, | ||
contentSupplier, | ||
mimeRulesSource, | ||
contentName, | ||
declaredContentType | ||
); | ||
} | ||
} |
Oops, something went wrong.