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

fixing issues from merge #157

Merged
merged 14 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test: generate fmt vet manifests
go tool cover -html=coverage.txt -o cover.html
# Run tests with existing cluster
test-existing: generate fmt vet manifests
TEST_USE_EXISTING_CLUSTER=true go test -v -coverprofile=coverage-existing.txt -covermode count ./api/... ./controllers/... ./pkg/resourcemanager/eventhubs/... ./pkg/resourcemanager/resourcegroups/... 2>&1 | tee testlogs-existing.txt
TEST_USE_EXISTING_CLUSTER=true go test -test.parallel 3 -v -coverprofile=coverage-existing.txt -covermode count ./api/... ./controllers/... ./pkg/resourcemanager/eventhubs/... ./pkg/resourcemanager/resourcegroups/... 2>&1 | tee testlogs-existing.txt
go-junit-report < testlogs-existing.txt > report-existing.xml
go tool cover -html=coverage-existing.txt -o cover-existing.html

Expand All @@ -33,6 +33,13 @@ deploy: manifests
kubectl apply -f config/crd/bases
kustomize build config/default | kubectl apply -f -

update:
IMG="docker.io/controllertest:1" make ARGS="${ARGS}" docker-build
kind load docker-image docker.io/controllertest:1 --loglevel "trace"
make install
make deploy
sed -i'' -e 's@image: .*@image: '"IMAGE_URL"'@' ./config/default/manager_image_patch.yaml

delete:
kubectl delete -f config/crd/bases
kustomize build config/default | kubectl delete -f -
Expand All @@ -55,7 +62,7 @@ generate: controller-gen

# Build the docker image
docker-build:
docker build . -t ${IMG}
docker build . -t ${IMG} ${ARGS}
@echo "updating kustomize image patch file for manager resource"
sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ To Extend the operator `github.com/Azure/azure-service-operator`:
5. Generate code `make generate`
6. Update operator `controller\eventhub_controller.go`
7. Update tests and run `make test`
8. Build `make build`
9. Deploy `make deploy`
8. Deploy `make deploy`

If you make changes to the operator and want to update the deployment without recreating the cluster (when testing locally), you can use the `make update` to update your Azure Operator pod. If you need to rebuild the docker image without cache, use `make ARGS="--no-cache" update`.

## Contributing

Expand Down
2 changes: 2 additions & 0 deletions api/v1/eventhub_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type EventhubSpec struct {
Properties EventhubProperties `json:"properties,omitempty"`
ResourceGroup string `json:"resourcegroup,omitempty"`
AuthorizationRule EventhubAuthorizationRule `json:"authorizationrule,omitempty"`
// SecretName - Used to specify the name of the secret. Defaults to Event Hub name if omitted.
SecretName string `json:"secretname,omitempty"`
}

// EventhubStatus defines the observed state of Eventhub
Expand Down
8 changes: 4 additions & 4 deletions api/v1/sqldatabase_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (
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"`
Edition sql.DBAddition `json:"edition"`
Location string `json:"location"`
ResourceGroup string `json:"resourcegroup,omitempty"`
Server string `json:"server"`
Edition sql.DBEdition `json:"edition"`
}

// SqlDatabaseStatus defines the observed state of SqlDatabase
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/azure.microsoft.com_eventhubs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ spec:
type: object
resourcegroup:
type: string
secretname:
description: SecretName - Used to specify the name of the secret. Defaults
to Event Hub name if omitted.
type: string
required:
- location
type: object
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/azure.microsoft.com_sqldatabases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ 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'
description: 'DBEdition - 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
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/azure.microsoft.com_sqlfirewallrules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,16 @@ spec:
spec:
description: SqlFirewallRuleSpec defines the desired state of SqlFirewallRule
properties:
endipaddress:
type: string
location:
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Important: Run "make" to regenerate code after modifying this file'
type: string
resourcegroup:
type: string
startipaddress:
type: string
required:
- location
type: object
Expand Down
86 changes: 63 additions & 23 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- eventhubs
- consumergroups
verbs:
- create
- delete
Expand All @@ -21,15 +21,11 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- eventhubs/status
- resourcegroups/status
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- azure.microsoft.com
resources:
Expand All @@ -51,7 +47,7 @@ rules:
- patch
- update
- apiGroups:
- apps
- ""
resources:
- secrets
verbs:
Expand All @@ -62,26 +58,33 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- watch
- apiGroups:
- apps
resources:
- consumergroups
- deployments/status
verbs:
- get
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
- eventhubnamespaces
- eventhubnamespaces/status
verbs:
- get
- patch
- update
- apiGroups:
- apps
- azure.microsoft.com
resources:
- deployments
- keyvaults
verbs:
- create
- delete
Expand All @@ -93,38 +96,54 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- consumergroups/status
- keyvaults/status
verbs:
- get
- patch
- update
- apiGroups:
- ""
- azure.microsoft.com
resources:
- eventhubnamespaces/status
- resourcegroups
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- azure.microsoft.com
resources:
- eventhubs/status
- sqlservers
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
- azure.microsoft.com
resources:
- events
verbs:
- create
- watch
- patch
- apiGroups:
- azure.microsoft.com
resources:
- deployments
- eventhubs/status
verbs:
- get
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
- sqldatabases
verbs:
- create
- delete
Expand All @@ -136,7 +155,23 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- eventhubnamespaces
- sqlservers/status
verbs:
- get
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
- consumergroups/status
verbs:
- get
- patch
- update
- apiGroups:
- azure.microsoft.com
resources:
- eventhubs
verbs:
- create
- delete
Expand All @@ -148,7 +183,7 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- resourcegroups
- eventhubnamespaces
verbs:
- create
- delete
Expand All @@ -160,15 +195,20 @@ rules:
- apiGroups:
- azure.microsoft.com
resources:
- events
- sqldatabases/status
verbs:
- create
- get
- patch
- update
- apiGroups:
- apps
resources:
- keyvaults/status
- deployments
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
1 change: 1 addition & 0 deletions config/samples/azure_v1_eventhub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ spec:
- "Listen"
- "Manage"
- "Send"
secretname: "secret-stream-eventhub-sample"
16 changes: 10 additions & 6 deletions controllers/consumergroup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ import (
var _ = Describe("ConsumerGroup Controller", func() {

const timeout = time.Second * 240
var rgName string
var ehnName string
var ehName string

BeforeEach(func() {
// Add any setup steps that needs to be executed before each test
rgName = resourceGroupName
ehnName = eventhubNamespaceName
ehName = eventhubName

})

AfterEach(func() {
Expand All @@ -50,9 +57,6 @@ var _ = Describe("ConsumerGroup Controller", func() {
Context("Create and Delete", func() {
It("should create and delete consumer groups", func() {

resourceGroupName = "t-rg-dev-controller"
eventhubNamespaceName = "t-ns-dev-eh-ns"
eventhubName = "t-eh-dev-sample"
consumerGroupName := "t-cg-" + helpers.RandomString(10)

var err error
Expand All @@ -64,9 +68,9 @@ var _ = Describe("ConsumerGroup Controller", func() {
Namespace: "default",
},
Spec: azurev1.ConsumerGroupSpec{
NamespaceName: eventhubNamespaceName,
ResourceGroupName: resourceGroupName,
EventhubName: eventhubName,
NamespaceName: ehnName,
ResourceGroupName: rgName,
EventhubName: ehName,
},
}

Expand Down
Loading