diff --git a/.bingo/.gitignore b/.bingo/.gitignore new file mode 100755 index 00000000..4f2055b6 --- /dev/null +++ b/.bingo/.gitignore @@ -0,0 +1,12 @@ + +# Ignore everything +* + +# But not these files: +!.gitignore +!*.mod +!README.md +!Variables.mk +!variables.env + +*tmp.mod diff --git a/.bingo/README.md b/.bingo/README.md new file mode 100755 index 00000000..70f92860 --- /dev/null +++ b/.bingo/README.md @@ -0,0 +1,13 @@ +# Project Development Dependencies. + +This is directory which stores Go modules with pinned buildable package that is used within this repository, managed by https://github.com/bwplotka/bingo. + +* Run `bingo get` to install all tools having each own module file in this directory. +* Run `bingo get ` to install that have own module file in this directory. +* For Makefile: Make sure to put `include .bingo/Variables.mk` in your Makefile, then use $() variable where is the .bingo/.mod. +* For shell: Run `source .bingo/variables.env` to source all environment variable for each tool +* See https://github.com/bwplotka/bingo or -h on how to add, remove or change binaries dependencies. + +## Requirements + +* Go 1.14+ diff --git a/.bingo/Variables.mk b/.bingo/Variables.mk new file mode 100644 index 00000000..089bf337 --- /dev/null +++ b/.bingo/Variables.mk @@ -0,0 +1,42 @@ +# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.2.3. DO NOT EDIT. +# All tools are designed to be build inside $GOBIN. +GOPATH ?= $(shell go env GOPATH) +GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin +GO ?= $(shell which go) + +# Bellow generated variables ensure that every time a tool under each variable is invoked, the correct version +# will be used; reinstalling only if needed. +# For example for gojsontoyaml variable: +# +# In your main Makefile (for non array binaries): +# +#include .bingo/Variables.mk # Assuming -dir was set to .bingo . +# +#command: $(GOJSONTOYAML) +# @echo "Running gojsontoyaml" +# @$(GOJSONTOYAML) +# +GOJSONTOYAML := $(GOBIN)/gojsontoyaml-v0.0.0-20200602132005-3697ded27e8c +$(GOJSONTOYAML): .bingo/gojsontoyaml.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)/gojsontoyaml-v0.0.0-20200602132005-3697ded27e8c" + @cd .bingo && $(GO) build -mod=mod -modfile=gojsontoyaml.mod -o=$(GOBIN)/gojsontoyaml-v0.0.0-20200602132005-3697ded27e8c "github.com/brancz/gojsontoyaml" + +JB := $(GOBIN)/jb-v0.4.0 +$(JB): .bingo/jb.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)/jb-v0.4.0" + @cd .bingo && $(GO) build -mod=mod -modfile=jb.mod -o=$(GOBIN)/jb-v0.4.0 "github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb" + +JSONNET := $(GOBIN)/jsonnet-v0.16.0 +$(JSONNET): .bingo/jsonnet.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)/jsonnet-v0.16.0" + @cd .bingo && $(GO) build -mod=mod -modfile=jsonnet.mod -o=$(GOBIN)/jsonnet-v0.16.0 "github.com/google/go-jsonnet/cmd/jsonnet" + +JSONNETFMT := $(GOBIN)/jsonnetfmt-v0.16.0 +$(JSONNETFMT): .bingo/jsonnetfmt.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)/jsonnetfmt-v0.16.0" + @cd .bingo && $(GO) build -mod=mod -modfile=jsonnetfmt.mod -o=$(GOBIN)/jsonnetfmt-v0.16.0 "github.com/google/go-jsonnet/cmd/jsonnetfmt" + diff --git a/.bingo/go.mod b/.bingo/go.mod new file mode 100755 index 00000000..610249af --- /dev/null +++ b/.bingo/go.mod @@ -0,0 +1 @@ +module _ // Fake go.mod auto-created by 'bingo' for go -moddir compatibility with non-Go projects. Commit this file, together with other .mod files. \ No newline at end of file diff --git a/.bingo/gojsontoyaml.mod b/.bingo/gojsontoyaml.mod new file mode 100644 index 00000000..658d4964 --- /dev/null +++ b/.bingo/gojsontoyaml.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/brancz/gojsontoyaml v0.0.0-20200602132005-3697ded27e8c diff --git a/.bingo/jb.mod b/.bingo/jb.mod new file mode 100644 index 00000000..bbd0f55b --- /dev/null +++ b/.bingo/jb.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/jsonnet-bundler/jsonnet-bundler v0.4.0 // cmd/jb diff --git a/.bingo/jsonnet.mod b/.bingo/jsonnet.mod new file mode 100644 index 00000000..95399072 --- /dev/null +++ b/.bingo/jsonnet.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/google/go-jsonnet v0.16.0 // cmd/jsonnet diff --git a/.bingo/jsonnetfmt.mod b/.bingo/jsonnetfmt.mod new file mode 100644 index 00000000..a35e9851 --- /dev/null +++ b/.bingo/jsonnetfmt.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.15 + +require github.com/google/go-jsonnet v0.16.0 // cmd/jsonnetfmt diff --git a/.bingo/variables.env b/.bingo/variables.env new file mode 100644 index 00000000..29f233b5 --- /dev/null +++ b/.bingo/variables.env @@ -0,0 +1,18 @@ +# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.2.3. DO NOT EDIT. +# All tools are designed to be build inside $GOBIN. +# Those variables will work only until 'bingo get' was invoked, or if tools were installed via Makefile's Variables.mk. +GOBIN=${GOBIN:=$(go env GOBIN)} + +if [ -z "$GOBIN" ]; then + GOBIN="$(go env GOPATH)/bin" +fi + + +GOJSONTOYAML="$GOBIN/gojsontoyaml-v0.0.0-20200602132005-3697ded27e8c" + +JB="$GOBIN/jb-v0.4.0" + +JSONNET="$GOBIN/jsonnet-v0.16.0" + +JSONNETFMT="$GOBIN/jsonnetfmt-v0.16.0" + diff --git a/Makefile b/Makefile index eccd7c70..203ef995 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ SHELL=/usr/bin/env bash -o pipefail +include .bingo/Variables.mk VERSION := $(strip $(shell [ -d .git ] && git describe --always --tags --dirty)) BUILD_DATE := $(shell date -u +"%Y-%m-%d") @@ -8,9 +9,7 @@ VCS_REF := $(strip $(shell [ -d .git ] && git rev-parse --short HEAD)) DOCKER_REPO ?= quay.io/observatorium/observatorium-operator BIN_DIR ?= $(shell pwd)/tmp/bin - CONTROLLER_GEN ?= $(BIN_DIR)/controller-gen -JB ?= $(BIN_DIR)/jb # Generate manifests e.g. CRD, RBAC etc. manifests: example/manifests/observatorium.yaml manifests/crds/core.observatorium.io_observatoria.yaml @@ -19,7 +18,7 @@ manifests/crds/core.observatorium.io_observatoria.yaml: $(CONTROLLER_GEN) $(find $(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=manifests/crds example/manifests/observatorium.yaml: example/main.jsonnet - jsonnet -J jsonnet/vendor example/main.jsonnet | gojsontoyaml > example/manifests/observatorium.yaml + $(JSONNET) -J jsonnet/vendor example/main.jsonnet | $(GOJSONTOYAML) > example/manifests/observatorium.yaml # Run go fmt against code fmt: @@ -65,8 +64,9 @@ $(BIN_DIR): $(CONTROLLER_GEN): $(BIN_DIR) GO111MODULE="on" go build -o $@ sigs.k8s.io/controller-tools/cmd/controller-gen -$(JB): $(BIN_DIR) - go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb - GO111MODULE="on" go build -o $@ github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb - JSONNET_SRC = $(shell find . -type f -not -path './*vendor/*' \( -name '*.libsonnet' -o -name '*.jsonnet' \)) +JSONNETFMT_CMD := $(JSONNETFMT) -n 2 --max-blank-lines 2 --string-style s --comment-style s + +.PHONY: jsonnet-fmt +jsonnet-fmt: | $(JSONNETFMT) + PATH=$$PATH:$(BIN_DIR):$(FIRST_GOPATH)/bin echo ${JSONNET_SRC} | xargs -n 1 -- $(JSONNETFMT_CMD) -i diff --git a/tools.go b/tools.go index 4d7ae310..f935e9c0 100644 --- a/tools.go +++ b/tools.go @@ -3,8 +3,7 @@ package main import ( - _ "sigs.k8s.io/controller-tools/cmd/controller-gen" _ "github.com/brancz/locutus" - _ "github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb" _ "github.com/observatorium/observatorium/test/tls" + _ "sigs.k8s.io/controller-tools/cmd/controller-gen" )