initial commit
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Robert Kaussow 2023-03-08 12:54:34 +01:00
commit 214cce1cc9
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
6 changed files with 221 additions and 0 deletions

64
.drone.yml Normal file
View File

@ -0,0 +1,64 @@
---
kind: pipeline
name: build
platform:
os: linux
arch: amd64
steps:
- name: generate
image: thegeeklab/alpine-tools
commands:
- curl -SsfL -o /usr/local/bin/openapi2jsonschema "https://raw.githubusercontent.com/yannh/kubeconform/master/scripts/openapi2jsonschema.py"
- chmod +x /usr/local/bin/openapi2jsonschema
- make
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
---
kind: pipeline
name: notifications
platform:
os: linux
arch: amd64
steps:
- name: matrix
image: thegeeklab/drone-matrix
settings:
homeserver:
from_secret: matrix_homeserver
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
template: "Status: **{{ .Build.Status }}**<br/> Build: [{{ .Repo.Owner }}/{{ .Repo.Name }}]({{ .Build.Link }}){{ if .Build.Branch }} ({{ .Build.Branch }}){{ end }} by {{ .Commit.Author }}<br/> Message: {{ .Commit.Message.Title }}"
username:
from_secret: matrix_username
when:
status:
- success
- failure
trigger:
ref:
- refs/heads/main
- refs/tags/**
status:
- success
- failure
depends_on:
- build
---
kind: signature
hmac: a72cd768ef5389dc4d62333cf26ec47c9a7b14a3d244fa76c15ca73887cd1296
...

1
.gitignore vendored Executable file
View File

@ -0,0 +1 @@
/dist

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Robert Kaussow <mail@thegeeklab.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

27
Makefile Normal file
View File

@ -0,0 +1,27 @@
CWD ?= $(shell pwd)
.EXPORT_ALL_VARIABLES:
DIST := $(CWD)/dist
TMP_CRD_DIR := $(HOME)/.crds-catalog
DIST_DIRS := $(DIST) $(TMP_CRD_DIR)
# renovate: datasource=github-releases depName=projectcalico/calico
CALICO_VERSION := v3.25.0
# renovate: datasource=github-releases depName=fluxcd/flux2
FLUXCD_VERSION := v0.40.0
# renovate: datasource=github-releases depName=cert-manager/cert-manager
CERTMANAGER_VERSION := v1.11.0
# renovate: datasource=github-releases depName=cloudnative-pg/cloudnative-pg
CNPG_VERSION := v1.19.0
.PHONY: all
all: clean generate
.PHONY: clean
clean:
@rm -rf $(DIST_DIRS)
.PHONY: generate
generate:
@mkdir -p $(DIST)
@./generate.sh

20
README.md Normal file
View File

@ -0,0 +1,20 @@
# crds-catalog
[![Build Status](https://img.shields.io/drone/build/infra/crds-catalog?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/infra/crds-catalog)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](LICENSE)
This repository to aggregatepopular Kubernetes CRDs (CustomResourceDefinition) in JSON schema format. These schemas can be used by various tools such as Datree, Kubeconform and Kubeval to perform validation on custom (and native) Kuberentes resources. Running Kubernetes schema validation checks helps apply the "shift-left approach" on machines without giving them access to your cluster (e.g. locally or on CI).
The project is inspired by [Datree's CRDs-catalog](https://github.com/datreeio/CRDs-catalog) and was created to manage CRDs required for my own Kubernetes deployments.
## Usage
### Kubeconform
```Shell
kubeconform -schema-location default -schema-location 'https://gitea.rknet.org/infra/crds-catalog/raw/branch/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' [MANIFEST]
```
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/ansible/galaxy/blob/main/LICENSE) file for details.

88
generate.sh Executable file
View File

@ -0,0 +1,88 @@
#!/usr/bin/env bash
set -eo pipefail
shopt -s globstar
default_openapi_handler() {
printf "Processing %s ...\n" $API
mkdir -p "${WORKDIR}"
curl -SsfL -o "${WORKDIR}/${NAME}.crds.yaml" "${SOURCE}"
(
cd "$WORKDIR"
openapi2jsonschema "${NAME}.crds.yaml" >/dev/null
)
TARGET_DIR="$DIST/$API"
mkdir -p "$TARGET_DIR"
for FILE in "${WORKDIR}"/*.json; do
FILENAME=$(basename "$FILE")
mv "$FILE" "$TARGET_DIR/$FILENAME"
done
}
## Calico
API=projectcalico.org
WORKDIR="${TMP_CRD_DIR}/calico"
SOURCE=" "
printf "Processing %s ...\n" $API
mkdir -p "${WORKDIR}"
curl -SsfL -o "${WORKDIR}/calico.crds.yaml" "${SOURCE}"
(
cd "$WORKDIR"
openapi2jsonschema "calico.crds.yaml" >/dev/null
)
TARGET_DIR="$DIST/$API"
mkdir -p "$TARGET_DIR"
for FILE in "${WORKDIR}"/*.json; do
FILENAME=$(basename "$FILE")
mv "$FILE" "$TARGET_DIR/${FILENAME//_v1/_v3}"
done
## Flux2
API=toolkit.fluxcd.io
WORKDIR="${TMP_CRD_DIR}/flux"
SOURCE="https://github.com/fluxcd/flux2/releases/download/${FLUXCD_VERSION}/crd-schemas.tar.gz"
printf "Processing %s ...\n" $API
mkdir -p "${WORKDIR}"
curl -SsfL "${SOURCE}" | tar xz -C "${WORKDIR}"
for FILE in "${WORKDIR}"/*.json; do
FILENAME=$(basename "$FILE")
PREFIX="${FILENAME%%\-*}"
MIDDLE="${FILENAME#*-}"
SUFFIX="${MIDDLE#*-}"
MIDDLE="${MIDDLE%%\-*}"
TARGET_DIR="$DIST/$MIDDLE.$API"
TARGET_NAME="$TARGET_DIR/$PREFIX""_""$SUFFIX"
mkdir -p "$TARGET_DIR"
mv "$FILE" "$TARGET_NAME"
done
## Cloudnative-PG
API=postgresql.cnpg.io
NAME=cnpg
WORKDIR="${TMP_CRD_DIR}/$NAME"
SOURCE="https://github.com/cloudnative-pg/cloudnative-pg/releases/download/${CNPG_VERSION}/cnpg-${CNPG_VERSION##v}.yaml"
default_openapi_handler
## Cert-Manager
API=cert-manager.io
NAME=cert-manager
WORKDIR="${TMP_CRD_DIR}/$NAME"
SOURCE="https://github.com/cert-manager/cert-manager/releases/download/${CERTMANAGER_VERSION}/cert-manager.crds.yaml"
default_openapi_handler
## Minio
API=minio.min.io
NAME=minio
WORKDIR="${TMP_CRD_DIR}/$NAME"
SOURCE="https://raw.githubusercontent.com/minio/operator/v4.5.8/resources/base/crds/minio.min.io_tenants.yaml"
default_openapi_handler