Skip to content
This repository has been archived by the owner on Sep 25, 2020. It is now read-only.

Commit

Permalink
Create resources in the same namespace with WordpressInstance.
Browse files Browse the repository at this point in the history
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
  • Loading branch information
muvaf committed Sep 13, 2019
1 parent faa5a59 commit 7dfdffa
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions controllers/wordpressinstance_controller.go
Expand Up @@ -61,20 +61,14 @@ func (r *WordpressInstanceReconciler) Reconcile(req ctrl.Request) (ctrl.Result,
}

instanceUID := i.ObjectMeta.GetUID()
instanceNamespace := i.ObjectMeta.GetNamespace()

rawTemplate := `---
apiVersion: v1
kind: Namespace
metadata:
name: wordpresses
labels:
stack: sample-stack-wordpress
---
apiVersion: compute.crossplane.io/v1alpha1
kind: KubernetesCluster
metadata:
name: wordpress-cluster-{{ .UID }}
namespace: wordpresses
namespace: {{ .namespace }}
labels:
stack: sample-stack-wordpress
spec:
Expand All @@ -85,7 +79,7 @@ apiVersion: database.crossplane.io/v1alpha1
kind: MySQLInstance
metadata:
name: wordpress-mysql-{{ .UID }}
namespace: wordpresses
namespace: {{ .namespace }}
labels:
stack: sample-stack-wordpress
spec:
Expand All @@ -100,7 +94,7 @@ apiVersion: workload.crossplane.io/v1alpha1
kind: KubernetesApplication
metadata:
name: wordpress-app-{{ .UID }}
namespace: wordpresses
namespace: {{ .namespace }}
labels:
stack: sample-stack-wordpress
spec:
Expand Down Expand Up @@ -208,7 +202,8 @@ spec:
var sb strings.Builder

data := map[string]interface{}{
"UID": instanceUID,
"UID": instanceUID,
"namespace": instanceNamespace,
}

tmpl.Execute(&sb, data)
Expand Down

0 comments on commit 7dfdffa

Please sign in to comment.