-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1beta1 for azure sql failover groups
- Loading branch information
Showing
14 changed files
with
211 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha1 | ||
|
||
func (*AzureSqlFailoverGroup) Hub() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 azuresqlfailovergrouplog = logf.Log.WithName("azuresqlfailovergroup-resource") | ||
|
||
func (r *AzureSqlFailoverGroup) SetupWebhookWithManager(mgr ctrl.Manager) error { | ||
return ctrl.NewWebhookManagedBy(mgr). | ||
For(r). | ||
Complete() | ||
} | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
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 | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
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. | ||
|
||
// 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"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// AzureSqlFailoverGroup is the Schema for the azuresqlfailovergroups API | ||
// +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" | ||
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message" | ||
type AzureSqlFailoverGroup struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec AzureSqlFailoverGroupSpec `json:"spec,omitempty"` | ||
Status v1alpha1.ASOStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// AzureSqlFailoverGroupList contains a list of AzureSqlFailoverGroup | ||
type AzureSqlFailoverGroupList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []AzureSqlFailoverGroup `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&AzureSqlFailoverGroup{}, &AzureSqlFailoverGroupList{}) | ||
} | ||
|
||
func (s *AzureSqlFailoverGroup) IsSubmitted() bool { | ||
return s.Status.Provisioned || s.Status.Provisioning | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# permissions for end users to edit azuresqlfailovergroups. | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: azuresqlfailovergroup-editor-role | ||
rules: | ||
- apiGroups: | ||
- azure.microsoft.com | ||
resources: | ||
- azuresqlfailovergroups | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- azure.microsoft.com | ||
resources: | ||
- azuresqlfailovergroups/status | ||
verbs: | ||
- get |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# permissions for end users to view azuresqlfailovergroups. | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: azuresqlfailovergroup-viewer-role | ||
rules: | ||
- apiGroups: | ||
- azure.microsoft.com | ||
resources: | ||
- azuresqlfailovergroups | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- azure.microsoft.com | ||
resources: | ||
- azuresqlfailovergroups/status | ||
verbs: | ||
- get |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: azure.microsoft.com/v1beta1 | ||
kind: AzureSqlFailoverGroup | ||
metadata: | ||
name: azuresqlfailovergroup-sample | ||
spec: | ||
location: eastus | ||
resourceGroup: resourcegroup-azure-operators | ||
server: sqlserver-samplepri | ||
failoverpolicy: automatic | ||
failovergraceperiod: 30 | ||
secondaryserver: sqlserver-samplesec | ||
secondaryserverresourcegroup: resourcegroup-azure-operators | ||
databaselist: | ||
- "azuresqldatabase-sample" | ||
- "azuresqldatabase-sample2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters