Skip to content

Commit

Permalink
Merge pull request #55 from crossplane-contrib/deps
Browse files Browse the repository at this point in the history
Bump Go Runtime version to 1.22
  • Loading branch information
uzaxirr authored Mar 19, 2024
2 parents ca91954 + bc16e85 commit 35c5c7c
Show file tree
Hide file tree
Showing 18 changed files with 865 additions and 1,117 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:

env:
# Common versions
GO_VERSION: '1.18'
GOLANGCI_VERSION: 'v1.47.1'
GO_VERSION: '1.22'
GOLANGCI_VERSION: 'v1.56.2'
DOCKER_BUILDX_VERSION: 'v0.8.2'

# Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run
Expand Down Expand Up @@ -59,14 +59,14 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ steps.go.outputs.cache }}
key: ${{ runner.os }}-build-lint-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-build-lint-${{ hashFiles('**/go.sum') }}-v2
restore-keys: ${{ runner.os }}-build-lint-

- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}-v2
restore-keys: ${{ runner.os }}-pkg-

- name: Vendor Dependencies
Expand Down Expand Up @@ -105,14 +105,14 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ steps.go.outputs.cache }}
key: ${{ runner.os }}-build-check-diff-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-build-check-diff-${{ hashFiles('**/go.sum') }}-v2
restore-keys: ${{ runner.os }}-build-check-diff-

- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}-v2
restore-keys: ${{ runner.os }}-pkg-

- name: Vendor Dependencies
Expand Down Expand Up @@ -148,14 +148,14 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ steps.go.outputs.cache }}
key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }}-v2
restore-keys: ${{ runner.os }}-build-unit-tests-

- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}-v2
restore-keys: ${{ runner.os }}-pkg-

- name: Vendor Dependencies
Expand Down Expand Up @@ -208,14 +208,14 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ steps.go.outputs.cache }}
key: ${{ runner.os }}-build-e2e-tests-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-build-e2e-tests-${{ hashFiles('**/go.sum') }}-v2
restore-keys: ${{ runner.os }}-build-e2e-tests-

- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}-v2
restore-keys: |
${{ runner.os }}-pkg-
- name: Vendor Dependencies
Expand Down Expand Up @@ -262,14 +262,14 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ steps.go.outputs.cache }}
key: ${{ runner.os }}-build-publish-artifacts-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-build-publish-artifacts-${{ hashFiles('**/go.sum') }}-v2
restore-keys: ${{ runner.os }}-build-publish-artifacts-

- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}-v2
restore-keys: ${{ runner.os }}-pkg-

- name: Vendor Dependencies
Expand Down
26 changes: 26 additions & 0 deletions apis/civo/cluster/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ type CivoKubernetesSpec struct {
// If set, the value must be a valid kubernetes version, you can use the following command to get the valid versions: `civo k3s versions`
// Changing the version to a higher version will upgrade the cluster. Note that this may cause breaking changes to the Kubernetes API so please check kubernetes deprecations/mitigations before upgrading.
Version *string `json:"version,omitempty"`

// ProviderReference holds configs (region, API key etc) for the crossplane provider that is being used.
ProviderReference *xpv1.Reference `json:"providerReference"`
// TODO: Update the examples as well
}

// A CivoKubernetesStatus represents the observed state of a CivoKubernetes.
Expand All @@ -86,6 +90,28 @@ type CivoKubernetes struct {
Status CivoKubernetesStatus `json:"status,omitempty"`
}

// SetManagementPolicies sets up management policies.
func (mg *CivoKubernetes) SetManagementPolicies(r xpv1.ManagementPolicies) {}

// GetManagementPolicies gets management policies.
func (mg *CivoKubernetes) GetManagementPolicies() xpv1.ManagementPolicies {
// Note: Crossplane runtime reconciler should leave handling of
// ManagementPolicies to the provider controller. This is a temporary hack
// until we remove the ManagementPolicy field from the Provider Kubernetes
// Object in favor of the one in the ResourceSpec.
return []xpv1.ManagementAction{xpv1.ManagementActionAll}
}

