Skip to content

Commit 0823499

Browse files
committed
Initial import.
Signed-off-by: Dinko Korunic <[email protected]>
0 parents  commit 0823499

36 files changed

+1520
-0
lines changed

.circleci/config.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
version: 2
2+
jobs:
3+
lint-scripts:
4+
docker:
5+
- image: koalaman/shellcheck-alpine
6+
steps:
7+
- checkout
8+
- run:
9+
command: |
10+
shellcheck -x .circleci/install_charts.sh
11+
shellcheck -x .circleci/install_tools.sh
12+
shellcheck -x .circleci/release.sh
13+
lint-charts:
14+
docker:
15+
- image: quay.io/helmpack/chart-testing:v3.0.0-beta.1
16+
steps:
17+
- checkout
18+
- run:
19+
command: ct lint --config .circleci/ct.yaml
20+
install-charts:
21+
machine: true
22+
steps:
23+
- checkout
24+
- run:
25+
no_output_timeout: 20m
26+
command: .circleci/install_charts.sh
27+
release-charts:
28+
machine: true
29+
steps:
30+
- checkout
31+
- add_ssh_keys:
32+
fingerprints:
33+
- "7f:84:3b:70:a1:c8:63:8e:dc:5f:51:51:b8:f4:7c:76"
34+
- run:
35+
command: |
36+
echo "export GIT_REPOSITORY_URL=$CIRCLE_REPOSITORY_URL" >> $BASH_ENV
37+
echo "export GIT_USERNAME=$CIRCLE_PROJECT_USERNAME" >> $BASH_ENV
38+
.circleci/install_tools.sh
39+
.circleci/release.sh
40+
workflows:
41+
version: 2
42+
lint-and-test:
43+
jobs:
44+
- lint-scripts:
45+
filters:
46+
branches:
47+
ignore: gh-pages
48+
- lint-charts:
49+
filters:
50+
branches:
51+
ignore: gh-pages
52+
- install-charts:
53+
requires:
54+
- lint-charts
55+
filters:
56+
branches:
57+
ignore: gh-pages
58+
release:
59+
jobs:
60+
- release-charts:
61+
filters:
62+
tags:
63+
ignore: /.*/
64+
branches:
65+
only: master

.circleci/ct.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
helm-extra-args: --timeout 800

.circleci/install_charts.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
readonly CT_VERSION=v3.0.0-beta.1
8+
readonly KIND_VERSION=v0.6.1
9+
readonly CLUSTER_NAME=chart-testing
10+
11+
create_ct_container() {
12+
echo "Starting Chart Testing container"
13+
docker run --rm --interactive --detach --network host --name ct \
14+
--volume "$(pwd)/.circleci/ct.yaml:/etc/ct/ct.yaml" \
15+
--volume "$(pwd):/workdir" \
16+
--workdir /workdir \
17+
"quay.io/helmpack/chart-testing:${CT_VERSION}" \
18+
cat
19+
}
20+
21+
cleanup() {
22+
echo "Removing ct container"
23+
docker kill ct > /dev/null 2>&1
24+
}
25+
26+
docker_exec() {
27+
docker exec --interactive ct "$@"
28+
}
29+
30+
create_kind_cluster() {
31+
echo "Installing kind"
32+
curl -sSLo kind "https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64"
33+
chmod +x kind
34+
sudo mv kind /usr/local/bin/kind
35+
36+
echo "Creating cluster"
37+
kind create cluster --name "${CLUSTER_NAME}" --wait 5m
38+
39+
echo "Copying kubeconfig to container"
40+
local kubeconfig
41+
kubeconfig="$(kind get kubeconfig-path --name "${CLUSTER_NAME}")"
42+
docker_exec mkdir -p /root/.kube
43+
docker cp "${kubeconfig}" ct:/root/.kube/config
44+
45+
docker_exec kubectl cluster-info
46+
docker_exec kubectl get nodes
47+
}
48+
49+
install_local_path_provisioner() {
50+
docker_exec kubectl delete storageclass standard
51+
docker_exec kubectl apply -f "https://github.com/raw/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml"
52+
}
53+
54+
install_charts() {
55+
docker_exec ct install
56+
echo
57+
}
58+
59+
main() {
60+
create_ct_container
61+
trap cleanup EXIT
62+
63+
echo "Testing for chart repo changes"
64+
local changed
65+
changed=$(docker_exec ct list-changed)
66+
if [[ -z "${changed}" ]]; then
67+
echo "No chart changes detected"
68+
return
69+
fi
70+
71+
create_kind_cluster
72+
install_local_path_provisioner
73+
install_charts
74+
}
75+
76+
main

