Skip to content

Commit

Permalink
feat(#1): skeleton helm chart with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jumpy-Squirrel committed Oct 16, 2023
1 parent a6d8f5e commit ba3192f
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/helm-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Run Helm Unit-Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
run-helm-unit-tests:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout repository
run: 'git clone -b "$BRANCH_OR_TAG_NAME" --depth 1 "$FULL_REPO_URL" app'
shell: bash
env:
FULL_REPO_URL: "https://github.com/${{ github.repository }}"
BRANCH_OR_TAG_NAME: ${{ github.ref_name }}

- name: Docker build and push image
run: >
cd app &&
docker run --rm -v ${{ github.workspace }}/app:/apps helmunittest/helm-unittest:3.12.3-0.3.5 .
shell: bash
12 changes: 12 additions & 0 deletions .helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.git/
.gitignore

*.swp
*.tmp

.idea/
.vscode/

tests
*.tgz

6 changes: 6 additions & 0 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: eurofurence-regsys
version: 0.0.1
description: A helm chart that can deploy the Eurofurence Registration System.
type: application
home: https://github.com/eurofurence/reg-helm-chart
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# reg-helm-chart

<img src="https://github.com/eurofurence/reg-helm-chart/actions/workflows/helm-unit-tests.yml/badge.svg" alt="test status"/>

## Overview

A helm chart that can deploy the Eurofurence Registration System.

## Installation

To use, you just need helm in your path.

To run the unittests, use the [helm-unittest/helm-unittest](https://github.com/helm-unittest/helm-unittest) helm plugin or docker container.

If you have the plugin installed, `helm unittest .` runs all
unit tests on the command line.
36 changes: 36 additions & 0 deletions templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if (.Values.ingress).enable }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: regsys
{{- with .Values.global.namespace }}
namespace: '{{ . }}'
{{- end }}
annotations:
cert-manager.io/cluster-issuer: letsencrypt-live
nginx.ingress.kubernetes.io/proxy-body-size: 100m
nginx.ingress.kubernetes.io/limit-rps: "9"
nginx.ingress.kubernetes.io/limit-rpm: "360"
nginx.ingress.kubernetes.io/limit-burst-multiplier: "5"
nginx.ingress.kubernetes.io/limit-whitelist: "10.200.10.1/24,85.199.154.55/32,2001:1a50:a::/64,31.16.177.200/32"
labels:
name: ef-regsys
spec:
ingressClassName: nginx
rules:
- host: regsys.test.eurofurence.org
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: regsys
port:
number: 8080
tls:
- hosts:
- regsys.test.eurofurence.org
secretName: regsys-test-certificate
---
{{- end }}
37 changes: 37 additions & 0 deletions tests/ingress_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
suite: test ingress
templates:
- ingress.yaml
tests:
- it: should not create anything by default
asserts:
- hasDocuments:
count: 0
- it: should create an ingress if enabled
set:
ingress:
enable: true
asserts:
- isKind:
of: Ingress
- hasDocuments:
count: 1
- it: should not set namespace if unset
set:
ingress:
enable: true
asserts:
- notExists:
path: metadata.namespace
- equal:
path: spec.rules[0].host
value: regsys.test.eurofurence.org
- it: should set namespace if specified
set:
ingress:
enable: true
global:
namespace: hellospace
asserts:
- equal:
path: metadata.namespace
value: hellospace
28 changes: 28 additions & 0 deletions values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$id": "https://github.com/eurofurence/reg-helm-chart/values.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"title": "Values",
"description": "Definition of available values.yaml fields",
"type": "object",
"properties": {
"global": {
"type": "object",
"description": "global properties (can be set by ArgoCD)",
"properties": {

}
},
"ingress": {
"type": "object",
"description": "settings for an ingress (optional, off by default)",
"properties": {
"enable": {
"type": "boolean",
"description": "enable creating an ingress",
"default": false
}
}
}
}
}
6 changes: 6 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
global: {}
# set this to supply a namespace with all the resources.
# namespace: my-namespace

ingress:
enable: false

0 comments on commit ba3192f

Please sign in to comment.