summaryrefslogtreecommitdiffstats
path: root/src/orchestrator
diff options
context:
space:
mode:
Diffstat (limited to 'src/orchestrator')
-rw-r--r--src/orchestrator/api/instantiation_handler.go17
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/Chart.yaml4
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/Chart.yaml4
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/templates/service.yaml15
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/values.yaml17
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/Chart.yaml4
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/templates/service.yaml15
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/values.yaml35
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/templates/NOTES.txt1
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/templates/service.yaml22
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/values.yaml55
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/Chart.yaml4
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/Chart.yaml4
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/templates/service.yaml15
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/values.yaml17
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/Chart.yaml4
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/templates/service.yaml15
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/values.yaml35
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/delete.yaml22
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/templates/NOTES.txt1
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/templates/service.yaml22
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/values.yaml55
-rw-r--r--src/orchestrator/mock_files/mock_profiles/profile1/faulty-dest-manifest.yaml7
-rw-r--r--src/orchestrator/mock_files/mock_profiles/profile1/faulty-manifest.yaml8
-rw-r--r--src/orchestrator/mock_files/mock_profiles/profile1/faulty-src-manifest.yaml7
-rw-r--r--src/orchestrator/mock_files/mock_profiles/profile1/manifest.yaml7
-rw-r--r--src/orchestrator/mock_files/mock_profiles/profile1/override_values.yaml9
-rw-r--r--src/orchestrator/mock_files/mock_profiles/profile1/subdir/p1.yaml22
-rw-r--r--src/orchestrator/pkg/module/instantiation.go7
-rw-r--r--src/orchestrator/pkg/rtcontext/rtcontext_test.go4
-rw-r--r--src/orchestrator/utils/helm/helm.go35
-rw-r--r--src/orchestrator/utils/helm/helm_test.go203
-rw-r--r--src/orchestrator/utils/helm/profile_yaml.go (renamed from src/orchestrator/utils/profile_yaml.go)2
-rw-r--r--src/orchestrator/utils/types/types.go41
-rw-r--r--src/orchestrator/utils/utils.go (renamed from src/orchestrator/utils/util-functions.go)0
35 files changed, 658 insertions, 77 deletions
diff --git a/src/orchestrator/api/instantiation_handler.go b/src/orchestrator/api/instantiation_handler.go
index d9da2183..c95785f2 100644
--- a/src/orchestrator/api/instantiation_handler.go
+++ b/src/orchestrator/api/instantiation_handler.go
@@ -29,23 +29,6 @@ type instantiationHandler struct {
client moduleLib.InstantiationManager
}
-// func (h instantiationHandler) approveInstantiationHandler(w http.ResponseWriter, r *http.Request) {
-
-// vars := mux.Vars(r)
-// p := vars["project-name"]
-// ca := vars["composite-app-name"]
-// v := vars["composite-app-version"]
-// di := vars["deployment-intent-group-name"]
-
-// instantiateErr := h.client.ApproveInstantiation(p, ca, v, di)
-// if instantiateErr != nil {
-// http.Error(w, instantiateErr.Error(), http.StatusInternalServerError)
-// return
-// }
-
-// w.WriteHeader(http.StatusCreated)
-// }
-
func (h instantiationHandler) instantiateHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
diff --git a/src/orchestrator/mock_files/mock_charts/testchart1/Chart.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/Chart.yaml
new file mode 100644
index 00000000..91a641bd
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart1/Chart.yaml
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: testchart1
+version: 0.1.0
diff --git a/src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/Chart.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/Chart.yaml
new file mode 100644
index 00000000..be3edcef
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/Chart.yaml
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: subcharta
+version: 0.1.0
diff --git a/src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/templates/service.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/templates/service.yaml
new file mode 100644
index 00000000..fdf75aa9
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Chart.Name }}
+ labels:
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ protocol: TCP
+ name: {{ .Values.service.name }}
+ selector:
+ app: {{ .Chart.Name }}
diff --git a/src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/values.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/values.yaml
new file mode 100644
index 00000000..f0381ae6
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/values.yaml
@@ -0,0 +1,17 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+# subchartA
+service:
+ name: apache
+ type: ClusterIP
+ externalPort: 80
+ internalPort: 80
+SCAdata:
+ SCAbool: false
+ SCAfloat: 3.1
+ SCAint: 55
+ SCAstring: "jabba"
+ SCAnested1:
+ SCAnested2: true
+
diff --git a/src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/Chart.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/Chart.yaml
new file mode 100644
index 00000000..c3c6bbaf
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/Chart.yaml
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: subchartb
+version: 0.1.0
diff --git a/src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/templates/service.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/templates/service.yaml
new file mode 100644
index 00000000..fdf75aa9
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Chart.Name }}
+ labels:
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ protocol: TCP
+ name: {{ .Values.service.name }}
+ selector:
+ app: {{ .Chart.Name }}
diff --git a/src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/values.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/values.yaml
new file mode 100644
index 00000000..774fdd75
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/values.yaml
@@ -0,0 +1,35 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+service:
+ name: nginx
+ type: ClusterIP
+ externalPort: 80
+ internalPort: 80
+
+SCBdata:
+ SCBbool: true
+ SCBfloat: 7.77
+ SCBint: 33
+ SCBstring: "boba"
+
+exports:
+ SCBexported1:
+ SCBexported1A:
+ SCBexported1B: 1965
+
+ SCBexported2:
+ SCBexported2A: "blaster"
+
+global:
+ kolla:
+ nova:
+ api:
+ all:
+ port: 8774
+ metadata:
+ all:
+ port: 8775
+
+
+
diff --git a/src/orchestrator/mock_files/mock_charts/testchart1/templates/NOTES.txt b/src/orchestrator/mock_files/mock_charts/testchart1/templates/NOTES.txt
new file mode 100644
index 00000000..4bdf443f
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart1/templates/NOTES.txt
@@ -0,0 +1 @@
+Sample notes for {{ .Chart.Name }} \ No newline at end of file
diff --git a/src/orchestrator/mock_files/mock_charts/testchart1/templates/service.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/templates/service.yaml
new file mode 100644
index 00000000..e06d19b9
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart1/templates/service.yaml
@@ -0,0 +1,22 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Chart.Name }}
+ labels:
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+ namespace: "{{ .Release.Namespace }}"
+ release-name: "{{ .Release.Name }}"
+ release-is-upgrade: "{{ .Release.IsUpgrade }}"
+ release-is-install: "{{ .Release.IsInstall }}"
+ kube-version/major: "{{ .Capabilities.KubeVersion.Major }}"
+ kube-version/minor: "{{ .Capabilities.KubeVersion.Minor }}"
+ kube-version/gitversion: "v{{ .Capabilities.KubeVersion.Major }}.{{ .Capabilities.KubeVersion.Minor }}.0"
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ protocol: TCP
+ name: {{ .Values.service.name }}
+ selector:
+ app: {{ .Chart.Name }}
diff --git a/src/orchestrator/mock_files/mock_charts/testchart1/values.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/values.yaml
new file mode 100644
index 00000000..72d3fa5c
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart1/values.yaml
@@ -0,0 +1,55 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+# subchart1
+service:
+ name: nginx
+ type: ClusterIP
+ externalPort: 80
+ internalPort: 80
+
+
+SC1data:
+ SC1bool: true
+ SC1float: 3.14
+ SC1int: 100
+ SC1string: "dollywood"
+ SC1extra1: 11
+
+imported-chartA:
+ SC1extra2: 1.337
+
+overridden-chartA:
+ SCAbool: true
+ SCAfloat: 3.14
+ SCAint: 100
+ SCAstring: "jabathehut"
+ SC1extra3: true
+
+imported-chartA-B:
+ SC1extra5: "tiller"
+
+overridden-chartA-B:
+ SCAbool: true
+ SCAfloat: 3.33
+ SCAint: 555
+ SCAstring: "wormwood"
+ SCAextra1: 23
+
+ SCBbool: true
+ SCBfloat: 0.25
+ SCBint: 98
+ SCBstring: "murkwood"
+ SCBextra1: 13
+
+ SC1extra6: 77
+
+SCBexported1A:
+ SC1extra7: true
+
+exports:
+ SC1exported1:
+ global:
+ SC1exported2:
+ all:
+ SC1exported3: "SC1expstr" \ No newline at end of file
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/Chart.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/Chart.yaml
new file mode 100644
index 00000000..f2818e52
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/Chart.yaml
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: testchart2
+version: 0.1.0
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/Chart.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/Chart.yaml
new file mode 100644
index 00000000..be3edcef
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/Chart.yaml
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: subcharta
+version: 0.1.0
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/templates/service.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/templates/service.yaml
new file mode 100644
index 00000000..fdf75aa9
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Chart.Name }}
+ labels:
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ protocol: TCP
+ name: {{ .Values.service.name }}
+ selector:
+ app: {{ .Chart.Name }}
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/values.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/values.yaml
new file mode 100644
index 00000000..f0381ae6
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/values.yaml
@@ -0,0 +1,17 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+# subchartA
+service:
+ name: apache
+ type: ClusterIP
+ externalPort: 80
+ internalPort: 80
+SCAdata:
+ SCAbool: false
+ SCAfloat: 3.1
+ SCAint: 55
+ SCAstring: "jabba"
+ SCAnested1:
+ SCAnested2: true
+
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/Chart.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/Chart.yaml
new file mode 100644
index 00000000..c3c6bbaf
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/Chart.yaml
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: subchartb
+version: 0.1.0
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/templates/service.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/templates/service.yaml
new file mode 100644
index 00000000..fdf75aa9
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Chart.Name }}
+ labels:
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ protocol: TCP
+ name: {{ .Values.service.name }}
+ selector:
+ app: {{ .Chart.Name }}
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/values.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/values.yaml
new file mode 100644
index 00000000..774fdd75
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/values.yaml
@@ -0,0 +1,35 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+service:
+ name: nginx
+ type: ClusterIP
+ externalPort: 80
+ internalPort: 80
+
+SCBdata:
+ SCBbool: true
+ SCBfloat: 7.77
+ SCBint: 33
+ SCBstring: "boba"
+
+exports:
+ SCBexported1:
+ SCBexported1A:
+ SCBexported1B: 1965
+
+ SCBexported2:
+ SCBexported2A: "blaster"
+
+global:
+ kolla:
+ nova:
+ api:
+ all:
+ port: 8774
+ metadata:
+ all:
+ port: 8775
+
+
+
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/delete.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/delete.yaml
new file mode 100644
index 00000000..70efc671
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/delete.yaml
@@ -0,0 +1,22 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: testchart2
+ labels:
+ chart: "testchart2-0.1.0"
+ namespace: "testnamespace"
+ release-name: "testreleasename"
+ release-is-upgrade: "false"
+ release-is-install: "true"
+ kube-version/major: "1"
+ kube-version/minor: "14"
+ kube-version/gitversion: "v1.14.0"
+spec:
+ type: ClusterIP
+ ports:
+ - port: 80
+ targetPort: 80
+ protocol: TCP
+ name: nginx
+ selector:
+ app: testchart2 \ No newline at end of file
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/templates/NOTES.txt b/src/orchestrator/mock_files/mock_charts/testchart2/templates/NOTES.txt
new file mode 100644
index 00000000..4bdf443f
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/templates/NOTES.txt
@@ -0,0 +1 @@
+Sample notes for {{ .Chart.Name }} \ No newline at end of file
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/templates/service.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/templates/service.yaml
new file mode 100644
index 00000000..e06d19b9
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/templates/service.yaml
@@ -0,0 +1,22 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Chart.Name }}
+ labels:
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+ namespace: "{{ .Release.Namespace }}"
+ release-name: "{{ .Release.Name }}"
+ release-is-upgrade: "{{ .Release.IsUpgrade }}"
+ release-is-install: "{{ .Release.IsInstall }}"
+ kube-version/major: "{{ .Capabilities.KubeVersion.Major }}"
+ kube-version/minor: "{{ .Capabilities.KubeVersion.Minor }}"
+ kube-version/gitversion: "v{{ .Capabilities.KubeVersion.Major }}.{{ .Capabilities.KubeVersion.Minor }}.0"
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ protocol: TCP
+ name: {{ .Values.service.name }}
+ selector:
+ app: {{ .Chart.Name }}
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/values.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/values.yaml
new file mode 100644
index 00000000..72d3fa5c
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/values.yaml
@@ -0,0 +1,55 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+# subchart1
+service:
+ name: nginx
+ type: ClusterIP
+ externalPort: 80
+ internalPort: 80
+
+
+SC1data:
+ SC1bool: true
+ SC1float: 3.14
+ SC1int: 100
+ SC1string: "dollywood"
+ SC1extra1: 11
+
+imported-chartA:
+ SC1extra2: 1.337
+
+overridden-chartA:
+ SCAbool: true
+ SCAfloat: 3.14
+ SCAint: 100
+ SCAstring: "jabathehut"
+ SC1extra3: true
+
+imported-chartA-B:
+ SC1extra5: "tiller"
+
+overridden-chartA-B:
+ SCAbool: true
+ SCAfloat: 3.33
+ SCAint: 555
+ SCAstring: "wormwood"
+ SCAextra1: 23
+
+ SCBbool: true
+ SCBfloat: 0.25
+ SCBint: 98
+ SCBstring: "murkwood"
+ SCBextra1: 13
+
+ SC1extra6: 77
+
+SCBexported1A:
+ SC1extra7: true
+
+exports:
+ SC1exported1:
+ global:
+ SC1exported2:
+ all:
+ SC1exported3: "SC1expstr" \ No newline at end of file
diff --git a/src/orchestrator/mock_files/mock_profiles/profile1/faulty-dest-manifest.yaml b/src/orchestrator/mock_files/mock_profiles/profile1/faulty-dest-manifest.yaml
new file mode 100644
index 00000000..8c61a4e4
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_profiles/profile1/faulty-dest-manifest.yaml
@@ -0,0 +1,7 @@
+---
+version: v1
+type:
+ values: "override_values.yaml"
+ configresource:
+ - filepath: subdir/p1.yaml
+ chartpath: testchart1/folderdoesNOTexist/p1.yaml
diff --git a/src/orchestrator/mock_files/mock_profiles/profile1/faulty-manifest.yaml b/src/orchestrator/mock_files/mock_profiles/profile1/faulty-manifest.yaml
new file mode 100644
index 00000000..a123111a
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_profiles/profile1/faulty-manifest.yaml
@@ -0,0 +1,8 @@
+---
+version: v1
+type:
+ values:
+ - override_values.yaml
+ configresource:
+ - filepath: subdir/p1.yaml
+ chartpath: testchart1/templates/p1.yaml
diff --git a/src/orchestrator/mock_files/mock_profiles/profile1/faulty-src-manifest.yaml b/src/orchestrator/mock_files/mock_profiles/profile1/faulty-src-manifest.yaml
new file mode 100644
index 00000000..eff534bb
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_profiles/profile1/faulty-src-manifest.yaml
@@ -0,0 +1,7 @@
+---
+version: v1
+type:
+ values: "override_values.yaml"
+ configresource:
+ - filepath: subdir/filedoesNOTexist.yaml
+ chartpath: testchart1/templates/p1.yaml
diff --git a/src/orchestrator/mock_files/mock_profiles/profile1/manifest.yaml b/src/orchestrator/mock_files/mock_profiles/profile1/manifest.yaml
new file mode 100644
index 00000000..e4beada0
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_profiles/profile1/manifest.yaml
@@ -0,0 +1,7 @@
+---
+version: v1
+type:
+ values: "override_values.yaml"
+ configresource:
+ - filepath: subdir/p1.yaml
+ chartpath: testchart1/templates/p1.yaml
diff --git a/src/orchestrator/mock_files/mock_profiles/profile1/override_values.yaml b/src/orchestrator/mock_files/mock_profiles/profile1/override_values.yaml
new file mode 100644
index 00000000..0186c662
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_profiles/profile1/override_values.yaml
@@ -0,0 +1,9 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+# subchart1
+service:
+ name: nginx
+ type: ClusterIP
+ externalPort: 8080
+ internalPort: 8080 \ No newline at end of file
diff --git a/src/orchestrator/mock_files/mock_profiles/profile1/subdir/p1.yaml b/src/orchestrator/mock_files/mock_profiles/profile1/subdir/p1.yaml
new file mode 100644
index 00000000..2dad677a
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_profiles/profile1/subdir/p1.yaml
@@ -0,0 +1,22 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Chart.Name }}-override
+ labels:
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+ namespace: "{{ .Release.Namespace }}"
+ release-name: "{{ .Release.Name }}"
+ release-is-upgrade: "{{ .Release.IsUpgrade }}"
+ release-is-install: "{{ .Release.IsInstall }}"
+ kube-version/major: "{{ .Capabilities.KubeVersion.Major }}"
+ kube-version/minor: "{{ .Capabilities.KubeVersion.Minor }}"
+ kube-version/gitversion: "v{{ .Capabilities.KubeVersion.Major }}.{{ .Capabilities.KubeVersion.Minor }}.0"
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ protocol: TCP
+ name: {{ .Values.service.name }}
+ selector:
+ app: {{ .Chart.Name }}
diff --git a/src/orchestrator/pkg/module/instantiation.go b/src/orchestrator/pkg/module/instantiation.go
index 3c704181..5fabe81e 100644
--- a/src/orchestrator/pkg/module/instantiation.go
+++ b/src/orchestrator/pkg/module/instantiation.go
@@ -20,7 +20,6 @@ import (
"fmt"
"github.com/onap/multicloud-k8s/src/orchestrator/utils/helm"
- "github.com/onap/multicloud-k8s/src/orchestrator/utils/types"
pkgerrors "github.com/pkg/errors"
"encoding/base64"
@@ -67,11 +66,11 @@ func getOverrideValuesByAppName(ov []OverrideValues, a string) map[string]string
// GetSortedTemplateForApp returns the sorted templates.
//It takes in arguments - appName, project, compositeAppName, releaseName, compositeProfileName, array of override values
-func GetSortedTemplateForApp(appName, p, ca, v, rName, cp string, overrideValues []OverrideValues) ([]types.KubernetesResourceTemplate, error) {
+func GetSortedTemplateForApp(appName, p, ca, v, rName, cp string, overrideValues []OverrideValues) ([]helm.KubernetesResourceTemplate, error) {
log.Println("Processing App.. ", appName)
- var sortedTemplates []types.KubernetesResourceTemplate
+ var sortedTemplates []helm.KubernetesResourceTemplate
aC, err := NewAppClient().GetAppContent(appName, p, ca, v)
if err != nil {
@@ -107,7 +106,7 @@ func GetSortedTemplateForApp(appName, p, ca, v, rName, cp string, overrideValues
sortedTemplates, err = helm.NewTemplateClient("", "default", rName,
ManifestFileName).Resolve(appContent,
appProfileContent, overrideValuesOfAppStr,
- rName, appName)
+ appName)
log.Printf("The len of the sortedTemplates :: %d", len(sortedTemplates))
diff --git a/src/orchestrator/pkg/rtcontext/rtcontext_test.go b/src/orchestrator/pkg/rtcontext/rtcontext_test.go
index e9610ef0..eedbeb82 100644
--- a/src/orchestrator/pkg/rtcontext/rtcontext_test.go
+++ b/src/orchestrator/pkg/rtcontext/rtcontext_test.go
@@ -59,7 +59,7 @@ func (c *MockContextDb) Delete(key string) error {
// Delete all function
func (c *MockContextDb) DeleteAll(key string) error {
- for kvKey, _ := range c.Items {
+ for kvKey := range c.Items {
delete(c.Items, kvKey)
}
return c.Err
@@ -69,7 +69,7 @@ func (c *MockContextDb) DeleteAll(key string) error {
func (c *MockContextDb) GetAllKeys(path string) ([]string, error) {
var keys []string
- for k, _ := range c.Items {
+ for k := range c.Items {
keys = append(keys, string(k))
}
return keys, c.Err
diff --git a/src/orchestrator/utils/helm/helm.go b/src/orchestrator/utils/helm/helm.go
index f0d15fbf..80cdfe5a 100644
--- a/src/orchestrator/utils/helm/helm.go
+++ b/src/orchestrator/utils/helm/helm.go
@@ -19,7 +19,6 @@ package helm
import (
"bytes"
utils "github.com/onap/multicloud-k8s/src/orchestrator/utils"
- "github.com/onap/multicloud-k8s/src/orchestrator/utils/types"
pkgerrors "github.com/pkg/errors"
"log"
@@ -46,6 +45,15 @@ import (
"k8s.io/helm/pkg/timeconv"
)
+//KubernetesResourceTemplate - Represents the template that is used to create a particular
+//resource in Kubernetes
+type KubernetesResourceTemplate struct {
+ // Tracks the apiVersion and Kind of the resource
+ GVK schema.GroupVersionKind
+ // Path to the file that contains the resource info
+ FilePath string
+}
+
// Template is the interface for all helm templating commands
// Any backend implementation will implement this interface and will
// access the functionality via this.
@@ -144,10 +152,10 @@ func (h *TemplateClient) mergeValues(dest map[string]interface{}, src map[string
// GenerateKubernetesArtifacts a mapping of type to fully evaluated helm template
func (h *TemplateClient) GenerateKubernetesArtifacts(inputPath string, valueFiles []string,
- values []string) ([]types.KubernetesResourceTemplate, error) {
+ values []string) ([]KubernetesResourceTemplate, error) {
var outputDir, chartPath, namespace, releaseName string
- var retData []types.KubernetesResourceTemplate
+ var retData []KubernetesResourceTemplate
releaseName = h.releaseName
namespace = h.kubeNameSpace
@@ -255,7 +263,7 @@ func (h *TemplateClient) GenerateKubernetesArtifacts(inputPath string, valueFile
return retData, err
}
- kres := types.KubernetesResourceTemplate{
+ kres := KubernetesResourceTemplate{
GVK: gvk,
FilePath: mfilePath,
}
@@ -281,13 +289,20 @@ func getGroupVersionKind(data string) (schema.GroupVersionKind, error) {
// Resolver is an interface exposes the helm related functionalities
type Resolver interface {
- Resolve(appContent, appProfileContent []byte, overrideValuesOfAppStr []string, rName string) ([]types.KubernetesResourceTemplate, error)
+ Resolve(appContent, appProfileContent []byte, overrideValuesOfAppStr []string, appName string) ([]KubernetesResourceTemplate, error)
}
// Resolve function
-func (h *TemplateClient) Resolve(appContent []byte, appProfileContent []byte, overrideValuesOfAppStr []string, rName, appName string) ([]types.KubernetesResourceTemplate, error) {
+func (h *TemplateClient) Resolve(appContent []byte, appProfileContent []byte, overrideValuesOfAppStr []string, appName string) ([]KubernetesResourceTemplate, error) {
+
+ var sortedTemplates []KubernetesResourceTemplate
- var sortedTemplates []types.KubernetesResourceTemplate
+ //chartBasePath is the tmp path where the appContent(rawHelmCharts) is extracted.
+ chartBasePath, err := utils.ExtractTarBall(bytes.NewBuffer(appContent))
+ if err != nil {
+ return sortedTemplates, pkgerrors.Wrap(err, "Extracting appContent")
+ }
+ log.Printf("The chartBasePath :: %s", chartBasePath)
//prPath is the tmp path where the appProfileContent is extracted.
prPath, err := utils.ExtractTarBall(bytes.NewBuffer(appProfileContent))
@@ -296,16 +311,12 @@ func (h *TemplateClient) Resolve(appContent []byte, appProfileContent []byte, ov
}
log.Printf("The profile path:: %s", prPath)
- prYamlClient, err := utils.ProcessProfileYaml(prPath, h.manifestName)
+ prYamlClient, err := ProcessProfileYaml(prPath, h.manifestName)
if err != nil {
return sortedTemplates, pkgerrors.Wrap(err, "Processing Profile Manifest")
}
log.Println("Got the profileYamlClient..")
- //chartBasePath is the tmp path where the appContent(rawHelmCharts) is extracted.
- chartBasePath, err := utils.ExtractTarBall(bytes.NewBuffer(appContent))
- log.Printf("The chartBasePath :: %s", chartBasePath)
-
err = prYamlClient.CopyConfigurationOverrides(chartBasePath)
if err != nil {
return sortedTemplates, pkgerrors.Wrap(err, "Copying configresources to chart")
diff --git a/src/orchestrator/utils/helm/helm_test.go b/src/orchestrator/utils/helm/helm_test.go
new file mode 100644
index 00000000..e9442e8a
--- /dev/null
+++ b/src/orchestrator/utils/helm/helm_test.go
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2020 Intel Corporation, Inc
+ *
+ * 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 helm
+
+import (
+ "crypto/sha256"
+ "fmt"
+
+ "io/ioutil"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+func TestProcessValues(t *testing.T) {
+
+ chartDir := "../../mock_files/mock_charts/testchart2"
+ profileDir := "../../mock_files/mock_profiles/profile1"
+
+ testCases := []struct {
+ label string
+ valueFiles []string
+ values []string
+ expectedHash string
+ expectedError string
+ }{
+ {
+ label: "Process Values with Value Files Override",
+ valueFiles: []string{
+ filepath.Join(chartDir, "values.yaml"),
+ filepath.Join(profileDir, "override_values.yaml"),
+ },
+ //Hash of a combined values.yaml file that is expected
+ expectedHash: "c18a70f426933de3c051c996dc34fd537d0131b2d13a2112a2ecff674db6c2f9",
+ expectedError: "",
+ },
+ {
+ label: "Process Values with Values Pair Override",
+ valueFiles: []string{
+ filepath.Join(chartDir, "values.yaml"),
+ },
+ //Use the same convention as specified in helm template --set
+ values: []string{
+ "service.externalPort=82",
+ },
+ //Hash of a combined values.yaml file that is expected
+ expectedHash: "028a3521fc9f8777ea7e67a6de0c51f2c875b88ca91734999657f0ca924ddb7a",
+ expectedError: "",
+ },
+ {
+ label: "Process Values with Both Overrides",
+ valueFiles: []string{
+ filepath.Join(chartDir, "values.yaml"),
+ filepath.Join(profileDir, "override_values.yaml"),
+ },
+ //Use the same convention as specified in helm template --set
+ //Key takes precedence over the value from override_values.yaml
+ values: []string{
+ "service.externalPort=82",
+ },
+ //Hash of a combined values.yaml file that is expected
+ expectedHash: "516fab4ab7b76ba2ff35a97c2a79b74302543f532857b945f2fe25e717e755be",
+ expectedError: "",
+ },
+ {
+ label: "Process complex Pair Override",
+ values: []string{
+ "name={a,b,c}",
+ "servers[0].port=80",
+ },
+ expectedError: "",
+ expectedHash: "50d9401b003f65c1ccfd1c5155106fff88c8201ab8b7d66bd6ffa4fe2883bead",
+ },
+ }
+
+ h := sha256.New()
+
+ for _, testCase := range testCases {
+ t.Run(testCase.label, func(t *testing.T) {
+ tc := NewTemplateClient("1.12.3", "testnamespace", "testreleasename", "manifest.yaml")
+ out, err := tc.processValues(testCase.valueFiles, testCase.values)
+ if err != nil {
+ if testCase.expectedError == "" {
+ t.Fatalf("Got an error %s", err)
+ }
+ if strings.Contains(err.Error(), testCase.expectedError) == false {
+ t.Fatalf("Got unexpected error message %s", err)
+ }
+ } else {
+ //Compute the hash of returned data and compare
+ h.Write(out)
+ gotHash := fmt.Sprintf("%x", h.Sum(nil))
+ h.Reset()
+ if gotHash != testCase.expectedHash {
+ t.Fatalf("Got unexpected hash '%s' of values.yaml:\n%s", gotHash, out)
+ }
+ }
+ })
+ }
+}
+
+func TestGenerateKubernetesArtifacts(t *testing.T) {
+
+ chartDir := "../../mock_files/mock_charts/testchart2"
+ profileDir := "../../mock_files/mock_profiles/profile1"
+
+ testCases := []struct {
+ label string
+ chartPath string
+ valueFiles []string
+ values []string
+ expectedHashMap map[string]string
+ expectedError string
+ }{
+ {
+ label: "Generate artifacts without any overrides",
+ chartPath: chartDir,
+ valueFiles: []string{},
+ values: []string{},
+ //sha256 hash of the evaluated templates in each chart
+ expectedHashMap: map[string]string{
+ "testchart2/templates/service.yaml": "fdd6a2b6795486f0dd1d8c44379afb5ffe4072c09f9cf6594738e8ded4dd872d",
+ "subcharta/templates/service.yaml": "570389588fffdb7193ab265888d781f3d751f3a40362533344f9aa7bb93a8bb0",
+ "subchartb/templates/service.yaml": "5654e03d922e8ec49649b4bbda9dfc9e643b3b7c9c18b602cc7e26fd36a39c2a",
+ },
+ expectedError: "",
+ },
+ {
+ label: "Generate artifacts with overrides",
+ chartPath: chartDir,
+ valueFiles: []string{
+ filepath.Join(profileDir, "override_values.yaml"),
+ },
+ values: []string{
+ "service.externalPort=82",
+ },
+ //sha256 hash of the evaluated templates in each chart
+ expectedHashMap: map[string]string{
+ "testchart2/templates/service.yaml": "2bb96e791ecb6a3404bc5de3f6c4182aed881630269e2aa6766df38b0f852724",
+ "subcharta/templates/service.yaml": "570389588fffdb7193ab265888d781f3d751f3a40362533344f9aa7bb93a8bb0",
+ "subchartb/templates/service.yaml": "5654e03d922e8ec49649b4bbda9dfc9e643b3b7c9c18b602cc7e26fd36a39c2a",
+ },
+ expectedError: "",
+ },
+ }
+
+ h := sha256.New()
+
+ for _, testCase := range testCases {
+ t.Run(testCase.label, func(t *testing.T) {
+ tc := NewTemplateClient("1.12.3", "testnamespace", "testreleasename", "manifest.yaml")
+ out, err := tc.GenerateKubernetesArtifacts(testCase.chartPath, testCase.valueFiles,
+ testCase.values)
+ if err != nil {
+ if testCase.expectedError == "" {
+ t.Fatalf("Got an error %s", err)
+ }
+ if strings.Contains(err.Error(), testCase.expectedError) == false {
+ t.Fatalf("Got unexpected error message %s", err)
+ }
+ } else {
+ //Compute the hash of returned data and compare
+ for _, v := range out {
+ f := v.FilePath
+ data, err := ioutil.ReadFile(f)
+ if err != nil {
+ t.Errorf("Unable to read file %s", v)
+ }
+ h.Write(data)
+ gotHash := fmt.Sprintf("%x", h.Sum(nil))
+ h.Reset()
+
+ //Find the right hash from expectedHashMap
+ expectedHash := ""
+ for k1, v1 := range testCase.expectedHashMap {
+ if strings.Contains(f, k1) == true {
+ expectedHash = v1
+ break
+ }
+ }
+ if gotHash != expectedHash {
+ t.Fatalf("Got unexpected hash for %s", f)
+ }
+ }
+ }
+ })
+ }
+
+}
diff --git a/src/orchestrator/utils/profile_yaml.go b/src/orchestrator/utils/helm/profile_yaml.go
index 91687c0a..e72fdbdc 100644
--- a/src/orchestrator/utils/profile_yaml.go
+++ b/src/orchestrator/utils/helm/profile_yaml.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package utils
+package helm
import (
"io/ioutil"
diff --git a/src/orchestrator/utils/types/types.go b/src/orchestrator/utils/types/types.go
deleted file mode 100644
index 4ffb4180..00000000
--- a/src/orchestrator/utils/types/types.go
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2020 Intel Corporation, Inc
- *
- * 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 types
-
-import (
- "k8s.io/apimachinery/pkg/runtime/schema"
-)
-
-// KubernetesResourceTemplate - Represents the template that is used to create a particular
-// resource in Kubernetes
-type KubernetesResourceTemplate struct {
- // Tracks the apiVersion and Kind of the resource
- GVK schema.GroupVersionKind
- // Path to the file that contains the resource info
- FilePath string
-}
-
-// KubernetesResource is the resource that is created in Kubernetes
-// It is the type that will be used for tracking a resource.
-// Any future information such as status, time can be added here
-// for tracking.
-type KubernetesResource struct {
- // Tracks the apiVersion and Kind of the resource
- GVK schema.GroupVersionKind
- // Name of resource in Kubernetes
- Name string
-}
diff --git a/src/orchestrator/utils/util-functions.go b/src/orchestrator/utils/utils.go
index 13c78ba4..13c78ba4 100644
--- a/src/orchestrator/utils/util-functions.go
+++ b/src/orchestrator/utils/utils.go