.circleci/install_tools.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
readonly HELM_VERSION=3.0.1
6+
readonly CHART_RELEASER_VERSION=0.2.3
7+
8+
install_helm() {
9+
echo "Installing Helm"
10+
curl -sSLO "https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz"
11+
sudo mkdir -p "/usr/local/helm-v${HELM_VERSION}"
12+
sudo tar -xzf "helm-v${HELM_VERSION}-linux-amd64.tar.gz" -C "/usr/local/helm-v${HELM_VERSION}"
13+
sudo ln -s "/usr/local/helm-v${HELM_VERSION}/linux-amd64/helm" /usr/local/bin/helm
14+
sudo chmod +x /usr/local/helm-v${HELM_VERSION}/linux-amd64/helm
15+
rm -f "helm-v${HELM_VERSION}-linux-amd64.tar.gz"
16+
helm init
17+
}
18+
19+
install_cr() {
20+
echo "Installing Chart Releaser"
21+
curl -sSLO "https://github.com/helm/chart-releaser/releases/download/v${CHART_RELEASER_VERSION}/chart-releaser_${CHART_RELEASER_VERSION}_linux_amd64.tar.gz"
22+
sudo mkdir -p "/usr/local/chart-releaser-v${CHART_RELEASER_VERSION}"
23+
sudo tar -xzf "chart-releaser_${CHART_RELEASER_VERSION}_linux_amd64.tar.gz" -C "/usr/local/chart-releaser-v${CHART_RELEASER_VERSION}"
24+
sudo ln -s "/usr/local/chart-releaser-v${CHART_RELEASER_VERSION}/cr" /usr/local/bin/cr
25+
sudo chmod +x "/usr/local/chart-releaser-v${CHART_RELEASER_VERSION}/cr"
26+
rm -f "chart-releaser_${CHART_RELEASER_VERSION}_linux_amd64.tar.gz"
27+
}
28+
29+
main() {
30+
install_helm
31+
install_cr
32+
}
33+
34+
main

.circleci/release.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
: "${CR_TOKEN:?Environment variable CR_TOKEN must be set}"
8+
: "${GIT_REPOSITORY_URL:?Environment variable GIT_REPOSITORY_URL must be set}"
9+
: "${GIT_USERNAME:?Environment variable GIT_USERNAME must be set}"
10+
: "${GIT_EMAIL:?Environment variable GIT_EMAIL must be set}"
11+
12+
readonly OWNER=haproxytech
13+
readonly GIT_REPO=helm-charts
14+
readonly PACKAGE_PATH=.deploy
15+
readonly CHARTS_URL=https://haproxytech.github.io/helm-charts
16+
readonly REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel)}"
17+
18+
find_latest_tag() {
19+
if ! git describe --tags --abbrev=0 2> /dev/null; then
20+
git rev-list --max-parents=0 --first-parent HEAD
21+
fi
22+
}
23+
24+
package_chart() {
25+
local chart="$1"
26+
helm dependency build "${chart}"
27+
helm package "${chart}" --destination "${PACKAGE_PATH}"
28+
}
29+
30+
release_charts() {
31+
echo "Upload Helm chart packages"
32+
cr upload -o "${OWNER}" -r "${GIT_REPO}" -p "${PACKAGE_PATH}"
33+
}
34+
35+
update_index() {
36+
echo "Generating Helm chart index"
37+
git config user.email "${GIT_EMAIL}"
38+
git config user.name "${GIT_USERNAME}"
39+
git checkout gh-pages
40+
41+
#rm -f index.yaml
42+
cr index -i index.yaml -o "${OWNER}" -r "${GIT_REPO}" -c "${CHARTS_URL}" -p "${PACKAGE_PATH}"
43+
44+
git add index.yaml
45+
git commit --message="Update index.yaml" --signoff
46+
git push "${GIT_REPOSITORY_URL}" gh-pages
47+
}
48+
49+
main() {
50+
pushd "${REPO_ROOT}" > /dev/null
51+
52+
echo "Fetching tags"
53+
git fetch --tags
54+
55+
local latest_tag
56+
latest_tag=$(find_latest_tag)
57+
58+
local latest_tag_rev
59+
latest_tag_rev=$(git rev-parse --verify "${latest_tag}")
60+
echo "${latest_tag_rev} ${latest_tag} (latest tag)"
61+
62+
local head_rev
63+
head_rev=$(git rev-parse --verify HEAD)
64+
echo "${head_rev} HEAD"
65+
66+
if [[ "${latest_tag_rev}" == "${head_rev}" ]]; then
67+
echo "No code changes. Nothing to release."
68+
exit
69+
fi
70+
71+
#rm -rf "${PACKAGE_PATH}"
72+
mkdir -p "${PACKAGE_PATH}"
73+
74+
echo "Identifying changed charts since tag ${latest_tag}"
75+
76+
local changed_charts=()
77+
readarray -t changed_charts <<< "$(git diff --find-renames --name-only "${latest_tag_rev}" | grep '\.yaml$' | cut -d '/' -f 1 | sort -u)"
78+
79+
if [[ -n "${changed_charts[*]}" ]]; then
80+
for chart in "${changed_charts[@]}"; do
81+
if [[ -f "${chart}/Chart.yaml" ]]; then
82+
echo "Packaging chart ${chart}"
83+
package_chart "${chart}"
84+
fi
85+
done
86+
87+
release_charts
88+
update_index
89+
else
90+
echo "Nothing to do. No chart changes detected."
91+
fi
92+
93+
popd > /dev/null
94+
}
95+
96+
main

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# General files
2+
*.tgz
3+
.project
4+
.deploy
5+
6+
# MacOS
7+
._*
8+
.DS_Store
9+
10+
# JetBrains
11+
.idea/
12+
*.iml
13+
14+
# VSC
15+
.vscode
16+
17+
# Emacs
18+
*~
19+
\#*\#
20+
.\#*
21+
22+
# Vim
23+
[._]*.s[a-w][a-z]
24+
[._]s[a-w][a-z]
25+
*.un~
26+
Session.vim
27+
.netrwhist
28+
29+
# TODO
30+
TODO

