chore(repo): add pre-commit (#1345)

* chore(repo): add pre-commit

Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com>

* feat(helm): add schema

Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com>

---------

Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com>
This commit is contained in:
Oliver Bähler
2025-02-05 11:23:20 +01:00
committed by GitHub
parent c22044016a
commit e6e35fff2f
4 changed files with 869 additions and 4 deletions

52
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,52 @@
repos:
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.20.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ['@commitlint/config-conventional', 'commitlint-plugin-function-rules']
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-executables-have-shebangs
- id: check-yaml
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: run-helm-docs
name: Execute helm-docs
entry: make helm-docs
language: system
files: ^charts/
- id: run-helm-schema
name: Execute helm-schema
entry: make helm-schema
language: system
files: ^charts/
- id: run-helm-lint
name: Execute helm-lint
entry: make helm-lint
language: system
files: ^charts/
- id: golangci-lint
name: Execute golangci-lint
entry: make golint
language: system
files: \.go$
- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
- id: go-vet
- id: go-vet-mod
- id: go-vet-pkg
- id: go-vet-repo-mod
- id: go-vet-repo-pkg
- id: go-revive
- id: go-revive-mod
- id: go-revive-repo-mod
- id: go-sec-mod
- id: go-sec-pkg
- id: go-sec-repo-mod
- id: go-sec-repo-pkg

View File

@@ -17,6 +17,10 @@ IMG_BASE ?= $(REPOSITORY)
IMG ?= $(IMG_BASE):$(VERSION)
CAPSULE_IMG ?= $(REGISTRY)/$(IMG_BASE)
## Tool Binaries
KUBECTL ?= kubectl
HELM ?= helm
# Options for 'bundle-build'
ifneq ($(origin CHANNELS), undefined)
BUNDLE_CHANNELS := --channels=$(CHANNELS)
@@ -70,6 +74,9 @@ helm-docs: docker
helm-lint: docker
@docker run -v "$(SRC_ROOT):/workdir" --entrypoint /bin/sh quay.io/helmpack/chart-testing:$(CT_VERSION) -c "cd /workdir; ct lint --config .github/configs/ct.yaml --lint-conf .github/configs/lintconf.yaml --all --debug"
helm-schema: helm-plugin-schema
cd charts/capsule && $(HELM) schema
helm-test: kind ct ko-build-all
@$(KIND) create cluster --wait=60s --name capsule-charts --image kindest/node:$${KIND_K8S_VERSION:-v1.27.0}
@make helm-test-exec
@@ -89,7 +96,7 @@ docker:
}
# Setup development env
# Usage:
# Usage:
# LAPTOP_HOST_IP=<YOUR_LAPTOP_IP> make dev-setup
# For example:
# LAPTOP_HOST_IP=192.168.10.101 make dev-setup
@@ -123,7 +130,7 @@ dev-setup:
kubectl create secret tls capsule-tls -n capsule-system \
--cert=/tmp/k8s-webhook-server/serving-certs/tls.crt\
--key=/tmp/k8s-webhook-server/serving-certs/tls.key || true
rm -f _tls.cnf
rm -f _tls.cnf
export WEBHOOK_URL="https://$${LAPTOP_HOST_IP}:9443"; \
export CA_BUNDLE=`openssl base64 -in /tmp/k8s-webhook-server/serving-certs/tls.crt | tr -d '\n'`; \
helm upgrade \
@@ -189,6 +196,15 @@ ko-publish-capsule: ko-login ## Build and publish kyvernopre image (with ko)
.PHONY: ko-publish-all
ko-publish-all: ko-publish-capsule
####################
# -- Helm Plugins
####################
HELM_SCHEMA_VERSION := ""
helm-plugin-schema:
$(HELM) plugin install https://github.com/losisin/helm-values-schema-json.git --version $(HELM_SCHEMA_VERSION) || true
####################
# -- Binaries
####################
@@ -273,7 +289,7 @@ golint: golangci-lint
.PHONY: e2e
e2e: ginkgo
$(MAKE) e2e-build && $(MAKE) e2e-exec && $(MAKE) e2e-destroy
e2e-build: kind
$(KIND) create cluster --wait=60s --name capsule --image kindest/node:$${KIND_K8S_VERSION:-v1.27.0}
$(MAKE) e2e-install
@@ -309,4 +325,3 @@ e2e-destroy: kind
SPELL_CHECKER = npx spellchecker-cli
docs-lint:
cd docs/content && $(SPELL_CHECKER) -f "*.md" "*/*.md" "!general/crds-apis.md" -d dictionary.txt

View File

@@ -0,0 +1,4 @@
input:
- values.yaml
- ci/test-values.yaml
- ci/proxy-values.yaml

