Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ COPY controllers/ controllers/
COPY common/ common/
COPY utils/ utils/

ARG VERSION_LABEL=1.0.0
ARG RELEASE_LABEL=XX
ARG VCS_REF=0123456789012345678901234567890123456789

# Build
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -ldflags="-s -w" -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -ldflags="-s -w -X 'main.Version=$VERSION_LABEL' -X 'main.VCS_REF=$VCS_REF' -X 'main.BuildDate=$(date)'" -a -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
12 changes: 9 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"flag"
"fmt"
"os"
"runtime"
"time"

"k8s.io/apimachinery/pkg/runtime"
k8sruntime "k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
Expand All @@ -43,8 +44,11 @@ import (
)

var (
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
scheme = k8sruntime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
Version = "1.0.0"
BuildDate = ""
VCS_REF = "0123456789012345678901234567890123456789"
)

func init() {
Expand Down Expand Up @@ -77,6 +81,8 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseDevMode(true)))

setupLog.Info("Version Info", "Version", Version, "Runtime", runtime.Version(),
"Platform", runtime.GOOS+"/"+runtime.GOARCH, "VCS_REF", VCS_REF, "BuildDate", BuildDate)
// see https://github.com/operator-framework/operator-sdk/issues/1813
leaseDuration := 30 * time.Second
renewDeadline := 20 * time.Second
Expand Down