Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The proxy never uploads artifact bytes to a scanner. Each scanner is notified wi
| RPM | RHEL/Fedora | | ✓ |
| Alpine | Alpine Linux | | ✓ |
| Arch | Arch Linux | | ✓ |
| Chef | Chef | | ✗ |
| Chef Supermarket | Chef | | ✓ |
| Generic | Any | | ✓ |
| Helm | Kubernetes | Yes | ✓ |
| Vagrant | Vagrant | | ✗ |
Expand Down Expand Up @@ -369,6 +369,24 @@ conan remote disable conancenter

Or configure in `~/.conan2/remotes.json`.

### Chef Supermarket (Berkshelf, Policyfiles)

Point Berkshelf at the proxy in your `Berksfile`:

```ruby
source "http://localhost:8080/chef"
```

Or set the default source of a Policyfile:

```ruby
default_source :supermarket, "http://localhost:8080/chef"
```

The proxy serves the `/universe` dependency index and the cookbook API, rewriting every download location to itself while leaving dependency constraints unchanged. Cookbook archives are fetched through the Supermarket download redirect and cached, so they stay available when the Supermarket is down. With `cache_metadata` on, the universe and cookbook metadata follow the usual TTL and stale fallback.

To proxy a private Supermarket instead of `supermarket.chef.io`, set `upstream.chef` (or `PROXY_UPSTREAM_CHEF`) and add credentials under `upstream.auth` if it needs them. See [docs/configuration.md](docs/configuration.md#upstream-registries).

### Conda

Configure in `~/.condarc`:
Expand Down Expand Up @@ -1114,6 +1132,7 @@ Recently cached:
| `GET /nuget/*` | NuGet V3 API |
| `GET /composer/*` | Composer/Packagist protocol |
| `GET /conan/*` | Conan C/C++ protocol |
| `GET /chef/*` | Chef Supermarket protocol (universe, cookbook API and downloads) |
| `GET /conda/*` | Conda/Anaconda protocol |
| `GET /cran/*` | CRAN (R) protocol |
| `GET /julia/*` | Julia Pkg server protocol |
Expand Down
1 change: 1 addition & 0 deletions cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ func runServe() {
fmt.Fprintf(os.Stderr, " PROXY_UPSTREAM_COMPOSER Packagist API upstream URL\n")
fmt.Fprintf(os.Stderr, " PROXY_UPSTREAM_COMPOSER_REPOSITORY Packagist repository upstream URL\n")
fmt.Fprintf(os.Stderr, " PROXY_UPSTREAM_CONAN Conan registry upstream URL\n")
fmt.Fprintf(os.Stderr, " PROXY_UPSTREAM_CHEF Chef Supermarket upstream URL\n")
fmt.Fprintf(os.Stderr, " PROXY_UPSTREAM_CONDA Conda channel upstream URL\n")
fmt.Fprintf(os.Stderr, " PROXY_UPSTREAM_CRAN CRAN mirror upstream URL\n")
fmt.Fprintf(os.Stderr, " PROXY_UPSTREAM_JULIA Julia package server upstream URL\n")
Expand Down
1 change: 1 addition & 0 deletions cmd/proxy/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestServeHelpListsUpstreamEnvironmentVariables(t *testing.T) {
"PROXY_UPSTREAM_COMPOSER",
"PROXY_UPSTREAM_COMPOSER_REPOSITORY",
"PROXY_UPSTREAM_CONAN",
"PROXY_UPSTREAM_CHEF",
"PROXY_UPSTREAM_CONDA",
"PROXY_UPSTREAM_CRAN",
"PROXY_UPSTREAM_JULIA",
Expand Down
4 changes: 4 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ upstream:
# Conan registry URL
conan: "https://center.conan.io"

# Chef Supermarket URL (used by /chef/). Point it at a private
# Supermarket to proxy that instead.
chef: "https://supermarket.chef.io"

# Conda channel base URL
conda: "https://conda.anaconda.org"

Expand Down
12 changes: 12 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ Each upstream used by a built-in package route can be set in YAML or JSON under
| `upstream.composer` | `PROXY_UPSTREAM_COMPOSER` | `https://packagist.org` |
| `upstream.composer_repository` | `PROXY_UPSTREAM_COMPOSER_REPOSITORY` | `https://repo.packagist.org` |
| `upstream.conan` | `PROXY_UPSTREAM_CONAN` | `https://center.conan.io` |
| `upstream.chef` | `PROXY_UPSTREAM_CHEF` | `https://supermarket.chef.io` |
| `upstream.conda` | `PROXY_UPSTREAM_CONDA` | `https://conda.anaconda.org` |
| `upstream.cran` | `PROXY_UPSTREAM_CRAN` | `https://cloud.r-project.org` |
| `upstream.julia` | `PROXY_UPSTREAM_JULIA` | `https://pkg.julialang.org` |
Expand Down Expand Up @@ -284,6 +285,17 @@ upstream:

`upstream.hex_api` is used for cooldown timestamps and must expose Hex's `/api/packages/{name}` JSON endpoint.

`upstream.chef` is the Supermarket served at `/chef/`, for Berkshelf (`source "https://proxy.example.com/chef"`) and Policyfiles (`default_source :supermarket, "https://proxy.example.com/chef"`). The upstream has to serve the Supermarket API: `/universe`, `/api/v1/cookbooks/{name}`, its versions and their downloads. A private Supermarket that needs credentials takes them from `upstream.auth`, scoped to its URL. A download redirect to another host, such as the storage bucket behind Supermarket, does not receive them:

```yaml
upstream:
chef: "https://supermarket.example.com"
auth:
"https://supermarket.example.com":
type: bearer
token: "${SUPERMARKET_TOKEN}"
```

### Private package routes

Clients that use the proxy as their only registry can still install private packages. A package route sends every package whose name matches a pattern to a private registry, and never to the default upstream:
Expand Down
7 changes: 7 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,11 @@ type UpstreamConfig struct {
// Default: https://center.conan.io
Conan string `json:"conan" yaml:"conan"`

// Chef is the upstream Chef Supermarket URL, served at /chef/. Point it
// at a private Supermarket to proxy that instead of the public one.
// Default: https://supermarket.chef.io
Chef string `json:"chef" yaml:"chef"`

// Conda is the upstream Conda channel base URL.
// Default: https://conda.anaconda.org
Conda string `json:"conda" yaml:"conda"`
Expand Down Expand Up @@ -1052,6 +1057,7 @@ func Default() *Config {
Composer: "https://packagist.org",
ComposerRepository: "https://repo.packagist.org",
Conan: "https://center.conan.io",
Chef: "https://supermarket.chef.io",
Conda: "https://conda.anaconda.org",
CRAN: "https://cloud.r-project.org",
Julia: "https://pkg.julialang.org",
Expand Down Expand Up @@ -1195,6 +1201,7 @@ func (c *Config) LoadFromEnv() {
setEnvString(&c.Upstream.Composer, "PROXY_UPSTREAM_COMPOSER")
setEnvString(&c.Upstream.ComposerRepository, "PROXY_UPSTREAM_COMPOSER_REPOSITORY")
setEnvString(&c.Upstream.Conan, "PROXY_UPSTREAM_CONAN")
setEnvString(&c.Upstream.Chef, "PROXY_UPSTREAM_CHEF")
setEnvString(&c.Upstream.Conda, "PROXY_UPSTREAM_CONDA")
setEnvString(&c.Upstream.CRAN, "PROXY_UPSTREAM_CRAN")
setEnvString(&c.Upstream.Julia, "PROXY_UPSTREAM_JULIA")
Expand Down
4 changes: 4 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func upstreamConfigValues(upstream UpstreamConfig) map[string]string {
"composer": upstream.Composer,
"composer_repository": upstream.ComposerRepository,
"conan": upstream.Conan,
"chef": upstream.Chef,
"conda": upstream.Conda,
"cran": upstream.CRAN,
"julia": upstream.Julia,
Expand Down Expand Up @@ -64,6 +65,7 @@ func defaultUpstreamValues() map[string]string {
"composer": "https://packagist.org",
"composer_repository": "https://repo.packagist.org",
"conan": "https://center.conan.io",
"chef": "https://supermarket.chef.io",
"conda": "https://conda.anaconda.org",
"cran": "https://cloud.r-project.org",
"julia": "https://pkg.julialang.org",
Expand Down Expand Up @@ -95,6 +97,7 @@ func upstreamEnvironmentVariables() map[string]string {
"composer": "PROXY_UPSTREAM_COMPOSER",
"composer_repository": "PROXY_UPSTREAM_COMPOSER_REPOSITORY",
"conan": "PROXY_UPSTREAM_CONAN",
"chef": "PROXY_UPSTREAM_CHEF",
"conda": "PROXY_UPSTREAM_CONDA",
"cran": "PROXY_UPSTREAM_CRAN",
"julia": "PROXY_UPSTREAM_JULIA",
Expand Down Expand Up @@ -385,6 +388,7 @@ upstream:
composer: "https://upstream.example.com/composer"
composer_repository: "https://upstream.example.com/composer_repository"
conan: "https://upstream.example.com/conan"
chef: "https://upstream.example.com/chef"
conda: "https://upstream.example.com/conda"
cran: "https://upstream.example.com/cran"
julia: "https://upstream.example.com/julia"
Expand Down
Loading
Loading