diff --git a/PROJECT b/PROJECT index 1a340ea02a3..9f105b0c929 100644 --- a/PROJECT +++ b/PROJECT @@ -47,11 +47,10 @@ resources: kind: PostgreSQLDatabase version: v1alpha1 - group: azure - kind: PostgreSQLFirewallRule - version: v1alpha1 kind: PostgreSQLVNetRule + version: v1alpha1 - group: azure - kind: PostgreSQLVNetRule + kind: PostgreSQLFirewallRule version: v1alpha1 - group: azure kind: APIMgmtAPI @@ -93,14 +92,14 @@ resources: kind: AzureVirtualMachine version: v1alpha1 - group: azure - version: v1alpha1 kind: AzureSQLManagedUser -- group: azure version: v1alpha1 - kind: AzureLoadBalancer - group: azure + kind: AzureLoadBalancer version: v1alpha1 +- group: azure kind: AzureVMScaleSet + version: v1alpha1 - group: azure kind: AzureSqlServer version: v1beta1 @@ -116,4 +115,7 @@ resources: - group: azure kind: BlobContainer version: v1alpha2 +- group: azure + kind: MySQLServer + version: v1alpha2 version: "2" diff --git a/api/v1alpha1/azuresqldatabase_conversion.go b/api/v1alpha1/azuresqldatabase_conversion.go index c1fd67bfd6e..f3b30008ac7 100644 --- a/api/v1alpha1/azuresqldatabase_conversion.go +++ b/api/v1alpha1/azuresqldatabase_conversion.go @@ -3,4 +3,46 @@ package v1alpha1 -func (*AzureSqlDatabase) Hub() {} +import ( + "github.com/Azure/azure-service-operator/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/conversion" +) + +func (src *AzureSqlDatabase) ConvertTo(dstRaw conversion.Hub) error { + dst := dstRaw.(*v1beta1.AzureSqlDatabase) + + // ObjectMeta + dst.ObjectMeta = src.ObjectMeta + + // Spec + dst.Spec.ResourceGroup = src.Spec.ResourceGroup + dst.Spec.Location = src.Spec.Location + dst.Spec.Server = src.Spec.Server + dst.Spec.Edition = v1beta1.DBEdition(src.Spec.Edition) + dst.Spec.DbName = src.Spec.DbName + + // Status + dst.Status = v1beta1.ASOStatus(src.Status) + + return nil +} + +func (dst *AzureSqlDatabase) ConvertFrom(srcRaw conversion.Hub) error { + src := srcRaw.(*v1beta1.AzureSqlDatabase) + + // ObjectMeta + dst.ObjectMeta = src.ObjectMeta + + // Spec + dst.Spec.ResourceGroup = src.Spec.ResourceGroup + dst.Spec.Location = src.Spec.Location + dst.Spec.Server = src.Spec.Server + dst.Spec.Edition = DBEdition(src.Spec.Edition) + dst.Spec.DbName = src.Spec.DbName + + // Status + dst.Status = ASOStatus(src.Status) + + return nil + +} diff --git a/api/v1alpha1/azuresqldatabase_types.go b/api/v1alpha1/azuresqldatabase_types.go index 3960ff59e5a..8585313c24d 100644 --- a/api/v1alpha1/azuresqldatabase_types.go +++ b/api/v1alpha1/azuresqldatabase_types.go @@ -24,7 +24,6 @@ type AzureSqlDatabaseSpec struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:storageversion // AzureSqlDatabase is the Schema for the azuresqldatabases API // +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" diff --git a/api/v1alpha1/azuresqlfailovergroup_conversion.go b/api/v1alpha1/azuresqlfailovergroup_conversion.go index 38a5e3dcca4..feb2ffbaf2f 100644 --- a/api/v1alpha1/azuresqlfailovergroup_conversion.go +++ b/api/v1alpha1/azuresqlfailovergroup_conversion.go @@ -3,4 +3,54 @@ package v1alpha1 -func (*AzureSqlFailoverGroup) Hub() {} +import ( + "github.com/Azure/azure-service-operator/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/conversion" +) + +func (src *AzureSqlFailoverGroup) ConvertTo(dstRaw conversion.Hub) error { + dst := dstRaw.(*v1beta1.AzureSqlFailoverGroup) + + // ObjectMeta + dst.ObjectMeta = src.ObjectMeta + + // Spec + dst.Spec.ResourceGroup = src.Spec.ResourceGroup + dst.Spec.Location = src.Spec.Location + dst.Spec.Server = src.Spec.Server + dst.Spec.FailoverGracePeriod = src.Spec.FailoverGracePeriod + dst.Spec.FailoverPolicy = v1beta1.ReadWriteEndpointFailoverPolicy(src.Spec.FailoverPolicy) + dst.Spec.SecondaryServer = src.Spec.SecondaryServer + dst.Spec.SecondaryServerResourceGroup = src.Spec.SecondaryServerResourceGroup + dst.Spec.DatabaseList = src.Spec.DatabaseList + dst.Spec.KeyVaultToStoreSecrets = src.Spec.KeyVaultToStoreSecrets + + // Status + dst.Status = v1beta1.ASOStatus(src.Status) + + return nil +} + +func (dst *AzureSqlFailoverGroup) ConvertFrom(srcRaw conversion.Hub) error { + src := srcRaw.(*v1beta1.AzureSqlFailoverGroup) + + // ObjectMeta + dst.ObjectMeta = src.ObjectMeta + + // Spec + dst.Spec.ResourceGroup = src.Spec.ResourceGroup + dst.Spec.Location = src.Spec.Location + dst.Spec.Server = src.Spec.Server + dst.Spec.FailoverGracePeriod = src.Spec.FailoverGracePeriod + dst.Spec.FailoverPolicy = ReadWriteEndpointFailoverPolicy(src.Spec.FailoverPolicy) + dst.Spec.SecondaryServer = src.Spec.SecondaryServer + dst.Spec.SecondaryServerResourceGroup = src.Spec.SecondaryServerResourceGroup + dst.Spec.DatabaseList = src.Spec.DatabaseList + dst.Spec.KeyVaultToStoreSecrets = src.Spec.KeyVaultToStoreSecrets + + // Status + dst.Status = ASOStatus(src.Status) + + return nil + +} diff --git a/api/v1alpha1/azuresqlfailovergroup_types.go b/api/v1alpha1/azuresqlfailovergroup_types.go index a0270536060..0eaf653266d 100644 --- a/api/v1alpha1/azuresqlfailovergroup_types.go +++ b/api/v1alpha1/azuresqlfailovergroup_types.go @@ -25,7 +25,6 @@ type AzureSqlFailoverGroupSpec struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:storageversion // AzureSqlFailoverGroup is the Schema for the azuresqlfailovergroups API // +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" diff --git a/api/v1alpha1/azuresqlfirewallrule_conversion.go b/api/v1alpha1/azuresqlfirewallrule_conversion.go index a00b11217b1..7b54984e5b1 100644 --- a/api/v1alpha1/azuresqlfirewallrule_conversion.go +++ b/api/v1alpha1/azuresqlfirewallrule_conversion.go @@ -3,4 +3,44 @@ package v1alpha1 -func (*AzureSqlFirewallRule) Hub() {} +import ( + "github.com/Azure/azure-service-operator/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/conversion" +) + +func (src *AzureSqlFirewallRule) ConvertTo(dstRaw conversion.Hub) error { + dst := dstRaw.(*v1beta1.AzureSqlFirewallRule) + + // ObjectMeta + dst.ObjectMeta = src.ObjectMeta + + // Spec + dst.Spec.ResourceGroup = src.Spec.ResourceGroup + dst.Spec.Server = src.Spec.Server + dst.Spec.StartIPAddress = src.Spec.StartIPAddress + dst.Spec.EndIPAddress = src.Spec.EndIPAddress + + // Status + dst.Status = v1beta1.ASOStatus(src.Status) + + return nil +} + +func (dst *AzureSqlFirewallRule) ConvertFrom(srcRaw conversion.Hub) error { + src := srcRaw.(*v1beta1.AzureSqlFirewallRule) + + // ObjectMeta + dst.ObjectMeta = src.ObjectMeta + + // Spec + dst.Spec.ResourceGroup = src.Spec.ResourceGroup + dst.Spec.Server = src.Spec.Server + dst.Spec.StartIPAddress = src.Spec.StartIPAddress + dst.Spec.EndIPAddress = src.Spec.EndIPAddress + + // Status + dst.Status = ASOStatus(src.Status) + + return nil + +} diff --git a/api/v1alpha1/azuresqlfirewallrule_types.go b/api/v1alpha1/azuresqlfirewallrule_types.go index fde2ad7b871..043887afb47 100644 --- a/api/v1alpha1/azuresqlfirewallrule_types.go +++ b/api/v1alpha1/azuresqlfirewallrule_types.go @@ -23,7 +23,6 @@ type AzureSqlFirewallRuleSpec struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:storageversion // AzureSqlFirewallRule is the Schema for the azuresqlfirewallrules API // +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" diff --git a/api/v1alpha1/azuresqlserver_conversion.go b/api/v1alpha1/azuresqlserver_conversion.go index c09ec82d5f0..5373160a60f 100644 --- a/api/v1alpha1/azuresqlserver_conversion.go +++ b/api/v1alpha1/azuresqlserver_conversion.go @@ -3,4 +3,42 @@ package v1alpha1 -func (*AzureSqlServer) Hub() {} +import ( + "github.com/Azure/azure-service-operator/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/conversion" +) + +func (src *AzureSqlServer) ConvertTo(dstRaw conversion.Hub) error { + dst := dstRaw.(*v1beta1.AzureSqlServer) + + // ObjectMeta + dst.ObjectMeta = src.ObjectMeta + + // Spec + dst.Spec.ResourceGroup = src.Spec.ResourceGroup + dst.Spec.Location = src.Spec.Location + dst.Spec.KeyVaultToStoreSecrets = src.Spec.KeyVaultToStoreSecrets + + // Status + dst.Status = v1beta1.ASOStatus(src.Status) + + return nil +} + +func (dst *AzureSqlServer) ConvertFrom(srcRaw conversion.Hub) error { + src := srcRaw.(*v1beta1.AzureSqlServer) + + // ObjectMeta + dst.ObjectMeta = src.ObjectMeta + + // Spec + dst.Spec.ResourceGroup = src.Spec.ResourceGroup + dst.Spec.Location = src.Spec.Location + dst.Spec.KeyVaultToStoreSecrets = src.Spec.KeyVaultToStoreSecrets + + // Status + dst.Status = ASOStatus(src.Status) + + return nil + +} diff --git a/api/v1alpha1/azuresqlserver_types.go b/api/v1alpha1/azuresqlserver_types.go index 16535c2f340..19c9acf1440 100644 --- a/api/v1alpha1/azuresqlserver_types.go +++ b/api/v1alpha1/azuresqlserver_types.go @@ -22,7 +22,6 @@ type AzureSqlServerSpec struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:storageversion // AzureSqlServer is the Schema for the azuresqlservers API // +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" diff --git a/api/v1alpha1/blobcontainer_conversion.go b/api/v1alpha1/blobcontainer_conversion.go index 1da8331cbef..6517928605f 100644 --- a/api/v1alpha1/blobcontainer_conversion.go +++ b/api/v1alpha1/blobcontainer_conversion.go @@ -3,4 +3,44 @@ package v1alpha1 -func (*BlobContainer) Hub() {} +import ( + "github.com/Azure/azure-service-operator/api/v1alpha2" + "sigs.k8s.io/controller-runtime/pkg/conversion" +) + +func (src *BlobContainer) ConvertTo(dstRaw conversion.Hub) error { + dst := dstRaw.(*v1alpha2.BlobContainer) + + // ObjectMeta + dst.ObjectMeta = src.ObjectMeta + + // Spec + dst.Spec.ResourceGroup = src.Spec.ResourceGroup + dst.Spec.Location = src.Spec.Location + dst.Spec.AccountName = src.Spec.AccountName + dst.Spec.AccessLevel = src.Spec.AccessLevel + + // Status + dst.Status = v1alpha2.ASOStatus(src.Status) + + return nil +} + +func (dst *BlobContainer) ConvertFrom(srcRaw conversion.Hub) error { + src := srcRaw.(*v1alpha2.BlobContainer) + + // ObjectMeta + dst.ObjectMeta = src.ObjectMeta + + // Spec + dst.Spec.ResourceGroup = src.Spec.ResourceGroup + dst.Spec.Location = src.Spec.Location + dst.Spec.AccountName = src.Spec.AccountName + dst.Spec.AccessLevel = src.Spec.AccessLevel + + // Status + dst.Status = ASOStatus(src.Status) + + return nil + +} diff --git a/api/v1alpha1/blobcontainer_types.go b/api/v1alpha1/blobcontainer_types.go index cfc66a12fb5..0a79e571c2e 100644 --- a/api/v1alpha1/blobcontainer_types.go +++ b/api/v1alpha1/blobcontainer_types.go @@ -24,7 +24,6 @@ type BlobContainerSpec struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:storageversion // BlobContainer is the Schema for the blobcontainers API // +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" diff --git a/api/v1alpha1/mysqlserver_conversion.go b/api/v1alpha1/mysqlserver_conversion.go new file mode 100644 index 00000000000..623dc6f2795 --- /dev/null +++ b/api/v1alpha1/mysqlserver_conversion.go @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package v1alpha1 + +import ( + "github.com/Azure/azure-service-operator/api/v1alpha2" + "sigs.k8s.io/controller-runtime/pkg/conversion" +) + +func (src *MySQLServer) ConvertTo(dstRaw conversion.Hub) error { + dst := dstRaw.(*v1alpha2.MySQLServer) + + // ObjectMeta + dst.ObjectMeta = src.ObjectMeta + + // Spec + dst.Spec.ResourceGroup = src.Spec.ResourceGroup + dst.Spec.Location = src.Spec.Location + dst.Spec.Sku = v1alpha2.AzureDBsSQLSku{ + Name: src.Spec.Sku.Name, + Tier: v1alpha2.SkuTier(src.Spec.Sku.Tier), + Capacity: src.Spec.Sku.Capacity, + Size: src.Spec.Sku.Size, + Family: src.Spec.Sku.Family, + } + + dst.Spec.ServerVersion = v1alpha2.ServerVersion(src.Spec.ServerVersion) + dst.Spec.SSLEnforcement = v1alpha2.SslEnforcementEnum(src.Spec.SSLEnforcement) + dst.Spec.CreateMode = src.Spec.CreateMode + dst.Spec.ReplicaProperties = v1alpha2.ReplicaProperties(src.Spec.ReplicaProperties) + dst.Spec.KeyVaultToStoreSecrets = src.Spec.KeyVaultToStoreSecrets + + // New Spec + //dst.Spec.StorageProfile = nil + + // Status + dst.Status = v1alpha2.ASOStatus(src.Status) + + return nil +} + +func (dst *MySQLServer) ConvertFrom(srcRaw conversion.Hub) error { + src := srcRaw.(*v1alpha2.MySQLServer) + + // ObjectMeta + dst.ObjectMeta = src.ObjectMeta + + // Spec + dst.Spec.ResourceGroup = src.Spec.ResourceGroup + dst.Spec.Location = src.Spec.Location + dst.Spec.Sku = AzureDBsSQLSku{ + Name: src.Spec.Sku.Name, + Tier: SkuTier(src.Spec.Sku.Tier), + Capacity: src.Spec.Sku.Capacity, + Size: src.Spec.Sku.Size, + Family: src.Spec.Sku.Family, + } + dst.Spec.ServerVersion = ServerVersion(src.Spec.ServerVersion) + dst.Spec.SSLEnforcement = SslEnforcementEnum(src.Spec.SSLEnforcement) + dst.Spec.CreateMode = src.Spec.CreateMode + dst.Spec.ReplicaProperties = ReplicaProperties(src.Spec.ReplicaProperties) + dst.Spec.KeyVaultToStoreSecrets = src.Spec.KeyVaultToStoreSecrets + + // Status + dst.Status = ASOStatus(src.Status) + + return nil + +} diff --git a/api/v1alpha1/mysqlserver_webhook.go b/api/v1alpha1/mysqlserver_webhook.go new file mode 100644 index 00000000000..b450eae334c --- /dev/null +++ b/api/v1alpha1/mysqlserver_webhook.go @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package v1alpha1 + +import ( + ctrl "sigs.k8s.io/controller-runtime" + logf "sigs.k8s.io/controller-runtime/pkg/log" +) + +// log is for logging in this package. +var mysqlserverlog = logf.Log.WithName("mysqlserver-resource") + +func (r *MySQLServer) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(r). + Complete() +} + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! diff --git a/api/v1alpha2/aso_types.go b/api/v1alpha2/aso_types.go new file mode 100644 index 00000000000..cbd72c135b5 --- /dev/null +++ b/api/v1alpha2/aso_types.go @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package v1alpha2 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// ASOStatus (AzureServiceOperatorsStatus) defines the observed state of resource actions +type ASOStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file + + Provisioning bool `json:"provisioning,omitempty"` + Provisioned bool `json:"provisioned,omitempty"` + State string `json:"state,omitempty"` + Message string `json:"message,omitempty"` + ResourceId string `json:"resourceId,omitempty"` + PollingURL string `json:"pollingUrl,omitempty"` + SpecHash string `json:"specHash,omitempty"` + ContainsUpdate bool `json:"containsUpdate,omitempty"` + RequestedAt *metav1.Time `json:"requested,omitempty"` + CompletedAt *metav1.Time `json:"completed,omitempty"` + FailedProvisioning bool `json:"failedProvisioning,omitempty"` + FlattenedSecrets bool `json:"flattenedSecrets,omitempty"` +} + +// GenericSpec is a struct to help get the KeyVaultName from the Spec +type GenericSpec struct { + KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"` +} + +// GenericResource is a struct to help get a generic resource to extract keyvault name +type GenericResource struct { + Spec GenericSpec `json:"spec,omitempty"` +} + +// // StatusedObject used to unmarshall runtime.Object when we need Status +// type StatusedObject struct { +// metav1.TypeMeta `json:",inline"` +// metav1.ObjectMeta `json:"metadata,omitempty"` + +// Status ASOStatus `json:"status,omitempty"` +// } diff --git a/api/v1alpha2/blobcontainer_conversion.go b/api/v1alpha2/blobcontainer_conversion.go index 07ba2acdd5d..19bb9d12ccb 100644 --- a/api/v1alpha2/blobcontainer_conversion.go +++ b/api/v1alpha2/blobcontainer_conversion.go @@ -3,44 +3,4 @@ package v1alpha2 -import ( - "github.com/Azure/azure-service-operator/api/v1alpha1" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -func (src *BlobContainer) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*v1alpha1.BlobContainer) - - // ObjectMeta - dst.ObjectMeta = src.ObjectMeta - - // Spec - dst.Spec.ResourceGroup = src.Spec.ResourceGroup - dst.Spec.Location = src.Spec.Location - dst.Spec.AccountName = src.Spec.AccountName - dst.Spec.AccessLevel = src.Spec.AccessLevel - - // Status - dst.Status = src.Status - - return nil -} - -func (dst *BlobContainer) ConvertFrom(srcRaw conversion.Hub) error { - src := srcRaw.(*v1alpha1.BlobContainer) - - // ObjectMeta - dst.ObjectMeta = src.ObjectMeta - - // Spec - dst.Spec.ResourceGroup = src.Spec.ResourceGroup - dst.Spec.Location = src.Spec.Location - dst.Spec.AccountName = src.Spec.AccountName - dst.Spec.AccessLevel = src.Spec.AccessLevel - - // Status - dst.Status = src.Status - - return nil - -} +func (*BlobContainer) Hub() {} diff --git a/api/v1alpha2/blobcontainer_types.go b/api/v1alpha2/blobcontainer_types.go index bfa4e2813ea..b8938ce5b65 100644 --- a/api/v1alpha2/blobcontainer_types.go +++ b/api/v1alpha2/blobcontainer_types.go @@ -5,7 +5,6 @@ package v1alpha2 import ( s "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage" - "github.com/Azure/azure-service-operator/api/v1alpha1" helpers "github.com/Azure/azure-service-operator/pkg/helpers" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -25,6 +24,7 @@ type BlobContainerSpec struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:storageversion // BlobContainer is the Schema for the blobcontainers API // +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" @@ -33,8 +33,8 @@ type BlobContainer struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec BlobContainerSpec `json:"spec,omitempty"` - Status v1alpha1.ASOStatus `json:"status,omitempty"` + Spec BlobContainerSpec `json:"spec,omitempty"` + Status ASOStatus `json:"status,omitempty"` } // +kubebuilder:object:root=true diff --git a/api/v1alpha2/mysqlserver_conversion.go b/api/v1alpha2/mysqlserver_conversion.go new file mode 100644 index 00000000000..29a0c0ea60a --- /dev/null +++ b/api/v1alpha2/mysqlserver_conversion.go @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package v1alpha2 + +func (*MySQLServer) Hub() {} diff --git a/api/v1alpha2/mysqlserver_types.go b/api/v1alpha2/mysqlserver_types.go new file mode 100644 index 00000000000..0a05465a285 --- /dev/null +++ b/api/v1alpha2/mysqlserver_types.go @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package v1alpha2 + +import ( + "github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2017-12-01/mysql" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +type AzureDBsSQLSku struct { + // Name - The name of the sku, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8. + Name string `json:"name,omitempty"` + // Tier - The tier of the particular SKU, e.g. Basic. Possible values include: 'Basic', 'GeneralPurpose', 'MemoryOptimized' + Tier SkuTier `json:"tier,omitempty"` + // Capacity - The scale up/out capacity, representing server's compute units. + Capacity int32 `json:"capacity,omitempty"` + // Size - The size code, to be interpreted by resource as appropriate. + Size string `json:"size,omitempty"` + // Family - The family of hardware. + Family string `json:"family,omitempty"` +} + +// ServerVersion enumerates the values for server version. +type ServerVersion string + +const ( + // NineFullStopFive ... + NineFullStopFive ServerVersion = "9.5" + // NineFullStopSix ... + NineFullStopSix ServerVersion = "9.6" + // OneOne ... + OneOne ServerVersion = "11" + // OneZero ... + OneZero ServerVersion = "10" + // OneZeroFullStopTwo ... + OneZeroFullStopTwo ServerVersion = "10.2" + // OneZeroFullStopZero ... + OneZeroFullStopZero ServerVersion = "10.0" +) + +type SkuTier string + +const ( + // Basic ... + PSQLBasic SkuTier = "Basic" + // GeneralPurpose ... + PSQLGeneralPurpose SkuTier = "GeneralPurpose" + // MemoryOptimized ... + PSQLMemoryOptimized SkuTier = "MemoryOptimized" +) + +type SslEnforcementEnum string + +const ( + // SslEnforcementEnumDisabled ... + SslEnforcementEnumDisabled SslEnforcementEnum = "Disabled" + // SslEnforcementEnumEnabled ... + SslEnforcementEnumEnabled SslEnforcementEnum = "Enabled" +) + +type StorageProfile struct { + // BackupRetentionDays - Backup retention days for the server. + BackupRetentionDays *int32 `json:"backupRetentionDays,omitempty"` + // GeoRedundantBackup - Enable Geo-redundant or not for server backup. Possible values include: 'Enabled', 'Disabled' + GeoRedundantBackup mysql.GeoRedundantBackup `json:"geoRedundantBackup,omitempty"` + // StorageMB - Max storage allowed for a server. + StorageMB *int32 `json:"storageMB,omitempty"` + // StorageAutogrow - Enable Storage Auto Grow. Possible values include: 'StorageAutogrowEnabled', 'StorageAutogrowDisabled' + StorageAutogrow mysql.StorageAutogrow `json:"storageAutogrow,omitempty"` +} + +type ReplicaProperties struct { + SourceServerId string `json:"sourceServerId,omitempty"` +} + +// MySQLServerSpec defines the desired state of MySQLServer +type MySQLServerSpec struct { + Location string `json:"location"` + ResourceGroup string `json:"resourceGroup,omitempty"` + Sku AzureDBsSQLSku `json:"sku,omitempty"` + ServerVersion ServerVersion `json:"serverVersion,omitempty"` + SSLEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"` + CreateMode string `json:"createMode,omitempty"` + ReplicaProperties ReplicaProperties `json:"replicaProperties,omitempty"` + StorageProfile *StorageProfile `json:"storageProfile,omitempty"` + KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion + +// MySQLServer is the Schema for the mysqlservers API +// +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" +// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message" +type MySQLServer struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec MySQLServerSpec `json:"spec,omitempty"` + Status ASOStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// MySQLServerList contains a list of MySQLServer +type MySQLServerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []MySQLServer `json:"items"` +} + +func init() { + SchemeBuilder.Register(&MySQLServer{}, &MySQLServerList{}) +} + +func NewDefaultMySQLServer(name, resourceGroup, location string) *MySQLServer { + return &MySQLServer{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: "default", + }, + Spec: MySQLServerSpec{ + Location: location, + ResourceGroup: resourceGroup, + Sku: AzureDBsSQLSku{ + Name: "GP_Gen5_4", + Tier: SkuTier("GeneralPurpose"), + Family: "Gen5", + Size: "51200", + Capacity: 4, + }, + ServerVersion: ServerVersion("8.0"), + SSLEnforcement: SslEnforcementEnumEnabled, + CreateMode: "Default", + }, + } +} + +func NewReplicaMySQLServer(name, resourceGroup, location string, sourceserverid string) *MySQLServer { + return &MySQLServer{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: "default", + }, + Spec: MySQLServerSpec{ + Location: location, + ResourceGroup: resourceGroup, + CreateMode: "Replica", + ReplicaProperties: ReplicaProperties{ + SourceServerId: sourceserverid, + }, + }, + } +} diff --git a/api/v1beta1/aso_types.go b/api/v1beta1/aso_types.go new file mode 100644 index 00000000000..b8df721332c --- /dev/null +++ b/api/v1beta1/aso_types.go @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package v1beta1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// ASOStatus (AzureServiceOperatorsStatus) defines the observed state of resource actions +type ASOStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file + + Provisioning bool `json:"provisioning,omitempty"` + Provisioned bool `json:"provisioned,omitempty"` + State string `json:"state,omitempty"` + Message string `json:"message,omitempty"` + ResourceId string `json:"resourceId,omitempty"` + PollingURL string `json:"pollingUrl,omitempty"` + SpecHash string `json:"specHash,omitempty"` + ContainsUpdate bool `json:"containsUpdate,omitempty"` + RequestedAt *metav1.Time `json:"requested,omitempty"` + CompletedAt *metav1.Time `json:"completed,omitempty"` + FailedProvisioning bool `json:"failedProvisioning,omitempty"` + FlattenedSecrets bool `json:"flattenedSecrets,omitempty"` +} + +// GenericSpec is a struct to help get the KeyVaultName from the Spec +type GenericSpec struct { + KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"` +} + +// GenericResource is a struct to help get a generic resource to extract keyvault name +type GenericResource struct { + Spec GenericSpec `json:"spec,omitempty"` +} + +// // StatusedObject used to unmarshall runtime.Object when we need Status +// type StatusedObject struct { +// metav1.TypeMeta `json:",inline"` +// metav1.ObjectMeta `json:"metadata,omitempty"` + +// Status ASOStatus `json:"status,omitempty"` +// } diff --git a/api/v1beta1/azuresqldatabase_conversion.go b/api/v1beta1/azuresqldatabase_conversion.go index 058385e1066..b725581fdb3 100644 --- a/api/v1beta1/azuresqldatabase_conversion.go +++ b/api/v1beta1/azuresqldatabase_conversion.go @@ -3,46 +3,4 @@ package v1beta1 -import ( - "github.com/Azure/azure-service-operator/api/v1alpha1" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -func (src *AzureSqlDatabase) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*v1alpha1.AzureSqlDatabase) - - // ObjectMeta - dst.ObjectMeta = src.ObjectMeta - - // Spec - dst.Spec.ResourceGroup = src.Spec.ResourceGroup - dst.Spec.Location = src.Spec.Location - dst.Spec.Server = src.Spec.Server - dst.Spec.Edition = src.Spec.Edition - dst.Spec.DbName = src.Spec.DbName - - // Status - dst.Status = src.Status - - return nil -} - -func (dst *AzureSqlDatabase) ConvertFrom(srcRaw conversion.Hub) error { - src := srcRaw.(*v1alpha1.AzureSqlDatabase) - - // ObjectMeta - dst.ObjectMeta = src.ObjectMeta - - // Spec - dst.Spec.ResourceGroup = src.Spec.ResourceGroup - dst.Spec.Location = src.Spec.Location - dst.Spec.Server = src.Spec.Server - dst.Spec.Edition = src.Spec.Edition - dst.Spec.DbName = src.Spec.DbName - - // Status - dst.Status = src.Status - - return nil - -} +func (*AzureSqlDatabase) Hub() {} diff --git a/api/v1beta1/azuresqldatabase_types.go b/api/v1beta1/azuresqldatabase_types.go index 015adcdbcad..9e7f8c77460 100644 --- a/api/v1beta1/azuresqldatabase_types.go +++ b/api/v1beta1/azuresqldatabase_types.go @@ -4,27 +4,29 @@ package v1beta1 import ( - "github.com/Azure/azure-service-operator/api/v1alpha1" helpers "github.com/Azure/azure-service-operator/pkg/helpers" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. +type DBEdition byte + // AzureSqlDatabaseSpec defines the desired state of AzureSqlDatabase type AzureSqlDatabaseSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file - Location string `json:"location"` - ResourceGroup string `json:"resourceGroup,omitempty"` - Server string `json:"server"` - Edition v1alpha1.DBEdition `json:"edition"` + Location string `json:"location"` + ResourceGroup string `json:"resourceGroup,omitempty"` + Server string `json:"server"` + Edition DBEdition `json:"edition"` // optional DbName string `json:"dbName,omitempty"` } // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:storageversion // AzureSqlDatabase is the Schema for the azuresqldatabases API // +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" @@ -34,7 +36,7 @@ type AzureSqlDatabase struct { metav1.ObjectMeta `json:"metadata,omitempty"` Spec AzureSqlDatabaseSpec `json:"spec,omitempty"` - Status v1alpha1.ASOStatus `json:"status,omitempty"` + Status ASOStatus `json:"status,omitempty"` } // +kubebuilder:object:root=true diff --git a/api/v1beta1/azuresqlfailovergroup_conversion.go b/api/v1beta1/azuresqlfailovergroup_conversion.go index a009965dc56..2915b817777 100644 --- a/api/v1beta1/azuresqlfailovergroup_conversion.go +++ b/api/v1beta1/azuresqlfailovergroup_conversion.go @@ -3,54 +3,4 @@ package v1beta1 -import ( - "github.com/Azure/azure-service-operator/api/v1alpha1" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -func (src *AzureSqlFailoverGroup) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*v1alpha1.AzureSqlFailoverGroup) - - // ObjectMeta - dst.ObjectMeta = src.ObjectMeta - - // Spec - dst.Spec.ResourceGroup = src.Spec.ResourceGroup - dst.Spec.Location = src.Spec.Location - dst.Spec.Server = src.Spec.Server - dst.Spec.FailoverGracePeriod = src.Spec.FailoverGracePeriod - dst.Spec.FailoverPolicy = src.Spec.FailoverPolicy - dst.Spec.SecondaryServer = src.Spec.SecondaryServer - dst.Spec.SecondaryServerResourceGroup = src.Spec.SecondaryServerResourceGroup - dst.Spec.DatabaseList = src.Spec.DatabaseList - dst.Spec.KeyVaultToStoreSecrets = src.Spec.KeyVaultToStoreSecrets - - // Status - dst.Status = src.Status - - return nil -} - -func (dst *AzureSqlFailoverGroup) ConvertFrom(srcRaw conversion.Hub) error { - src := srcRaw.(*v1alpha1.AzureSqlFailoverGroup) - - // ObjectMeta - dst.ObjectMeta = src.ObjectMeta - - // Spec - dst.Spec.ResourceGroup = src.Spec.ResourceGroup - dst.Spec.Location = src.Spec.Location - dst.Spec.Server = src.Spec.Server - dst.Spec.FailoverGracePeriod = src.Spec.FailoverGracePeriod - dst.Spec.FailoverPolicy = src.Spec.FailoverPolicy - dst.Spec.SecondaryServer = src.Spec.SecondaryServer - dst.Spec.SecondaryServerResourceGroup = src.Spec.SecondaryServerResourceGroup - dst.Spec.DatabaseList = src.Spec.DatabaseList - dst.Spec.KeyVaultToStoreSecrets = src.Spec.KeyVaultToStoreSecrets - - // Status - dst.Status = src.Status - - return nil - -} +func (*AzureSqlFailoverGroup) Hub() {} diff --git a/api/v1beta1/azuresqlfailovergroup_types.go b/api/v1beta1/azuresqlfailovergroup_types.go index 4b5824dcf9d..ec2c4a1afe6 100644 --- a/api/v1beta1/azuresqlfailovergroup_types.go +++ b/api/v1beta1/azuresqlfailovergroup_types.go @@ -4,28 +4,29 @@ package v1beta1 import ( - "github.com/Azure/azure-service-operator/api/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. +type ReadWriteEndpointFailoverPolicy string // AzureSqlFailoverGroupSpec defines the desired state of AzureSqlFailoverGroup type AzureSqlFailoverGroupSpec struct { // Important: Run "make" to regenerate code after modifying this file - Location string `json:"location"` - ResourceGroup string `json:"resourceGroup,omitempty"` - Server string `json:"server"` - FailoverPolicy v1alpha1.ReadWriteEndpointFailoverPolicy `json:"failoverPolicy"` - FailoverGracePeriod int32 `json:"failoverGracePeriod"` - SecondaryServer string `json:"secondaryServer"` - SecondaryServerResourceGroup string `json:"secondaryServerResourceGroup"` - DatabaseList []string `json:"databaseList"` - KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"` + Location string `json:"location"` + ResourceGroup string `json:"resourceGroup,omitempty"` + Server string `json:"server"` + FailoverPolicy ReadWriteEndpointFailoverPolicy `json:"failoverPolicy"` + FailoverGracePeriod int32 `json:"failoverGracePeriod"` + SecondaryServer string `json:"secondaryServer"` + SecondaryServerResourceGroup string `json:"secondaryServerResourceGroup"` + DatabaseList []string `json:"databaseList"` + KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"` } // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:storageversion // AzureSqlFailoverGroup is the Schema for the azuresqlfailovergroups API // +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" @@ -35,7 +36,7 @@ type AzureSqlFailoverGroup struct { metav1.ObjectMeta `json:"metadata,omitempty"` Spec AzureSqlFailoverGroupSpec `json:"spec,omitempty"` - Status v1alpha1.ASOStatus `json:"status,omitempty"` + Status ASOStatus `json:"status,omitempty"` } // +kubebuilder:object:root=true diff --git a/api/v1beta1/azuresqlfirewallrule_conversion.go b/api/v1beta1/azuresqlfirewallrule_conversion.go index 986278c1d85..8676d4d28f4 100644 --- a/api/v1beta1/azuresqlfirewallrule_conversion.go +++ b/api/v1beta1/azuresqlfirewallrule_conversion.go @@ -3,44 +3,4 @@ package v1beta1 -import ( - "github.com/Azure/azure-service-operator/api/v1alpha1" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -func (src *AzureSqlFirewallRule) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*v1alpha1.AzureSqlFirewallRule) - - // ObjectMeta - dst.ObjectMeta = src.ObjectMeta - - // Spec - dst.Spec.ResourceGroup = src.Spec.ResourceGroup - dst.Spec.Server = src.Spec.Server - dst.Spec.StartIPAddress = src.Spec.StartIPAddress - dst.Spec.EndIPAddress = src.Spec.EndIPAddress - - // Status - dst.Status = src.Status - - return nil -} - -func (dst *AzureSqlFirewallRule) ConvertFrom(srcRaw conversion.Hub) error { - src := srcRaw.(*v1alpha1.AzureSqlFirewallRule) - - // ObjectMeta - dst.ObjectMeta = src.ObjectMeta - - // Spec - dst.Spec.ResourceGroup = src.Spec.ResourceGroup - dst.Spec.Server = src.Spec.Server - dst.Spec.StartIPAddress = src.Spec.StartIPAddress - dst.Spec.EndIPAddress = src.Spec.EndIPAddress - - // Status - dst.Status = src.Status - - return nil - -} +func (*AzureSqlFirewallRule) Hub() {} diff --git a/api/v1beta1/azuresqlfirewallrule_types.go b/api/v1beta1/azuresqlfirewallrule_types.go index 89d5e95e5c1..ac3d683b27d 100644 --- a/api/v1beta1/azuresqlfirewallrule_types.go +++ b/api/v1beta1/azuresqlfirewallrule_types.go @@ -4,7 +4,6 @@ package v1beta1 import ( - "github.com/Azure/azure-service-operator/api/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" ) @@ -24,6 +23,7 @@ type AzureSqlFirewallRuleSpec struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:storageversion // AzureSqlFirewallRule is the Schema for the azuresqlfirewallrules API // +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" @@ -33,7 +33,7 @@ type AzureSqlFirewallRule struct { metav1.ObjectMeta `json:"metadata,omitempty"` Spec AzureSqlFirewallRuleSpec `json:"spec,omitempty"` - Status v1alpha1.ASOStatus `json:"status,omitempty"` + Status ASOStatus `json:"status,omitempty"` } // +kubebuilder:object:root=true diff --git a/api/v1beta1/azuresqlserver_conversion.go b/api/v1beta1/azuresqlserver_conversion.go index c55b0103f95..d7500dfa66d 100644 --- a/api/v1beta1/azuresqlserver_conversion.go +++ b/api/v1beta1/azuresqlserver_conversion.go @@ -3,40 +3,4 @@ package v1beta1 -import ( - "github.com/Azure/azure-service-operator/api/v1alpha1" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -func (src *AzureSqlServer) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*v1alpha1.AzureSqlServer) - - // ObjectMeta - dst.ObjectMeta = src.ObjectMeta - - // Spec - dst.Spec.ResourceGroup = src.Spec.ResourceGroup - dst.Spec.Location = src.Spec.Location - - // Status - dst.Status = src.Status - - return nil -} - -func (dst *AzureSqlServer) ConvertFrom(srcRaw conversion.Hub) error { - src := srcRaw.(*v1alpha1.AzureSqlServer) - - // ObjectMeta - dst.ObjectMeta = src.ObjectMeta - - // Spec - dst.Spec.ResourceGroup = src.Spec.ResourceGroup - dst.Spec.Location = src.Spec.Location - - // Status - dst.Status = src.Status - - return nil - -} +func (*AzureSqlServer) Hub() {} diff --git a/api/v1beta1/azuresqlserver_types.go b/api/v1beta1/azuresqlserver_types.go index 041a9ef582d..83986cc8a05 100644 --- a/api/v1beta1/azuresqlserver_types.go +++ b/api/v1beta1/azuresqlserver_types.go @@ -4,7 +4,6 @@ package v1beta1 import ( - "github.com/Azure/azure-service-operator/api/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" ) @@ -23,14 +22,17 @@ type AzureSqlServerSpec struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:storageversion // AzureSqlServer is the Schema for the azuresqlservers API +// +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" +// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message" type AzureSqlServer struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` Spec AzureSqlServerSpec `json:"spec,omitempty"` - Status v1alpha1.ASOStatus `json:"status,omitempty"` + Status ASOStatus `json:"status,omitempty"` } // +kubebuilder:object:root=true diff --git a/config/rbac/mysqlserver_editor_role.yaml b/config/rbac/mysqlserver_editor_role.yaml new file mode 100644 index 00000000000..5ce31344d33 --- /dev/null +++ b/config/rbac/mysqlserver_editor_role.yaml @@ -0,0 +1,24 @@ +# permissions for end users to edit mysqlservers. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: mysqlserver-editor-role +rules: +- apiGroups: + - azure.microsoft.com + resources: + - mysqlservers + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - azure.microsoft.com + resources: + - mysqlservers/status + verbs: + - get diff --git a/config/rbac/mysqlserver_viewer_role.yaml b/config/rbac/mysqlserver_viewer_role.yaml new file mode 100644 index 00000000000..ed5932a047c --- /dev/null +++ b/config/rbac/mysqlserver_viewer_role.yaml @@ -0,0 +1,20 @@ +# permissions for end users to view mysqlservers. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: mysqlserver-viewer-role +rules: +- apiGroups: + - azure.microsoft.com + resources: + - mysqlservers + verbs: + - get + - list + - watch +- apiGroups: + - azure.microsoft.com + resources: + - mysqlservers/status + verbs: + - get diff --git a/config/samples/azure_v1alpha2_mysqlserver.yaml b/config/samples/azure_v1alpha2_mysqlserver.yaml new file mode 100644 index 00000000000..f96ed87e9d1 --- /dev/null +++ b/config/samples/azure_v1alpha2_mysqlserver.yaml @@ -0,0 +1,25 @@ +apiVersion: azure.microsoft.com/v1alpha2 +kind: MySQLServer +metadata: + name: mysqlserver-verztest2 +spec: + location: eastus2 + resourceGroup: resourcegroup-mysqlverz + serverVersion: "8.0" + sslEnforcement: Enabled + minimalTLSVersion: TLS10 # Possible values include: 'TLS10', 'TLS11', 'TLS12', 'Disabled' + infrastructureEncryption: Enabled # Possible values include: Enabled, Disabled + createMode: Default # Possible values include: Default, Replica, PointInTimeRestore (not implemented), GeoRestore (not implemented) + sku: + name: GP_Gen5_4 # tier + family + cores eg. - B_Gen4_1, GP_Gen5_4 + tier: GeneralPurpose # possible values - 'Basic', 'GeneralPurpose', 'MemoryOptimized' + family: Gen5 + size: "51200" + capacity: 4 + # Optional Backup Retention Config + storageProfile: + backupRetentionDays: 10 + geoRedundantBackup: Disabled # or Enabled + storageMB: 200 # max storage + storageAutogrow: Disabled # or Enabled + \ No newline at end of file diff --git a/controllers/azuresql_combined_test.go b/controllers/azuresql_combined_test.go index 434be02bb8a..d1ec46604a4 100644 --- a/controllers/azuresql_combined_test.go +++ b/controllers/azuresql_combined_test.go @@ -11,6 +11,7 @@ import ( "testing" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1beta1" "github.com/stretchr/testify/assert" helpers "github.com/Azure/azure-service-operator/pkg/helpers" @@ -38,10 +39,10 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) { sqlServerNamespacedName2 := types.NamespacedName{Name: sqlServerTwoName, Namespace: "default"} // Create the SqlServer object and expect the Reconcile to be created - sqlServerInstance := azurev1alpha1.NewAzureSQLServer(sqlServerNamespacedName, rgName, rgLocation) + sqlServerInstance := v1beta1.NewAzureSQLServer(sqlServerNamespacedName, rgName, rgLocation) // Send request for 2nd server (failovergroup test) before waiting on first server - sqlServerInstance2 := azurev1alpha1.NewAzureSQLServer(sqlServerNamespacedName2, rgName, rgLocation2) + sqlServerInstance2 := v1beta1.NewAzureSQLServer(sqlServerNamespacedName2, rgName, rgLocation2) // create and wait RequireInstance(ctx, t, tc, sqlServerInstance) @@ -60,7 +61,7 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) { }, tc.timeoutFast, tc.retry, "wait for server to have secret") sqlDatabaseName := GenerateTestResourceNameWithRandom("sqldatabase", 10) - var sqlDatabaseInstance *azurev1alpha1.AzureSqlDatabase + var sqlDatabaseInstance *v1beta1.AzureSqlDatabase sqlFirewallRuleNamespacedNameLocal := types.NamespacedName{ Name: GenerateTestResourceNameWithRandom("sqlfwr-local", 10), @@ -71,8 +72,8 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) { Namespace: "default", } - var sqlFirewallRuleInstanceLocal *azurev1alpha1.AzureSqlFirewallRule - var sqlFirewallRuleInstanceRemote *azurev1alpha1.AzureSqlFirewallRule + var sqlFirewallRuleInstanceLocal *v1beta1.AzureSqlFirewallRule + var sqlFirewallRuleInstanceRemote *v1beta1.AzureSqlFirewallRule // run sub tests that require 1 sql server ---------------------------------- t.Run("group1", func(t *testing.T) { @@ -92,12 +93,12 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) { t.Parallel() // Create the SqlDatabase object and expect the Reconcile to be created - sqlDatabaseInstance = &azurev1alpha1.AzureSqlDatabase{ + sqlDatabaseInstance = &v1beta1.AzureSqlDatabase{ ObjectMeta: metav1.ObjectMeta{ Name: sqlDatabaseName, Namespace: "default", }, - Spec: azurev1alpha1.AzureSqlDatabaseSpec{ + Spec: v1beta1.AzureSqlDatabaseSpec{ Location: rgLocation, ResourceGroup: rgName, Server: sqlServerName, @@ -114,7 +115,7 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) { t.Parallel() // Create the SqlFirewallRule object and expect the Reconcile to be created - sqlFirewallRuleInstanceLocal = azurev1alpha1.NewAzureSQLFirewallRule( + sqlFirewallRuleInstanceLocal = v1beta1.NewAzureSQLFirewallRule( sqlFirewallRuleNamespacedNameLocal, rgName, sqlServerName, @@ -129,7 +130,7 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) { t.Parallel() // Create the SqlFirewallRule object and expect the Reconcile to be created - sqlFirewallRuleInstanceRemote = azurev1alpha1.NewAzureSQLFirewallRule( + sqlFirewallRuleInstanceRemote = v1beta1.NewAzureSQLFirewallRule( sqlFirewallRuleNamespacedNameRemote, rgName, sqlServerName, @@ -316,7 +317,7 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) { assert.Equal(oldSecret["username"], newSecret["username"], "usernames should be the same") }) - var sqlFailoverGroupInstance *azurev1alpha1.AzureSqlFailoverGroup + var sqlFailoverGroupInstance *v1beta1.AzureSqlFailoverGroup sqlFailoverGroupName := GenerateTestResourceNameWithRandom("sqlfog-dev", 10) sqlFailoverGroupNamespacedName := types.NamespacedName{Name: sqlFailoverGroupName, Namespace: "default"} @@ -372,12 +373,12 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) { t.Parallel() // Create the SqlFailoverGroup object and expect the Reconcile to be created - sqlFailoverGroupInstance = &azurev1alpha1.AzureSqlFailoverGroup{ + sqlFailoverGroupInstance = &v1beta1.AzureSqlFailoverGroup{ ObjectMeta: metav1.ObjectMeta{ Name: sqlFailoverGroupNamespacedName.Name, Namespace: sqlFailoverGroupNamespacedName.Namespace, }, - Spec: azurev1alpha1.AzureSqlFailoverGroupSpec{ + Spec: v1beta1.AzureSqlFailoverGroupSpec{ Location: rgLocation, ResourceGroup: rgName, Server: sqlServerName, diff --git a/controllers/azuresqldatabase_controller.go b/controllers/azuresqldatabase_controller.go index 5c3216dc6e5..750d39bee22 100644 --- a/controllers/azuresqldatabase_controller.go +++ b/controllers/azuresqldatabase_controller.go @@ -4,8 +4,7 @@ package controllers import ( - azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" - + "github.com/Azure/azure-service-operator/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" ) @@ -19,12 +18,12 @@ type AzureSqlDatabaseReconciler struct { // Reconcile function does the main reconciliation loop of the operator func (r *AzureSqlDatabaseReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { - return r.Reconciler.Reconcile(req, &azurev1alpha1.AzureSqlDatabase{}) + return r.Reconciler.Reconcile(req, &v1beta1.AzureSqlDatabase{}) } // SetupWithManager function sets up the functions with the controller func (r *AzureSqlDatabaseReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&azurev1alpha1.AzureSqlDatabase{}). + For(&v1beta1.AzureSqlDatabase{}). Complete(r) } diff --git a/controllers/azuresqldatabase_controller_test.go b/controllers/azuresqldatabase_controller_test.go index 7601267edb3..54d0db9ad58 100644 --- a/controllers/azuresqldatabase_controller_test.go +++ b/controllers/azuresqldatabase_controller_test.go @@ -9,8 +9,7 @@ import ( "context" "testing" - azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" - + "github.com/Azure/azure-service-operator/api/v1beta1" "github.com/Azure/azure-service-operator/pkg/errhelp" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -26,12 +25,12 @@ func TestAzureSqlDatabaseControllerNoResourceGroup(t *testing.T) { sqlDatabaseName := GenerateTestResourceNameWithRandom("sqldatabase-dev", 10) // Create the SqlDatabase object and expect the Reconcile to be created - sqlDatabaseInstance := &azurev1alpha1.AzureSqlDatabase{ + sqlDatabaseInstance := &v1beta1.AzureSqlDatabase{ ObjectMeta: metav1.ObjectMeta{ Name: sqlDatabaseName, Namespace: "default", }, - Spec: azurev1alpha1.AzureSqlDatabaseSpec{ + Spec: v1beta1.AzureSqlDatabaseSpec{ Location: rgLocation, ResourceGroup: GenerateTestResourceNameWithRandom("rg-test-srv", 10), Server: sqlServerName, @@ -55,12 +54,12 @@ func TestAzureSqlDatabaseControllerNoServer(t *testing.T) { sqlDatabaseName := GenerateTestResourceNameWithRandom("sqldatabase-dev", 10) // Create the SqlDatabase object and expect the Reconcile to be created - sqlDatabaseInstance := &azurev1alpha1.AzureSqlDatabase{ + sqlDatabaseInstance := &v1beta1.AzureSqlDatabase{ ObjectMeta: metav1.ObjectMeta{ Name: sqlDatabaseName, Namespace: "default", }, - Spec: azurev1alpha1.AzureSqlDatabaseSpec{ + Spec: v1beta1.AzureSqlDatabaseSpec{ Location: rgLocation, ResourceGroup: rgName, Server: sqlServerName, diff --git a/controllers/azuresqlfailovergroup_controller.go b/controllers/azuresqlfailovergroup_controller.go index b23e5e75112..9290d2a38bf 100644 --- a/controllers/azuresqlfailovergroup_controller.go +++ b/controllers/azuresqlfailovergroup_controller.go @@ -4,9 +4,8 @@ package controllers import ( + "github.com/Azure/azure-service-operator/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" - - azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" ) // AzureSqlFailoverGroupReconciler reconciles a AzureSqlFailoverGroup object @@ -19,11 +18,11 @@ type AzureSqlFailoverGroupReconciler struct { // Reconcile function does the main reconciliation loop of the operator func (r *AzureSqlFailoverGroupReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { - return r.Reconciler.Reconcile(req, &azurev1alpha1.AzureSqlFailoverGroup{}) + return r.Reconciler.Reconcile(req, &v1beta1.AzureSqlFailoverGroup{}) } func (r *AzureSqlFailoverGroupReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&azurev1alpha1.AzureSqlFailoverGroup{}). + For(&v1beta1.AzureSqlFailoverGroup{}). Complete(r) } diff --git a/controllers/azuresqlfailovergroup_controller_test.go b/controllers/azuresqlfailovergroup_controller_test.go index 23248104150..5bfe283bd40 100644 --- a/controllers/azuresqlfailovergroup_controller_test.go +++ b/controllers/azuresqlfailovergroup_controller_test.go @@ -9,8 +9,7 @@ import ( "context" "testing" - azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" - + "github.com/Azure/azure-service-operator/api/v1beta1" "github.com/Azure/azure-service-operator/pkg/errhelp" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -35,12 +34,12 @@ func TestAzureSqlFailoverGroupControllerNoResourceGroup(t *testing.T) { sqlFailoverGroupName := GenerateTestResourceNameWithRandom("sqlfog-dev", 10) // Create the SqlFailoverGroup object and expect the Reconcile to be created - sqlFailoverGroupInstance := &azurev1alpha1.AzureSqlFailoverGroup{ + sqlFailoverGroupInstance := &v1beta1.AzureSqlFailoverGroup{ ObjectMeta: metav1.ObjectMeta{ Name: sqlFailoverGroupName, Namespace: "default", }, - Spec: azurev1alpha1.AzureSqlFailoverGroupSpec{ + Spec: v1beta1.AzureSqlFailoverGroupSpec{ Location: rgLocation1, ResourceGroup: GenerateTestResourceNameWithRandom("rg-fake", 10), Server: sqlServerOneName, diff --git a/controllers/azuresqlfirewallrule_controller.go b/controllers/azuresqlfirewallrule_controller.go index 6fb0c17586e..dc85507c6a3 100644 --- a/controllers/azuresqlfirewallrule_controller.go +++ b/controllers/azuresqlfirewallrule_controller.go @@ -6,7 +6,7 @@ package controllers import ( ctrl "sigs.k8s.io/controller-runtime" - azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1beta1" ) // AzureSqlFirewallRuleReconciler reconciles a AzureSqlFirewallRule object @@ -19,12 +19,12 @@ type AzureSqlFirewallRuleReconciler struct { // Reconcile function does the main reconciliation loop of the operator func (r *AzureSqlFirewallRuleReconciler) Reconcile(req ctrl.Request) (result ctrl.Result, err error) { - return r.Reconciler.Reconcile(req, &azurev1alpha1.AzureSqlFirewallRule{}) + return r.Reconciler.Reconcile(req, &v1beta1.AzureSqlFirewallRule{}) } // SetupWithManager function sets up the functions with the controller func (r *AzureSqlFirewallRuleReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&azurev1alpha1.AzureSqlFirewallRule{}). + For(&v1beta1.AzureSqlFirewallRule{}). Complete(r) } diff --git a/controllers/azuresqlfirewallrule_controller_test.go b/controllers/azuresqlfirewallrule_controller_test.go index eebbe717721..5f824f105d1 100644 --- a/controllers/azuresqlfirewallrule_controller_test.go +++ b/controllers/azuresqlfirewallrule_controller_test.go @@ -9,8 +9,7 @@ import ( "context" "testing" - azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" - + "github.com/Azure/azure-service-operator/api/v1beta1" "github.com/Azure/azure-service-operator/pkg/errhelp" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -26,12 +25,12 @@ func TestAzureSqlFirewallRuleControllerNoResourceGroup(t *testing.T) { sqlFirewallRuleName := GenerateTestResourceNameWithRandom("fwrule-dev", 10) // Create the SqlFirewallRule object and expect the Reconcile to be created - sqlFirewallRuleInstance := &azurev1alpha1.AzureSqlFirewallRule{ + sqlFirewallRuleInstance := &v1beta1.AzureSqlFirewallRule{ ObjectMeta: metav1.ObjectMeta{ Name: sqlFirewallRuleName, Namespace: "default", }, - Spec: azurev1alpha1.AzureSqlFirewallRuleSpec{ + Spec: v1beta1.AzureSqlFirewallRuleSpec{ ResourceGroup: GenerateTestResourceNameWithRandom("rg-fake-srv", 10), Server: sqlServerName, StartIPAddress: "0.0.0.0", diff --git a/controllers/azuresqlserver_controller.go b/controllers/azuresqlserver_controller.go index a05419a1fab..fa2d0292836 100644 --- a/controllers/azuresqlserver_controller.go +++ b/controllers/azuresqlserver_controller.go @@ -6,7 +6,7 @@ package controllers import ( ctrl "sigs.k8s.io/controller-runtime" - azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1beta1" ) // AzureSqlServerReconciler reconciles an AzureSqlServer object @@ -18,11 +18,11 @@ type AzureSqlServerReconciler struct { // +kubebuilder:rbac:groups=azure.microsoft.com,resources=azuresqlservers/status,verbs=get;update;patch func (r *AzureSqlServerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { - return r.Reconciler.Reconcile(req, &azurev1alpha1.AzureSqlServer{}) + return r.Reconciler.Reconcile(req, &v1beta1.AzureSqlServer{}) } func (r *AzureSqlServerReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&azurev1alpha1.AzureSqlServer{}). + For(&v1beta1.AzureSqlServer{}). Complete(r) } diff --git a/controllers/azuresqlserver_controller_test.go b/controllers/azuresqlserver_controller_test.go index 86e42e0e420..9fe41c52d51 100644 --- a/controllers/azuresqlserver_controller_test.go +++ b/controllers/azuresqlserver_controller_test.go @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -// +build all azuresqlserver +// +build all azuresqlserver asql package controllers @@ -9,7 +9,7 @@ import ( "context" "testing" - azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1beta1" "github.com/Azure/azure-service-operator/pkg/errhelp" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -22,12 +22,12 @@ func TestAzureSqlServerControllerNoResourceGroup(t *testing.T) { sqlServerName := GenerateTestResourceNameWithRandom("sqlserver-dev", 10) // Create the SqlServer object and expect the Reconcile to be created - sqlServerInstance := &azurev1alpha1.AzureSqlServer{ + sqlServerInstance := &v1beta1.AzureSqlServer{ ObjectMeta: metav1.ObjectMeta{ Name: sqlServerName, Namespace: "default", }, - Spec: azurev1alpha1.AzureSqlServerSpec{ + Spec: v1beta1.AzureSqlServerSpec{ Location: tc.resourceGroupLocation, ResourceGroup: GenerateTestResourceNameWithRandom("rg-fake-dev", 10), }, diff --git a/controllers/blobcontainer_controller.go b/controllers/blobcontainer_controller.go index 8ed0132060b..fa9908e95b9 100644 --- a/controllers/blobcontainer_controller.go +++ b/controllers/blobcontainer_controller.go @@ -4,9 +4,8 @@ package controllers import ( + "github.com/Azure/azure-service-operator/api/v1alpha2" ctrl "sigs.k8s.io/controller-runtime" - - azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" ) const blobContainerFinalizerName = "blobcontainer.finalizers.com" @@ -20,11 +19,11 @@ type BlobContainerReconciler struct { // +kubebuilder:rbac:groups=azure.microsoft.com,resources=blobcontainers/status,verbs=get;update;patch func (r *BlobContainerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { - return r.Reconciler.Reconcile(req, &azurev1alpha1.BlobContainer{}) + return r.Reconciler.Reconcile(req, &v1alpha2.BlobContainer{}) } func (r *BlobContainerReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&azurev1alpha1.BlobContainer{}). + For(&v1alpha2.BlobContainer{}). Complete(r) } diff --git a/controllers/blobcontainer_controller_test.go b/controllers/blobcontainer_controller_test.go index 7289729ea30..cabbcb8e114 100644 --- a/controllers/blobcontainer_controller_test.go +++ b/controllers/blobcontainer_controller_test.go @@ -12,7 +12,8 @@ import ( s "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage" "github.com/Azure/go-autorest/autorest/to" - azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1alpha2" "github.com/Azure/azure-service-operator/pkg/errhelp" helpers "github.com/Azure/azure-service-operator/pkg/helpers" @@ -37,15 +38,15 @@ func TestBlobContainerControlleNoResourceGroup(t *testing.T) { resourceGroupName := GenerateTestResourceNameWithRandom("rg", 10) // Create Storage account - saInstance := &azurev1alpha1.StorageAccount{ + saInstance := &v1alpha1.StorageAccount{ ObjectMeta: metav1.ObjectMeta{ Name: saName, Namespace: "default", }, - Spec: azurev1alpha1.StorageAccountSpec{ + Spec: v1alpha1.StorageAccountSpec{ Location: tc.resourceGroupLocation, ResourceGroup: tc.resourceGroupName, - Sku: azurev1alpha1.StorageAccountSku{ + Sku: v1alpha1.StorageAccountSku{ Name: "Standard_RAGRS", }, Kind: "StorageV2", @@ -55,12 +56,12 @@ func TestBlobContainerControlleNoResourceGroup(t *testing.T) { } EnsureInstance(ctx, t, tc, saInstance) - blobContainerInstance := &azurev1alpha1.BlobContainer{ + blobContainerInstance := &v1alpha2.BlobContainer{ ObjectMeta: metav1.ObjectMeta{ Name: blobContainerName, Namespace: "default", }, - Spec: azurev1alpha1.BlobContainerSpec{ + Spec: v1alpha2.BlobContainerSpec{ Location: rgLocation, ResourceGroup: resourceGroupName, AccountName: saName, @@ -89,12 +90,12 @@ func TestTestBlobContainerControllerNoStorageAccount(t *testing.T) { blobContainerName := GenerateTestResourceNameWithRandom("bc", 10) storageAccountName := helpers.FillWithRandom(GenerateAlphaNumTestResourceName("sa"), 24) - blobContainerInstance := &azurev1alpha1.BlobContainer{ + blobContainerInstance := &v1alpha2.BlobContainer{ ObjectMeta: metav1.ObjectMeta{ Name: blobContainerName, Namespace: "default", }, - Spec: azurev1alpha1.BlobContainerSpec{ + Spec: v1alpha2.BlobContainerSpec{ Location: rgLocation, ResourceGroup: rgName, AccountName: storageAccountName, diff --git a/controllers/eventhub_storageaccount_controller_test.go b/controllers/eventhub_storageaccount_controller_test.go index 94882a5016d..4ddc63929bf 100644 --- a/controllers/eventhub_storageaccount_controller_test.go +++ b/controllers/eventhub_storageaccount_controller_test.go @@ -11,6 +11,7 @@ import ( s "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1alpha2" "github.com/Azure/azure-service-operator/pkg/errhelp" @@ -223,12 +224,12 @@ func TestEventHubCapture_StorageAccountAndBlob_Controllers(t *testing.T) { EnsureInstance(ctx, t, tc, saInstance) // Create blob container - blobContainerInstance := &azurev1alpha1.BlobContainer{ + blobContainerInstance := &v1alpha2.BlobContainer{ ObjectMeta: metav1.ObjectMeta{ Name: bcName, Namespace: "default", }, - Spec: azurev1alpha1.BlobContainerSpec{ + Spec: v1alpha2.BlobContainerSpec{ Location: rgLocation, ResourceGroup: rgName, AccountName: saName, diff --git a/controllers/mysql_combined_test.go b/controllers/mysql_combined_test.go index 1e570f76783..1b118d19489 100644 --- a/controllers/mysql_combined_test.go +++ b/controllers/mysql_combined_test.go @@ -12,6 +12,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1alpha2" ) func TestMySQLHappyPath(t *testing.T) { @@ -26,12 +27,12 @@ func TestMySQLHappyPath(t *testing.T) { mySQLReplicaName := GenerateTestResourceNameWithRandom("mysql-rep", 10) // Create the mySQLServer object and expect the Reconcile to be created - mySQLServerInstance := azurev1alpha1.NewDefaultMySQLServer(mySQLServerName, rgName, rgLocation) + mySQLServerInstance := v1alpha2.NewDefaultMySQLServer(mySQLServerName, rgName, rgLocation) RequireInstance(ctx, t, tc, mySQLServerInstance) // Create a mySQL replica - mySQLReplicaInstance := azurev1alpha1.NewReplicaMySQLServer(mySQLReplicaName, rgName, rgLocation, mySQLServerInstance.Status.ResourceId) + mySQLReplicaInstance := v1alpha2.NewReplicaMySQLServer(mySQLReplicaName, rgName, rgLocation, mySQLServerInstance.Status.ResourceId) EnsureInstance(ctx, t, tc, mySQLReplicaInstance) diff --git a/controllers/mysqlserver_controller.go b/controllers/mysqlserver_controller.go index 770fb388102..65f12e54b1a 100644 --- a/controllers/mysqlserver_controller.go +++ b/controllers/mysqlserver_controller.go @@ -4,9 +4,8 @@ package controllers import ( + "github.com/Azure/azure-service-operator/api/v1alpha2" ctrl "sigs.k8s.io/controller-runtime" - - azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" ) // MySQLServerReconciler reconciles a MySQLServer object @@ -18,11 +17,11 @@ type MySQLServerReconciler struct { // +kubebuilder:rbac:groups=azure.microsoft.com,resources=mysqlservers/status,verbs=get;update;patch func (r *MySQLServerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { - return r.Reconciler.Reconcile(req, &azurev1alpha1.MySQLServer{}) + return r.Reconciler.Reconcile(req, &v1alpha2.MySQLServer{}) } func (r *MySQLServerReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&azurev1alpha1.MySQLServer{}). + For(&v1alpha2.MySQLServer{}). Complete(r) } diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 1aff36b0c5a..073df4155fd 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -15,6 +15,8 @@ import ( "testing" "time" + kscheme "k8s.io/client-go/kubernetes/scheme" + k8sSecrets "github.com/Azure/azure-service-operator/pkg/secrets/kube" "k8s.io/client-go/rest" @@ -52,6 +54,8 @@ import ( telemetry "github.com/Azure/azure-service-operator/pkg/telemetry" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1alpha2" + "github.com/Azure/azure-service-operator/api/v1beta1" "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -108,10 +112,22 @@ func setup() error { return fmt.Errorf("rest config nil") } + err = kscheme.AddToScheme(scheme.Scheme) + if err != nil { + return err + } err = azurev1alpha1.AddToScheme(scheme.Scheme) if err != nil { return err } + err = v1alpha2.AddToScheme(scheme.Scheme) + if err != nil { + return err + } + err = v1beta1.AddToScheme(scheme.Scheme) + if err != nil { + return err + } var k8sManager ctrl.Manager diff --git a/go.sum b/go.sum index 24a2ed91b3c..f76b9eb8bff 100644 --- a/go.sum +++ b/go.sum @@ -43,6 +43,7 @@ github.com/Azure/go-autorest/tracing v0.1.0 h1:TRBxC5Pj/fIuh4Qob0ZpkggbfT8RC0Sub github.com/Azure/go-autorest/tracing v0.1.0/go.mod h1:ROEEAFwXycQw7Sn3DXNtEedEvdeRAgDr0izn4z5Ij88= github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= @@ -233,6 +234,7 @@ github.com/googleapis/gnostic v0.3.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTV github.com/googleapis/gnostic v0.3.1 h1:WeAefnSUHlBb0iJKwxFDZdbfGwkd7xRNuV+IpXMJhYk= github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU= github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= @@ -284,6 +286,7 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= @@ -418,7 +421,9 @@ github.com/sethvargo/go-password v0.1.2/go.mod h1:qKHfdSjT26DpHQWHWWR5+X4BI45jT3 github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= diff --git a/main.go b/main.go index 0b02b54f8be..4ee5f851f0a 100644 --- a/main.go +++ b/main.go @@ -774,6 +774,11 @@ func main() { setupLog.Error(err, "unable to create webhook", "webhook", "BlobContainer") os.Exit(1) } + + if err = (&azurev1alpha1.MySQLServer{}).SetupWebhookWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create webhook", "webhook", "MySQLServer") + os.Exit(1) + } // +kubebuilder:scaffold:builder setupLog.Info("starting manager") diff --git a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go index e6947b01aa1..50f2a48c15e 100644 --- a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go @@ -8,7 +8,9 @@ import ( "fmt" "strings" + "github.com/Azure/azure-service-operator/api/v1alpha1" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1beta1" "github.com/Azure/azure-service-operator/pkg/errhelp" "github.com/Azure/azure-service-operator/pkg/helpers" "github.com/Azure/azure-service-operator/pkg/resourcemanager" @@ -50,7 +52,7 @@ func (db *AzureSqlDbManager) Ensure(ctx context.Context, obj runtime.Object, opt azureSQLDatabaseProperties := azuresqlshared.SQLDatabaseProperties{ DatabaseName: dbName, - Edition: dbEdition, + Edition: v1alpha1.DBEdition(dbEdition), } instance.Status.Provisioning = true @@ -164,11 +166,12 @@ func (g *AzureSqlDbManager) GetStatus(obj runtime.Object) (*azurev1alpha1.ASOSta if err != nil { return nil, err } - return &instance.Status, nil + st := azurev1alpha1.ASOStatus(instance.Status) + return &st, nil } -func (*AzureSqlDbManager) convert(obj runtime.Object) (*azurev1alpha1.AzureSqlDatabase, error) { - local, ok := obj.(*azurev1alpha1.AzureSqlDatabase) +func (*AzureSqlDbManager) convert(obj runtime.Object) (*v1beta1.AzureSqlDatabase, error) { + local, ok := obj.(*v1beta1.AzureSqlDatabase) if !ok { return nil, fmt.Errorf("failed type assertion on kind: %s", obj.GetObjectKind().GroupVersionKind().String()) } diff --git a/pkg/resourcemanager/azuresql/azuresqlfailovergroup/azuresqlfailovergroup.go b/pkg/resourcemanager/azuresql/azuresqlfailovergroup/azuresqlfailovergroup.go index 2b9bcf7b5df..2f076012ccd 100644 --- a/pkg/resourcemanager/azuresql/azuresqlfailovergroup/azuresqlfailovergroup.go +++ b/pkg/resourcemanager/azuresql/azuresqlfailovergroup/azuresqlfailovergroup.go @@ -7,7 +7,7 @@ import ( "context" "net/http" - azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1beta1" azuresqlshared "github.com/Azure/azure-service-operator/pkg/resourcemanager/azuresql/azuresqlshared" "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" "github.com/Azure/azure-service-operator/pkg/secrets" @@ -168,7 +168,7 @@ func (sdk *AzureSqlFailoverGroupManager) CreateOrUpdateFailoverGroup(ctx context failoverGroup) } -func (f *AzureSqlFailoverGroupManager) GetOrPrepareSecret(ctx context.Context, instance *azurev1alpha1.AzureSqlFailoverGroup) (map[string][]byte, error) { +func (f *AzureSqlFailoverGroupManager) GetOrPrepareSecret(ctx context.Context, instance *v1beta1.AzureSqlFailoverGroup) (map[string][]byte, error) { failovergroupname := instance.ObjectMeta.Name azuresqlprimaryserver := instance.Spec.Server azuresqlsecondaryserver := instance.Spec.SecondaryServer diff --git a/pkg/resourcemanager/azuresql/azuresqlfailovergroup/azuresqlfailovergroup_reconcile.go b/pkg/resourcemanager/azuresql/azuresqlfailovergroup/azuresqlfailovergroup_reconcile.go index 4a32fe22bff..597897c9502 100644 --- a/pkg/resourcemanager/azuresql/azuresqlfailovergroup/azuresqlfailovergroup_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqlfailovergroup/azuresqlfailovergroup_reconcile.go @@ -7,7 +7,9 @@ import ( "context" "fmt" + "github.com/Azure/azure-service-operator/api/v1alpha1" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1beta1" "github.com/Azure/azure-service-operator/pkg/errhelp" "github.com/Azure/azure-service-operator/pkg/helpers" "github.com/Azure/azure-service-operator/pkg/resourcemanager" @@ -37,7 +39,7 @@ func (fg *AzureSqlFailoverGroupManager) Ensure(ctx context.Context, obj runtime. serverName := instance.Spec.Server failoverGroupName := instance.ObjectMeta.Name sqlFailoverGroupProperties := azuresqlshared.SQLFailoverGroupProperties{ - FailoverPolicy: instance.Spec.FailoverPolicy, + FailoverPolicy: v1alpha1.ReadWriteEndpointFailoverPolicy(instance.Spec.FailoverPolicy), FailoverGracePeriod: instance.Spec.FailoverGracePeriod, SecondaryServer: instance.Spec.SecondaryServer, SecondaryServerResourceGroup: instance.Spec.SecondaryServerResourceGroup, @@ -203,11 +205,13 @@ func (g *AzureSqlFailoverGroupManager) GetStatus(obj runtime.Object) (*azurev1al if err != nil { return nil, err } - return &instance.Status, nil + st := azurev1alpha1.ASOStatus(instance.Status) + + return &st, nil } -func (fg *AzureSqlFailoverGroupManager) convert(obj runtime.Object) (*azurev1alpha1.AzureSqlFailoverGroup, error) { - local, ok := obj.(*azurev1alpha1.AzureSqlFailoverGroup) +func (fg *AzureSqlFailoverGroupManager) convert(obj runtime.Object) (*v1beta1.AzureSqlFailoverGroup, error) { + local, ok := obj.(*v1beta1.AzureSqlFailoverGroup) if !ok { return nil, fmt.Errorf("failed type assertion on kind: %s", obj.GetObjectKind().GroupVersionKind().String()) } diff --git a/pkg/resourcemanager/azuresql/azuresqlfirewallrule/azuresqlfirewallrule_reconcile.go b/pkg/resourcemanager/azuresql/azuresqlfirewallrule/azuresqlfirewallrule_reconcile.go index e6b1002fb9b..bac1577a9a7 100644 --- a/pkg/resourcemanager/azuresql/azuresqlfirewallrule/azuresqlfirewallrule_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqlfirewallrule/azuresqlfirewallrule_reconcile.go @@ -8,6 +8,7 @@ import ( "fmt" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1beta1" "github.com/Azure/azure-service-operator/pkg/errhelp" "github.com/Azure/azure-service-operator/pkg/helpers" "github.com/Azure/azure-service-operator/pkg/resourcemanager" @@ -123,11 +124,12 @@ func (g *AzureSqlFirewallRuleManager) GetStatus(obj runtime.Object) (*azurev1alp if err != nil { return nil, err } - return &instance.Status, nil + st := azurev1alpha1.ASOStatus(instance.Status) + return &st, nil } -func (fw *AzureSqlFirewallRuleManager) convert(obj runtime.Object) (*azurev1alpha1.AzureSqlFirewallRule, error) { - local, ok := obj.(*azurev1alpha1.AzureSqlFirewallRule) +func (fw *AzureSqlFirewallRuleManager) convert(obj runtime.Object) (*v1beta1.AzureSqlFirewallRule, error) { + local, ok := obj.(*v1beta1.AzureSqlFirewallRule) if !ok { return nil, fmt.Errorf("failed type assertion on kind: %s", obj.GetObjectKind().GroupVersionKind().String()) } diff --git a/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver_reconcile.go b/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver_reconcile.go index 0ab9549136e..c5f62d1d358 100644 --- a/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqlserver/azuresqlserver_reconcile.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1beta1" "github.com/Azure/azure-service-operator/pkg/errhelp" "github.com/Azure/azure-service-operator/pkg/helpers" "github.com/Azure/azure-service-operator/pkg/resourcemanager" @@ -117,6 +118,7 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object, // or if the hash wasnt empty and the Spec Hash matches the calculated hash // this indicates that we've already issued and update and its worth // checking to see if the server is there + if instance.Status.Provisioning || (!specHashWasEmpty && instance.Status.SpecHash == hash) { @@ -139,6 +141,10 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object, } } + if azerr.Type == errhelp.ResourceGroupNotFoundErrorCode { + return false, nil + } + // @Todo: ResourceNotFound should be handled if the time since the last PUT is unreasonable if azerr.Type != errhelp.ResourceNotFound { return false, err @@ -319,11 +325,12 @@ func (g *AzureSqlServerManager) GetStatus(obj runtime.Object) (*v1alpha1.ASOStat if err != nil { return nil, err } - return &instance.Status, nil + st := v1alpha1.ASOStatus(instance.Status) + return &st, nil } -func (s *AzureSqlServerManager) convert(obj runtime.Object) (*v1alpha1.AzureSqlServer, error) { - local, ok := obj.(*v1alpha1.AzureSqlServer) +func (s *AzureSqlServerManager) convert(obj runtime.Object) (*v1beta1.AzureSqlServer, error) { + local, ok := obj.(*v1beta1.AzureSqlServer) if !ok { return nil, fmt.Errorf("failed type assertion on kind: %s", obj.GetObjectKind().GroupVersionKind().String()) } diff --git a/pkg/resourcemanager/mysql/server/client.go b/pkg/resourcemanager/mysql/server/client.go index 22f78de705d..d6fb58241e8 100644 --- a/pkg/resourcemanager/mysql/server/client.go +++ b/pkg/resourcemanager/mysql/server/client.go @@ -70,44 +70,42 @@ func (m *MySQLServerClient) CreateServerIfValid(ctx context.Context, servername if !valid { return "", server, err } + var result mysql.ServersCreateFuture + var serverProperties mysql.BasicServerPropertiesForCreate + var skuData *mysql.Sku + if strings.EqualFold(createmode, "replica") { - result, _ = client.Create( - ctx, - resourcegroup, - servername, - mysql.ServerForCreate{ - Location: &location, - Tags: tags, - Properties: &mysql.ServerPropertiesForReplica{ - SourceServerID: to.StringPtr(sourceserver), - CreateMode: mysql.CreateModeReplica, - }, - }, - ) + serverProperties = &mysql.ServerPropertiesForReplica{ + SourceServerID: to.StringPtr(sourceserver), + CreateMode: mysql.CreateModeReplica, + } } else { + serverProperties = &mysql.ServerPropertiesForDefaultCreate{ + AdministratorLogin: &adminlogin, + AdministratorLoginPassword: &adminpassword, + Version: serverversion, + SslEnforcement: sslenforcement, + //StorageProfile: &mysql.StorageProfile{}, + CreateMode: mysql.CreateModeServerPropertiesForCreate, + } + skuData = &skuInfo - result, _ = client.Create( - ctx, - resourcegroup, - servername, - mysql.ServerForCreate{ - Location: &location, - Tags: tags, - Properties: &mysql.ServerPropertiesForDefaultCreate{ - AdministratorLogin: &adminlogin, - AdministratorLoginPassword: &adminpassword, - Version: serverversion, - SslEnforcement: sslenforcement, - //StorageProfile: &mysql.StorageProfile{}, - CreateMode: mysql.CreateModeServerPropertiesForCreate, - }, - Sku: &skuInfo, - }, - ) } + result, _ = client.Create( + ctx, + resourcegroup, + servername, + mysql.ServerForCreate{ + Location: &location, + Tags: tags, + Properties: serverProperties, + Sku: skuData, + }, + ) + res, err := result.Result(client) return result.PollingURL(), res, err diff --git a/pkg/resourcemanager/mysql/server/reconcile.go b/pkg/resourcemanager/mysql/server/reconcile.go index c8a75490add..789e5ddf825 100644 --- a/pkg/resourcemanager/mysql/server/reconcile.go +++ b/pkg/resourcemanager/mysql/server/reconcile.go @@ -11,6 +11,8 @@ import ( mysql "github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2017-12-01/mysql" "github.com/Azure/azure-service-operator/api/v1alpha1" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1alpha2" + azurev1alpha2 "github.com/Azure/azure-service-operator/api/v1alpha2" "github.com/Azure/azure-service-operator/pkg/errhelp" "github.com/Azure/azure-service-operator/pkg/helpers" "github.com/Azure/azure-service-operator/pkg/resourcemanager" @@ -250,12 +252,13 @@ func (m *MySQLServerClient) GetStatus(obj runtime.Object) (*v1alpha1.ASOStatus, if err != nil { return nil, err } - return &instance.Status, nil + st := v1alpha1.ASOStatus(instance.Status) + return &st, nil } // convert concerts a runtime.Object to a MySQLServer object -func (m *MySQLServerClient) convert(obj runtime.Object) (*v1alpha1.MySQLServer, error) { - local, ok := obj.(*v1alpha1.MySQLServer) +func (m *MySQLServerClient) convert(obj runtime.Object) (*v1alpha2.MySQLServer, error) { + local, ok := obj.(*v1alpha2.MySQLServer) if !ok { return nil, fmt.Errorf("failed type assertion on kind: %s", obj.GetObjectKind().GroupVersionKind().String()) } @@ -263,7 +266,7 @@ func (m *MySQLServerClient) convert(obj runtime.Object) (*v1alpha1.MySQLServer, } // AddServerCredsToSecrets saves the server's admin credentials in the secret store -func (m *MySQLServerClient) AddServerCredsToSecrets(ctx context.Context, secretName string, data map[string][]byte, instance *azurev1alpha1.MySQLServer) error { +func (m *MySQLServerClient) AddServerCredsToSecrets(ctx context.Context, secretName string, data map[string][]byte, instance *azurev1alpha2.MySQLServer) error { key := types.NamespacedName{ Name: secretName, Namespace: instance.Namespace, @@ -283,7 +286,7 @@ func (m *MySQLServerClient) AddServerCredsToSecrets(ctx context.Context, secretN } // UpdateSecretWithFullServerName updates the secret with the fully qualified server name -func (m *MySQLServerClient) UpdateServerNameInSecret(ctx context.Context, secretName string, data map[string][]byte, fullservername string, instance *azurev1alpha1.MySQLServer) error { +func (m *MySQLServerClient) UpdateServerNameInSecret(ctx context.Context, secretName string, data map[string][]byte, fullservername string, instance *azurev1alpha2.MySQLServer) error { key := types.NamespacedName{ Name: secretName, Namespace: instance.Namespace, @@ -305,7 +308,7 @@ func (m *MySQLServerClient) UpdateServerNameInSecret(ctx context.Context, secret } // GetOrPrepareSecret gets tje admin credentials if they are stored or generates some if not -func (m *MySQLServerClient) GetOrPrepareSecret(ctx context.Context, instance *azurev1alpha1.MySQLServer) (map[string][]byte, error) { +func (m *MySQLServerClient) GetOrPrepareSecret(ctx context.Context, instance *azurev1alpha2.MySQLServer) (map[string][]byte, error) { name := instance.Name createmode := instance.Spec.CreateMode diff --git a/pkg/resourcemanager/storages/blobcontainer/blob_container_reconcile.go b/pkg/resourcemanager/storages/blobcontainer/blob_container_reconcile.go index 619c6c453f5..4d4811d2ea8 100644 --- a/pkg/resourcemanager/storages/blobcontainer/blob_container_reconcile.go +++ b/pkg/resourcemanager/storages/blobcontainer/blob_container_reconcile.go @@ -9,6 +9,7 @@ import ( "strings" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" + "github.com/Azure/azure-service-operator/api/v1alpha2" "github.com/Azure/azure-service-operator/pkg/errhelp" "github.com/Azure/azure-service-operator/pkg/helpers" "github.com/Azure/azure-service-operator/pkg/resourcemanager" @@ -149,11 +150,12 @@ func (bc *AzureBlobContainerManager) GetStatus(obj runtime.Object) (*azurev1alph if err != nil { return nil, err } - return &instance.Status, nil + st := azurev1alpha1.ASOStatus(instance.Status) + return &st, nil } -func (bc *AzureBlobContainerManager) convert(obj runtime.Object) (*azurev1alpha1.BlobContainer, error) { - local, ok := obj.(*azurev1alpha1.BlobContainer) +func (bc *AzureBlobContainerManager) convert(obj runtime.Object) (*v1alpha2.BlobContainer, error) { + local, ok := obj.(*v1alpha2.BlobContainer) if !ok { return nil, fmt.Errorf("failed type assertion on kind: %s", obj.GetObjectKind().GroupVersionKind().String()) }