Skip to content

Commit

Permalink
Make Appversion in operator.yaml templatable. (#1026)
Browse files Browse the repository at this point in the history
What this PR does / why we need it:
Make the version and appVersion variables in operator.yaml as a template to statefulset.yaml. This is still a WIP, and creating this PR as I need guidance in completing this.

Fixes #871
  • Loading branch information
sivaramsk authored and alenkacz committed Nov 6, 2019
1 parent 62c4475 commit 9fd189a
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pkg/apis/kudo/v1beta1/operatorversion_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import (
// OperatorVersionSpec defines the desired state of OperatorVersion.
type OperatorVersionSpec struct {
// +optional
Operator corev1.ObjectReference `json:"operator,omitempty"`
Version string `json:"version,omitempty"`
Operator corev1.ObjectReference `json:"operator,omitempty"`
Version string `json:"version,omitempty"`
AppVersion string `json:"appVersion,omitempty"`

// Yaml captures a templated yaml list of elements that define the application operator instance.
Templates map[string]string `json:"templates,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/instance/instance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func (r *Reconciler) Reconcile(request ctrl.Request) (ctrl.Result, error) {
metadata := &engine.Metadata{
OperatorVersionName: ov.Name,
OperatorVersion: ov.Spec.Version,
AppVersion: ov.Spec.AppVersion,
ResourcesOwner: instance,
OperatorName: ov.Spec.Operator.Name,
InstanceNamespace: instance.Namespace,
Expand Down
1 change: 1 addition & 0 deletions pkg/engine/task/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func render(resourceNames []string, templates map[string]string, params map[stri
configs["PlanName"] = meta.PlanName
configs["PhaseName"] = meta.PhaseName
configs["StepName"] = meta.StepName
configs["AppVersion"] = meta.AppVersion

resources := map[string]string{}
engine := renderer.New()
Expand Down
1 change: 1 addition & 0 deletions pkg/engine/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Metadata struct {
OperatorName string
OperatorVersionName string
OperatorVersion string
AppVersion string

// the object that will own all the resources created by this execution
ResourcesOwner metav1.Object
Expand Down
1 change: 1 addition & 0 deletions pkg/kudoctl/packages/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ func (p *PackageFiles) getCRDs() (*Resources, error) {
Name: p.Operator.Name,
Kind: "Operator",
},
AppVersion: p.Operator.AppVersion,
Version: p.Operator.Version,
Templates: p.Templates,
Tasks: p.Operator.Tasks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ spec:
kind: Operator
# Add fields here
version: "0.1.0"
appVersion: "3.4.10"
parameters:
- name: cpus
description: Amount of cpu to provide to Zookeeper pods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ spec:
kind: Operator
# Add fields here
version: "0.1.0"
appVersion: "3.4.10"
parameters:
- name: cpus
description: Amount of cpu to provide to Zookeeper pods
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apiVersion: kudo.dev/v1beta1
name: "first-operator"
version: "0.1.0"
appVersion: "1.7.9"
kubernetesVersion: 1.13.0
maintainers:
- name: Your name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ spec:
spec:
containers:
- name: nginx
image: nginx:1.7.9
image: nginx:{{ .AppVersion }}
ports:
- containerPort: 80

0 comments on commit 9fd189a

Please sign in to comment.