diff options
author | 2020-04-03 07:43:11 +0000 | |
---|---|---|
committer | 2020-04-13 16:46:10 +0000 | |
commit | c8ba8f21b68b64b4068f188614dd7c891edf035f (patch) | |
tree | bf7b48d32552a60b6635204c49fd2a3f7665e310 /src/orchestrator/utils/helm/helm.go | |
parent | 502b61039dbdc9089768a49b87163e654d8cbfb7 (diff) |
Test cases for resolving the helm templates
Added test cases for overriding values and
resolving the helm charts.
Also addressed the merge conflicts
and review comments
Issue-ID: MULTICLOUD-1041
Signed-off-by: Rajamohan Raj <rajamohan.raj@intel.com>
Change-Id: I511e8e2e71c60e878df434370fc053f09cda1f66
Diffstat (limited to 'src/orchestrator/utils/helm/helm.go')
-rw-r--r-- | src/orchestrator/utils/helm/helm.go | 35 |
1 files changed, 23 insertions, 12 deletions
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") |