Skip to content

Commit

Permalink
[sophora-schema-docs] add support (#28)
Browse files Browse the repository at this point in the history
* added support for sophora-schema-docs

* changed ingress property

* fixed issue with indent value

* added test values

* added missing values from code review

* changed nameOverride for test values

* fixed formatting issues in test values

* added config map

* removed unnecessary comments

* removed configuration duplicate

* fixed typo

* changed extraEnv condition

* fixed issue with nindent causing test job failure

---------

Co-authored-by: Tom <[email protected]>
  • Loading branch information
dustin-wickert and tom-schoener authored Jul 4, 2023
1 parent 8fad46a commit 3f23b52
Show file tree
Hide file tree
Showing 11 changed files with 331 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/sophora-schema-docs/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions charts/sophora-schema-docs/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: sophora-schema-docs
description: A Helm chart for sophora schema docs

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 4.0.0

3 changes: 3 additions & 0 deletions charts/sophora-schema-docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Sophora Schema Docs

The Sophora Schema Docs module generates documentation of the document model of your Sophora repository.
64 changes: 64 additions & 0 deletions charts/sophora-schema-docs/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "sophora-schema-docs.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "sophora-schema-docs.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "sophora-schema-docs.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "sophora-schema-docs.labels" -}}
helm.sh/chart: {{ include "sophora-schema-docs.chart" . }}
{{ include "sophora-schema-docs.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "sophora-schema-docs.selectorLabels" -}}
app.kubernetes.io/name: {{ include "sophora-schema-docs.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Renders a value that contains template.
Usage:
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }}
*/}}
{{- define "common.tplvalues.render" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .context }}
{{- else }}
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}
8 changes: 8 additions & 0 deletions charts/sophora-schema-docs/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "sophora-schema-docs.fullname" . }}
labels:
{{- include "sophora-schema-docs.labels" . | nindent 4 }}
data:
application.yaml: |- {{ toYaml (required "A valid application.yml config is required" .Values.sophora.configuration) | nindent 4 }}
54 changes: 54 additions & 0 deletions charts/sophora-schema-docs/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "sophora-schema-docs.fullname" . }}
labels:
{{- include "sophora-schema-docs.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "sophora-schema-docs.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "sophora-schema-docs.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: schemadoc
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- mountPath: /app/config
name: config
ports:
- name: http
containerPort: 1837
protocol: TCP
env:
- name: JDK_JAVA_OPTIONS
value: {{ .Values.javaOptions }}
- name: SOPHORA_CLIENT_SERVERCONNECTION_USERNAME
valueFrom:
secretKeyRef:
key: {{ .Values.sophora.authentication.secret.usernameKey | quote }}
name: {{ required "A valid secret name must be provided in .Values.sophora.authentication.secret.name" .Values.sophora.authentication.secret.name | quote }}
- name: SOPHORA_CLIENT_SERVERCONNECTION_PASSWORD
valueFrom:
secretKeyRef:
key: {{ .Values.sophora.authentication.secret.passwordKey | quote }}
name: {{ required "A valid secret name must be provided in .Values.sophora.authentication.secret.name" .Values.sophora.authentication.secret.name | quote }}
{{- if .Values.schemadocs.extraEnv }}
{{- toYaml .Values.schemadocs.extraEnv | nindent 12 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ include "sophora-schema-docs.name" . }}
4 changes: 4 additions & 0 deletions charts/sophora-schema-docs/templates/extra-list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{- range .Values.extraDeploy }}
---
{{ include "common.tplvalues.render" (dict "value" . "context" $) }}
{{- end }}
41 changes: 41 additions & 0 deletions charts/sophora-schema-docs/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "sophora-schema-docs.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "sophora-schema-docs.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
- path: {{ .path }}
pathType: {{ default "ImplementationSpecific" .pathType }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- end }}
{{- end }}
19 changes: 19 additions & 0 deletions charts/sophora-schema-docs/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "sophora-schema-docs.fullname" . }}
labels:
{{- include "sophora-schema-docs.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "sophora-schema-docs.selectorLabels" . | nindent 4 }}
41 changes: 41 additions & 0 deletions charts/sophora-schema-docs/test-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
nameOverride: schemadoc

image:
repository: docker.subshell.com/sophora/schemadoc
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"

imagePullSecrets:
- name: docker-subshell

sophora:
authentication:
secret:
name: "sophora-secret"

configuration:
sophora:
client:
server-connection:
urls:
- 'http://sophora-server.example.com:1196'
username: # in secret
password: # in secret

schemadocs:
extraEnv:
- name: AAA
value: a-value
- name: BBB
value: b-value


podAnnotations: {}

ingress:
enabled: true
ingressClassName: nginx
annotations: {}
hosts:
tls: []
50 changes: 50 additions & 0 deletions charts/sophora-schema-docs/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Settings for the Sophora server connection.

image:
repository: docker.subshell.com/sophora/schemadoc
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

javaOptions: "-XX:InitialRAMPercentage=50.0 -XX:MaxRAMPercentage=80.0 -XX:+ExitOnOutOfMemoryError -XX:+PerfDisableSharedMem"

sophora:

authentication:
secret:
name: ""
passwordKey: "password"
usernameKey: "username"

# Represents the application.yml of sophora schema docs:
configuration:
sophora:
client:
server-connection:
urls: []
username: # in secret
password: # in secret

schemadocs:
extraEnv:

service:
type: ClusterIP
port: 8080
annotations: {}

ingress:
enabled: false
ingressClassName: nginx
annotations: {}
hosts:
tls: []

extraDeploy: []

podAnnotations: {}

0 comments on commit 3f23b52

Please sign in to comment.