CONTRIBUTING.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Contributing Guidelines
2+
3+
Contributions are welcome via GitHub pull requests.
4+
This document outlines the process to help get your contribution accepted.
5+
6+
## Sign off Your Work
7+
8+
The Developer Certificate of Origin (DCO) is a lightweight way for contributors to certify that they wrote or otherwise have the right to submit the code they are contributing to the project.
9+
Here is the full text of the [DCO](http://developercertificate.org/):
10+
11+
```
12+
Developer Certificate of Origin
13+
Version 1.1
14+
15+
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
16+
1 Letterman Drive
17+
Suite D4700
18+
San Francisco, CA, 94129
19+
20+
Everyone is permitted to copy and distribute verbatim copies of this
21+
license document, but changing it is not allowed.
22+
23+
24+
Developer's Certificate of Origin 1.1
25+
26+
By making a contribution to this project, I certify that:
27+
28+
(a) The contribution was created in whole or in part by me and I
29+
have the right to submit it under the open source license
30+
indicated in the file; or
31+
32+
(b) The contribution is based upon previous work that, to the best
33+
of my knowledge, is covered under an appropriate open source
34+
license and I have the right under that license to submit that
35+
work with modifications, whether created in whole or in part
36+
by me, under the same open source license (unless I am
37+
permitted to submit under a different license), as indicated
38+
in the file; or
39+
40+
(c) The contribution was provided directly to me by some other
41+
person who certified (a), (b) or (c) and I have not modified
42+
it.
43+
44+
(d) I understand and agree that this project and the contribution
45+
are public and that a record of the contribution (including all
46+
personal information I submit with it, including my sign-off) is
47+
maintained indefinitely and may be redistributed consistent with
48+
this project or the open source license(s) involved.
49+
```
50+
51+
Contributors must sign-off that they adhere to these requirements by adding a `Signed-off-by` line to commit messages.
52+
53+
```
54+
This is my commit message
55+
56+
Signed-off-by: Random J Developer <[email protected]>
57+
```
58+
59+
Git has a `-s` command line option to append this automatically to your commit message:
60+
61+
```console
62+
$ git commit -s -m 'This is my commit message'
63+
```
64+
65+
## How to Contribute
66+
67+
1. Fork this repository, develop, and test your changes.
68+
1. Remember to sign off your commits as described above.
69+
1. Submit a pull request.
70+
71+
***NOTE***: In order to make testing and merging of PRs easier, please submit changes to multiple charts in separate PRs.
72+
73+
### Technical Requirements
74+
75+
* Must pass linting and installing with the [chart-testing](https://github.com/helm/chart-testing) tool
76+
* Must follow [best practices](https://github.com/helm/helm/tree/master/docs/chart_best_practices) and [review guidelines](https://github.com/helm/charts/blob/master/REVIEW_GUIDELINES.md)
77+
78+
### Documentation Requirements
79+
80+
* A chart's `README.md` must include configuration options
81+
* A chart's `NOTES.txt` must include relevant post-installation information
82+
83+
### Merge Approval and Release Process
84+
85+
* Must pass DCO check
86+
* Must pass CI jobs for linting and installing changed charts
87+
* Any change to a chart requires a version bump following [semver](https://semver.org/) principles
88+
89+
Once changes have been merged, the release job will automatically run to package and release changed charts.

0 commit comments

Comments
 (0)