Skip to content

Commit

Permalink
Fixing merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
aka-msft committed Sep 6, 2019
2 parents 4398173 + 4069507 commit fa72a32
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 68 deletions.
92 changes: 44 additions & 48 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- sqlservers/status
- resourcegroups/status
verbs:
- get
- patch
- update
- apiGroups:
- apps
resources:
- cosmosdbs
- deployments
verbs:
- create
- delete
Expand All @@ -29,15 +29,15 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- cosmosdbs/status
- consumergroups/status
verbs:
- get
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
- sqlfirewallrules/status
- rediscaches
verbs:
- create
- delete
Expand All @@ -49,7 +49,7 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- storages
- keyvaults
verbs:
- create
- delete
Expand All @@ -61,18 +61,27 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- eventhubs/status
- sqlservers
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- azure.microsoft.com
resources:
- events
- eventhubs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- azure.microsoft.com
resources:
Expand All @@ -88,7 +97,7 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- sqlservers
- sqlfirewallrules
verbs:
- create
- delete
Expand All @@ -100,19 +109,15 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- eventhubnamespaces
- storages/status
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- azure.microsoft.com
resources:
- resourcegroups
- consumergroups
verbs:
- create
- delete
Expand All @@ -124,7 +129,7 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- resourcegroups/status
- cosmosdbs
verbs:
- create
- delete
Expand All @@ -136,31 +141,31 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- sqlfirewallrules
- eventhubs/status
verbs:
- get
- patch
- update
- apiGroups:
- apps
- azure.microsoft.com
resources:
- deployments
- sqlfirewallrules/status
verbs:
- get
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
- eventhubnamespaces/status
- sqldatabases/status
verbs:
- get
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
- keyvaults
- eventhubnamespaces
verbs:
- create
- delete
Expand All @@ -172,31 +177,31 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- rediscaches
- eventhubnamespaces/status
verbs:
- get
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
- sqldatabases/status
- cosmosdbs/status
verbs:
- get
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
- consumergroups/status
- sqlservers/status
verbs:
- get
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
- keyvaults/status
- storages
verbs:
- create
- delete
Expand All @@ -208,35 +213,37 @@ rules:
- apiGroups:
- ""
resources:
- rediscaches/status
- events
verbs:
- get
- create
- watch
- apiGroups:
- azure.microsoft.com
resources:
- events
verbs:
- create
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
- storages/status
- keyvaults/status
verbs:
- get
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
- consumergroups
- rediscaches/status
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- azure.microsoft.com
resources:
- sqldatabases
- resourcegroups
verbs:
- create
- delete
Expand All @@ -248,14 +255,7 @@ rules:
- apiGroups:
- ""
resources:
- events
verbs:
- create
- watch
- apiGroups:
- azure.microsoft.com
resources:
- eventhubs
- secrets
verbs:
- create
- delete
Expand All @@ -265,14 +265,10 @@ rules:
- update
- watch
- apiGroups:
- ""
- apps
resources:
- secrets
- deployments/status
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
25 changes: 5 additions & 20 deletions controllers/sqlserver_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package controllers
import (
"context"
"fmt"
"math/rand"
"strings"
"time"

Expand All @@ -30,21 +29,22 @@ import (
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

azurev1 "github.com/Azure/azure-service-operator/api/v1"
<<<<<<< HEAD
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
=======
>>>>>>> 4069507d55113f1da40bf9b2029abb53b86caed9
)

// SqlServerReconciler reconciles a SqlServer object
type SqlServerReconciler struct {
client.Client
Log logr.Logger
Recorder record.EventRecorder
Scheme *runtime.Scheme
}

// +kubebuilder:rbac:groups=azure.microsoft.com,resources=sqlservers,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -139,8 +139,8 @@ func (r *SqlServerReconciler) reconcileExternal(instance *azurev1.SqlServer) err
}

sqlServerProperties := sql.SQLServerProperties{
AdministratorLogin: to.StringPtr(""),
AdministratorLoginPassword: to.StringPtr(""),
AdministratorLogin: to.StringPtr("iamadmin"),
AdministratorLoginPassword: to.StringPtr("generate_me_1234"),
}

// Check to see if secret already exists for admin username/password
Expand Down Expand Up @@ -284,18 +284,3 @@ func (r *SqlServerReconciler) deleteExternal(instance *azurev1.SqlServer) error
r.Recorder.Event(instance, "Normal", "Deleted", name+" deleted")
return nil
}

// helper function to generate username/password for secrets
func generateRandomString(n int) string {
rand.Seed(time.Now().UnixNano())

const characterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~!@#$%^&*()_+-=<>"

// TODO: add logic to enforce password policy rules for sql server
b := make([]byte, n)
for i := range b {
b[i] = characterBytes[rand.Intn(len(characterBytes))]
}

return string(b)
}

0 comments on commit fa72a32

Please # to comment.