Skip to content

Commit

Permalink
Minimum version selection
Browse files Browse the repository at this point in the history
This patch updates all of the go.mod files in this repository,
*other than the one for building the manager binary*, to specify
the minimum required version of Go and minimum required versions
for dependencies.

This change allows downstream consumers of things like VM Op's API
module to use a version of Go older than the one used by this repo.
It turns out that Go 1.21 changed the meaning of the Go version in
go.mod. Prior to 1.21, the version of Go in go.mod was informational.
With Go 1.21 and after, it's required. That means if someone depends
on VM Op's API module, and the module specifies Go 1.23.2, then the
project depending on us requires 1.23.2.

Of course our main binary still specifies the latest Go version and
newest dependencies for handling CVEs. However, our sub-modules that
are made to be pulled into *other* targets, such as our own manager,
have no reason to specify the latest version of Go or dependencies.
  • Loading branch information
akutz committed Nov 7, 2024
1 parent d107a82 commit f28e4a8
Show file tree
Hide file tree
Showing 23 changed files with 350 additions and 1,378 deletions.
28 changes: 15 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -301,27 +301,29 @@ fix: lint-go ## Tries to fix errors reported by lint-go-full target
## Generate
## --------------------------------------

GO_MOD_DIRS := $(filter-out ./,$(dir $(shell find . -name go.mod)))

.PHONY: $(GO_MOD_DIRS)
$(GO_MOD_DIRS):
go -C $@ mod $(GO_MOD_OP)

.PHONY: modules
modules: GO_MOD_OP=tidy
modules: $(GO_MOD_DIRS)
modules: ## Validates the modules
go mod tidy
cd hack/tools && go mod tidy
cd api && go mod tidy
cd pkg/backup/api && go mod tidy
cd pkg/constants/testlabels && go mod tidy
go mod $(GO_MOD_OP)

.PHONY: modules-vendor
modules-vendor: GO_MOD_OP=vendor
modules-vendor: $(GO_MOD_DIRS)
modules-vendor: ## Vendors the modules
go mod vendor
cd hack/tools && go mod vendor
cd api && go mod vendor
cd pkg/constants/testlabels && go mod vendor
go mod $(GO_MOD_OP)

.PHONY: modules-download
modules-download: GO_MOD_OP=download
modules-download: $(GO_MOD_DIRS)
modules-download: ## Downloads and caches the modules
go mod download
cd hack/tools && go mod download
cd api && go mod download
cd pkg/constants/testlabels && go mod download
go mod $(GO_MOD_OP)

.PHONY: generate
generate: ## Generate code
Expand Down
4 changes: 3 additions & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/vmware-tanzu/vm-operator/api

go 1.23
go 1.22.0

toolchain go1.23.2

require (
github.com/google/go-cmp v0.6.0
Expand Down
23 changes: 2 additions & 21 deletions external/byok/go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
module github.com/vmware-tanzu/vm-operator/external/byok

go 1.22.5
go 1.13

require k8s.io/apimachinery v0.30.0

require (
github.com/go-logr/logr v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
require k8s.io/apimachinery v0.17.4
152 changes: 83 additions & 69 deletions external/byok/go.sum

Large diffs are not rendered by default.

23 changes: 2 additions & 21 deletions external/capabilities/go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
module github.com/vmware-tanzu/vm-operator/external/capabilities

go 1.22.7
go 1.13

require k8s.io/apimachinery v0.31.1

require (
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/text v0.16.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
require k8s.io/apimachinery v0.17.4
155 changes: 87 additions & 68 deletions external/capabilities/go.sum

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions external/storage-policy-quota/api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "cns.vmware.com", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
// schemeBuilder is used to add go types to the GroupVersionKind scheme.
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
AddToScheme = schemeBuilder.AddToScheme

const (
StoragePolicyQuota_CRDPlural = "storagepolicyquotas"
StoragePolicyQuota_CRDSingular = "storagepolicyquota"
StorageQuota_CRDPlural = "storagequotas"
StorageQuota_CRDSingular = "storagequota"
StoragePolicyUsage_CRDPlural = "storagepolicyusages"
StoragePolicyUsage_CRDSingular = "storagepolicyusage"
objectTypes = []runtime.Object{}
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion, objectTypes...)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ type StoragePolicyQuotaList struct {
}

func init() {
SchemeBuilder.Register(&StoragePolicyQuota{}, &StoragePolicyQuotaList{})
objectTypes = append(objectTypes, &StoragePolicyQuota{}, &StoragePolicyQuotaList{})
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ type StoragePolicyUsageList struct {
}

func init() {
SchemeBuilder.Register(&StoragePolicyUsage{}, &StoragePolicyUsageList{})
objectTypes = append(objectTypes, &StoragePolicyUsage{}, &StoragePolicyUsageList{})
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ type StorageQuotaList struct {
}

func init() {
SchemeBuilder.Register(&StorageQuota{}, &StorageQuotaList{})
objectTypes = append(objectTypes, &StorageQuota{}, &StorageQuotaList{})
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 2 additions & 22 deletions external/storage-policy-quota/go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
module github.com/vmware-tanzu/vm-operator/external/storage-policy-quota

go 1.21.9
go 1.13

require (
k8s.io/apimachinery v0.29.1
sigs.k8s.io/controller-runtime v0.17.2
)

require (
github.com/go-logr/logr v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
require k8s.io/apimachinery v0.17.4
Loading

0 comments on commit f28e4a8

Please sign in to comment.