// SetPublishConnectionDetailsTo sets up connection details.
func (mg *CivoKubernetes) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) {
mg.Spec.PublishConnectionDetailsTo = r
}

// GetPublishConnectionDetailsTo gets publish connection details.
func (mg *CivoKubernetes) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo {
return mg.Spec.PublishConnectionDetailsTo
}

// +kubebuilder:object:root=true

// CivoKubernetesList contains a list of CivoKubernetes
Expand Down
7 changes: 6 additions & 1 deletion apis/civo/cluster/v1alpha1/zz_generated.deepcopy.go

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

25 changes: 25 additions & 0 deletions apis/civo/instance/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ type SecretReference struct {
type CivoInstanceSpec struct {
xpv1.ResourceSpec `json:",inline"`
InstanceConfig CivoInstanceConfig `json:"instanceConfig"`

// ProviderReference holds configs (region, API key etc) for the crossplane provider that is being used.
ProviderReference *xpv1.Reference `json:"providerReference"`
}

// CivoInstanceObservation observation fields
Expand Down Expand Up @@ -91,6 +94,28 @@ type CivoInstance struct {
Status CivoInstanceStatus `json:"status,omitempty"`
}

// SetManagementPolicies sets up management policies.
func (mg *CivoInstance) SetManagementPolicies(r xpv1.ManagementPolicies) {}

// GetManagementPolicies gets management policies.
func (mg *CivoInstance) GetManagementPolicies() xpv1.ManagementPolicies {
// Note: Crossplane runtime reconciler should leave handling of
// ManagementPolicies to the provider controller. This is a temporary hack
// until we remove the ManagementPolicy field from the Provider Kubernetes
// Object in favor of the one in the ResourceSpec.
return []xpv1.ManagementAction{xpv1.ManagementActionAll}
}

// SetPublishConnectionDetailsTo sets up connection details.
func (mg *CivoInstance) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) {
mg.Spec.PublishConnectionDetailsTo = r
}

// GetPublishConnectionDetailsTo gets publish connection details.
func (mg *CivoInstance) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo {
return mg.Spec.PublishConnectionDetailsTo
}

// +kubebuilder:object:root=true

// CivoInstanceList contains a list of CivoInstance
Expand Down
7 changes: 6 additions & 1 deletion apis/civo/instance/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 1 addition & 2 deletions apis/civo/provider/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 2 additions & 1 deletion apis/generate.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build generate
// +build generate

