Compare commits
26 Commits
v0.9.21
...
random-fix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75ce6caa2b | ||
|
|
d05b119a68 | ||
|
|
ed26e692c9 | ||
|
|
5909c728ab | ||
|
|
d77654e763 | ||
|
|
73c3ac1d58 | ||
|
|
083203128c | ||
|
|
ccc2997745 | ||
|
|
1f5ee3d487 | ||
|
|
87ace81dee | ||
|
|
2618e72a46 | ||
|
|
1aac550f66 | ||
|
|
bacaea1b92 | ||
|
|
acfa1f16a1 | ||
|
|
8b68a4d305 | ||
|
|
114d0a13c8 | ||
|
|
c733d2821e | ||
|
|
69306605a3 | ||
|
|
67ec3105f0 | ||
|
|
e69149ec64 | ||
|
|
cedb7f8fca | ||
|
|
fee81b25a6 | ||
|
|
b5eea11050 | ||
|
|
dbf6f6debc | ||
|
|
002b0faaa1 | ||
|
|
a676d10ed0 |
@@ -11,6 +11,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -68,23 +69,20 @@ func ProcessConfigArgs(args []string) ([]*ServiceKeyValue, error) {
|
||||
err := fmt.Errorf("No args were provided. Please provide args to configure the current context")
|
||||
return nil, err
|
||||
}
|
||||
notValidErr := fmt.Errorf("Please provide valid args for this command")
|
||||
resultSvcKV := make([]*ServiceKeyValue, len(args))
|
||||
// qliksense.mongodb=somethig
|
||||
re1 := regexp.MustCompile(`([\w\-]{1,}).([\w\-]{1,})=("*[\w\-?=_/:0-9\.]+"*)`)
|
||||
for i, arg := range args {
|
||||
LogDebugMessage("Arg received: %s", arg)
|
||||
first := strings.SplitN(arg, "=", 2)
|
||||
if len(first) != 2 {
|
||||
return nil, notValidErr
|
||||
}
|
||||
second := strings.SplitN(first[0], ".", 2)
|
||||
if len(second) != 2 {
|
||||
return nil, notValidErr
|
||||
result := re1.FindStringSubmatch(arg)
|
||||
// check if result array's length is == 4 (index 0 - is the full match & indices 1,2,3- are the fields we need)
|
||||
if len(result) != 4 {
|
||||
err := fmt.Errorf("Please provide valid args for this command")
|
||||
return nil, err
|
||||
}
|
||||
resultSvcKV[i] = &ServiceKeyValue{
|
||||
SvcName: second[0],
|
||||
Key: second[1],
|
||||
Value: strings.ReplaceAll(first[1], `"`, ""),
|
||||
SvcName: result[1],
|
||||
Key: result[2],
|
||||
Value: strings.ReplaceAll(result[3], `"`, ""),
|
||||
}
|
||||
}
|
||||
return resultSvcKV, nil
|
||||
|
||||
@@ -11,11 +11,10 @@ func TestProcessConfigArgs(t *testing.T) {
|
||||
"test-dash.dash-key=value-dash",
|
||||
"test-dot.dot-key=127.0.0.1",
|
||||
"test123.key123=value123",
|
||||
"test-equal.keyequal=newvalue=@hj",
|
||||
}
|
||||
expectedKeys := []string{"mongodb", "test", "dash-key", "dot-key", "key123", "keyequal"}
|
||||
expectedValue := []string{"mongouri://something?ffall", "value_under", "value-dash", "127.0.0.1", "value123", "newvalue=@hj"}
|
||||
exppectedSvc := []string{"qliksense", "test_under", "test-dash", "test-dot", "test123", "test-equal"}
|
||||
expectedKeys := []string{"mongodb", "test", "dash-key", "dot-key", "key123"}
|
||||
expectedValue := []string{"mongouri://something?ffall", "value_under", "value-dash", "127.0.0.1", "value123"}
|
||||
exppectedSvc := []string{"qliksense", "test_under", "test-dash", "test-dot", "test123"}
|
||||
sv, err := ProcessConfigArgs(args)
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
|
||||
@@ -73,8 +73,8 @@ func mongoConnCheck(kubeConfigContents []byte, namespace, mongodbUrl string) err
|
||||
return err
|
||||
}
|
||||
|
||||
api.LogDebugMessage("stdout:%v\n", stdout)
|
||||
api.LogDebugMessage("stderr:%v\n", stderr)
|
||||
api.LogDebugMessage("stdout:", stdout)
|
||||
api.LogDebugMessage("stderr:", stderr)
|
||||
stringToCheck := "Implicit session"
|
||||
if strings.Contains(stdout, stringToCheck) || strings.Contains(stderr, stringToCheck) {
|
||||
fmt.Println("Preflight mongo check: PASSED")
|
||||
|
||||
@@ -2,16 +2,16 @@ package preflight
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/mitchellh/go-homedir"
|
||||
"github.com/qlik-oss/k-apis/pkg/cr"
|
||||
"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")
|
||||
@@ -69,16 +69,27 @@ func (qp *QliksensePreflight) checkCreateEntity(namespace, entityToTest string)
|
||||
} else {
|
||||
kusDir = filepath.Join(mfroot, "manifests", currentCR.Spec.Profile)
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
currentCR.SetName("random")
|
||||
currentCR.Spec.RotateKeys = "None"
|
||||
currentCR.Spec.ManifestsRoot = mfroot
|
||||
userHomeDir, err := homedir.Dir()
|
||||
if err != nil {
|
||||
fmt.Printf(`error fetching user's home directory: %v\n`, err)
|
||||
return err
|
||||
}
|
||||
sa := qliksense.GetYamlsFromMultiDoc(string(resultYamlBytes), entityToTest)
|
||||
|
||||
cr.GeneratePatches(¤tCR.KApiCr, path.Join(userHomeDir, ".kube", "config"))
|
||||
|
||||
resultYamlString, 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)
|
||||
if sa != "" {
|
||||
sa = strings.Replace(sa, "name: qliksense", "name: preflight", -1)
|
||||
// sa = strings.ReplaceAll(sa, "namespace: default\n", fmt.Sprintf("namespace: %s\n", namespace))
|
||||
} else {
|
||||
err := fmt.Errorf("Unable to retrieve yamls to apply on cluster")
|
||||
fmt.Println(err)
|
||||
|
||||
Reference in New Issue
Block a user