Skip to content

Commit

Permalink
Update ASO V2 dependencies (#1648)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthchr authored Jul 14, 2021
1 parent 77f01f2 commit 4460654
Show file tree
Hide file tree
Showing 26 changed files with 867 additions and 116 deletions.
4 changes: 2 additions & 2 deletions hack/crossplane/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ go 1.16

require (
github.com/crossplane/crossplane-runtime v0.11.0
k8s.io/apimachinery v0.19.2
sigs.k8s.io/controller-runtime v0.6.3
k8s.io/apimachinery v0.21.2
sigs.k8s.io/controller-runtime v0.9.2
)
370 changes: 370 additions & 0 deletions hack/crossplane/go.sum

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions hack/generated/controllers/controller_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@ package controllers

import (
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

resources "github.com/Azure/azure-service-operator/hack/generated/_apis/microsoft.resources/v1alpha1api20200601"
)

func GetKnownStorageTypes() []runtime.Object {
func GetKnownStorageTypes() []client.Object {
knownTypes := getKnownStorageTypes()

knownTypes = append(knownTypes, new(resources.ResourceGroup))

return knownTypes
}

func GetKnownTypes() []runtime.Object {
func GetKnownTypes() []client.Object {
knownTypes := getKnownTypes()

knownTypes = append(knownTypes, new(resources.ResourceGroup))
Expand Down
3 changes: 1 addition & 2 deletions hack/generated/controllers/crd_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ func Test_Disk_CRUD(t *testing.T) {
disk.Spec.NetworkAccessPolicy = &networkAccessPolicy
patcher.Patch(disk)

objectKey, err := client.ObjectKeyFromObject(disk)
tc.Expect(err).ToNot(HaveOccurred())
objectKey := client.ObjectKeyFromObject(disk)

// Ensure state eventually gets updated in k8s from change in Azure.
tc.Eventually(func() *compute.NetworkAccessPolicy_Status {
Expand Down
3 changes: 1 addition & 2 deletions hack/generated/controllers/crd_networking_publicip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ func Test_PublicIP_CRUD(t *testing.T) {
publicIPAddress.Spec.IdleTimeoutInMinutes = &idleTimeoutInMinutes
patcher.Patch(publicIPAddress)

objectKey, err := client.ObjectKeyFromObject(publicIPAddress)
tc.Expect(err).ToNot(HaveOccurred())
objectKey := client.ObjectKeyFromObject(publicIPAddress)

// ensure state got updated in Azure
tc.Eventually(func() *int {
Expand Down
6 changes: 3 additions & 3 deletions hack/generated/controllers/crd_resourcegroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (

"sigs.k8s.io/controller-runtime/pkg/client"

. "github.com/onsi/gomega"

resources "github.com/Azure/azure-service-operator/hack/generated/_apis/microsoft.resources/v1alpha1api20200601"
"github.com/Azure/azure-service-operator/hack/generated/pkg/armclient"
. "github.com/onsi/gomega"
)

func Test_ResourceGroup_CRUD(t *testing.T) {
Expand All @@ -36,8 +37,7 @@ func Test_ResourceGroup_CRUD(t *testing.T) {
rg.Spec.Tags["tag1"] = "value1"
patcher.Patch(rg)

objectKey, err := client.ObjectKeyFromObject(rg)
tc.Expect(err).ToNot(HaveOccurred())
objectKey := client.ObjectKeyFromObject(rg)

// ensure they get updated
tc.Eventually(func() map[string]string {
Expand Down
3 changes: 1 addition & 2 deletions hack/generated/controllers/crd_vmss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ func Test_VMSS_CRUD(t *testing.T) {
}
patcher.Patch(vmss)

objectKey, err := client.ObjectKeyFromObject(vmss)
tc.Expect(err).ToNot(HaveOccurred())
objectKey := client.ObjectKeyFromObject(vmss)

// Ensure state eventually gets updated in k8s from change in Azure.
tc.Eventually(func() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ func Test_DeploymentAccepted_LongRunningOperationFails_SucceedsAfterUpdate(t *te
tc.PatchResourceAndWaitAfter(acct, patcher, armclient.FailedProvisioningState)

// Ensure that the old failure information was cleared away
objectKey, err := client.ObjectKeyFromObject(acct)
tc.Expect(err).ToNot(HaveOccurred())
objectKey := client.ObjectKeyFromObject(acct)
updated := &storage.StorageAccount{}
tc.GetResource(objectKey, updated)

Expand Down Expand Up @@ -178,8 +177,7 @@ func Test_DeploymentRejected_SucceedsAfterUpdate(t *testing.T) {
tc.PatchResourceAndWaitAfter(vmss, patcher, armclient.FailedProvisioningState)

// Ensure that the old failure information was cleared away
objectKey, err := client.ObjectKeyFromObject(vmss)
tc.Expect(err).ToNot(HaveOccurred())
objectKey := client.ObjectKeyFromObject(vmss)
updated := &compute.VirtualMachineScaleSet{}
tc.GetResource(objectKey, updated)

Expand Down
11 changes: 5 additions & 6 deletions hack/generated/controllers/edge_case_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@ import (
"github.com/Azure/azure-service-operator/hack/generated/pkg/testcommon"
)

func waitForOwnerMissingError(tc testcommon.KubePerTestContext, obj controllerutil.Object) {
objectKey, err := client.ObjectKeyFromObject(obj)
tc.Expect(err).ToNot(HaveOccurred())
func waitForOwnerMissingError(tc testcommon.KubePerTestContext, obj client.Object) {
objectKey := client.ObjectKeyFromObject(obj)

tc.Eventually(func() string {
tc.GetResource(objectKey, obj)
return obj.GetAnnotations()[reconcilers.ResourceErrorAnnotation]
}).Should(MatchRegexp("owner.*is not ready"))
}

func doNotWait(_ testcommon.KubePerTestContext, _ controllerutil.Object) {}
func doNotWait(_ testcommon.KubePerTestContext, _ client.Object) {}

func storageAccountAndResourceGroupProvisionedOutOfOrderHelper(t *testing.T, waitHelper func(tc testcommon.KubePerTestContext, obj controllerutil.Object)) {
func storageAccountAndResourceGroupProvisionedOutOfOrderHelper(t *testing.T, waitHelper func(tc testcommon.KubePerTestContext, obj client.Object)) {
t.Parallel()

tc := globalTestContext.ForTest(t)
Expand Down Expand Up @@ -71,7 +70,7 @@ func storageAccountAndResourceGroupProvisionedOutOfOrderHelper(t *testing.T, wai
tc.G.Eventually(acct, tc.RemainingTime()).Should(tc.Match.BeProvisioned())
}

func subnetAndVNETCreatedProvisionedOutOfOrder(t *testing.T, waitHelper func(tc testcommon.KubePerTestContext, obj controllerutil.Object)) {
func subnetAndVNETCreatedProvisionedOutOfOrder(t *testing.T, waitHelper func(tc testcommon.KubePerTestContext, obj client.Object)) {
t.Parallel()

tc := globalTestContext.ForTest(t)
Expand Down
19 changes: 10 additions & 9 deletions hack/generated/controllers/generic_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
kerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -67,7 +67,7 @@ func (options *Options) setDefaults() {
}
}

func RegisterWebhooks(mgr ctrl.Manager, objs []runtime.Object) error {
func RegisterWebhooks(mgr ctrl.Manager, objs []client.Object) error {
var errs []error

for _, obj := range objs {
Expand All @@ -79,7 +79,7 @@ func RegisterWebhooks(mgr ctrl.Manager, objs []runtime.Object) error {
return kerrors.NewAggregate(errs)
}

func registerWebhook(mgr ctrl.Manager, obj runtime.Object) error {
func registerWebhook(mgr ctrl.Manager, obj client.Object) error {
_, err := conversion.EnforcePtr(obj)
if err != nil {
return errors.Wrap(err, "obj was expected to be ptr but was not")
Expand All @@ -90,7 +90,7 @@ func registerWebhook(mgr ctrl.Manager, obj runtime.Object) error {
Complete()
}

func RegisterAll(mgr ctrl.Manager, applier armclient.Applier, objs []runtime.Object, log logr.Logger, options Options) error {
func RegisterAll(mgr ctrl.Manager, applier armclient.Applier, objs []client.Object, log logr.Logger, options Options) error {
options.setDefaults()

reconciledResourceLookup, err := MakeResourceGVKLookup(mgr, objs)
Expand All @@ -108,7 +108,7 @@ func RegisterAll(mgr ctrl.Manager, applier armclient.Applier, objs []runtime.Obj
return kerrors.NewAggregate(errs)
}

func register(mgr ctrl.Manager, reconciledResourceLookup map[schema.GroupKind]schema.GroupVersionKind, applier armclient.Applier, obj runtime.Object, log logr.Logger, options Options) error {
func register(mgr ctrl.Manager, reconciledResourceLookup map[schema.GroupKind]schema.GroupVersionKind, applier armclient.Applier, obj client.Object, log logr.Logger, options Options) error {
v, err := conversion.EnforcePtr(obj)
if err != nil {
return errors.Wrap(err, "obj was expected to be ptr but was not")
Expand Down Expand Up @@ -157,7 +157,7 @@ func register(mgr ctrl.Manager, reconciledResourceLookup map[schema.GroupKind]sc

// MakeResourceGVKLookup creates a map of schema.GroupKind to schema.GroupVersionKind. This can be used to look up
// the version of a GroupKind that is being reconciled.
func MakeResourceGVKLookup(mgr ctrl.Manager, objs []runtime.Object) (map[schema.GroupKind]schema.GroupVersionKind, error) {
func MakeResourceGVKLookup(mgr ctrl.Manager, objs []client.Object) (map[schema.GroupKind]schema.GroupVersionKind, error) {
result := make(map[schema.GroupKind]schema.GroupVersionKind)

for _, obj := range objs {
Expand All @@ -176,8 +176,7 @@ func MakeResourceGVKLookup(mgr ctrl.Manager, objs []runtime.Object) (map[schema.
}

// Reconcile will take state in K8s and apply it to Azure
func (gr *GenericReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
ctx := context.Background()
func (gr *GenericReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := gr.Log.WithValues("name", req.Name, "namespace", req.Namespace)

obj, err := gr.KubeClient.GetObjectOrDefault(ctx, req.NamespacedName, gr.GVK)
Expand All @@ -194,7 +193,9 @@ func (gr *GenericReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-api-machinery/controllers.md, which says:
// Never mutate original objects! Caches are shared across controllers, this means that if you mutate your "copy"
// (actually a reference or shallow copy) of an object, you'll mess up other controllers (not just your own).
obj = obj.DeepCopyObject()
obj = obj.DeepCopyObject().(client.Object)

gr.Log.V(0).Info("Reconcile invoked", "kind", fmt.Sprintf("%T", obj))

// The Go type for the Kubernetes object must understand how to
// convert itself to/from the corresponding Azure types.
Expand Down
40 changes: 25 additions & 15 deletions hack/generated/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,48 @@ module github.com/Azure/azure-service-operator/hack/generated
go 1.16

require (
cloud.google.com/go v0.46.3 // indirect
github.com/Azure/go-autorest/autorest v0.11.0
github.com/Azure/go-autorest/autorest v0.11.19
github.com/Azure/go-autorest/autorest/azure/auth v0.5.0
github.com/Azure/go-autorest/autorest/date v0.3.0
github.com/Azure/go-autorest/autorest/to v0.4.0
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/coreos/go-etcd v2.0.0+incompatible // indirect
github.com/cpuguy83/go-md2man v1.0.10 // indirect
github.com/devigned/tab v0.1.1
github.com/dnaeon/go-vcr v1.1.0
github.com/go-logr/logr v0.1.0
github.com/google/go-cmp v0.5.2
github.com/google/uuid v1.1.1
github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0 // indirect
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 // indirect
github.com/go-logr/logr v0.4.0
github.com/go-openapi/validate v0.19.5 // indirect
github.com/google/go-cmp v0.5.5
github.com/google/uuid v1.1.2
github.com/gophercloud/gophercloud v0.1.0 // indirect
github.com/kr/pretty v0.2.0
github.com/kr/text v0.2.0 // indirect
github.com/kylelemons/godebug v1.1.0
github.com/leanovate/gopter v0.2.8
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/onsi/gomega v1.10.1
github.com/onsi/gomega v1.14.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.0 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect
golang.org/x/sys v0.0.0-20210317225723-c4fcb01b228e // indirect
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 // indirect
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 // indirect
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/api v0.18.6
k8s.io/apiextensions-apiserver v0.18.6 // indirect
k8s.io/apimachinery v0.18.6
k8s.io/client-go v0.18.6
k8s.io/klog/v2 v2.0.0
sigs.k8s.io/controller-runtime v0.6.5
gotest.tools v2.2.0+incompatible // indirect
k8s.io/api v0.21.2
k8s.io/apiextensions-apiserver v0.21.2 // indirect
k8s.io/apimachinery v0.21.2
k8s.io/client-go v0.21.2
k8s.io/klog v1.0.0 // indirect
k8s.io/klog/v2 v2.8.0
sigs.k8s.io/controller-runtime v0.9.2
sigs.k8s.io/structured-merge-diff/v3 v3.0.0 // indirect
)

replace github.com/Azure/azure-service-operator => ../../
Loading

0 comments on commit 4460654

Please sign in to comment.