Skip to content

Commit

Permalink
add prefix preflight (#282)
Browse files Browse the repository at this point in the history
Signed-off-by: Foysal Iqbal <[email protected]>
  • Loading branch information
Foysal Iqbal authored Apr 6, 2020
1 parent eed4d49 commit b36b891
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pkg/preflight/role_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b36b891

Please sign in to comment.