From 7af48a7c924270738b91a0106ba57ccbece56c92 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 12 Dec 2023 15:25:28 +0100 Subject: [PATCH 1/5] chore: add editorconfig and linting --- .drone.star | 354 ++++++++++++++++++++++++++------------------------ .editorconfig | 20 +++ 2 files changed, 205 insertions(+), 169 deletions(-) create mode 100644 .editorconfig diff --git a/.drone.star b/.drone.star index bfc68c3..07aeada 100644 --- a/.drone.star +++ b/.drone.star @@ -3,11 +3,11 @@ KUBECTL_IMAGE = "docker.io/bitnami/kubectl:1.28" K3D_IMAGE = "ghcr.io/k3d-io/k3d:5-dind" def main(ctx): - pipeline_starlark = starlark(ctx) + pipeline_lint = lint(ctx) pipeline_release = release(ctx) pipeline_docs = documentation(ctx) - pipeline_docs[0]["depends_on"].append(pipeline_starlark[0]["name"]) + pipeline_docs[0]["depends_on"].append(pipeline_lint[0]["name"]) config = { "branches": [ @@ -29,31 +29,37 @@ def main(ctx): pipeline["depends_on"].append(pipeline_kubernetes[0]["name"]) pipeline_release[0]["depends_on"].append(pipeline["name"]) - return pipeline_starlark + pipeline_docs + pipeline_kubernetes + pipeline_deployments + pipeline_release + return pipeline_lint + pipeline_docs + pipeline_kubernetes + pipeline_deployments + pipeline_release -def starlark(ctx): - return [{ - "kind": "pipeline", - "type": "docker", - "name": "starlark", - "steps": [ - { - "name": "starlark-format", - "image": "docker.io/owncloudci/bazel-buildifier", - "commands": [ - "buildifier -d -diff_command='diff -u' .drone.star", +def lint(ctx): + return [ + { + "kind": "pipeline", + "type": "docker", + "name": "starlark", + "steps": [ + { + "name": "starlark-format", + "image": "docker.io/owncloudci/bazel-buildifier", + "commands": [ + "buildifier -d -diff_command='diff -u' .drone.star", + ], + }, + { + "name": "editorconfig-format", + "image": "docker.io/mstruebing/editorconfig-checker", + }, + ], + "depends_on": [], + "trigger": { + "ref": [ + "refs/heads/main", + "refs/tags/**", + "refs/pull/**", ], }, - ], - "depends_on": [], - "trigger": { - "ref": [ - "refs/heads/main", - "refs/tags/**", - "refs/pull/**", - ], }, - }] + ] def kubernetes(ctx, config): pipeline = { @@ -117,174 +123,184 @@ def kubernetes(ctx, config): return [pipeline] def deployments(ctx): - return [{ - "kind": "pipeline", - "type": "docker", - "name": "k3d", - "steps": wait(ctx) + install(ctx), - "services": [ - { - "name": "k3d", - "image": K3D_IMAGE, - "privileged": True, - "commands": [ - "nohup dockerd-entrypoint.sh &", - "until docker ps 2>&1 > /dev/null; do sleep 1s; done", - "k3d cluster create --config ci/k3d-drone.yaml --api-port k3d:6445", - "until kubectl get deployment coredns -n kube-system -o go-template='{{.status.availableReplicas}}' | grep -v -e ''; do sleep 1s; done", - "k3d kubeconfig get drone > kubeconfig-$${DRONE_BUILD_NUMBER}.yaml", - "chmod 0600 kubeconfig-$${DRONE_BUILD_NUMBER}.yaml", - "printf '@@@@@@@@@@@@@@@@@@@@@@@\n@@@@ k3d is ready @@@@\n@@@@@@@@@@@@@@@@@@@@@@@\n'", - "kubectl get events -Aw", + return [ + { + "kind": "pipeline", + "type": "docker", + "name": "k3d", + "steps": wait(ctx) + install(ctx), + "services": [ + { + "name": "k3d", + "image": K3D_IMAGE, + "privileged": True, + "commands": [ + "nohup dockerd-entrypoint.sh &", + "until docker ps 2>&1 > /dev/null; do sleep 1s; done", + "k3d cluster create --config ci/k3d-drone.yaml --api-port k3d:6445", + "until kubectl get deployment coredns -n kube-system -o go-template='{{.status.availableReplicas}}' | grep -v -e ''; do sleep 1s; done", + "k3d kubeconfig get drone > kubeconfig-$${DRONE_BUILD_NUMBER}.yaml", + "chmod 0600 kubeconfig-$${DRONE_BUILD_NUMBER}.yaml", + "printf '@@@@@@@@@@@@@@@@@@@@@@@\n@@@@ k3d is ready @@@@\n@@@@@@@@@@@@@@@@@@@@@@@\n'", + "kubectl get events -Aw", + ], + }, + ], + "depends_on": [], + "trigger": { + "ref": [ + "refs/heads/main", + "refs/tags/**", + "refs/pull/**", ], }, - ], - "depends_on": [], - "trigger": { - "ref": [ - "refs/heads/main", - "refs/tags/**", - "refs/pull/**", - ], }, - }] + ] def install(ctx): - return [{ - "name": "helm-install", - "image": "docker.io/owncloudci/alpine", - "commands": [ - "export KUBECONFIG=kubeconfig-$${DRONE_BUILD_NUMBER}.yaml", - "helm install --values ci/ci-values.yaml --atomic --timeout 5m0s owncloud charts/owncloud/", - ], - }] + return [ + { + "name": "helm-install", + "image": "docker.io/owncloudci/alpine", + "commands": [ + "export KUBECONFIG=kubeconfig-$${DRONE_BUILD_NUMBER}.yaml", + "helm install --values ci/ci-values.yaml --atomic --timeout 5m0s owncloud charts/owncloud/", + ], + }, + ] def documentation(ctx): - return [{ - "kind": "pipeline", - "type": "docker", - "name": "documentation", - "steps": [ - { - "name": "helm-docs-readme", - "image": HELM_DOCS_IMAGE, - "commands": [ - "/usr/bin/helm-docs --badge-style=flat --template-files=ci/README.md.gotmpl --output-file=README.md", - ], - }, - { - "name": "check-unchanged", - "image": "docker.io/owncloudci/alpine", - "commands": [ - "git diff --exit-code", + return [ + { + "kind": "pipeline", + "type": "docker", + "name": "documentation", + "steps": [ + { + "name": "helm-docs-readme", + "image": HELM_DOCS_IMAGE, + "commands": [ + "/usr/bin/helm-docs --badge-style=flat --template-files=ci/README.md.gotmpl --output-file=README.md", + ], + }, + { + "name": "check-unchanged", + "image": "docker.io/owncloudci/alpine", + "commands": [ + "git diff --exit-code", + ], + }, + ], + "depends_on": [], + "trigger": { + "ref": [ + "refs/heads/main", + "refs/tags/**", + "refs/pull/**", ], }, - ], - "depends_on": [], - "trigger": { - "ref": [ - "refs/heads/main", - "refs/tags/**", - "refs/pull/**", - ], }, - }] + ] def release(ctx): - return [{ - "kind": "pipeline", - "type": "docker", - "name": "release", - "steps": [ - { - "name": "changelog", - "image": "quay.io/thegeeklab/git-chglog", - "commands": [ - "git fetch -tq", - "git-chglog --no-color --no-emoji %s" % (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "--next-tag unreleased unreleased"), - "git-chglog --no-color --no-emoji -o charts/owncloud/CHANGELOG.md %s" % (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "--next-tag unreleased unreleased"), - ], - }, - { - "name": "helmpack-package", - "image": "quay.io/helmpack/chart-releaser", - "commands": [ - "sed -i 's/version: 0.0.0-devel/version: %s/g' charts/owncloud/Chart.yaml" % (ctx.build.ref.replace("refs/tags/", "").replace("v", "") if ctx.build.event == "tag" else "0.0.0-devel"), - "cr package charts/owncloud/", - ], - }, - { - "name": "helmpack-upload", - "image": "quay.io/helmpack/chart-releaser", - "environment": { - "CR_TOKEN": { - "from_secret": "github_token", - }, - }, - "commands": [ - "cr upload charts/owncloud/", - ], - "when": { - "ref": [ - "refs/tags/**", + return [ + { + "kind": "pipeline", + "type": "docker", + "name": "release", + "steps": [ + { + "name": "changelog", + "image": "quay.io/thegeeklab/git-chglog", + "commands": [ + "git fetch -tq", + "git-chglog --no-color --no-emoji %s" % (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "--next-tag unreleased unreleased"), + "git-chglog --no-color --no-emoji -o charts/owncloud/CHANGELOG.md %s" % (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "--next-tag unreleased unreleased"), ], }, - }, - { - "name": "helmpack-index", - "image": "quay.io/helmpack/chart-releaser", - "commands": [ - "mkdir -p dist/docs/", - "cp README.md dist/docs/README.md", - "cr index", - ], - "when": { - "ref": [ - "refs/tags/**", + { + "name": "helmpack-package", + "image": "quay.io/helmpack/chart-releaser", + "commands": [ + "sed -i 's/version: 0.0.0-devel/version: %s/g' charts/owncloud/Chart.yaml" % (ctx.build.ref.replace("refs/tags/", "").replace("v", "") if ctx.build.event == "tag" else "0.0.0-devel"), + "cr package charts/owncloud/", ], }, - }, - { - "name": "pages", - "image": "docker.io/plugins/gh-pages", - "settings": { - "pages_directory": "dist/docs", - "copy_contents": True, - "delete": True, - "password": { - "from_secret": "github_token", + { + "name": "helmpack-upload", + "image": "quay.io/helmpack/chart-releaser", + "environment": { + "CR_TOKEN": { + "from_secret": "github_token", + }, }, - "target_branch": "gh_pages", - "username": { - "from_secret": "github_username", + "commands": [ + "cr upload charts/owncloud/", + ], + "when": { + "ref": [ + "refs/tags/**", + ], }, }, - "when": { - "ref": [ - "refs/tags/**", + { + "name": "helmpack-index", + "image": "quay.io/helmpack/chart-releaser", + "commands": [ + "mkdir -p dist/docs/", + "cp README.md dist/docs/README.md", + "cr index", ], + "when": { + "ref": [ + "refs/tags/**", + ], + }, + }, + { + "name": "pages", + "image": "docker.io/plugins/gh-pages", + "settings": { + "pages_directory": "dist/docs", + "copy_contents": True, + "delete": True, + "password": { + "from_secret": "github_token", + }, + "target_branch": "gh_pages", + "username": { + "from_secret": "github_username", + }, + }, + "when": { + "ref": [ + "refs/tags/**", + ], + }, }, - }, - ], - "depends_on": [], - "trigger": { - "ref": [ - "refs/heads/main", - "refs/tags/**", - "refs/pull/**", ], + "depends_on": [], + "trigger": { + "ref": [ + "refs/heads/main", + "refs/tags/**", + "refs/pull/**", + ], + }, }, - }] + ] def wait(config): - return [{ - "name": "wait", - "image": KUBECTL_IMAGE, - "user": "root", - "commands": [ - "export KUBECONFIG=kubeconfig-$${DRONE_BUILD_NUMBER}.yaml", - "until test -f $${KUBECONFIG}; do sleep 1s; done", - "kubectl config view", - "kubectl get pods -A", - ], - }] + return [ + { + "name": "wait", + "image": KUBECTL_IMAGE, + "user": "root", + "commands": [ + "export KUBECONFIG=kubeconfig-$${DRONE_BUILD_NUMBER}.yaml", + "until test -f $${KUBECONFIG}; do sleep 1s; done", + "kubectl config view", + "kubectl get pods -A", + ], + }, + ] diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b52dcac --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# https://editorconfig.org/ + +root = true + +[*] +indent_style = space +indent_size = 2 +tab_width = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[Makefile] +indent_style = tab +indent_size = 4 + +[*.star] +indent_style = space +indent_size = 4 From 5b10079b55d2f9c438e8c895a1b09a783671e847 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 12 Dec 2023 15:38:26 +0100 Subject: [PATCH 2/5] relax editorconfig for license file --- .editorconfig | 4 ++++ charts/owncloud/templates/NOTES.txt | 4 ++-- charts/owncloud/values.yaml | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.editorconfig b/.editorconfig index b52dcac..ecb414e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,3 +18,7 @@ indent_size = 4 [*.star] indent_style = space indent_size = 4 + +[LICENSE] +indent_size = unset +tab_width = unset diff --git a/charts/owncloud/templates/NOTES.txt b/charts/owncloud/templates/NOTES.txt index e91441f..09dbe6a 100644 --- a/charts/owncloud/templates/NOTES.txt +++ b/charts/owncloud/templates/NOTES.txt @@ -10,8 +10,8 @@ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT {{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "owncloud.fullname" . }}' + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "owncloud.fullname" . }}' export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "owncloud.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") echo http://$SERVICE_IP:{{ .Values.service.port }} {{- else if contains "ClusterIP" .Values.service.type }} diff --git a/charts/owncloud/values.yaml b/charts/owncloud/values.yaml index 902f47c..13003a5 100644 --- a/charts/owncloud/values.yaml +++ b/charts/owncloud/values.yaml @@ -412,7 +412,7 @@ persistence: # -- owncloud data Persistent Volume Storage Class. If defined, `storageClassName` of the PVC is set to the value defined here. If set to "-", `storageClassName`of the PVC is set to `""`, which disables dynamic provisioning. If undefined (the default) or set to null, no `storageClassName` spec is set, choosing the default provisioner. storageClassName: "" # -- Set annotations on the owncloud PVC. - annotations: + annotations: "helm.sh/resource-policy": keep # -- Number of replicas for each scalable service. Has no effect when `autoscaling.enabled` is set to `true`. @@ -442,7 +442,6 @@ service: # -- Service annotations. annotations: {} - ingress: # -- Enables the Ingress. enabled: false From e37b0d66ed6b0a0c6f4089c27bb3a1a7f6e2eb73 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 12 Dec 2023 16:09:26 +0100 Subject: [PATCH 3/5] set default tab_width to 4 --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index ecb414e..8ebbf1e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,7 +5,7 @@ root = true [*] indent_style = space indent_size = 2 -tab_width = 2 +tab_width = 4 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true From 8bce413dca1f2b654f440c7f5d2c7b6301613ad4 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 12 Dec 2023 16:13:20 +0100 Subject: [PATCH 4/5] set default tab_width back to 2 --- .editorconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 8ebbf1e..02b68eb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,7 +5,7 @@ root = true [*] indent_style = space indent_size = 2 -tab_width = 4 +tab_width = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true @@ -14,10 +14,12 @@ insert_final_newline = true [Makefile] indent_style = tab indent_size = 4 +tab_width = 4 [*.star] indent_style = space indent_size = 4 +tab_width = 4 [LICENSE] indent_size = unset From 5d54f5ed748d772581008b41a1be1920bff6d159 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 12 Dec 2023 16:14:34 +0100 Subject: [PATCH 5/5] remove tab_width as it defaults to indent_size --- .editorconfig | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.editorconfig b/.editorconfig index 02b68eb..57d5c52 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,7 +5,6 @@ root = true [*] indent_style = space indent_size = 2 -tab_width = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true @@ -14,13 +13,10 @@ insert_final_newline = true [Makefile] indent_style = tab indent_size = 4 -tab_width = 4 [*.star] indent_style = space indent_size = 4 -tab_width = 4 [LICENSE] indent_size = unset -tab_width = unset