Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlDatabase controller changes #144

Merged
merged 20 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f29f02f
feat: implement keyvault controller
alexeldeib Aug 7, 2019
30d70a0
Ace's KV changes with updates
jananivMS Aug 14, 2019
f4eadbb
Added an event for the final successful provisioning
jananivMS Aug 14, 2019
4893ac3
Updated changes based on the PR comments
jananivMS Aug 19, 2019
add1b86
removing unwanted file
jananivMS Aug 19, 2019
a3f4985
making resource group name the one in the keyvault yaml
jananivMS Aug 19, 2019
145fdce
Merge branch 'jananivMS-jananiv/kvchanges'
jananivMS Aug 19, 2019
0e91b3e
Fix merge conflicts
jananivMS Aug 19, 2019
75fa72c
Merge branch 'azure-sql' of https://github.com/Azure/azure-service-op…
jananivMS Aug 20, 2019
8c85968
Merge branch 'azure-sql' of https://github.com/Azure/azure-service-op…
jananivMS Aug 20, 2019
1e26f3a
need to handled unexpected error types...like validation.error (#111)
frodopwns Aug 20, 2019
f5fd2cb
refactor tests (#90)
priyakumarank Aug 21, 2019
ea86ff6
Updates to KV controller from Ace (#80) (#112)
frodopwns Aug 21, 2019
fdd8991
Merge branch 'azure-sql' of https://github.com/Azure/azure-service-op…
jananivMS Aug 21, 2019
87da12d
adding sql server tests
jananivMS Aug 21, 2019
6202039
Merge branch 'master' of https://github.com/Azure/azure-service-opera…
jananivMS Aug 21, 2019
ec270c8
Merge branch 'azure-sql' of https://github.com/Azure/azure-service-op…
jananivMS Aug 22, 2019
3a8a20e
wwqw:wq
jananivMS Aug 22, 2019
9e81543
SqlDatabase controller changes
jananivMS Aug 26, 2019
c824ab5
Fix merge conflicts and PR comments
jananivMS Aug 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions api/v1/sqldatabase_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ limitations under the License.
package v1

import (
sql "github.com/Azure/azure-service-operator/pkg/resourcemanager/sqlclient"
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.

// SqlDatabaseSpec defines the desired state of SqlDatabase
type SqlDatabaseSpec 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"`
Location string `json:"location"`
ResourceGroup string `json:"resourcegroup,omitempty"`
Server string `json:"server"`
Edition sql.DBAddition `json:"edition"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS this the one that is meant to be Edition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

}

// SqlDatabaseStatus defines the observed state of SqlDatabase
Expand Down
79 changes: 79 additions & 0 deletions api/v1/sqldatabase_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*

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 (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"golang.org/x/net/context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

// These tests are written in BDD-style using Ginkgo framework. Refer to
// http://onsi.github.io/ginkgo to learn more.

var _ = Describe("SqlDatabase", func() {
var (
key types.NamespacedName
created, fetched *SqlDatabase
)

BeforeEach(func() {
// Add any setup steps that needs to be executed before each test
})

AfterEach(func() {
// Add any teardown steps that needs to be executed after each test
})

// Add Tests for OpenAPI validation (or additonal CRD features) specified in
// your API definition.
// Avoid adding tests for vanilla CRUD operations because they would
// test Kubernetes API server, which isn't the goal here.
Context("Create API", func() {

It("should create an object successfully", func() {

key = types.NamespacedName{
Name: "foo",
Namespace: "default",
}
created = &SqlDatabase{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
},
Spec: SqlDatabaseSpec{
//TODO: fill out
}}

By("creating an API obj")
Expect(k8sClient.Create(context.TODO(), created)).To(Succeed())

fetched = &SqlDatabase{}
Expect(k8sClient.Get(context.TODO(), key, fetched)).To(Succeed())
Expect(fetched).To(Equal(created))

By("deleting the created object")
Expect(k8sClient.Delete(context.TODO(), created)).To(Succeed())
Expect(k8sClient.Get(context.TODO(), key, created)).ToNot(Succeed())
})

})

})
79 changes: 79 additions & 0 deletions api/v1/sqlserver_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*

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 (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"golang.org/x/net/context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

// These tests are written in BDD-style using Ginkgo framework. Refer to
// http://onsi.github.io/ginkgo to learn more.

var _ = Describe("SqlServer", func() {
var (
key types.NamespacedName
created, fetched *SqlServer
)

BeforeEach(func() {
// Add any setup steps that needs to be executed before each test
})

AfterEach(func() {
// Add any teardown steps that needs to be executed after each test
})

// Add Tests for OpenAPI validation (or additonal CRD features) specified in
// your API definition.
// Avoid adding tests for vanilla CRUD operations because they would
// test Kubernetes API server, which isn't the goal here.
Context("Create API", func() {

It("should create an object successfully", func() {

key = types.NamespacedName{
Name: "foo",
Namespace: "default",
}
created = &SqlServer{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
},
Spec: SqlServerSpec{
//TODO: fill out
}}

By("creating an API obj")
Expect(k8sClient.Create(context.TODO(), created)).To(Succeed())

fetched = &SqlServer{}
Expect(k8sClient.Get(context.TODO(), key, fetched)).To(Succeed())
Expect(fetched).To(Equal(created))

By("deleting the created object")
Expect(k8sClient.Delete(context.TODO(), created)).To(Succeed())
Expect(k8sClient.Get(context.TODO(), key, created)).ToNot(Succeed())
})

})

})
4 changes: 4 additions & 0 deletions config/crd/bases/azure.microsoft.com_sqldatabases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ spec:
spec:
description: SqlDatabaseSpec defines the desired state of SqlDatabase
properties:
edition:
description: 'DBAddition - wraps: https://godoc.org/github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2015-05-01-preview/sql#DatabaseEdition'
type: integer
location:
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Important: Run "make" to regenerate code after modifying this file'
Expand All @@ -410,6 +413,7 @@ spec:
server:
type: string
required:
- edition
- location
- server
type: object
Expand Down
23 changes: 14 additions & 9 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ rules:
resources:
- resourcegroups/status
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- azure.microsoft.com
resources:
Expand All @@ -43,13 +47,9 @@ rules:
resources:
- sqlfirewallrules/status
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
Expand All @@ -63,13 +63,21 @@ rules:
- update
- watch
- apiGroups:
- azure.microsoft.com
- apps
resources:
- sqlservers/status
verbs:
- get
- patch
- update
- apiGroups:
- apps
resources:
- deployments/status
verbs:
- get
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
Expand Down Expand Up @@ -126,7 +134,7 @@ rules:
- create
- watch
- apiGroups:
- apps
- azure.microsoft.com
resources:
- eventhubnamespaces
verbs:
Expand Down Expand Up @@ -177,10 +185,7 @@ rules:
resources:
- keyvaults
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
Expand Down
8 changes: 5 additions & 3 deletions config/samples/azure_v1_sqldatabase.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
apiVersion: azure.microsoft.com/v1
kind: SqlDatabase
metadata:
name: sqldatabase-sample
name: sqldatabase-sample
spec:
# Add fields here
foo: bar
location: westus
resourcegroup: resourcegroup-sample-1907
edition: 0
server: sqlserver-sample
2 changes: 1 addition & 1 deletion config/samples/azure_v1_sqlserver.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: azure.microsoft.com/v1
kind: SqlServer
metadata:
name: holy-guacamole
name: sqlserver-sample
spec:
location: "westus"
resourcegroup: "resourcegroup-sample-1907"
Loading