Skip to content

Commit

Permalink
feat: add docs generation and validation (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys authored Sep 27, 2022
1 parent ba886b8 commit ee98ed4
Show file tree
Hide file tree
Showing 13 changed files with 312 additions and 216 deletions.
60 changes: 16 additions & 44 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ config = {
def main(ctx):
pipeline_starlark = starlark(ctx)

pipeline_docs = documentation(ctx)
pipeline_docs[0]["depends_on"].append(pipeline_starlark[0]["name"])

pipeline_kubernetes = kubernetes(ctx, config)
pipeline_kubernetes[0]["depends_on"].append(pipeline_starlark[0]["name"])
pipeline_kubernetes[0]["depends_on"].append(pipeline_docs[0]["name"])

pipeline_deployments = deployments(ctx)
for pipeline in pipeline_deployments:
pipeline["depends_on"].append(pipeline_kubernetes[0]["name"])

return pipeline_starlark + pipeline_kubernetes + pipeline_deployments
return pipeline_starlark + pipeline_docs + pipeline_kubernetes + pipeline_deployments

def starlark(ctx):
return [{
Expand Down Expand Up @@ -68,22 +71,22 @@ def kubernetes(ctx, config):
"steps": [
{
"name": "helm-lint",
"image": "owncloudci/alpine:latest",
"image": "owncloudci/alpine",
"commands": [
"helm lint --strict charts/owncloud",
],
},
{
"name": "helm-template",
"image": "owncloudci/alpine:latest",
"image": "owncloudci/alpine",
"commands": [
"helm template charts/owncloud -f ci/ci-values.yaml > ci/owncloud-ci-templated.yaml",
],
"depends_on": ["helm-lint"],
},
{
"name": "kube-lint",
"image": "stackrox/kube-linter:latest",
"image": "stackrox/kube-linter",
"entrypoint": [
"/kube-linter",
"lint",
Expand All @@ -105,7 +108,7 @@ def kubernetes(ctx, config):
pipeline["steps"].append(
{
"name": "kubeconform-%s" % version,
"image": "ghcr.io/yannh/kubeconform:master",
"image": "ghcr.io/yannh/kubeconform",
"entrypoint": [
"/kubeconform",
"-kubernetes-version",
Expand All @@ -121,7 +124,7 @@ def kubernetes(ctx, config):
return [pipeline]

def deployments(ctx):
pipeline = {
return [{
"kind": "pipeline",
"type": "docker",
"name": "k3d",
Expand Down Expand Up @@ -150,14 +153,12 @@ def deployments(ctx):
"refs/pull/**",
],
},
}

return [pipeline]
}]

def install(ctx):
return [{
"name": "helm-install",
"image": "owncloudci/alpine:latest",
"image": "owncloudci/alpine",
"commands": [
"export KUBECONFIG=kubeconfig-$${DRONE_BUILD_NUMBER}.yaml",
"helm install -f ci/ci-values.yaml --atomic --timeout 5m0s owncloud charts/owncloud/",
Expand All @@ -172,43 +173,14 @@ def documentation(ctx):
"steps": [
{
"name": "helm-docs-readme",
"image": "jnorwood/helm-docs:v1.11.0",
"commands": [
"image": "jnorwood/helm-docs",
"entrypoint": [
"/usr/bin/helm-docs",
"--template-files=README.md.gotmpl",
"--badge-style=flat",
"--template-files=ci/README.md.gotmpl",
"--output-file=README.md",
],
},
{
"name": "helm-docs-values-table-adoc",
"image": "jnorwood/helm-docs:v1.11.0",
"commands": [
"/usr/bin/helm-docs",
"--template-files=charts/owncloud/docs/templates/values-desc-table.adoc.gotmpl",
"--output-file=docs/values-desc-table.adoc",
],
},
{
"name": "helm-docs-kube-versions-adoc",
"image": "jnorwood/helm-docs:v1.11.0",
"commands": [
"/usr/bin/helm-docs",
"--template-files=charts/owncloud/docs/templates/kube-versions.adoc.gotmpl",
"--output-file=kube-versions.adoc",
],
},
{
"name": "gomplate-values-adoc",
"image": "hairyhenderson/gomplate:v3.10.0-alpine",
"enviornment": {
"ASSUME_NO_MOVING_GC_UNSAFE_RISK_IT_WITH": "go1.18",
},
"commands": [
"/bin/gomplate",
"--file=charts/owncloud/docs/templates/values.adoc.yaml.gotmpl",
"--out=charts/owncloud/docs/values.adoc.yaml",
],
},
{
"name": "check-unchanged",
"image": "owncloudci/alpine",
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
charts/**/README.md
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
HELM_DOCS_PACKAGE_VERSION := latest
KUBE_LINTER_PACKAGE_VERSION := latest
KUBECONFORM_PACKAGE_VERSION := latest

SHELL := bash
GO ?= go

HELM_DOCS_PACKAGE ?= github.com/norwoodj/helm-docs/cmd/helm-docs@$(HELM_DOCS_PACKAGE_VERSION)
KUBE_LINTER_PACKAGE ?= golang.stackrox.io/kube-linter/cmd/kube-linter@$(KUBE_LINTER_PACKAGE_VERSION)
KUBECONFORM_PACKAGE ?= github.com/yannh/kubeconform/cmd/kubeconform@$(KUBECONFORM_PACKAGE_VERSION)

all: docs lint api clean

.PHONY: docs
docs:
$(GO) run $(HELM_DOCS_PACKAGE) --badge-style=flat --template-files ci/README.md.gotmpl --output-file=README.md

.PHONY: ci-template
ci-template:
helm template charts/owncloud -f ci/ci-values.yaml > ci/owncloud-ci-templated.yaml

.PHONY: clean
clean:
@rm ci/owncloud-ci-templated.yaml

.PHONY: lint
lint: ci-template
helm lint charts/owncloud
$(GO) run $(KUBE_LINTER_PACKAGE) lint ci/owncloud-ci-templated.yaml

.PHONY: api
api: ci-template
$(GO) run $(KUBECONFORM_PACKAGE) -kubernetes-version 1.21.0 -summary -strict ci/owncloud-ci-templated.yaml
$(GO) run $(KUBECONFORM_PACKAGE) -kubernetes-version 1.22.0 -summary -strict ci/owncloud-ci-templated.yaml
$(GO) run $(KUBECONFORM_PACKAGE) -kubernetes-version 1.23.0 -summary -strict ci/owncloud-ci-templated.yaml
$(GO) run $(KUBECONFORM_PACKAGE) -kubernetes-version 1.24.0 -summary -strict ci/owncloud-ci-templated.yaml
64 changes: 6 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ownCloud: Helm Charts

[![Build Status](https://img.shields.io/drone/build/owncloud-docker/helm?logo=drone&server=https%3A%2F%2Fdrone.owncloud.com)](https://drone.owncloud.com/owncloud-docker/helm)
[![GitHub contributors](https://img.shields.io/github/contributors/owncloud-docker/helm)](https://github.com/owncloud-docker/helm/graphs/contributors)
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/owncloud-docker/helm)
[![License: MIT](https://img.shields.io/github/license/owncloud-docker/helm)](https://github.com/owncloud-docker/helm/blob/master/LICENSE)
[![Build Status](https://img.shields.io/drone/build/owncloud-docker/helm-charts?logo=drone&server=https%3A%2F%2Fdrone.owncloud.com)](https://drone.owncloud.com/owncloud-docker/helm-charts)
[![GitHub contributors](https://img.shields.io/github/contributors/owncloud-docker/helm-charts)](https://github.com/owncloud-docker/helm-charts/graphs/contributors)
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/owncloud-docker/helm-charts)
[![License: MIT](https://img.shields.io/github/license/owncloud-docker/helm-charts)](https://github.com/owncloud-docker/helm-charts/blob/master/LICENSE)

The code is provided as-is with no warranties.

Expand All @@ -21,63 +21,11 @@ For instructions on how to run it anyways the the respective chart's readme.
[//]: # "```"
[//]: # "You can then run `helm search repo owncloud` to see the charts."

Chart documentation is available in the [owncloud directory](https://github.com/owncloud-docker/helm/blob/main/charts/owncloud/README.md).

## Values

| Key | Type | Default | Description |
| ------------------------------------------ | ------ | ----------------------------- | ----------- |
| affinity | object | `{}` | |
| autoscaling.enabled | bool | `false` | |
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.minReplicas | int | `1` | |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| externalDatabase.host | string | `""` | |
| externalDatabase.name | string | `"owncloud"` | |
| externalDatabase.password | string | `"owncloud"` | |
| externalDatabase.port | int | `3306` | |
| externalDatabase.type | string | `""` | |
| externalDatabase.user | string | `"owncloud"` | |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"docker.io/owncloud/server"` | |
| image.tag | float | `10.6` | |
| imagePullSecrets | list | `[]` | |
| ingress.annotations | string | `nil` | |
| ingress.enabled | bool | `true` | |
| ingress.hosts[0].host | string | `"owncloud.chart.example"` | |
| ingress.hosts[0].paths[0] | string | `"/*"` | |
| ingress.hosts[0].servicePort | int | `80` | |
| ingress.tls[0].hosts[0] | string | `"owncloud.chart.example"` | |
| ingress.tls[0].secretName | string | `"owncloud"` | |
| mariadb.enabled | bool | `false` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| owncloud.domain | string | `"owncloud.chart.example"` | |
| owncloud.password | string | `"owncloud"` | |
| owncloud.username | string | `"owncloud"` | |
| persistence.enabled | bool | `true` | |
| persistence.owncloud.accessMode | string | `"ReadWriteOnce"` | |
| persistence.owncloud.nfs | string | `nil` | |
| persistence.owncloud.size | string | `"8Gi"` | |
| podAnnotations | object | `{}` | |
| podSecurityContext | object | `{}` | |
| redis.enabled | bool | `false` | |
| replicaCount | int | `1` | |
| resources | object | `{}` | |
| securityContext | object | `{}` | |
| service.port | int | `80` | |
| service.type | string | `"LoadBalancer"` | |
| serviceAccount.annotations | object | `{}` | |
| serviceAccount.create | bool | `true` | |
| serviceAccount.name | string | `""` | |
| tolerations | list | `[]` | |

---
Chart documentation is available in the [owncloud directory](https://github.com/owncloud-docker/helm-charts/blob/main/charts/owncloud/README.md).

## License

This project is licensed under the Apache 2.0 License - see the [LICENSE](https://github.com/owncloud-docker/helm/blob/master/LICENSE) file for details.
This project is licensed under the Apache 2.0 License - see the [LICENSE](https://github.com/owncloud-docker/helm-charts/blob/master/LICENSE) file for details.

## Copyright

Expand Down
3 changes: 2 additions & 1 deletion charts/owncloud/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ name: owncloud
version: 0.1.0
description: ownCloud Server Helm chart
appVersion: 10.11.0
home: https://owncloud.com/
keywords:
- owncloud
- files
Expand All @@ -16,6 +17,6 @@ maintainers:
type: application
kubeVersion: "~1.21.0 || ~1.22.0 || ~1.23.0 || ~1.24.0 || ~1.25.0" # if this changes, also kubernetesVersions in .drone.star needs to be changed
sources:
- https://github.com/owncloud-docker/helm
- https://github.com/owncloud-docker/helm-charts
- https://github.com/owncloud-docker/server
- https://github.com/owncloud/core
93 changes: 93 additions & 0 deletions charts/owncloud/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# owncloud

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat) ![AppVersion: 10.11.0](https://img.shields.io/badge/AppVersion-10.11.0-informational?style=flat)

ownCloud Server Helm chart
**Homepage:** <https://owncloud.com/>
## Source Code

* <https://github.com/owncloud-docker/helm-charts>
* <https://github.com/owncloud-docker/server>
* <https://github.com/owncloud/core>
## Requirements

Kubernetes: `~1.21.0 || ~1.22.0 || ~1.23.0 || ~1.24.0 || ~1.25.0`

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | Node affinity selection constraint. |
| autoscaling.enabled | bool | `false` | Enables autoscaling. When set to `true`, `replicas` is no longer applied. |
| autoscaling.maxReplicas | int | `10` | Sets maximum replicas for autoscaling. |
| autoscaling.metrics | list | `[]` | Metrics to use for autoscaling. |
| autoscaling.minReplicas | int | `1` | Sets minimum replicas for autoscaling. |
| externalDatabase.host | string | `""` | |
| externalDatabase.name | string | `"owncloud"` | |
| externalDatabase.password | string | `"owncloud"` | |
| externalDatabase.port | int | `3306` | |
| externalDatabase.type | string | `""` | |
| externalDatabase.user | string | `"owncloud"` | |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | Image pull policy |
| image.repository | string | `"docker.io/owncloud/server"` | Image repository |
| image.sha | string | `""` | Image sha/digest (optional). |
| image.tag | string | The `appVersion` of the Chart. | Image tag. |
| imagePullSecrets | object | `{}` | List of references to secrets in the same namespace to use for pulling images from a private registry. |
| ingress.annotations | object | `{}` | Ingress annotations. |
| ingress.enabled | bool | `false` | Enables the Ingress. |
| ingress.ingressClassName | string | `""` | Ingress class to use. Uses the default ingress class if not set. |
| ingress.labels | object | `{}` | Labels for the ingress. |
| ingress.tls | list | `[]` | Ingress TLS configuration. |
| initResources | object | `{}` | Resources to apply to all init containers. |
| mariadb.enabled | bool | `false` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | Simple node selection constraint. |
| owncloud.configExtra | object | `{}` | |
| owncloud.domain | string | `"owncloud.chart.example"` | |
| owncloud.password | string | `"owncloud"` | |
| owncloud.username | string | `"owncloud"` | |
| owncloud.volume_apps | string | `"/mnt/data/apps"` | |
| owncloud.volume_config | string | `"/mnt/data/config"` | |
| owncloud.volume_files | string | `"/mnt/data/files"` | |
| owncloud.volume_root | string | `"/mnt/data"` | |
| persistence.enabled | bool | `true` | Enables persistence. |
| persistence.owncloud.accessMode[0] | string | `"ReadWriteOnce"` | |
| persistence.owncloud.nfs | object | `{}` | |
| persistence.owncloud.size | string | `"20Gi"` | |
| podAnnotations | object | `{}` | Annotations to attach metadata to the Pod. |
| podSecurityContext | object | `{}` | Security settings for the Pod. |
| redis.enabled | bool | `false` | |
| replicas | int | `1` | Number of replicas for each scalable service. Has no effect when `autoscaling.enabled` is set to `true`. |
| resources | object | `{}` | Resources to apply to all services. |
| securityContext | object | `{"readOnlyRootFilesystem":false}` | Security settings for the Container. |
| securityContext.readOnlyRootFilesystem | bool | `false` | Mounts the container's root filesystem as read-only. Currently only `false` is supported by ownCloud 10. |
| service.port | int | `8080` | |
| service.type | string | `"LoadBalancer"` | |
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account. |
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created or not. |
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and `create` is set to `true`, a name is generated using the fullname template. |
| tolerations | list | `[]` | Tolerations are applied to pods and allow the scheduler to schedule pods with matching taints. One or more taints need to be applied to a node to instruct this node to not accept any pods that do not tolerate the taints. |

## Examples

### Configure OpenID Connect

To configure OpenID Connect the configExtra object can be used.

```YAML
configExtra:
openid-connect:
auto-provision:
enabled: true
email-claim: "email"
display-name-claim: "given_name"
picture-claim: "picture"
provider-url: "https://example.com"
client-id: "myclientid"
client-secret: "mysecret"
autoRedirectOnLoginPage: false
mode: "email"
scopes: []
use-access-token-payload-for-user-info: false
```
12 changes: 12 additions & 0 deletions charts/owncloud/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,15 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
ownCloud image logic
*/}}
{{- define "owncloud.image" -}}
{{- $tag := default .Chart.AppVersion .Values.image.tag -}}
{{- if $.Values.image.sha -}}
"{{ $.Values.image.repository }}:{{ $tag }}@sha256:{{ $.Values.image.sha }}"
{{- else -}}
"{{ $.Values.image.repository }}:{{ $tag }}"
{{- end -}}
{{- end -}}
4 changes: 2 additions & 2 deletions charts/owncloud/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
ignore-check.kube-linter.io/no-read-only-root-fs : "ownCloud need to write /etc/environment on startup"
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
replicas: {{ .Values.replicas }}
{{- end }}
selector:
matchLabels:
Expand Down Expand Up @@ -45,7 +45,7 @@ spec:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: {{ template "owncloud.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: OWNCLOUD_DOMAIN
Expand Down
Loading

0 comments on commit ee98ed4

Please sign in to comment.