Skip to content

Commit

Permalink
Replace kubeval by kubeconform
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime Brunet <[email protected]>
  • Loading branch information
maxbrunet committed Mar 7, 2021
1 parent b8ecba6 commit dbbb406
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ $(JSONNETFMT): .bingo/jsonnetfmt.mod
@echo "(re)installing $(GOBIN)/jsonnetfmt-v0.17.1-0.20210101181740-31d71aaccda6"
@cd .bingo && $(GO) build -mod=mod -modfile=jsonnetfmt.mod -o=$(GOBIN)/jsonnetfmt-v0.17.1-0.20210101181740-31d71aaccda6 "github.com/google/go-jsonnet/cmd/jsonnetfmt"

KUBEVAL := $(GOBIN)/kubeval-v0.0.0-20201005082916-38668c6c5b23
$(KUBEVAL): .bingo/kubeval.mod
KUBECONFORM := $(GOBIN)/kubeconform-v0.4.4
$(KUBECONFORM): .bingo/kubeconform.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/kubeval-v0.0.0-20201005082916-38668c6c5b23"
@cd .bingo && $(GO) build -mod=mod -modfile=kubeval.mod -o=$(GOBIN)/kubeval-v0.0.0-20201005082916-38668c6c5b23 "github.com/instrumenta/kubeval"
@echo "(re)installing $(GOBIN)/kubeconform-v0.4.4"
@cd .bingo && $(GO) build -mod=mod -modfile=kubeconform.mod -o=$(GOBIN)/kubeconform-v0.4.4 "github.com/yannh/kubeconform/cmd/kubeconform"

2 changes: 1 addition & 1 deletion .bingo/kubeval.mod → .bingo/kubeconform.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.15

require github.com/instrumenta/kubeval v0.0.0-20201005082916-38668c6c5b23
require github.com/yannh/kubeconform v0.4.4 // cmd/kubeconform
2 changes: 1 addition & 1 deletion .bingo/variables.env
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ JSONNET="$GOBIN/jsonnet-v0.17.1-0.20210101181740-31d71aaccda6"

JSONNETFMT="$GOBIN/jsonnetfmt-v0.17.1-0.20210101181740-31d71aaccda6"

KUBEVAL="$GOBIN/kubeval-v0.0.0-20201005082916-38668c6c5b23"
KUBECONFORM="$GOBIN/kubeconform-v0.4.4"

19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ JSONNETFMT_CMD := $(JSONNETFMT) -n 2 --max-blank-lines 2 --string-style s --comm

EXAMPLES := examples
MANIFESTS := manifests
CRDSCHEMAS := .crdschemas
TMP := tmp

K8S_VERSION := 1.20.4
Expand Down Expand Up @@ -46,22 +47,22 @@ clean:
-rm -rf tmp/bin
rm -rf manifests/

${TMP}/openapi2jsonschema.py:
${TMP}/bin/openapi2jsonschema.py:
@$(PIP) show pyyaml >/dev/null
@mkdir -p $(TMP)
@curl -sSfo $@ https://raw.githubusercontent.com/yannh/kubeconform/v0.4.4/scripts/openapi2jsonschema.py
@chmod +x $@

.kubeval/v${K8S_VERSION}-standalone-strict: $(TMP)/openapi2jsonschema.py
@rm -rf .kubeval
${CRDSCHEMAS}: $(TMP)/bin/openapi2jsonschema.py
@rm -rf $@
@mkdir -p $@
@cd $@ && for crd in $(CRDS); do \
FILENAME_FORMAT='{kind}-{group}-{version}' ../../$(TMP)/openapi2jsonschema.py "$${crd}"; \
FILENAME_FORMAT='{kind}-{group}-{version}' $(CURDIR)/$(TMP)/bin/openapi2jsonschema.py "$${crd}"; \
done

.PHONY: validate
validate: $(KUBEVAL) $(MANIFESTS) $(EXAMPLES)/all/manifests
$(KUBEVAL) --force-color --strict --kubernetes-version $(K8S_VERSION) \
--schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master \
--additional-schema-locations "file://$(CURDIR)/.kubeval" \
$(MANIFESTS)/*.yaml $(EXAMPLES)/all/manifests/*.yaml
validate: $(KUBECONFORM) $(MANIFESTS) $(EXAMPLES)/all/manifests
$(KUBECONFORM) -strict -kubernetes-version $(K8S_VERSION) -output tap \
-schema-location 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master' \
-schema-location '$(CRDSCHEMAS)/{{ .ResourceKind }}{{ .KindSuffix }}.json' \
$(MANIFESTS) $(EXAMPLES)/all/manifests

0 comments on commit dbbb406

Please sign in to comment.