Skip to content

Commit

Permalink
Update go version in kubebuilder
Browse files Browse the repository at this point in the history
Signed-off-by: Sujil02 <sujil.shah@gmail.com>
  • Loading branch information
sujil02 committed May 18, 2021
1 parent 53b7bf2 commit 15e3ef3
Show file tree
Hide file tree
Showing 25 changed files with 44 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testdata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.15'
go-version: '1.16'
- name: Remove pre-installed kustomize
# This step is needed as the following one tries to remove
# kustomize for each test but has no permission to do so
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.15'
go-version: '1.16'
# This step is needed as the following one tries to remove
# kustomize for each test but has no permission to do so
- name: Remove pre-installed kustomize
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.15'
go-version: '1.16'
- name: Generate the coverage output
run: make test-coverage
- name: Send the coverage output
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.15 as builder
FROM golang:1.16 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -15,7 +15,7 @@ COPY apis/ apis/
COPY controllers/ controllers/

# 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 go build -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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module tutorial.kubebuilder.io/project

go 1.15
go 1.16

require (
github.com/go-logr/logr v0.2.1
Expand Down
4 changes: 2 additions & 2 deletions docs/book/src/cronjob-tutorial/testdata/project/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.15 as builder
FROM golang:1.16 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -15,7 +15,7 @@ COPY api/ api/
COPY controllers/ controllers/

# 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 go build -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
2 changes: 1 addition & 1 deletion docs/book/src/cronjob-tutorial/testdata/project/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module tutorial.kubebuilder.io/project

go 1.15
go 1.16

require (
github.com/go-logr/logr v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions docs/book/src/migration/manually_migration_guide_v2_v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ Ensure that your `go.mod` is using Go version `1.15` and the following dependenc
```go
module example

go 1.15
go 1.16

require (
github.com/go-logr/logr v0.3.0
Expand All @@ -377,7 +377,7 @@ FROM golang:1.13 as builder
With:
```
# Build the manager binary
FROM golang:1.15 as builder
FROM golang:1.16 as builder
```

#### Update your Makefile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.15 as builder
FROM golang:1.16 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -15,7 +15,7 @@ COPY api/ api/
COPY controllers/ controllers/

# 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 go build -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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module tutorial.kubebuilder.io/project

go 1.15
go 1.16

require (
github.com/go-logr/logr v0.3.0
Expand Down
2 changes: 1 addition & 1 deletion docs/book/utils/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module sigs.k8s.io/kubebuilder/docs/book/utils

go 1.15
go 1.16
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module sigs.k8s.io/kubebuilder/v3

go 1.15
go 1.16

require (
github.com/cloudflare/cfssl v1.5.0 // for `kubebuilder alpha config-gen`
github.com/go-logr/logr v0.3.0 // indirect
github.com/gobuffalo/flect v0.2.2
// TODO: remove this in favor of embed once using 1.16
github.com/markbates/pkger v0.17.1 // for `kubebuilder alpha config-gen`
Expand All @@ -15,9 +16,10 @@ require (
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e
// for `kubebuilder alpha config-gen`
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
k8s.io/api v0.20.2 // indirect
k8s.io/apiextensions-apiserver v0.20.1 // indirect
k8s.io/apimachinery v0.20.2 // for `kubebuilder alpha config-gen`
k8s.io/utils v0.0.0-20210111153108-fddb29f9d009 // indirect
sigs.k8s.io/controller-runtime v0.8.3
sigs.k8s.io/controller-tools v0.3.0 // for `kubebuilder alpha config-gen`
sigs.k8s.io/kustomize/kyaml v0.10.10 // for `kubebuilder alpha config-gen`
sigs.k8s.io/yaml v1.2.0
Expand Down
68 changes: 0 additions & 68 deletions go.sum

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pkg/plugins/golang/go_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ var (
major: 1,
minor: 13,
}
go116alpha1 = goVersion{
goVerMax = goVersion{
major: 1,
minor: 16,
minor: 17,
prerelease: "alpha1",
}

Expand Down Expand Up @@ -149,8 +149,8 @@ func checkGoVersion(verStr string) error {
return err
}

if version.compare(go113) < 0 || version.compare(go116alpha1) >= 0 {
return fmt.Errorf("requires 1.13 <= version < 1.16")
if version.compare(go113) < 0 || version.compare(goVerMax) >= 0 {
return fmt.Errorf("requires 1.13 <= version < 1.17")
}

return nil
Expand Down
8 changes: 5 additions & 3 deletions pkg/plugins/golang/go_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ var _ = Describe("checkGoVersion", func() {
Entry("for go 1.15.6", "go1.15.6"),
Entry("for go 1.15.7", "go1.15.7"),
Entry("for go 1.15.8", "go1.15.8"),
Entry("for go 1.16", "go1.16"),
Entry("for go 1.16.1", "go1.16.1"),
Entry("for go 1.16.2", "go1.16.2"),
Entry("for go 1.16.3", "go1.16.3"),
Entry("for go 1.16.4", "go1.16.4"),
)

DescribeTable("should return false for non-supported go versions",
Expand All @@ -182,8 +187,5 @@ var _ = Describe("checkGoVersion", func() {
Entry("for go 1.13beta1", "go1.13beta1"),
Entry("for go 1.13rc1", "go1.13rc1"),
Entry("for go 1.13rc2", "go1.13rc2"),
Entry("for go 1.16beta1", "go1.16beta1"),
Entry("for go 1.16rc1", "go1.16rc1"),
Entry("for go 1.16", "go1.16"),
)
})
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (f *Dockerfile) SetTemplateDefaults() error {
}

const dockerfileTemplate = `# Build the manager binary
FROM golang:1.15 as builder
FROM golang:1.16 as builder
WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -55,7 +55,7 @@ COPY api/ api/
COPY controllers/ controllers/
# 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 go build -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
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (f *GoMod) SetTemplateDefaults() error {
const goModTemplate = `
module {{ .Repo }}
go 1.15
go 1.16
require (
sigs.k8s.io/controller-runtime {{ .ControllerRuntimeVersion }}
Expand Down
1 change: 1 addition & 0 deletions test/testdata/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function test_project {

header_text "Performing tests in dir $1"
pushd "$(dirname "$0")/../../testdata/$1"
go mod tidy
make test
popd
}
Expand Down
4 changes: 2 additions & 2 deletions testdata/project-v3-addon/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.15 as builder
FROM golang:1.16 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -15,7 +15,7 @@ COPY api/ api/
COPY controllers/ controllers/

# 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 go build -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
2 changes: 1 addition & 1 deletion testdata/project-v3-addon/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/kubebuilder/testdata/project-v3-addon

go 1.15
go 1.16

require (
github.com/go-logr/logr v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions testdata/project-v3-config/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.15 as builder
FROM golang:1.16 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -15,7 +15,7 @@ COPY api/ api/
COPY controllers/ controllers/

# 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 go build -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
2 changes: 1 addition & 1 deletion testdata/project-v3-config/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/kubebuilder/testdata/project-v3-config

go 1.15
go 1.16

require (
github.com/go-logr/logr v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions testdata/project-v3-multigroup/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.15 as builder
FROM golang:1.16 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -15,7 +15,7 @@ COPY apis/ apis/
COPY controllers/ controllers/

# 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 go build -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
2 changes: 1 addition & 1 deletion testdata/project-v3-multigroup/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/kubebuilder/testdata/project-v3-multigroup

go 1.15
go 1.16

require (
github.com/go-logr/logr v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions testdata/project-v3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.15 as builder
FROM golang:1.16 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -15,7 +15,7 @@ COPY api/ api/
COPY controllers/ controllers/

# 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 go build -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
2 changes: 1 addition & 1 deletion testdata/project-v3/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/kubebuilder/testdata/project-v3

go 1.15
go 1.16

require (
github.com/go-logr/logr v0.3.0
Expand Down

0 comments on commit 15e3ef3

Please sign in to comment.