Skip to content

Commit

Permalink
Merge pull request #412 from FogDong/fix-dex
Browse files Browse the repository at this point in the history
Fix: fix dex parameter in velaux addon
  • Loading branch information
barnettZQG authored Jul 19, 2022
2 parents 39796f1 + dabc103 commit fcabaac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion addons/velaux/resources/parameter.cue
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ parameter: {
// +usage=Specify the names of imagePullSecret for private image registry, eg. "{a,b,c}"
imagePullSecrets?: [...string]
// +usage=Specify whether to enable the dex
dex: *"false" | "true"
dex: *false | bool
}
6 changes: 3 additions & 3 deletions addons/velaux/resources/velaux.cue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ output: {
if parameter["serviceType"] != _|_ {
exposeType: parameter["serviceType"]
}
if parameter["dex"] == "true" {
if parameter["dex"] == true {
env: [
{
name: "KUBEVELA_API_URL"
Expand All @@ -35,12 +35,12 @@ output: {
},
]
}
if parameter["dex"] == "false" {
if parameter["dex"] != true {
env: [
{
name: "KUBEVELA_API_URL"
value: "apiserver.vela-system:8000"
},
}
]
}
}
Expand Down
34 changes: 17 additions & 17 deletions test/e2e-test/addon-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

type AddonMeta struct {
Name string `json:"name"`
Name string `json:"name"`
Dependencies []Dependency `json:"dependencies"`
}

Expand Down Expand Up @@ -57,7 +57,7 @@ func main() {
}

// will check all needed enabled addons according to changed files.
func determineNeedEnableAddon (changedFile []string) map[string]bool {
func determineNeedEnableAddon(changedFile []string) map[string]bool {
needEnabledAddon := map[string]bool{}
globalRex := regexp.MustCompile(globalRexPattern)
regx := regexp.MustCompile(regexPattern)
Expand Down Expand Up @@ -86,9 +86,9 @@ func determineNeedEnableAddon (changedFile []string) map[string]bool {
}

for addon := range needEnabledAddon {
if err := checkAffectedAddon(addon, needEnabledAddon); err != nil {
panic(err)
}
if err := checkAffectedAddon(addon, needEnabledAddon); err != nil {
panic(err)
}
}

for addon := range needEnabledAddon {
Expand All @@ -110,7 +110,7 @@ func checkAffectedAddon(addonName string, needEnabledAddon map[string]bool) erro
if err != nil {
return err
}
for _, subDir := range dir {
for _, subDir := range dir {
if subDir.IsDir() {
meta, err := readAddonMeta(subDir.Name())
if err != nil {
Expand All @@ -128,12 +128,12 @@ func checkAffectedAddon(addonName string, needEnabledAddon map[string]bool) erro
return nil
}

func putInAllAddons (addons map[string]bool) error {
func putInAllAddons(addons map[string]bool) error {
dir, err := ioutil.ReadDir("./addons")
if err != nil {
return err
}
for _, subDir := range dir {
for _, subDir := range dir {
if subDir.IsDir() {
fmt.Println(subDir.Name())
addons[subDir.Name()] = true
Expand All @@ -143,7 +143,7 @@ func putInAllAddons (addons map[string]bool) error {
}

// these addons are depended by changed addons.
func checkAddonDependency(addon string, changedAddon map[string]bool ) {
func checkAddonDependency(addon string, changedAddon map[string]bool) {
meta, err := readAddonMeta(addon)
if err != nil {
panic(err)
Expand All @@ -169,7 +169,7 @@ func readAddonMeta(addonName string) (*AddonMeta, error) {

// This func will enable addon by order rely-on addon's relationShip dependency,
// this func is so dummy now that the order is written manually, we can generated a dependency DAG workflow in the furture.
func enableAddonsByOrder (changedAddon map[string]bool) error {
func enableAddonsByOrder(changedAddon map[string]bool) error {
dirPattern := "addons/%s"
if changedAddon["fluxcd"] {
if err := enableOneAddon(fmt.Sprintf(dirPattern, "fluxcd")); err != nil {
Expand Down Expand Up @@ -219,7 +219,7 @@ func enableAddonsByOrder (changedAddon map[string]bool) error {
}

func enableOneAddon(dir string) error {
cmd := exec.Command("vela","addon", "enable", dir)
cmd := exec.Command("vela", "addon", "enable", dir)
fmt.Println(cmd.String())
stdout, err := cmd.StdoutPipe()
cmd.Stderr = cmd.Stdout
Expand All @@ -238,13 +238,14 @@ func enableOneAddon(dir string) error {
}
}
if err = cmd.Wait(); err != nil {
checkAppStatus(dir)
return err
}
return nil
}

func disableOneAddon (addonName string) error {
cmd := exec.Command("vela","addon", "disable", addonName)
func disableOneAddon(addonName string) error {
cmd := exec.Command("vela", "addon", "disable", addonName)
fmt.Println(cmd.String())
stdout, err := cmd.StdoutPipe()
cmd.Stderr = cmd.Stdout
Expand All @@ -268,10 +269,9 @@ func disableOneAddon (addonName string) error {
return nil
}


// this func can be used for debug when addon enable failed.
func checkAppStatus(addonName string) {
cmd := exec.Command("vela","status", "-n", "vela-system", "addon-" + addonName)
func checkAppStatus(addonName string) {
cmd := exec.Command("vela", "status", "-n", "vela-system", "addon-"+addonName)
fmt.Println(cmd.String())
stdout, err := cmd.StdoutPipe()
cmd.Stderr = cmd.Stdout
Expand All @@ -296,7 +296,7 @@ func checkAppStatus(addonName string) {

// this func can be used for debug when addon enable failed.
func checkPodStatus(namespace string) {
cmd := exec.Command("kubectl","get pods", "-n", namespace)
cmd := exec.Command("kubectl", "get pods", "-n", namespace)
fmt.Println(cmd.String())
stdout, err := cmd.StdoutPipe()
cmd.Stderr = cmd.Stdout
Expand Down

0 comments on commit fcabaac

Please sign in to comment.