From dc81458b3dbab8c98ef16111d679e1a31677df4f Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Mon, 10 Jun 2024 19:49:13 +0200 Subject: [PATCH] review fixes --- Makefile | 30 +++++++++++++++++++++++ hack/tools/boskosctl/Makefile | 45 ----------------------------------- hack/tools/boskosctl/main.go | 16 +++++++++---- hack/tools/openvpn/Makefile | 29 ---------------------- 4 files changed, 41 insertions(+), 79 deletions(-) delete mode 100644 hack/tools/boskosctl/Makefile delete mode 100644 hack/tools/openvpn/Makefile diff --git a/Makefile b/Makefile index 85142d29b1..2eb00f4911 100644 --- a/Makefile +++ b/Makefile @@ -233,6 +233,14 @@ VM_OPERATOR_ALL_ARCH = amd64 arm64 NET_OPERATOR_IMAGE_NAME ?= cluster-api-net-operator NET_OPERATOR_IMG ?= $(STAGING_REGISTRY)/$(NET_OPERATOR_IMAGE_NAME) +# boskosctl +BOSKOSCTL_IMG ?= gcr.io/k8s-staging-capi-vsphere/extra/boskosctl +BOSKOSCTL_IMG_TAG ?= $(shell git describe --always --dirty) + +# openvpn +OPENVPN_IMG ?= gcr.io/k8s-staging-capi-vsphere/extra/openvpn +OPENVPN_IMG_TAG ?= $(shell git describe --always --dirty) + # It is set by Prow GIT_TAG, a git-based tag of the form vYYYYMMDD-hash, e.g., v20210120-v0.3.10-308-gc61521971 TAG ?= dev @@ -563,6 +571,28 @@ docker-build-net-operator: docker-pull-prerequisites ## Build the docker image f $(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./$(NETOP_DIR)/config/default/manager_pull_policy.yaml"; \ fi +.PHONY: docker-build-boskosctl +docker-build-boskosctl: + cat hack/tools/boskosctl/Dockerfile | DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) . -t $(BOSKOSCTL_IMG):$(BOSKOSCTL_IMG_TAG) --file - + docker tag $(BOSKOSCTL_IMG):$(BOSKOSCTL_IMG_TAG) $(BOSKOSCTL_IMG):latest +.PHONY: build + +.PHONY: docker-push-boskosctl +docker-push-boskosctl: + docker push $(BOSKOSCTL_IMG):$(BOSKOSCTL_IMG_TAG) + docker push $(BOSKOSCTL_IMG):latest + +.PHONY: docker-build-openvpn +docker-build-openvpn: + cat hack/tools/openvpn/Dockerfile | DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) . -t $(OPENVPN_IMG):$(OPENVPN_IMG_TAG) --file - + docker tag $(OPENVPN_IMG):$(OPENVPN_IMG_TAG) $(OPENVPN_IMG):latest +.PHONY: build + +.PHONY: docker-push-openvpn +docker-push-openvpn: + docker push $(OPENVPN_IMG):$(OPENVPN_IMG_TAG) + docker push $(OPENVPN_IMG):latest + ## -------------------------------------- ## Testing ## -------------------------------------- diff --git a/hack/tools/boskosctl/Makefile b/hack/tools/boskosctl/Makefile deleted file mode 100644 index 37e447381c..0000000000 --- a/hack/tools/boskosctl/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2019 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Go. -# -GO_VERSION ?= 1.22.3 -GO_CONTAINER_IMAGE ?= docker.io/library/golang:$(GO_VERSION) - -# Use GOPROXY environment variable if set -GOPROXY := $(shell go env GOPROXY) -ifeq ($(GOPROXY),) -GOPROXY := https://proxy.golang.org -endif -export GOPROXY - -# Active module mode, as we use go modules to manage dependencies -export GO111MODULE=on - -all: build - -VERSION ?= $(shell git describe --always --dirty) -IMAGE_NAME ?= gcr.io/k8s-staging-capi-vsphere/extra/boskosctl -IMAGE_TAG ?= $(IMAGE_NAME):$(VERSION) - -build: - cd ../../../; DOCKER_BUILDKIT=1 docker build --build-arg builder_image=docker.io/library/golang:$(GO_VERSION) --build-arg goproxy=$(GOPROXY) . -t $(IMAGE_TAG) --file hack/tools/boskosctl/Dockerfile - docker tag $(IMAGE_TAG) $(IMAGE_NAME):latest -.PHONY: build - -push: - docker push $(IMAGE_TAG) - docker push $(IMAGE_NAME):latest -.PHONY: push diff --git a/hack/tools/boskosctl/main.go b/hack/tools/boskosctl/main.go index cd85c291c5..e7de7c03e9 100644 --- a/hack/tools/boskosctl/main.go +++ b/hack/tools/boskosctl/main.go @@ -73,7 +73,7 @@ func setupCommands(ctx context.Context) *cobra.Command { Short: "boskosctl can be used to consume Boskos vSphere resources", } // Note: http://boskos.test-pods.svc.cluster.local is the URL of the service usually used in k8s.io clusters. - rootCmd.PersistentFlags().StringVar(&boskosHost, "boskos-host", getOrDefault(os.Getenv("BOSKOS_HOST"), "http://boskos.test-pods.svc.cluster.local"), "Boskos server URL.") + rootCmd.PersistentFlags().StringVar(&boskosHost, "boskos-host", getOrDefault(os.Getenv("BOSKOS_HOST"), "http://boskos.test-pods.svc.cluster.local"), "Boskos server URL. (can also be set via BOSKOS_HOST env var)") rootCmd.PersistentFlags().StringVar(&resourceOwner, "resource-owner", "", "Owner for the resource.") // acquire command @@ -101,8 +101,8 @@ func setupCommands(ctx context.Context) *cobra.Command { RunE: runCmd(ctx), } releaseCmd.PersistentFlags().StringVar(&resourceName, "resource-name", "", "Name of the resource.") - releaseCmd.PersistentFlags().StringVar(&vSphereUsername, "vsphere-username", os.Getenv("VSPHERE_USERNAME"), "vSphere username of the resource, required for cleanup before release") - releaseCmd.PersistentFlags().StringVar(&vSpherePassword, "vsphere-password", os.Getenv("VSPHERE_PASSWORD"), "vSphere password of the resource, required for cleanup before release") + releaseCmd.PersistentFlags().StringVar(&vSphereUsername, "vsphere-username", "", "vSphere username of the resource, required for cleanup before release (can also be set via VSPHERE_USERNAME env var)") + releaseCmd.PersistentFlags().StringVar(&vSpherePassword, "vsphere-password", "", "vSphere password of the resource, required for cleanup before release (can also be set via VSPHERE_PASSWORD env var)") releaseCmd.PersistentFlags().StringVar(&vSphereServer, "vsphere-server", "", "vSphere server of the resource, required for cleanup before release") releaseCmd.PersistentFlags().StringVar(&vSphereTLSThumbprint, "vsphere-tls-thumbprint", "", "vSphere TLS thumbprint of the resource, required for cleanup before release") releaseCmd.PersistentFlags().StringVar(&vSphereFolder, "vsphere-folder", "", "vSphere folder of the resource, required for cleanup before release") @@ -160,10 +160,16 @@ func runCmd(ctx context.Context) func(cmd *cobra.Command, _ []string) error { return fmt.Errorf("--resource-name must be set") } if vSphereUsername == "" { - return fmt.Errorf("--vsphere-username must be set") + vSphereUsername = os.Getenv("VSPHERE_USERNAME") + } + if vSphereUsername == "" { + return fmt.Errorf("--vsphere-username or VSPHERE_USERNAME env var must be set") + } + if vSpherePassword == "" { + vSpherePassword = os.Getenv("VSPHERE_PASSWORD") } if vSpherePassword == "" { - return fmt.Errorf("--vsphere-password must be set") + return fmt.Errorf("--vsphere-password or VSPHERE_PASSWORD env var must be set") } if vSphereServer == "" { return fmt.Errorf("--vsphere-server must be set") diff --git a/hack/tools/openvpn/Makefile b/hack/tools/openvpn/Makefile deleted file mode 100644 index d5d866dae8..0000000000 --- a/hack/tools/openvpn/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2019 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -all: build - -VERSION ?= $(shell git describe --always --dirty) -IMAGE_NAME ?= gcr.io/k8s-staging-capi-vsphere/extra/openvpn -IMAGE_TAG ?= $(IMAGE_NAME):$(VERSION) - -build: - docker build -t $(IMAGE_TAG) . - docker tag $(IMAGE_TAG) $(IMAGE_NAME):latest -.PHONY: build - -push: - docker push $(IMAGE_TAG) - docker push $(IMAGE_NAME):latest -.PHONY: push