Skip to content

Commit

Permalink
Merge pull request #39 from nukleros/fix-go118
Browse files Browse the repository at this point in the history
feat: upgrade to go version 1.18
  • Loading branch information
lander2k2 authored Jun 21, 2022
2 parents 0c7ca43 + e1af3cd commit 2ed532b
Show file tree
Hide file tree
Showing 19 changed files with 216 additions and 77 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: 1.18

- name: Checkout Code
uses: actions/checkout@v3

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2
version: v1.46.2
args: --timeout 3m
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.18

# TODO: readdress this task as it prevented a successful release
# See action https://github.com/vmware-tanzu-labs/operator-builder/runs/4861431396?check_suite_focus=true
Expand Down
28 changes: 24 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ jobs:
unit-test:
name: Unit Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- go-version: 1.17
- go-version: 1.18
steps:
- name: Checkout Code
uses: actions/checkout@v2
Expand All @@ -20,7 +26,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: ${{ matrix.go-version }}

- name: Run Test
uses: ./.github/common-actions/unit-test
Expand All @@ -32,6 +38,12 @@ jobs:
name: Build
runs-on: ubuntu-latest
needs: unit-test
strategy:
fail-fast: false
matrix:
include:
- go-version: 1.17
- go-version: 1.18
steps:
- name: Checkout Code
uses: actions/checkout@v2
Expand All @@ -41,7 +53,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: ${{ matrix.go-version }}

- name: Build Binary Artifact (operator-builder)
run: make build
Expand All @@ -66,15 +78,19 @@ jobs:
- name: Standalone Operator
artifact: standalone-codebase
test-workload-path: test/cases/standalone
go-version: 1.17
- name: Standalone Edge Cases Operator
artifact: standalone-edge-codebase
test-workload-path: test/cases/edge-standalone
go-version: 1.18
- name: Workload Collection Operator
artifact: collection-codebase
test-workload-path: test/cases/collection
go-version: 1.18
- name: Workload Collection Edge Cases Operator
artifact: collection-edge-codebase
test-workload-path: test/cases/edge-collection
go-version: 1.17
env:
TEST_WORKLOAD_PATH: "${{ matrix.test-workload-path }}"
TEST_PATH: "/tmp/operator-builder-func-test"
Expand All @@ -93,7 +109,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: ${{ matrix.go-version }}

- name: Initialize ${{ matrix.name }} Codebase
run: |
Expand Down Expand Up @@ -129,18 +145,22 @@ jobs:
artifact: standalone-codebase
test-build: "true"
test-deploy: "true"
go-version: 1.17
- name: Standalone Edge Cases Operator
artifact: standalone-edge-codebase
test-build: "false"
test-deploy: "false"
go-version: 1.18
- name: Workload Collection Operator
artifact: collection-codebase
test-build: "true"
test-deploy: "false"
go-version: 1.18
- name: Workload Collection Edge Cases Operator
artifact: collection-edge-codebase
test-build: "true"
test-deploy: "false"
go-version: 1.17
services:
registry:
image: registry:2
Expand All @@ -158,7 +178,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: ${{ matrix.go-version }}

- name: Download ${{ matrix.name }} Codebase
uses: actions/download-artifact@v2
Expand Down
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ linters-settings:
allow-unused: false
require-explanation: false
require-specific: false
staticcheck:
checks:
- all
- '-SA1019' # disable strings.Title check

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ install: build
#
# traditional testing
#
GOLANGCI_LINT_VERSION ?= v1.45.2
GOLANGCI_LINT_VERSION ?= v1.46.2
install-linter:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
sh -s -- -b $$(go env GOPATH)/bin $(GOLANGCI_LINT_VERSION)
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)

lint:
golangci-lint run
Expand Down
71 changes: 66 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,82 @@
module github.com/vmware-tanzu-labs/operator-builder

go 1.16
go 1.17