View File

@@ -0,0 +1,794 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"affinity": {
"properties": {},
"type": "object"
},
"certManager": {
"properties": {
"additionalSANS": {
"type": "array"
},
"generateCertificates": {
"type": "boolean"
}
},
"type": "object"
},
"crds": {
"properties": {
"annnotations": {
"properties": {},
"type": "object"
},
"exclusive": {
"type": "boolean"
},
"install": {
"type": "boolean"
},
"labels": {
"properties": {},
"type": "object"
}
},
"type": "object"
},
"customAnnotations": {
"properties": {},
"type": "object"
},
"customLabels": {
"properties": {},
"type": "object"
},
"fullnameOverride": {
"type": "string"
},
"global": {
"properties": {
"jobs": {
"properties": {
"kubectl": {
"properties": {
"affinity": {
"properties": {},
"type": "object"
},
"annotations": {
"properties": {},
"type": "object"
},
"backoffLimit": {
"type": "integer"
},
"image": {
"properties": {
"pullPolicy": {
"type": "string"
},
"registry": {
"type": "string"
},
"repository": {
"type": "string"
},
"tag": {
"type": "string"
}
},
"type": "object"
},
"imagePullSecrets": {
"type": "array"
},
"nodeSelector": {
"properties": {},
"type": "object"
},
"podSecurityContext": {
"properties": {
"seccompProfile": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"priorityClassName": {
"type": "string"
},
"resources": {
"properties": {},
"type": "object"
},
"restartPolicy": {
"type": "string"
},
"securityContext": {
"properties": {
"allowPrivilegeEscalation": {
"type": "boolean"
},
"capabilities": {
"properties": {
"drop": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"readOnlyRootFilesystem": {
"type": "boolean"
},
"runAsGroup": {
"type": "integer"
},
"runAsNonRoot": {
"type": "boolean"
},
"runAsUser": {
"type": "integer"
}
},
"type": "object"
},
"tolerations": {
"type": "array"
},
"topologySpreadConstraints": {
"type": "array"
},
"ttlSecondsAfterFinished": {
"type": "integer"
}
},
"type": "object"
}
},
"type": "object"
}
},
"type": "object"
},
"imagePullSecrets": {
"type": "array"
},
"jobs": {
"properties": {},
"type": "object"
},
"manager": {
"properties": {
"hostNetwork": {
"type": "boolean"
},
"image": {
"properties": {
"pullPolicy": {
"type": "string"
},
"registry": {
"type": "string"
},
"repository": {
"type": "string"
},
"tag": {
"type": "string"
}
},
"type": "object"
},
"kind": {
"type": "string"
},
"livenessProbe": {
"properties": {
"httpGet": {
"properties": {
"path": {
"type": "string"
},
"port": {
"type": "integer"
}
},
"type": "object"
}
},
"type": "object"
},
"options": {
"properties": {
"capsuleConfiguration": {
"type": "string"
},
"capsuleUserGroups": {
"items": {
"type": "string"
},
"type": "array"
},
"forceTenantPrefix": {
"type": "boolean"
},
"generateCertificates": {
"type": "boolean"
},
"logLevel": {
"type": "string"
},
"nodeMetadata": {
"properties": {
"forbiddenAnnotations": {
"properties": {
"denied": {
"type": "array"
},
"deniedRegex": {
"type": "string"
}
},
"type": "object"
},
"forbiddenLabels": {
"properties": {
"denied": {
"type": "array"
},
"deniedRegex": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"protectedNamespaceRegex": {
"type": "string"
}
},
"type": "object"
},
"rbac": {
"properties": {
"create": {
"type": "boolean"
},
"existingClusterRoles": {
"items": {
"type": "string"
},
"type": "array"
},
"existingRoles": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"readinessProbe": {
"properties": {
"httpGet": {
"properties": {
"path": {
"type": "string"
},
"port": {
"type": "integer"
}
},
"type": "object"
}
},
"type": "object"
},
"resources": {
"properties": {
"requests": {
"properties": {
"cpu": {
"type": "string"
},
"memory": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"webhookPort": {
"type": "integer"
}
},
"type": "object"
},
"nodeSelector": {
"properties": {},
"type": "object"
},
"podAnnotations": {
"properties": {},
"type": "object"
},
"podSecurityContext": {
"properties": {
"runAsGroup": {
"type": "integer"
},
"runAsNonRoot": {
"type": "boolean"
},
"runAsUser": {
"type": "integer"
},
"seccompProfile": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"priorityClassName": {
"type": "string"
},
"proxy": {
"properties": {
"enabled": {
"type": "boolean"
}
},
"type": "object"
},
"replicaCount": {
"type": "integer"
},
"securityContext": {
"properties": {
"allowPrivilegeEscalation": {
"type": "boolean"
},
"capabilities": {
"properties": {
"drop": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"readOnlyRootFilesystem": {
"type": "boolean"
}
},
"type": "object"
},
"serviceAccount": {
"properties": {
"annotations": {
"properties": {},
"type": "object"
},
"create": {
"type": "boolean"
},
"name": {
"type": "string"
}
},
"type": "object"
},
"serviceMonitor": {
"properties": {
"annotations": {
"properties": {},
"type": "object"
},
"enabled": {
"type": "boolean"
},
"endpoint": {
"properties": {
"interval": {
"type": "string"
},
"metricRelabelings": {
"type": "array"
},
"relabelings": {
"type": "array"
},
"scrapeTimeout": {
"type": "string"
}
},
"type": "object"
},
"labels": {
"properties": {},
"type": "object"
},
"matchLabels": {
"properties": {},
"type": "object"
},
"namespace": {
"type": "string"
},
"targetLabels": {
"type": "array"
}
},
"type": "object"
},
"tls": {
"properties": {
"create": {
"type": "boolean"
},
"enableController": {
"type": "boolean"
},
"name": {
"type": "string"
}
},
"type": "object"
},
"tolerations": {
"type": "array"
},
"topologySpreadConstraints": {
"type": "array"
},
"webhooks": {
"properties": {
"exclusive": {
"type": "boolean"
},
"hooks": {
"properties": {
"cordoning": {
"properties": {
"failurePolicy": {
"type": "string"
},
"namespaceSelector": {
"properties": {
"matchExpressions": {
"items": {
"properties": {
"key": {
"type": "string"
},
"operator": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
},
"defaults": {
"properties": {
"ingress": {
"properties": {
"failurePolicy": {
"type": "string"
},
"namespaceSelector": {
"properties": {
"matchExpressions": {
"items": {
"properties": {
"key": {
"type": "string"
},
"operator": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
},
"pods": {
"properties": {
"failurePolicy": {
"type": "string"
},
"namespaceSelector": {
"properties": {
"matchExpressions": {
"items": {
"properties": {
"key": {
"type": "string"
},
"operator": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
},
"pvc": {
"properties": {
"failurePolicy": {
"type": "string"
},
"namespaceSelector": {
"properties": {
"matchExpressions": {
"items": {
"properties": {
"key": {
"type": "string"
},
"operator": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
}
},
"type": "object"
},
"ingresses": {
"properties": {
"failurePolicy": {
"type": "string"
},
"namespaceSelector": {
"properties": {
"matchExpressions": {
"items": {
"properties": {
"key": {
"type": "string"
},
"operator": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
},
"namespaceOwnerReference": {
"properties": {
"failurePolicy": {
"type": "string"
}
},
"type": "object"
},
"namespaces": {
"properties": {
"failurePolicy": {
"type": "string"
}
},
"type": "object"
},
"networkpolicies": {
"properties": {
"failurePolicy": {
"type": "string"
},
"namespaceSelector": {
"properties": {
"matchExpressions": {
"items": {
"properties": {
"key": {
"type": "string"
},
"operator": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
},
"nodes": {
"properties": {
"failurePolicy": {
"type": "string"
}
},
"type": "object"
},
"persistentvolumeclaims": {
"properties": {
"failurePolicy": {
"type": "string"
},
"namespaceSelector": {
"properties": {
"matchExpressions": {
"items": {
"properties": {
"key": {
"type": "string"
},
"operator": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
},
"pods": {
"properties": {
"failurePolicy": {
"type": "string"
},
"namespaceSelector": {
"properties": {
"matchExpressions": {
"items": {
"properties": {
"key": {
"type": "string"
},
"operator": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
},
"services": {
"properties": {
"failurePolicy": {
"type": "string"
},
"namespaceSelector": {
"properties": {
"matchExpressions": {
"items": {
"properties": {
"key": {
"type": "string"
},
"operator": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
},
"tenantResourceObjects": {
"properties": {
"failurePolicy": {
"type": "string"
}
},
"type": "object"
},
"tenants": {
"properties": {
"failurePolicy": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"mutatingWebhooksTimeoutSeconds": {
"type": "integer"
},
"service": {
"properties": {
"caBundle": {
"type": "string"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"port": {
"type": "null"
},
"url": {
"type": "string"
}
},
"type": "object"
},
"validatingWebhooksTimeoutSeconds": {
"type": "integer"
}
},
"type": "object"
}
},
"type": "object"
}