Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix variables when passed to command #302

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ func newRunCmdFunc(e jumppad.Engine, dt cclients.ContainerTasks, bp getter.Gette
// parse the vars into a map
vars := map[string]string{}
for _, v := range *variables {
// if the variable is wrapped in single quotes remove them
v = strings.TrimPrefix(v, "'")
v = strings.TrimSuffix(v, "'")

parts := strings.Split(v, "=")
if len(parts) == 2 {
vars[parts[0]] = parts[1]
if len(parts) >= 2 {
vars[parts[0]] = strings.Join(parts[1:], "=")
}
}

Expand Down Expand Up @@ -174,7 +178,7 @@ func newRunCmdFunc(e jumppad.Engine, dt cclients.ContainerTasks, bp getter.Gette
cancel()
}()

res, err := e.ApplyWithVariables(ctx, dst, vars, *variablesFile)
config, err := e.ApplyWithVariables(ctx, dst, vars, *variablesFile)
if err != nil {
return err
}
Expand All @@ -185,30 +189,26 @@ func newRunCmdFunc(e jumppad.Engine, dt cclients.ContainerTasks, bp getter.Gette
browserList := []string{}
checkDuration := 30 * time.Second

for _, r := range res.Resources {
switch r.Metadata().Type {
case container.TypeContainer:
c := r.(*container.Container)
for _, p := range c.Ports {
for _, r := range config.Resources {
switch v := r.(type) {
case *container.Container:
for _, p := range v.Ports {
if p.Host != "" && p.OpenInBrowser != "" {
browserList = append(browserList, buildBrowserPath(r.Metadata().Name, p.Host, r.Metadata().Type, p.OpenInBrowser))
}
}
case ingress.TypeIngress:
c := r.(*ingress.Ingress)
if c.OpenInBrowser != "" {
browserList = append(browserList, buildBrowserPath(r.Metadata().Name, fmt.Sprintf("%d", c.Port), r.Metadata().Type, c.OpenInBrowser))
case *ingress.Ingress:
if v.OpenInBrowser != "" {
browserList = append(browserList, buildBrowserPath(r.Metadata().Name, fmt.Sprintf("%d", v.Port), r.Metadata().Type, v.OpenInBrowser))
}
case nomad.TypeNomadCluster:
c := r.(*nomad.NomadCluster)
if c.OpenInBrowser {
case *nomad.NomadCluster:
if v.OpenInBrowser {
// get the API port
browserList = append(browserList, buildBrowserPath("server."+r.Metadata().Name, fmt.Sprintf("%d", c.APIPort), r.Metadata().Type, "/"))
browserList = append(browserList, buildBrowserPath("server."+r.Metadata().Name, fmt.Sprintf("%d", v.APIPort), r.Metadata().Type, "/"))
}
case docs.TypeDocs:
c := r.(*docs.Docs)
if c.OpenInBrowser {
port := strconv.Itoa(c.Port)
case *docs.Docs:
if v.OpenInBrowser {
port := strconv.Itoa(v.Port)
if port == "0" {
port = "80"
}
Expand All @@ -226,7 +226,7 @@ func newRunCmdFunc(e jumppad.Engine, dt cclients.ContainerTasks, bp getter.Gette
for _, b := range browserList {
go func(uri string) {
// health check the URL
err := hc.HealthCheckHTTP(uri, "", nil, "", []int{200}, checkDuration)
err := hc.HealthCheckHTTP(uri, "", map[string][]string{}, "", []int{200}, checkDuration)
if err == nil {
be := bc.OpenBrowser(uri)
if be != nil {
Expand All @@ -247,7 +247,7 @@ func newRunCmdFunc(e jumppad.Engine, dt cclients.ContainerTasks, bp getter.Gette

// if we have a blueprint show the header
var b *blueprint.Blueprint
bps, _ := e.Config().FindResourcesByType(blueprint.TypeBlueprint)
bps, _ := config.FindResourcesByType(blueprint.TypeBlueprint)
for _, bp := range bps {
// pick the first blueprint in the root
if bp.Metadata().Module == "" {
Expand Down
Loading
Loading