-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace version/version.go with internal/version/version.go
On case-insensitive filesystems (which includes default macOS installations), it is not possible to have a "version" directory and a "VERSION" file in the same parent directory, and the repo cannot be cloned succesfully. To resolve this, we replace version/version.go with internal/version/version.go. Additionally, we stop using "0.0.1" as the version string, as it is not consistent with the contents of the VERSION file, nor with the Docker tag. Instead, we use the VERSION file as the one source of truth. We also add a "--version" command-line flag to the operator binary, which displays the version and exits. Signed-off-by: Antonin Bas <[email protected]>
- Loading branch information
1 parent
354e869
commit 435bb91
Showing
16 changed files
with
59 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
SHELL := /bin/bash | ||
LDFLAGS := | ||
|
||
# Options for 'bundle-build' | ||
ifneq ($(origin CHANNELS), undefined) | ||
|
@@ -21,6 +22,7 @@ ifndef IS_CERTIFICATION | |
endif | ||
|
||
include versioning.mk | ||
LDFLAGS += $(VERSION_LDFLAGS) | ||
|
||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) | ||
ifeq (,$(shell go env GOBIN)) | ||
|
@@ -41,7 +43,7 @@ PKG_IS_DEFAULT_CHANNEL := --default-channel | |
endif | ||
PKG_MAN_OPTS ?= $(FROM_VERSION) $(PKG_CHANNELS) $(PKG_IS_DEFAULT_CHANNEL) | ||
|
||
all: manager | ||
all: generate golangci manager | ||
|
||
.golangci-bin: | ||
@echo "===> Installing Golangci-lint <===" | ||
|
@@ -65,13 +67,13 @@ test: generate golangci manifests | |
source $(ENVTEST_ASSETS_DIR)/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out | ||
|
||
# Build manager binary | ||
manager: generate golangci | ||
manager: | ||
@echo "===> Building antrea-operator binary <===" | ||
go build -o bin/manager main.go | ||
go build -o bin/manager -ldflags '$(LDFLAGS)' main.go | ||
|
||
# Run against the configured Kubernetes cluster in ~/.kube/config | ||
run: generate golangci manifests | ||
go run ./main.go | ||
go run -ldflags '$(LDFLAGS)' ./main.go | ||
|
||
# Install CRDs into a cluster | ||
install: manifests kustomize | ||
|
@@ -97,7 +99,7 @@ generate: controller-gen | |
|
||
# Build the docker image | ||
docker-build: | ||
docker build -f build/Dockerfile . -t ${IMG} | ||
docker build -f build/Dockerfile --label version="$(VERSION)" . -t ${IMG} | ||
docker tag ${IMG} antrea/antrea-operator | ||
|
||
# find or download controller-gen | ||
|
@@ -117,11 +119,7 @@ kustomize: | |
ifeq (, $(shell which kustomize)) | ||
@{ \ | ||
set -e ;\ | ||
KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$KUSTOMIZE_GEN_TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
go get sigs.k8s.io/kustomize/kustomize/[email protected] ;\ | ||
rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\ | ||
go install sigs.k8s.io/kustomize/kustomize/[email protected] ;\ | ||
} | ||
KUSTOMIZE=$(GOBIN)/kustomize | ||
else | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,11 @@ COPY go.sum go.sum | |
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
|
||
# Copy the go source | ||
COPY main.go main.go | ||
COPY api/ api/ | ||
COPY controllers/ controllers/ | ||
COPY version/ version/ | ||
# Copy source files | ||
COPY . . | ||
|
||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on make manager | ||
|
||
|
||
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest | ||
|
@@ -24,7 +21,8 @@ LABEL name="antrea-operator-for-kubernetes" | |
LABEL maintainer="Antrea <[email protected]>" | ||
LABEL vendor="Project Antrea" | ||
LABEL summary="A cluster operator to deploy Antrea CNI plugin" | ||
LABEL version="0.0.1" | ||
# set at build time | ||
LABEL version="" | ||
LABEL release="1" | ||
LABEL description="Manage deployments, daemonsets, and config maps for Antrea" | ||
|
||
|
@@ -37,7 +35,7 @@ ENV OPERATOR=/usr/local/bin/antrea-operator \ | |
|
||
COPY build/bin /usr/local/bin | ||
# install operator binary | ||
COPY --from=antrea-operator-build /workspace/manager ${OPERATOR} | ||
COPY --from=antrea-operator-build /workspace/bin/manager ${OPERATOR} | ||
COPY antrea-manifest /antrea-manifest | ||
RUN /usr/local/bin/user_setup | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{{.AntreaAgentConfig | indent 4}} | ||
{{- .AntreaAgentConfig | nindent 4 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{{.AntreaCNIConfig | indent 4}} | ||
{{- .AntreaCNIConfig | nindent 4 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{{.AntreaControllerConfig | indent 4}} | ||
{{- .AntreaControllerConfig | nindent 4 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/python3 | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/python3 | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* Copyright © 2020 VMware, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 */ | ||
|
||
package version | ||
|
||
// Version is set at build-time. | ||
var Version string | ||
|
||
func GetVersion() string { | ||
if Version == "" { | ||
return "UNKNOWN" | ||
} | ||
return Version | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters