mirror of
https://github.com/gravitational/teleport.git
synced 2026-11-02 14:59:53 +08:00
* Move operator into `integrations/` * fixup! Move operator into `integrations/` * fixup! fixup! Move operator into `integrations/` * fixup! fixup! fixup! Move operator into `integrations/` * fixup! fixup! fixup! fixup! Move operator into `integrations/`
43 lines
1.8 KiB
Makefile
43 lines
1.8 KiB
Makefile
build:
|
|
go build -o protoc-gen-crd
|
|
|
|
.PHONY: test
|
|
test: build
|
|
# The wrappers.proto file needed for this generator exist only inside the go mod cache,
|
|
# so we retrieve the file path for the cached proto files with go mod tools.
|
|
$(eval PROTOBUF_MOD_PATH := $(shell go mod download --json github.com/gogo/protobuf | awk -F: '/"Dir"/ { print $$2 }' | tr -d ' ",'))
|
|
$(eval CUSTOM_IMPORTS_TMP_DIR := $(shell mktemp -d))
|
|
mkdir -p $(CUSTOM_IMPORTS_TMP_DIR)/github.com/gravitational/teleport/api/types/wrappers
|
|
cp testdata/protofiles/wrappers.proto $(CUSTOM_IMPORTS_TMP_DIR)/github.com/gravitational/teleport/api/types/wrappers
|
|
$(eval CRD_OUT_PATH := $(shell mktemp -d))
|
|
protoc \
|
|
-I=testdata/protofiles \
|
|
-I=$(PROTOBUF_MOD_PATH) \
|
|
-I=$(CUSTOM_IMPORTS_TMP_DIR) \
|
|
--plugin=./protoc-gen-crd \
|
|
--crd_out=$(CRD_OUT_PATH) \
|
|
types.proto
|
|
diff testdata/golden/ $(CRD_OUT_PATH);\
|
|
EXIT_CODE=$$?;\
|
|
rm -rf $(CRD_OUT_PATH) $(CUSTOM_IMPORTS_TMP_DIR);\
|
|
exit $$EXIT_CODE
|
|
|
|
# Updates CRD snapshots used for `protoc-gen-crd` tests, they are stored in `testdata/golden`
|
|
.PHONY: update-snapshot
|
|
update-snapshot: build
|
|
$(eval PROTOBUF_MOD_PATH := $(shell go mod download --json github.com/gogo/protobuf | awk -F: '/"Dir"/ { print $$2 }' | tr -d ' ",'))
|
|
$(eval CUSTOM_IMPORTS_TMP_DIR := $(shell mktemp -d))
|
|
mkdir -p $(CUSTOM_IMPORTS_TMP_DIR)/github.com/gravitational/teleport/api/types/wrappers
|
|
cp testdata/protofiles/wrappers.proto $(CUSTOM_IMPORTS_TMP_DIR)/github.com/gravitational/teleport/api/types/wrappers
|
|
$(eval CRD_OUT_PATH := $(shell mktemp -d))
|
|
protoc \
|
|
-I=testdata/protofiles \
|
|
-I=$(PROTOBUF_MOD_PATH) \
|
|
-I=$(CUSTOM_IMPORTS_TMP_DIR) \
|
|
--plugin=./protoc-gen-crd \
|
|
--crd_out=$(CRD_OUT_PATH) \
|
|
types.proto
|
|
rm -rf testdata/golden
|
|
cp -r $(CRD_OUT_PATH) testdata/golden
|
|
rm -rf $(CRD_OUT_PATH)
|