/*
Expand All @@ -23,7 +24,7 @@ limitations under the License.
//go:generate rm -rf ../package/crds

// Generate deepcopy methodsets and CRD manifests
//go:generate go run -tags generate sigs.k8s.io/controller-tools/cmd/controller-gen object:headerFile=../hack/boilerplate.go.txt paths=./... crd:trivialVersions=true,crdVersions=v1 output:artifacts:config=../package/crds
//go:generate go run -tags generate sigs.k8s.io/controller-tools/cmd/controller-gen object:headerFile=../hack/boilerplate.go.txt paths=./... crd:crdVersions=v1 output:artifacts:config=../package/crds

// Generate crossplane-runtime methodsets (resource.Claim, etc)
//go:generate go run -tags generate github.com/crossplane/crossplane-tools/cmd/angryjet generate-methodsets --header-file=../hack/boilerplate.go.txt ./...
Expand Down
2 changes: 1 addition & 1 deletion build
30 changes: 18 additions & 12 deletions cmd/provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (
"os"
"path/filepath"

"github.com/crossplane/crossplane-runtime/pkg/ratelimiter"
"sigs.k8s.io/controller-runtime/pkg/cache"

civoinstance "github.com/crossplane-contrib/provider-civo/internal/controller/civoinstance"

log "github.com/sirupsen/logrus"
Expand All @@ -28,12 +31,10 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

"github.com/crossplane/crossplane-runtime/pkg/logging"
"github.com/crossplane/crossplane-runtime/pkg/ratelimiter"

"github.com/crossplane-contrib/provider-civo/apis"
civokubernetes "github.com/crossplane-contrib/provider-civo/internal/controller/civokubernetes"
civoprovider "github.com/crossplane-contrib/provider-civo/internal/controller/provider"
"github.com/crossplane/crossplane-runtime/pkg/logging"
)

func init() {
Expand All @@ -48,15 +49,17 @@ func init() {

func main() {
var (
app = kingpin.New(filepath.Base(os.Args[0]), "Template support for Crossplane.").DefaultEnvars()
debug = app.Flag("debug", "Run with debug logging.").Short('d').Bool()
syncPeriod = app.Flag("sync", "Controller manager sync period such as 300ms, 1.5h, or 2h45m").Short('s').Default("1h").Duration()
leaderElection = app.Flag("leader-election", "Use leader election for the controller manager.").Short('l').Default("false").OverrideDefaultFromEnvar("LEADER_ELECTION").Bool()
app = kingpin.New(filepath.Base(os.Args[0]), "Template support for Crossplane.").DefaultEnvars()
debug = app.Flag("debug", "Run with debug logging.").Short('d').Bool()
syncPeriod = app.Flag("sync", "Controller manager sync period such as 300ms, 1.5h, or 2h45m").Short('s').Default("1h").Duration()
leaderElection = app.Flag("leader-election", "Use leader election for the controller manager.").Short('l').Default("false").OverrideDefaultFromEnvar("LEADER_ELECTION").Bool()
maxReconcileRate = app.Flag("max-reconcile-rate", "The number of concurrent reconciliations that may be running at one time.").Default("100").Int()
)
kingpin.MustParse(app.Parse(os.Args[1:]))

zl := zap.New(zap.UseDevMode(*debug))
log := logging.NewLogrLogger(zl.WithName("provider-template"))
ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
if *debug {
// The controller-runtime runs with a no-op logger by default. It is
// *very* verbose even at info level, so we only provide it a real
Expand All @@ -72,14 +75,17 @@ func main() {
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
LeaderElection: *leaderElection,
LeaderElectionID: "crossplane-leader-election-provider-template",
SyncPeriod: syncPeriod,
Cache: cache.Options{
SyncPeriod: syncPeriod,
},
})
kingpin.FatalIfError(err, "Cannot create controller manager")

rl := ratelimiter.NewDefaultProviderRateLimiter(ratelimiter.DefaultProviderRPS)
rateLimiter := ratelimiter.NewGlobal(*maxReconcileRate)

kingpin.FatalIfError(apis.AddToScheme(mgr.GetScheme()), "Cannot add Template APIs to scheme")
kingpin.FatalIfError(civokubernetes.Setup(mgr, log, rl), "Cannot setup Civo K3 Cluster controllers")
kingpin.FatalIfError(civoinstance.Setup(mgr, log, rl), "Cannot setup Civo Instance controllers")
kingpin.FatalIfError(civoprovider.Setup(mgr, log, rl), "Cannot setup Provider controllers")
kingpin.FatalIfError(civokubernetes.Setup(mgr, log, *rateLimiter), "Cannot setup Civo K3 Cluster controllers")
kingpin.FatalIfError(civoinstance.Setup(mgr, log, *rateLimiter), "Cannot setup Civo Instance controllers")
kingpin.FatalIfError(civoprovider.Setup(mgr, log, *rateLimiter), "Cannot setup Provider controllers")
kingpin.FatalIfError(mgr.Start(ctrl.SetupSignalHandler()), "Cannot start controller manager")
}
Loading

0 comments on commit 35c5c7c

Please sign in to comment.