require (
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator v9.31.0+incompatible
github.com/leodido/go-urn v1.2.1 // indirect
github.com/sirupsen/logrus v1.8.1
github.com/spf13/afero v1.6.0
github.com/spf13/cobra v1.2.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
github.com/vmware-tanzu-labs/object-code-generator-for-k8s v0.5.0
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
k8s.io/apimachinery v0.22.2
k8s.io/client-go v0.22.2
sigs.k8s.io/kubebuilder/v3 v3.0.0
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/cloudflare/cfssl v1.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/go-openapi/jsonpointer v0.19.3 // indirect
github.com/go-openapi/jsonreference v0.19.3 // indirect
github.com/go-openapi/spec v0.19.5 // indirect
github.com/go-openapi/swag v0.19.5 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/gobuffalo/flect v0.2.2 // indirect
github.com/gobuffalo/here v0.6.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/certificate-transparency-go v1.0.21 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/huandu/xstrings v1.3.1 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmoiron/sqlx v1.2.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mailru/easyjson v0.7.0 // indirect
github.com/markbates/pkger v0.17.1 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/weppos/publicsuffix-go v0.13.0 // indirect
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
github.com/zmap/zcrypto v0.0.0-20200911161511-43ff0ea04f21 // indirect
github.com/zmap/zlint/v2 v2.2.1 // indirect
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 // indirect
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/tools v0.1.2 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.22.2 // indirect
k8s.io/apiextensions-apiserver v0.20.1 // indirect
k8s.io/klog/v2 v2.9.0 // indirect
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a // indirect
sigs.k8s.io/controller-tools v0.3.0 // indirect
sigs.k8s.io/kustomize/kyaml v0.10.10 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func (f *Definition) SetTemplateDefaults() error {
)

// determine if we need to import the strconv package
for _, child := range f.Manifest.ChildResources {
if child.UseStrConv {
for i := range f.Manifest.ChildResources {
if f.Manifest.ChildResources[i].UseStrConv {
f.UseStrConv = true

break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package templates

import (
"sigs.k8s.io/kubebuilder/v3/pkg/machinery"

"github.com/vmware-tanzu-labs/operator-builder/internal/utils"
)

const (
Expand All @@ -16,6 +18,8 @@ var _ machinery.Template = &Dockerfile{}
// Dockerfile scaffolds a file that defines the containerized build process.
type Dockerfile struct {
machinery.TemplateMixin

GoVersion string
}

// SetTemplateDefaults implements file.Template.
Expand All @@ -24,15 +28,15 @@ func (f *Dockerfile) SetTemplateDefaults() error {
f.Path = defaultDockerfilePath
}

f.GoVersion = utils.GeneratedGoVersionPreferred
f.IfExistsAction = machinery.OverwriteFile

f.TemplateBody = dockerfileTemplate

return nil
}

const dockerfileTemplate = `# Build the manager binary
FROM golang:1.16 as builder
FROM golang:{{ .GoVersion }} as builder
WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
53 changes: 36 additions & 17 deletions internal/plugins/workload/v1/scaffolds/templates/gomod.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package templates

import (
"sigs.k8s.io/kubebuilder/v3/pkg/machinery"

"github.com/vmware-tanzu-labs/operator-builder/internal/utils"
)

var _ machinery.Template = &GoMod{}
Expand All @@ -14,7 +16,9 @@ type GoMod struct {
machinery.TemplateMixin
machinery.RepositoryMixin

Dependencies map[string]string
GoVersionMinimum string
Dependencies map[string]string
IndirectDependencies map[string]string
}

// goModDependencyMap pins the versions within the go.mod file so that they
Expand All @@ -23,19 +27,26 @@ type GoMod struct {
// See https://github.com/vmware-tanzu-labs/operator-builder/issues/250
func goModDependencyMap() map[string]string {
return map[string]string{
"github.com/go-logr/logr": "v0.4.0",
"github.com/nukleros/operator-builder-tools": "v0.2.0",
"github.com/onsi/ginkgo": "v1.16.4",
"github.com/onsi/gomega": "v1.15.0",
"github.com/spf13/cobra": "v1.2.1",
"github.com/stretchr/testify": "v1.7.0",
"github.com/go-logr/logr": "v1.2.3",
"github.com/nukleros/operator-builder-tools": "v0.3.0",
"github.com/onsi/ginkgo": "v1.16.5",
"github.com/onsi/gomega": "v1.19.0",
"github.com/spf13/cobra": "v1.4.0",
"github.com/stretchr/testify": "v1.7.3",
"google.golang.org/api": "v0.84.0",
"gopkg.in/yaml.v2": "v2.4.0",
"k8s.io/api": "v0.22.2",
"k8s.io/apimachinery": "v0.22.2",
"k8s.io/client-go": "v0.22.2",
"sigs.k8s.io/controller-runtime": "v0.10.2",
"sigs.k8s.io/kubebuilder/v3": "v3.2.0",
"sigs.k8s.io/yaml": "v1.2.0",
"k8s.io/api": "v0.24.2",
"k8s.io/apimachinery": "v0.24.2",
"k8s.io/client-go": "v0.24.2",
"sigs.k8s.io/controller-runtime": "v0.12.1",
"sigs.k8s.io/kubebuilder/v3": "v3.4.1",
"sigs.k8s.io/yaml": "v1.3.0",
}
}

func goModIndirectDependencyMap() map[string]string {
return map[string]string{
"gopkg.in/check.v1": "v1.0.0-20201130134442-10cb98267c6c",
}
}

Expand All @@ -44,7 +55,9 @@ func (f *GoMod) SetTemplateDefaults() error {
f.Path = "go.mod"
}

f.GoVersionMinimum = utils.GeneratedGoVersionMinimum
f.Dependencies = goModDependencyMap()
f.IndirectDependencies = goModIndirectDependencyMap()
f.TemplateBody = goModTemplate
f.IfExistsAction = machinery.OverwriteFile

Expand All @@ -54,11 +67,17 @@ func (f *GoMod) SetTemplateDefaults() error {
const goModTemplate = `
module {{ .Repo }}
go 1.15
go {{ .GoVersionMinimum }}
require (
{{ range $package, $version := $.Dependencies }}
"{{ $package }}" {{ $version }}
{{- end }}
)
require (
{{ range $k, $v := $.Dependencies }}
"{{ $k }}" {{ $v }}
{{ end -}}
{{ range $package, $version := $.IndirectDependencies }}
"{{ $package }}" {{ $version }}
{{- end }}
)
`
Loading

0 comments on commit 2ed532b

Please sign in to comment.