From b36b8917da7cde5ee7091ad6bc100ed1bc1a5538 Mon Sep 17 00:00:00 2001 From: Foysal Iqbal Date: Mon, 6 Apr 2020 02:24:25 -0400 Subject: [PATCH] add prefix preflight (#282) Signed-off-by: Foysal Iqbal --- pkg/preflight/role_check.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg/preflight/role_check.go b/pkg/preflight/role_check.go index 895d09db..63f5139f 100644 --- a/pkg/preflight/role_check.go +++ b/pkg/preflight/role_check.go @@ -3,12 +3,15 @@ package preflight import ( "fmt" "path/filepath" + "strings" "github.com/qlik-oss/sense-installer/pkg/api" qapi "github.com/qlik-oss/sense-installer/pkg/api" "github.com/qlik-oss/sense-installer/pkg/qliksense" ) +var resultYamlBytes = []byte("") + func (qp *QliksensePreflight) CheckCreateRole(namespace string) error { // create a Role fmt.Printf("Preflight role check: \n") @@ -66,15 +69,16 @@ func (qp *QliksensePreflight) checkCreateEntity(namespace, entityToTest string) } else { kusDir = filepath.Join(mfroot, "manifests", currentCR.Spec.Profile) } - resultYamlString, err := qliksense.ExecuteKustomizeBuild(kusDir) - if err != nil { - fmt.Printf("Unable to retrieve manifests from executing kustomize: %v\n", err) - return err + if len(resultYamlBytes) == 0 { + resultYamlBytes, err = qliksense.ExecuteKustomizeBuild(kusDir) + if err != nil { + fmt.Printf("Unable to retrieve manifests from executing kustomize: %v\n", err) + return err + } } - - sa := qliksense.GetYamlsFromMultiDoc(string(resultYamlString), entityToTest) + sa := qliksense.GetYamlsFromMultiDoc(string(resultYamlBytes), entityToTest) if sa != "" { - // sa = strings.ReplaceAll(sa, "namespace: default\n", fmt.Sprintf("namespace: %s\n", namespace)) + sa = strings.Replace(sa, "name: qliksense", "name: preflight", -1) } else { err := fmt.Errorf("Unable to retrieve yamls to apply on cluster") fmt.Println(err)