Skip to content

Commit

Permalink
Add openapi spec to test-adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswuerbach committed Sep 27, 2020
1 parent 1127a32 commit edd77be
Show file tree
Hide file tree
Showing 3 changed files with 13,855 additions and 3 deletions.
24 changes: 21 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ TEMP_DIR:=$(shell mktemp -d)
ARCH?=amd64
OUT_DIR?=./_output

OPENAPI_PATH=$(GOPATH)/src/k8s.io/kube-openapi

VERSION?=latest

ifeq ($(PLATFORM),Linux)
SED_REPLACE :=
else
SED_REPLACE := ''
endif

.PHONY: all build-test-adapter test verify-gofmt gofmt verify test-adapter-container

all: build-test-adapter
build-test-adapter: vendor
CGO_ENABLED=0 GOARCH=$(ARCH) go build -o $(OUT_DIR)/$(ARCH)/test-adapter github.com/kubernetes-incubator/custom-metrics-apiserver/test-adapter
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -o $(OUT_DIR)/$(ARCH)/test-adapter github.com/kubernetes-incubator/custom-metrics-apiserver/test-adapter

vendor: tidy
go mod vendor
Expand All @@ -32,7 +40,17 @@ verify: verify-gofmt test
test-adapter-container: build-test-adapter
cp test-adapter-deploy/Dockerfile $(TEMP_DIR)
cp $(OUT_DIR)/$(ARCH)/test-adapter $(TEMP_DIR)/adapter
cd $(TEMP_DIR) && sed -i "s|BASEIMAGE|scratch|g" Dockerfile
sed -i 's|REGISTRY|'${REGISTRY}'|g' test-adapter-deploy/testing-adapter.yaml
cd $(TEMP_DIR) && sed -i $(SED_REPLACE) "s|BASEIMAGE|scratch|g" Dockerfile
sed -i $(SED_REPLACE) 's|REGISTRY|'${REGISTRY}'|g' test-adapter-deploy/testing-adapter.yaml
docker build -t $(REGISTRY)/$(IMAGE)-$(ARCH):$(VERSION) $(TEMP_DIR)
rm -rf $(TEMP_DIR)

test-kind:
kind load docker-image $(REGISTRY)/$(IMAGE)-$(ARCH):$(VERSION)
kubectl apply -f test-adapter-deploy/testing-adapter.yaml
kubectl rollout restart -n custom-metrics deployment/custom-metrics-apiserver

test-adapter/generated/openapi/zz_generated.openapi.go:
GO111MODULE=off go get -d k8s.io/kube-openapi || true
rm -rf test-adapter/generated/openapi
cd $(OPENAPI_PATH) && go run ./cmd/openapi-gen/openapi-gen.go --logtostderr -i k8s.io/metrics/pkg/apis/custom_metrics,k8s.io/metrics/pkg/apis/custom_metrics/v1beta1,k8s.io/metrics/pkg/apis/custom_metrics/v1beta2,k8s.io/metrics/pkg/apis/external_metrics,k8s.io/metrics/pkg/apis/external_metrics/v1beta1,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/api/resource,k8s.io/apimachinery/pkg/version,k8s.io/api/core/v1 -p github.com/kubernetes-incubator/custom-metrics-apiserver/test-adapter/generated/openapi -O zz_generated.openapi -r /dev/null
Loading

0 comments on commit edd77be

Please sign in to comment.