Skip to content

Commit

Permalink
Remove "infra" from resource suffix (#1712)
Browse files Browse the repository at this point in the history
Also update the finalizer name
  • Loading branch information
matthchr authored Aug 11, 2021
1 parent d772e2d commit fa62dda
Show file tree
Hide file tree
Showing 58 changed files with 230 additions and 230 deletions.
10 changes: 5 additions & 5 deletions hack/README-old_root.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ $ k logs pod/aso-controller-manager-b98bc664-6h6sv -n azureoperator-system -c ma

# let's create an Azure ResourceGroup in westus2 with the name "foo-2019"
cat <<EOF | kubectl apply -f -
apiVersion: microsoft.resources.infra.azure.com/v20191001
apiVersion: microsoft.resources.azure.com/v20191001
kind: ResourceGroup
metadata:
name: foo-2019
spec:
location: westus2
EOF
# resourcegroup.microsoft.resources.infra.azure.com/foo-2019 created
# resourcegroup.microsoft.resources.azure.com/foo-2019 created

# let's see what the ResourceGroup resource looks like
$ k describe resourcegroups/foo-2019
Name: foo-2019
Namespace: default
Labels: <none>
Annotations: resource-sig.infra.azure.com: 56da597b51d66c934c510b22e183a69994a6654bbae92d88fdb46f962272220a
API Version: microsoft.resources.infra.azure.com/v20191001
Annotations: resource-sig.azure.com: 56da597b51d66c934c510b22e183a69994a6654bbae92d88fdb46f962272220a
API Version: microsoft.resources.azure.com/v20191001
Kind: ResourceGroup
Metadata:
Creation Timestamp: 2020-05-13T22:55:56Z
Expand All @@ -78,7 +78,7 @@ Events:

# delete the ResourceGroup
$ k delete resourcegroups/foo-2019
# resourcegroup.microsoft.resources.infra.azure.com "foo-2019" deleted
# resourcegroup.microsoft.resources.azure.com "foo-2019" deleted
```

For samples of additional resources, see the [resource samples directory in the repo](https://github.com/Azure/k8s-infra/tree/master/config/samples).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Licensed under the MIT license.
// +kubebuilder:object:generate=true
// All object properties are optional by default, this will be overridden when needed:
// +kubebuilder:validation:Optional
// +groupName=microsoft.resources.infra.azure.com
// +groupName=microsoft.resources.azure.com
package v1alpha1api20200601

import (
Expand All @@ -18,7 +18,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "microsoft.resources.infra.azure.com", Version: "v1alpha1api20200601"}
GroupVersion = schema.GroupVersion{Group: "microsoft.resources.azure.com", Version: "v1alpha1api20200601"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
// +kubebuilder:rbac:groups=core,resources=events,verbs=get;list;watch;create;patch
// +kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=get;list;watch;create;update;patch;delete

// +kubebuilder:rbac:groups=microsoft.resources.infra.azure.com,resources=resourcegroups,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=microsoft.resources.infra.azure.com,resources={resourcegroups/status,resourcegroups/finalizers},verbs=get;update;patch
// +kubebuilder:rbac:groups=microsoft.resources.azure.com,resources=resourcegroups,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=microsoft.resources.azure.com,resources={resourcegroups/status,resourcegroups/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
Expand All @@ -35,7 +35,7 @@ type ResourceGroup struct {
Status ResourceGroupStatus `json:"status,omitempty"`
}

// +kubebuilder:webhook:path=/mutate-microsoft-resources-infra-azure-com-v1alpha1api20200601-resourcegroup,mutating=true,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=microsoft.resources.infra.azure.com,resources=resourcegroups,verbs=create;update,versions=v1alpha1api20200601,name=default.v1alpha1api20200601.resourcegroups.microsoft.resources.infra.azure.com,admissionReviewVersions=v1beta1
// +kubebuilder:webhook:path=/mutate-microsoft-resources-azure-com-v1alpha1api20200601-resourcegroup,mutating=true,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=microsoft.resources.azure.com,resources=resourcegroups,verbs=create;update,versions=v1alpha1api20200601,name=default.v1alpha1api20200601.resourcegroups.microsoft.resources.azure.com,admissionReviewVersions=v1beta1

var _ admission.Defaulter = &ResourceGroup{}

Expand Down
4 changes: 2 additions & 2 deletions hack/generated/config/rbac/resourcegroup_editor_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: resourcegroup-editor-role
rules:
- apiGroups:
- microsoft.resources.infra.azure.com
- microsoft.resources.azure.com
resources:
- resourcegroups
verbs:
Expand All @@ -17,7 +17,7 @@ rules:
- update
- watch
- apiGroups:
- microsoft.resources.infra.azure.com
- microsoft.resources.azure.com
resources:
- resourcegroups/status
verbs:
Expand Down
4 changes: 2 additions & 2 deletions hack/generated/config/rbac/resourcegroup_viewer_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ metadata:
name: resourcegroup-viewer-role
rules:
- apiGroups:
- microsoft.resources.infra.azure.com
- microsoft.resources.azure.com
resources:
- resourcegroups
verbs:
- get
- list
- watch
- apiGroups:
- microsoft.resources.infra.azure.com
- microsoft.resources.azure.com
resources:
- resourcegroups/status
verbs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: microsoft.batch.infra.azure.com/v1alpha1api20210101
apiVersion: microsoft.batch.azure.com/v1alpha1api20210101
kind: BatchAccount
metadata:
name: samplekubebatch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: microsoft.batch.infra.azure.com/v1alpha1api20210101
apiVersion: microsoft.batch.azure.com/v1alpha1api20210101
kind: BatchAccountsPool
metadata:
name: samplekubebatchpool
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: microsoft.compute.infra.azure.com/v1alpha1api20201201
apiVersion: microsoft.compute.azure.com/v1alpha1api20201201
kind: VirtualMachineScaleSet
metadata:
name: samplevmss
Expand Down Expand Up @@ -39,7 +39,7 @@ spec:
- name: sampleipconfiguration
subnet:
reference:
group: microsoft.network.infra.azure.com
group: microsoft.network.azure.com
kind: VirtualNetworksSubnet
namespace: default
name: samplesubnet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: microsoft.network.infra.azure.com/v1alpha1api20201101
apiVersion: microsoft.network.azure.com/v1alpha1api20201101
kind: LoadBalancer
metadata:
name: sampleloadbalancer
Expand All @@ -13,7 +13,7 @@ spec:
- name: LoadBalancerFrontend
publicIPAddress:
reference:
group: microsoft.network.infra.azure.com
group: microsoft.network.azure.com
kind: PublicIPAddress
namespace: default
name: samplepublicipaddress
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: microsoft.network.infra.azure.com/v1alpha1api20201101
apiVersion: microsoft.network.azure.com/v1alpha1api20201101
kind: PublicIPAddress
metadata:
name: samplepublicip
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: microsoft.network.infra.azure.com/v1alpha1api20201101
apiVersion: microsoft.network.azure.com/v1alpha1api20201101
kind: VirtualNetwork
metadata:
name: samplevnet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: microsoft.network.infra.azure.com/v1alpha1api20201101
apiVersion: microsoft.network.azure.com/v1alpha1api20201101
kind: VirtualNetworksSubnet
metadata:
name: samplesubnet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: microsoft.resources.infra.azure.com/v1alpha1api20200601
apiVersion: microsoft.resources.azure.com/v1alpha1api20200601
kind: ResourceGroup
metadata:
name: aso-sample-rg
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: microsoft.storage.infra.azure.com/v1alpha1api20210401
apiVersion: microsoft.storage.azure.com/v1alpha1api20210401
kind: StorageAccount
metadata:
name: samplekubestorage
Expand Down
2 changes: 1 addition & 1 deletion hack/generated/controllers/edge_case_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func Test_CreateStorageAccountThatAlreadyExists_ReconcilesSuccessfully(t *testin

// Patch the account to remove the finalizer
old := acct.DeepCopy()
controllerutil.RemoveFinalizer(acct, "generated.infra.azure.com/finalizer")
controllerutil.RemoveFinalizer(acct, "serviceoperator.azure.com/finalizer")
tc.Patch(old, acct)

// Delete the account
Expand Down
2 changes: 1 addition & 1 deletion hack/generated/pkg/genruntime/base_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

// TODO: These should become Status properties at some point.
const (
ResourceIDAnnotation = "resource-id.infra.azure.com"
ResourceIDAnnotation = "resource-id.azure.com"
)

// MetaObject represents an arbitrary ASO custom resource
Expand Down
2 changes: 1 addition & 1 deletion hack/generated/pkg/genruntime/resource_hierarchy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (

// If we wanted to type-assert we'd have to solve some circular dependency problems... for now this is ok.
const ResourceGroupKind = "ResourceGroup"
const ResourceGroupGroup = "microsoft.resources.infra.azure.com"
const ResourceGroupGroup = "microsoft.resources.azure.com"

type ResourceHierarchy []MetaObject

Expand Down
6 changes: 3 additions & 3 deletions hack/generated/pkg/genruntime/resource_reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
)

var validARMIDRef = genruntime.ResourceReference{ARMID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/microsoft.compute/VirtualMachine/myvm"}
var validKubRef = genruntime.ResourceReference{Group: "microsoft.resources.infra.azure.com", Kind: "ResourceGroup", Namespace: "default", Name: "myrg"}
var invalidRefBothSpecified = genruntime.ResourceReference{Group: "microsoft.resources.infra.azure.com", Kind: "ResourceGroup", Namespace: "default", Name: "myrg", ARMID: "oops"}
var validKubRef = genruntime.ResourceReference{Group: "microsoft.resources.azure.com", Kind: "ResourceGroup", Namespace: "default", Name: "myrg"}
var invalidRefBothSpecified = genruntime.ResourceReference{Group: "microsoft.resources.azure.com", Kind: "ResourceGroup", Namespace: "default", Name: "myrg", ARMID: "oops"}
var invalidRefNeitherSpecified = genruntime.ResourceReference{}
var invalidRefIncompleteKubReference = genruntime.ResourceReference{Group: "microsoft.resources.infra.azure.com", Namespace: "default", Name: "myrg"}
var invalidRefIncompleteKubReference = genruntime.ResourceReference{Group: "microsoft.resources.azure.com", Namespace: "default", Name: "myrg"}

func Test_ResourceReference_Validate(t *testing.T) {
tests := []struct {
Expand Down
8 changes: 4 additions & 4 deletions hack/generated/pkg/reconcilers/azure_deployment_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ import (

const (
// TODO: Delete these later in favor of something in status?
DeploymentIDAnnotation = "deployment-id.infra.azure.com"
DeploymentNameAnnotation = "deployment-name.infra.azure.com"
ResourceSigAnnotationKey = "resource-sig.infra.azure.com"
DeploymentIDAnnotation = "deployment-id.azure.com"
DeploymentNameAnnotation = "deployment-name.azure.com"
ResourceSigAnnotationKey = "resource-sig.azure.com"
)

// TODO: Do we actually want this at the controller level or this level?
const GenericControllerFinalizer = "generated.infra.azure.com/finalizer"
const GenericControllerFinalizer = "serviceoperator.azure.com/finalizer"

type CreateOrUpdateAction string

Expand Down
2 changes: 1 addition & 1 deletion hack/generator/cmd/gen_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewGenTypesCommand() (*cobra.Command, error) {
// TODO: arguments in cobra so this is the best we get... see:
// TODO: https://github.com/spf13/cobra/issues/395
Use: "gen-types <config>",
Short: "generate K8s infrastructure resources from Azure deployment template schema",
Short: "generate K8s resources from Azure deployment template schema",
Args: cobra.ExactArgs(1),
Run: xcobra.RunWithCtx(func(ctx context.Context, cmd *cobra.Command, args []string) error {
configFile := args[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ func (d *DefaulterBuilder) ToInterfaceImplementation() *InterfaceImplementation
panic(fmt.Sprintf("expected resource name %s to be a local package reference", d.resourceName.String()))
}

group := lpr.group // e.g. "microsoft.network.infra.azure.com"
group := lpr.group // e.g. "microsoft.network.azure.com"
resource := d.resourceName.Name() // e.g. "backendaddresspools"
version := lpr.version // e.g. "v1"

group = strings.ToLower(group + GroupSuffix)
nonPluralResource := strings.ToLower(resource)
resource = strings.ToLower(d.resourceName.Plural().Name())

// e.g. "mutate-microsoft-network-infra-azure-com-v1-backendaddresspool"
// e.g. "mutate-microsoft-network-azure-com-v1-backendaddresspool"
// note that this must match _exactly_ how controller-runtime generates the path
// or it will not work!
path := fmt.Sprintf("/mutate-%s-%s-%s", strings.ReplaceAll(group, ".", "-"), version, nonPluralResource)

// e.g. "default.v123.backendaddresspool.infra.azure.com"
// e.g. "default.v123.backendaddresspool.azure.com"
name := fmt.Sprintf("default.%s.%s.%s", version, resource, group)

annotation := fmt.Sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ func (v *ValidatorBuilder) ToInterfaceImplementation() *InterfaceImplementation
panic(fmt.Sprintf("expected resource name %s to be a local package reference", v.resourceName.String()))
}

group := lpr.group // e.g. "microsoft.network.infra.azure.com"
group := lpr.group // e.g. "microsoft.network.azure.com"
resource := v.resourceName.Name() // e.g. "backendaddresspools"
version := lpr.version // e.g. "v1"

group = strings.ToLower(group + GroupSuffix)
nonPluralResource := strings.ToLower(resource)
resource = strings.ToLower(v.resourceName.Plural().Name())

// e.g. "validate-microsoft-network-infra-azure-com-v1-backendaddresspool"
// e.g. "validate-microsoft-network-azure-com-v1-backendaddresspool"
// note that this must match _exactly_ how controller-runtime generates the path
// or it will not work!
path := fmt.Sprintf("/validate-%s-%s-%s", strings.ReplaceAll(group, ".", "-"), version, nonPluralResource)

// e.g. "default.v123.backendaddresspool.infra.azure.com"
// e.g. "default.v123.backendaddresspool.azure.com"
name := fmt.Sprintf("validate.%s.%s.%s", version, resource, group)

annotation := fmt.Sprintf(
Expand Down
4 changes: 2 additions & 2 deletions hack/generator/pkg/astmodel/package_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Licensed under the MIT license.
// +kubebuilder:object:generate=true
// All object properties are optional by default, this will be overridden when needed:
// +kubebuilder:validation:Optional
// +groupName={{.GroupName}}.infra.azure.com
// +groupName={{.GroupName}}.azure.com
package {{.PackageName}}
import (
Expand All @@ -217,7 +217,7 @@ import (
var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "{{.GroupName}}.infra.azure.com", Version: "{{.PackageName}}"}
GroupVersion = schema.GroupVersion{Group: "{{.GroupName}}.azure.com", Version: "{{.PackageName}}"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
2 changes: 1 addition & 1 deletion hack/generator/pkg/astmodel/package_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
const (
genRuntimePathPrefix = "github.com/Azure/azure-service-operator/hack/generated/pkg/genruntime"
GenRuntimePackageName = "genruntime"
GroupSuffix = ".infra.azure.com"
GroupSuffix = ".azure.com"
)

var MetaV1PackageReference = MakeExternalPackageReference("k8s.io/apimachinery/pkg/apis/meta/v1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package v20200101

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// +kubebuilder:rbac:groups=microsoft.person.infra.azure.com,resources=people,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=microsoft.person.infra.azure.com,resources={people/status,people/finalizers},verbs=get;update;patch
// +kubebuilder:rbac:groups=microsoft.person.azure.com,resources=people,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=microsoft.person.azure.com,resources={people/status,people/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// +kubebuilder:rbac:groups=test.infra.azure.com,resources=fakeresources,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=test.infra.azure.com,resources={fakeresources/status,fakeresources/finalizers},verbs=get;update;patch
// +kubebuilder:rbac:groups=test.azure.com,resources=fakeresources,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=test.azure.com,resources={fakeresources/status,fakeresources/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +kubebuilder:storageversion
Expand All @@ -26,7 +26,7 @@ type FakeResource struct {
Spec FakeResource_Spec `json:"spec,omitempty"`
}

// +kubebuilder:webhook:path=/mutate-test-infra-azure-com-v1alpha1api20200101-fakeresource,mutating=true,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.infra.azure.com,resources=fakeresources,verbs=create;update,versions=v1alpha1api20200101,name=default.v1alpha1api20200101.fakeresources.test.infra.azure.com,admissionReviewVersions=v1beta1
// +kubebuilder:webhook:path=/mutate-test-azure-com-v1alpha1api20200101-fakeresource,mutating=true,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=fakeresources,verbs=create;update,versions=v1alpha1api20200101,name=default.v1alpha1api20200101.fakeresources.test.azure.com,admissionReviewVersions=v1beta1

var _ admission.Defaulter = &FakeResource{}

Expand Down Expand Up @@ -62,7 +62,7 @@ func (fakeResource *FakeResource) Owner() *genruntime.ResourceReference {
return &genruntime.ResourceReference{Group: group, Kind: kind, Namespace: fakeResource.Namespace, Name: fakeResource.Spec.Owner.Name}
}

// +kubebuilder:webhook:path=/validate-test-infra-azure-com-v1alpha1api20200101-fakeresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.infra.azure.com,resources=fakeresources,verbs=create;update,versions=v1alpha1api20200101,name=validate.v1alpha1api20200101.fakeresources.test.infra.azure.com,admissionReviewVersions=v1beta1
// +kubebuilder:webhook:path=/validate-test-azure-com-v1alpha1api20200101-fakeresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=fakeresources,verbs=create;update,versions=v1alpha1api20200101,name=validate.v1alpha1api20200101.fakeresources.test.azure.com,admissionReviewVersions=v1beta1

var _ admission.Validator = &FakeResource{}

Expand Down Expand Up @@ -193,7 +193,7 @@ type FakeResource_Spec struct {
AzureName string `json:"azureName"`

// +kubebuilder:validation:Required
Owner genruntime.KnownResourceReference `group:"microsoft.resources.infra.azure.com" json:"owner" kind:"ResourceGroup"`
Owner genruntime.KnownResourceReference `group:"microsoft.resources.azure.com" json:"owner" kind:"ResourceGroup"`
Properties *Properties `json:"properties,omitempty"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +kubebuilder:rbac:groups=test.infra.azure.com,resources=fakeresources,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=test.infra.azure.com,resources={fakeresources/status,fakeresources/finalizers},verbs=get;update;patch
// +kubebuilder:rbac:groups=test.azure.com,resources=fakeresources,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=test.azure.com,resources={fakeresources/status,fakeresources/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +kubebuilder:storageversion
Expand Down
Loading

0 comments on commit fa62dda

Please sign in to comment.