Skip to content

Commit

Permalink
Revert "Revert "Roll admin credentials for SQL Server""
Browse files Browse the repository at this point in the history
  • Loading branch information
frodopwns committed Oct 10, 2019
1 parent d7073d2 commit 9e4e87b
Show file tree
Hide file tree
Showing 12 changed files with 483 additions and 39 deletions.
3 changes: 3 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ resources:
- group: azure
version: v1
kind: ConsumerGroup
- group: azure
version: v1
kind: SqlAction
70 changes: 70 additions & 0 deletions api/v1/sqlaction_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
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.

// SqlActionSpec defines the desired state of SqlAction
type SqlActionSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
ResourceGroup string `json:"resourcegroup"`
ActionName string `json:"actionname"`
ServerName string `json:"servername"`
}

// SqlActionStatus defines the observed state of SqlAction
type SqlActionStatus 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"`
Message string `json:"state,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// SqlAction is the Schema for the sqlactions API
type SqlAction struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec SqlActionSpec `json:"spec,omitempty"`
Status SqlActionStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// SqlActionList contains a list of SqlAction
type SqlActionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []SqlAction `json:"items"`
}

func init() {
SchemeBuilder.Register(&SqlAction{}, &SqlActionList{})
}

func (s *SqlAction) IsSubmitted() bool {
return s.Status.Provisioned || s.Status.Provisioning
}
4 changes: 4 additions & 0 deletions api/v1/sqlserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ func init() {
func (s *SqlServer) IsSubmitted() bool {
return s.Status.Provisioned || s.Status.Provisioning
}

func (s *SqlServer) IsProvisioned() bool {
return s.Status.Provisioned
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: keyvaults.azure.microsoft.com
name: sqlactions.azure.microsoft.com
spec:
group: azure.microsoft.com
names:
kind: KeyVault
plural: keyvaults
kind: SqlAction
plural: sqlactions
scope: ""
subresources:
status: {}
validation:
openAPIV3Schema:
description: KeyVault is the Schema for the keyvaults API
description: SqlAction is the Schema for the sqlactions API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand Down Expand Up @@ -399,23 +399,33 @@ spec:
type: string
type: object
spec:
description: KeyVaultSpec defines the desired state of KeyVault
description: SqlActionSpec defines the desired state of SqlAction
properties:
location:
actionname:
type: string
resourceGroup:
resourcegroup:
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Important: Run "make" to regenerate code after modifying this file'
type: string
servername:
type: string
required:
- location
- resourceGroup
- actionname
- resourcegroup
- servername
type: object
status:
description: KeyVaultStatus defines the observed state of KeyVault
description: SqlActionStatus defines the observed state of SqlAction
properties:
provisioned:
type: boolean
provisioning:
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
of cluster Important: Run "make" to regenerate code after modifying
this file'
type: boolean
state:
type: string
type: object
type: object
versions:
Expand Down
8 changes: 8 additions & 0 deletions config/crd/patches/cainjection_in_sqlactions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
certmanager.k8s.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: sqlactions.azure.microsoft.com
17 changes: 17 additions & 0 deletions config/crd/patches/webhook_in_sqlactions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# The following patch enables conversion webhook for CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: sqlactions.azure.microsoft.com
spec:
conversion:
strategy: Webhook
webhookClientConfig:
# this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank,
# but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager)
caBundle: Cg==
service:
namespace: system
name: webhook-service
path: /convert
8 changes: 8 additions & 0 deletions config/samples/azure_v1_sqlaction.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: azure.microsoft.com/v1
kind: SqlAction
metadata:
name: sqlaction-name
spec:
resourcegroup: resourcegroup-sample-1907
actionname: rollcreds
servername: sqlserver-sample
Loading

0 comments on commit 9e4e87b

Please sign in to comment.