From ded62076828e754e94bcefd04e8dcb5d6a026eb0 Mon Sep 17 00:00:00 2001 From: Nic Jackson Date: Wed, 9 Oct 2024 18:02:05 +0100 Subject: [PATCH] fix bug with health check method and set module cache to jumppad directory --- examples/single_file/container.hcl | 10 ++++++++++ pkg/clients/http/http.go | 2 +- pkg/config/zz_hclparser.go | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/examples/single_file/container.hcl b/examples/single_file/container.hcl index b31cb80a..22aaa875 100644 --- a/examples/single_file/container.hcl +++ b/examples/single_file/container.hcl @@ -73,6 +73,16 @@ resource "container" "consul" { destination = "/cache" type = "volume" } + + health_check { + timeout = "30s" + + http { + address = "http://localhost:8500/v1/status/leader" + success_codes = [200] + method = "POST" + } + } } output "consul_addr" { diff --git a/pkg/clients/http/http.go b/pkg/clients/http/http.go index b8f9ea45..5ae24b70 100644 --- a/pkg/clients/http/http.go +++ b/pkg/clients/http/http.go @@ -55,7 +55,7 @@ func (h *HTTPImpl) HealthCheckHTTP(address, method string, headers map[string][] return fmt.Errorf("timeout waiting for HTTP health check %s", address) } - if method != "" { + if method == "" { method = http.MethodGet } diff --git a/pkg/config/zz_hclparser.go b/pkg/config/zz_hclparser.go index 6cb9fbd5..3600cbb4 100644 --- a/pkg/config/zz_hclparser.go +++ b/pkg/config/zz_hclparser.go @@ -1,8 +1,11 @@ package config import ( + "path" + "github.com/jumppad-labs/hclconfig" "github.com/jumppad-labs/hclconfig/types" + "github.com/jumppad-labs/jumppad/pkg/utils" sdk "github.com/jumppad-labs/plugin-sdk" ) @@ -38,6 +41,7 @@ func NewParser(callback hclconfig.WalkCallback, variables map[string]string, var cfg.VariableEnvPrefix = "JUMPPAD_VAR_" cfg.Variables = variables cfg.VariablesFiles = variablesFiles + cfg.ModuleCache = path.Join(utils.JumppadHome(), "modules") p := hclconfig.NewParser(cfg)