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
32 changes: 30 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@ jobs:
cache: false

- name: Fmt
run: go fmt ./...

run: |
# Run gofmt in "diff" mode to check for unformatted code
UNFORMATTED_FILES=$(gofmt -l .)
# Check if any files are unformatted
if [[ -n "$UNFORMATTED_FILES" ]]; then
echo "::error::The following Go files are not formatted correctly:"
echo "$UNFORMATTED_FILES" # List unformatted files in the log
echo "::error::Please format your Go code by running \`go fmt ./...\` and commit the changes."
exit 1 # Fail the check
else
echo "All Go files are properly formatted."
fi
- name: Vet
run: go vet ./...

Expand All @@ -33,6 +43,24 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
# Generate example charts
- name: Generate example charts
run: |
cat test_data/sample-app.yaml | go run ./cmd/helmify examples/app
cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify examples/operator
- name: Check that chart examples were commited
run: |
if [[ -n "$(git status --porcelain)" ]]; then
# Capture the list of uncommitted files
UNCOMMITTED_FILES=$(git status --porcelain)
echo "::error::Chart examples generation step has uncommitted changes: $UNCOMMITTED_FILES
Please run following commands and commit the results:
- \`cat test_data/sample-app.yaml | go run ./cmd/helmify examples/app\`
- \`cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify examples/operator\`"
exit 1
else
echo "Chart examples generation check passed. No uncommitted changes."
fi
# Dry-run generated charts in cluster
- name: Install k8s cluster
uses: helm/[email protected]
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,26 @@ go test ./...
Beside unit-tests, project contains e2e test `pkg/app/app_e2e_test.go`.
It's a go test, which uses `test_data/*` to generate a chart in temporary directory.
Then runs `helm lint --strict` to check if generated chart is valid.

## Contribute

Following rules will help changes to be accepted faster:
- For more than one-line bugfixes consider creating an issue with bug description or feature request
- For feature request try to think about and cover following topics (when applicable):
- Motivation: why feature is needed? Which problem does it solve? What is current workaround?
- Backward-compatibility: existing users expect that after upgrading helmify version their existing generated charts wont be changed without consent.
- For bugfix PR consider adding example to [/test_data](./test_data/) source yamls reproducing bug.

### Contribution flow

Check list before submitting PR:
1. Run `go fmt ./...`
2. Run tests `go test ./...`
3. Update chart examples:
```shell
cat test_data/sample-app.yaml | go run ./cmd/helmify examples/app
```
```shell
cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify examples/operator
```
4. In case of long commit history (more than 3) squash local commits into one
2 changes: 1 addition & 1 deletion pkg/processor/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func ProcessObjMeta(appMeta helmify.AppMetadata, obj *unstructured.Unstructured,
}
}

if (obj.GetNamespace() != "") && (appMeta.Config().PreserveNs){
if (obj.GetNamespace() != "") && (appMeta.Config().PreserveNs) {
namespace, err = yamlformat.Marshal(map[string]interface{}{"namespace": obj.GetNamespace()}, 2)
if err != nil {
return "", err
Expand Down
Loading