aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/rb/profile.go
diff options
context:
space:
mode:
authorKonrad Bańka <k.banka@samsung.com>2020-09-04 14:44:45 +0200
committerKonrad Banka <k.banka@samsung.com>2020-09-08 11:29:55 +0000
commitcf79276e2b633211d9a0befcb0e978dea447a9cf (patch)
treee7e9c22c6e1e13bb7a039aa3eff23eff246875a1 /src/k8splugin/internal/rb/profile.go
parentd14246bb9a2c8874f9925c45322d678a93584adb (diff)
Provide capability to specify release-name during instantiation
Allow release-name property to be provided during instantiation that, if provided, overrides release-name specified in profile. Additionally updated Makefile to allow easy compilation with different go version easily. Issue-ID: MULTICLOUD-1175 Signed-off-by: Konrad Bańka <k.banka@samsung.com> Change-Id: Id8db484369045cfb0bc99543a80317644fc838f9
Diffstat (limited to 'src/k8splugin/internal/rb/profile.go')
-rw-r--r--src/k8splugin/internal/rb/profile.go33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/k8splugin/internal/rb/profile.go b/src/k8splugin/internal/rb/profile.go
index 6efa23b8..f8b07abf 100644
--- a/src/k8splugin/internal/rb/profile.go
+++ b/src/k8splugin/internal/rb/profile.go
@@ -268,50 +268,51 @@ func (v *ProfileClient) Download(rbName, rbVersion, prName string) ([]byte, erro
}
//Resolve returns the path where the helm chart merged with
-//configuration overrides resides.
+//configuration overrides resides and final ReleaseName picked for instantiation
func (v *ProfileClient) Resolve(rbName string, rbVersion string,
- profileName string, values []string) ([]helm.KubernetesResourceTemplate, error) {
+ profileName string, values []string, overrideReleaseName string) ([]helm.KubernetesResourceTemplate, string, error) {
var sortedTemplates []helm.KubernetesResourceTemplate
+ var finalReleaseName string
//Download and process the profile first
//If everything seems okay, then download the definition
prData, err := v.Download(rbName, rbVersion, profileName)
if err != nil {
- return sortedTemplates, pkgerrors.Wrap(err, "Downloading Profile")
+ return sortedTemplates, finalReleaseName, pkgerrors.Wrap(err, "Downloading Profile")
}
prPath, err := ExtractTarBall(bytes.NewBuffer(prData))
if err != nil {
- return sortedTemplates, pkgerrors.Wrap(err, "Extracting Profile Content")
+ return sortedTemplates, finalReleaseName, pkgerrors.Wrap(err, "Extracting Profile Content")
}
prYamlClient, err := ProcessProfileYaml(prPath, v.manifestName)
if err != nil {
- return sortedTemplates, pkgerrors.Wrap(err, "Processing Profile Manifest")
+ return sortedTemplates, finalReleaseName, pkgerrors.Wrap(err, "Processing Profile Manifest")
}
definitionClient := NewDefinitionClient()
definition, err := definitionClient.Get(rbName, rbVersion)
if err != nil {
- return sortedTemplates, pkgerrors.Wrap(err, "Getting Definition Metadata")
+ return sortedTemplates, finalReleaseName, pkgerrors.Wrap(err, "Getting Definition Metadata")
}
defData, err := definitionClient.Download(rbName, rbVersion)
if err != nil {
- return sortedTemplates, pkgerrors.Wrap(err, "Downloading Definition")
+ return sortedTemplates, finalReleaseName, pkgerrors.Wrap(err, "Downloading Definition")
}
chartBasePath, err := ExtractTarBall(bytes.NewBuffer(defData))
if err != nil {
- return sortedTemplates, pkgerrors.Wrap(err, "Extracting Definition Charts")
+ return sortedTemplates, finalReleaseName, pkgerrors.Wrap(err, "Extracting Definition Charts")
}
//Get the definition ID and download its contents
profile, err := v.Get(rbName, rbVersion, profileName)
if err != nil {
- return sortedTemplates, pkgerrors.Wrap(err, "Getting Profile")
+ return sortedTemplates, finalReleaseName, pkgerrors.Wrap(err, "Getting Profile")
}
//Copy the profile configresources to the chart locations
@@ -321,22 +322,28 @@ func (v *ProfileClient) Resolve(rbName string, rbVersion string,
// chartpath: chart/config/resources/config.yaml
err = prYamlClient.CopyConfigurationOverrides(chartBasePath)
if err != nil {
- return sortedTemplates, pkgerrors.Wrap(err, "Copying configresources to chart")
+ return sortedTemplates, finalReleaseName, pkgerrors.Wrap(err, "Copying configresources to chart")
+ }
+
+ if overrideReleaseName == "" {
+ finalReleaseName = profile.ReleaseName
+ } else {
+ finalReleaseName = overrideReleaseName
}
helmClient := helm.NewTemplateClient(profile.KubernetesVersion,
profile.Namespace,
- profile.ReleaseName)
+ finalReleaseName)
chartPath := filepath.Join(chartBasePath, definition.ChartName)
sortedTemplates, err = helmClient.GenerateKubernetesArtifacts(chartPath,
[]string{prYamlClient.GetValues()},
values)
if err != nil {
- return sortedTemplates, pkgerrors.Wrap(err, "Generate final k8s yaml")
+ return sortedTemplates, finalReleaseName, pkgerrors.Wrap(err, "Generate final k8s yaml")
}
- return sortedTemplates, nil
+ return sortedTemplates, finalReleaseName, nil
}
// Returns an empty profile with the following contents