Skip to content

Commit

Permalink
Merge pull request #3 from thatInfrastructureGuy/removeExtra
Browse files Browse the repository at this point in the history
Remove extra
  • Loading branch information
thatInfrastructureGuy authored Feb 10, 2020
2 parents 574a65d + 9cd19a5 commit d6692d4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ spec:
type: string
deploymentList:
type: string
image:
description: 'Important: Run "operator-sdk generate k8s" to regenerate
code after modifying this file Add custom validation using kubebuilder
tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html'
type: string
provider:
maxLength: 30
minLength: 1
Expand Down Expand Up @@ -67,11 +72,13 @@ spec:
status:
description: VaultSyncerStatus defines the observed state of VaultSyncer
properties:
dateUpdated:
secretName:
description: 'Important: Run "operator-sdk generate k8s" to regenerate
code after modifying this file Add custom validation using kubebuilder
tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html'
type: string
secretNamespace:
type: string
type: object
type: object
version: v1alpha1
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
serviceAccountName: vaultsync-operator
containers:
- name: vaultsync-operator
image: thatinfrastructureguy/vaultsync-operator:v0.0.1
image: thatinfrastructureguy/vaultsync-operator:v0.0.2
command:
- vaultsync-operator
imagePullPolicy: Always
Expand Down
4 changes: 3 additions & 1 deletion pkg/apis/operator/v1alpha1/vaultsyncer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
type VaultSyncerSpec struct {
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
// Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
Image string `json:"image,omitempty"`

// +kubebuilder:validation:MaxLength=30
// +kubebuilder:validation:MinLength=1
Expand All @@ -51,7 +52,8 @@ type VaultSyncerSpec struct {
type VaultSyncerStatus struct {
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
// Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
dateUpdated string `json:"dateUpdated,omitempty"`
SecretName string `json:"secretName,omitempty"`
SecretNamespace string `json:"secretNamespace,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
23 changes: 22 additions & 1 deletion pkg/controller/vaultsyncer/vaultsyncer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,30 @@ func (r *ReconcileVaultSyncer) Reconcile(request reconcile.Request) (reconcile.R
instance.Spec.ProviderCredsSecret = "provider-credentials"
}

if len(instance.Spec.Image) == 0 {
instance.Spec.Image = "thatinfrastructureguy/vaultsync:v0.0.14"
}

if len(instance.Spec.SecretName) == 0 {
instance.Spec.SecretName = instance.Spec.VaultName
}

if len(instance.Spec.SecretNamespace) == 0 {
instance.Spec.SecretNamespace = "default"
}

// Define a new Pod object
podObject := newPodForCR(instance)

// Update VaultSync Status
instance.Status.SecretName = instance.Spec.SecretName
instance.Status.SecretNamespace = instance.Spec.SecretNamespace
err = r.client.Status().Update(context.TODO(), instance)
if err != nil {
reqLogger.Error(err, "Failed to update VaultSyncer status")
return reconcile.Result{}, err
}

// Set VaultSyncer instance as the owner and controller
if err := controllerutil.SetControllerReference(instance, podObject, r.scheme); err != nil {
return reconcile.Result{}, err
Expand Down Expand Up @@ -161,7 +182,7 @@ func newPodForCR(cr *operatorv1alpha1.VaultSyncer) *corev1.Pod {
Containers: []corev1.Container{
{
Name: "vaultsync",
Image: "thatinfrastructureguy/vaultsync:v0.0.13",
Image: cr.Spec.Image,
Env: []corev1.EnvVar{
corev1.EnvVar{Name: "PROVIDER", Value: cr.Spec.Provider},
corev1.EnvVar{Name: "VAULT_NAME", Value: cr.Spec.VaultName},
Expand Down

0 comments on commit d6692d4

Please sign in to comment.