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
2 changes: 1 addition & 1 deletion .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: setup go environment
uses: actions/setup-go@v2
with:
go-version: '1.21'
go-version: '1.25'
- name: run unit tests
run: sudo pip install virtualenv && make test
- name: build binary
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: setup go environment
uses: actions/setup-go@v2
with:
go-version: '1.21'
go-version: '1.25'
- name: run unit tests
run: sudo pip install virtualenv && make test
- name: build binary
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.21"
go-version: "1.25"
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
**/*.tgz.prov
.chartmuseum.log
.cover/
.helm2/
.helm3/
.helm-version
.idea/
.robot/
.venv/
Expand Down
24 changes: 17 additions & 7 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
version: 2

env:
- GO111MODULE=on

before:
hooks:
- go mod download

builds:
- main: ./cmd/helm-cm-push
binary: ./bin/helm-cm-push
binary: bin/helm-cm-push
env:
- CGO_ENABLED=0
goos:
Expand All @@ -14,15 +18,21 @@ builds:
- windows
goarch:
- amd64
- arm
- arm64
goarm:
- "6"
- "7"
goamd64:
- v1
goarm64:
- v8.0
# Exclude windows arm builds (marked as broken by GoReleaser)
ignore:
- goos: windows
goarch: arm

archives:
- id: tarball
format: tar.gz
- id: default
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
files:
- LICENSE
- plugin.yaml
- testdata/plugin-helm3.yaml
- testdata/plugin-helm4.yaml
34 changes: 32 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,68 @@ HAS_PIP := $(shell command -v pip3;)
HAS_VENV := $(shell command -v virtualenv;)

.PHONY: build
build: build_linux build_mac build_windows
build: build_linux build_linux_arm64 build_mac build_mac_arm64 build_windows build_windows_arm64

build_windows: export GOARCH=amd64
build_windows: export GO111MODULE=on
build_windows:
@GOOS=windows go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/windows/amd64/helm-cm-push cmd/helm-cm-push/main.go # windows

build_windows_arm64: export GOARCH=arm64
build_windows_arm64: export GO111MODULE=on
build_windows_arm64:
@GOOS=windows go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/windows/arm64/helm-cm-push cmd/helm-cm-push/main.go # windows arm64

link_windows:
@cp bin/windows/amd64/helm-cm-push ./bin/helm-cm-push

link_windows_arm64:
@cp bin/windows/arm64/helm-cm-push ./bin/helm-cm-push

build_linux: export GOARCH=amd64
build_linux: export CGO_ENABLED=0
build_linux: export GO111MODULE=on
build_linux:
@GOOS=linux go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/linux/amd64/helm-cm-push cmd/helm-cm-push/main.go # linux

build_linux_arm64: export GOARCH=arm64
build_linux_arm64: export CGO_ENABLED=0
build_linux_arm64: export GO111MODULE=on
build_linux_arm64:
@GOOS=linux go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/linux/arm64/helm-cm-push cmd/helm-cm-push/main.go # linux arm64

link_linux:
@cp bin/linux/amd64/helm-cm-push ./bin/helm-cm-push

link_linux_arm64:
@cp bin/linux/arm64/helm-cm-push ./bin/helm-cm-push

build_mac: export GOARCH=amd64
build_mac: export CGO_ENABLED=0
build_mac: export GO111MODULE=on
build_mac:
@GOOS=darwin go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/darwin/amd64/helm-cm-push cmd/helm-cm-push/main.go # mac osx
-o bin/darwin/amd64/helm-cm-push cmd/helm-cm-push/main.go # mac osx intel
@cp bin/darwin/amd64/helm-cm-push ./bin/helm-cm-push # For use w make install

build_mac_arm64: export GOARCH=arm64
build_mac_arm64: export CGO_ENABLED=0
build_mac_arm64: export GO111MODULE=on
build_mac_arm64:
@GOOS=darwin go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/darwin/arm64/helm-cm-push cmd/helm-cm-push/main.go # mac osx apple silicon
@cp bin/darwin/arm64/helm-cm-push ./bin/helm-cm-push # For use w make install

link_mac:
@cp bin/darwin/amd64/helm-cm-push ./bin/helm-cm-push

link_mac_arm64:
@cp bin/darwin/arm64/helm-cm-push ./bin/helm-cm-push

.PHONY: clean
clean:
@git status --ignored --short | grep '^!! ' | sed 's/!! //' | xargs rm -rf
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ In ChartMuseum server (>0.7.1) this will automatically be added to index.yaml if

## Authentication
### Basic Auth
If you have added your repo with the `--username`/`--password` flags (Helm 2.9+), or have added your repo with the basic auth username/password in the URL (e.g. `https://myuser:mypass@my.chart.repo.com`), no further setup is required.
If you have added your repo with the `--username`/`--password` flags, or have added your repo with the basic auth username/password in the URL (e.g. `https://myuser:mypass@my.chart.repo.com`), no further setup is required.

The plugin will use the auth info located in `~/.helm/repository/repositories.yaml` (for Helm 2) or `~/.config/helm/repositories.yaml` (for Helm 3) in order to authenticate.
The plugin will use the auth info located in `~/.config/helm/repositories.yaml` in order to authenticate.

If you are running ChartMuseum with `AUTH_ANONYMOUS_GET=true`, and have added your repo without authentication, the plugin recognizes the following environment variables for basic auth on push operations:
```
Expand Down
10 changes: 5 additions & 5 deletions acceptance_tests/01-helm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Suite Setup Suite Setup
Suite Teardown Suite Teardown

*** Test Cases ***
Plugin installs on Helm 2
Test plugin installation 2

Plugin installs on Helm 3
Test plugin installation 3

Plugin installs on Helm 4
Test plugin installation 4

*** Keywords ***
Test plugin installation
[Arguments] ${version}
Expand Down Expand Up @@ -45,11 +45,11 @@ helm-push is not listed as a Helm plugin after removal
Suite Setup
set helm version 3
remove helm plugin
set helm version 2
set helm version 4
remove helm plugin

Suite Teardown
set helm version 3
remove helm plugin
set helm version 2
set helm version 4
remove helm plugin
24 changes: 8 additions & 16 deletions acceptance_tests/02-chartmuseum.robot
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,19 @@ Suite Setup Suite Setup
Suite Teardown Suite Teardown

*** Test Cases ***
Plugin works with ChartMuseum on Helm 2
Test ChartMuseum integration 2

Plugin works with ChartMuseum on Helm 3
Test ChartMuseum integration 3

Plugin works with ChartMuseum on Helm 4
Test ChartMuseum integration 4

*** Keywords ***
Test ChartMuseum integration
[Arguments] ${version}
set helm version ${version}
install helm plugin
helm major version detected by plugin is ${version}

use test chart built by same helm version
clear chartmuseum storage
Chart directory can be pushed to ChartMuseum
Chart directory can be pushed to ChartMuseum with custom version
Chart package can be pushed to ChartMuseum
Chart package can be pushed to ChartMuseum with custom version

use test chart built by opposite helm version
clear chartmuseum storage
Chart directory can be pushed to ChartMuseum
Chart directory can be pushed to ChartMuseum with custom version
Expand Down Expand Up @@ -114,20 +106,20 @@ Chart package can be pushed to ChartMuseum with custom version
Suite Setup
set helm version 3
remove helm plugin
set helm version 2
set helm version 4
remove helm plugin
remove chartmuseum logs
start chartmuseum
Sleep 2
set helm version 2
add chart repo
Sleep 5
set helm version 3
add chart repo
set helm version 4
add chart repo

Suite Teardown
set helm version 3
remove helm plugin
set helm version 2
set helm version 4
remove helm plugin
remove chart repo
stop chartmuseum
Expand Down
4 changes: 2 additions & 2 deletions acceptance_tests/lib/ChartMuseum.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def package_exists_in_chartmuseum_storage(self, find=''):
self.run_command('find %s -maxdepth 1 -name "*%s.tgz" | grep tgz' % (common.STORAGE_DIR, find))

def package_contains_expected_files(self):
# Check for requirements.yaml in Helm 2 (a Helm 2-specific file)
# Check for requirements.yaml (legacy dependency format)
checkRequirementsYamlCmd = '(cd %s && mkdir -p tmp && tar -xf *.tgz --directory tmp && find tmp -name requirements.yaml | grep requirements.yaml)' % common.STORAGE_DIR

# Check for values.schema.json in Helm 3 (a Helm 3-specific file)
# Check for values.schema.json (Helm 3+ specific file)
checkValuesSchemaJsonCmd = '(cd %s && mkdir -p tmp && tar -xf *.tgz --directory tmp && find tmp -name values.schema.json | grep values.schema.json)' % common.STORAGE_DIR

if common.USE_OPPOSITE_VERSION:
Expand Down
27 changes: 23 additions & 4 deletions acceptance_tests/lib/Helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
class Helm(common.CommandRunner):
def set_helm_version(self, version):
version = str(version)
if version == '2':
common.HELM_EXE = 'HELM_HOME=%s helm2' % os.getenv('TEST_V2_HELM_HOME', '')
elif version == '3':
if version == '3':
common.HELM_EXE = 'XDG_CACHE_HOME=%s XDG_CONFIG_HOME=%s XDG_DATA_HOME=%s helm3' % \
(os.getenv('TEST_V3_XDG_CACHE_HOME', ''), os.getenv('TEST_V3_XDG_CONFIG_HOME', ''),
os.getenv('TEST_V3_XDG_DATA_HOME', ''))
elif version == '4':
common.HELM_EXE = 'XDG_CACHE_HOME=%s XDG_CONFIG_HOME=%s XDG_DATA_HOME=%s helm4' % \
(os.getenv('TEST_V3_XDG_CACHE_HOME', ''), os.getenv('TEST_V3_XDG_CONFIG_HOME', ''),
os.getenv('TEST_V3_XDG_DATA_HOME', ''))
else:
raise Exception('invalid Helm version provided: %s' % version)

Expand All @@ -27,8 +29,25 @@ def add_chart_repo(self):
def remove_chart_repo(self):
self.run_command('%s repo remove %s' % (common.HELM_EXE, common.HELM_REPO_NAME))

def setup_plugin_manifest(self):
# In development mode, manually copy the correct manifest for this Helm version
if 'helm4' in common.HELM_EXE:
self.run_command('cp %s/testdata/plugin-helm4.yaml %s/plugin.yaml' % (self.rootdir, self.rootdir))
elif 'helm3' in common.HELM_EXE:
self.run_command('cp %s/testdata/plugin-helm3.yaml %s/plugin.yaml' % (self.rootdir, self.rootdir))

def install_helm_plugin(self):
self.run_command('%s plugin install %s' % (common.HELM_EXE, self.rootdir))
# Setup correct manifest before installing
self.setup_plugin_manifest()

# Set HELM_MAJOR_VERSION env var to help install script detect correct version
if 'helm4' in common.HELM_EXE:
helm_version = '4'
elif 'helm3' in common.HELM_EXE:
helm_version = '3'
else:
helm_version = '3' # Default to 3
self.run_command('HELM_MAJOR_VERSION=%s %s plugin install %s' % (helm_version, common.HELM_EXE, self.rootdir))

def check_helm_plugin(self):
self.run_command('%s plugin list | grep ^cm-push' % common.HELM_EXE)
Expand Down
10 changes: 2 additions & 8 deletions acceptance_tests/lib/HelmPush.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@

class HelmPush(common.CommandRunner):
def _testchart_path(self):
if common.USE_OPPOSITE_VERSION:
if 'helm3' in common.HELM_EXE:
return '%s/helm2/mychart' % common.TESTCHARTS_DIR
return '%s/helm3/my-v3-chart' % common.TESTCHARTS_DIR
else:
if 'helm3' in common.HELM_EXE:
return '%s/helm3/my-v3-chart' % common.TESTCHARTS_DIR
return '%s/helm2/mychart' % common.TESTCHARTS_DIR
# Both Helm 3 and Helm 4 use the same helm3 chart
return '%s/helm3/my-v3-chart' % common.TESTCHARTS_DIR

def helm_major_version_detected_by_plugin_is(self, version):
cmd = '%s cm-push --check-helm-version' % common.HELM_EXE
Expand Down
4 changes: 3 additions & 1 deletion acceptance_tests/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
ACCEPTANCE_DIR = '.acceptance/'
STORAGE_DIR = os.path.join(ACCEPTANCE_DIR, 'storage/')
LOGFILE = '.chartmuseum.log'
HELM_EXE = 'HELM_HOME=%s helm2' % os.getenv('TEST_HELM_HOME', '')
HELM_EXE = 'XDG_CACHE_HOME=%s XDG_CONFIG_HOME=%s XDG_DATA_HOME=%s helm3' % \
(os.getenv('TEST_V3_XDG_CACHE_HOME', ''), os.getenv('TEST_V3_XDG_CONFIG_HOME', ''),
os.getenv('TEST_V3_XDG_DATA_HOME', ''))
USE_OPPOSITE_VERSION = False


Expand Down
Loading
Loading