From 592288677882775a5d0260e07b7a283237ac9e03 Mon Sep 17 00:00:00 2001 From: Mathieu Corbin Date: Sat, 1 Jul 2023 16:06:24 +0200 Subject: [PATCH] add host support for the HTTP health check --- cmd/healthcheck_http.go | 8 ++++++++ go.mod | 2 +- go.sum | 12 ++---------- .../appclacks/go-types/healthcheck_http.go | 1 + vendor/modules.txt | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cmd/healthcheck_http.go b/cmd/healthcheck_http.go index 3f44cd2..f072b14 100644 --- a/cmd/healthcheck_http.go +++ b/cmd/healthcheck_http.go @@ -30,6 +30,7 @@ func createHTTPHealthcheckCmd() *cobra.Command { var query []string var protocol string var path string + var host string var createHTTPHealthcheck = &cobra.Command{ Use: "create", @@ -63,6 +64,7 @@ func createHTTPHealthcheckCmd() *cobra.Command { Headers: headersMap, Protocol: protocol, Path: path, + Host: host, }, } ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout) @@ -111,6 +113,8 @@ func createHTTPHealthcheckCmd() *cobra.Command { createHTTPHealthcheck.PersistentFlags().StringVar(&path, "path", "", "Path to use for the healthcheck") + createHTTPHealthcheck.PersistentFlags().StringVar(&host, "host", "", "Host header to use for the health check HTTP requests") + createHTTPHealthcheck.PersistentFlags().StringVar(&timeout, "timeout", "5s", "healthcheck timeout") createHTTPHealthcheck.PersistentFlags().StringSliceVar(&headers, "headers", []string{}, "healthchecks http headers (example: foo=bar)") @@ -142,6 +146,7 @@ func updateHTTPHealthcheckCmd() *cobra.Command { var query []string var protocol string var path string + var host string var updateHTTPHealthcheck = &cobra.Command{ Use: "update", @@ -176,6 +181,7 @@ func updateHTTPHealthcheckCmd() *cobra.Command { Headers: headersMap, Protocol: protocol, Path: path, + Host: host, }, } ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout) @@ -228,6 +234,8 @@ func updateHTTPHealthcheckCmd() *cobra.Command { updateHTTPHealthcheck.PersistentFlags().StringVar(&path, "path", "", "Path to use for the healthcheck") + updateHTTPHealthcheck.PersistentFlags().StringVar(&host, "host", "", "Host header to use for the health check HTTP requests") + updateHTTPHealthcheck.PersistentFlags().StringVar(&timeout, "timeout", "5s", "healthcheck timeout") updateHTTPHealthcheck.PersistentFlags().StringSliceVar(&headers, "headers", []string{}, "healthchecks http headers (example: foo=bar)") diff --git a/go.mod b/go.mod index d33fde5..5768e89 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/appclacks/cli go 1.20 require ( - github.com/appclacks/go-types v0.0.0-20230514202307-77b895c55c7e + github.com/appclacks/go-types v0.0.0-20230701132920-beebbdd4d0ee github.com/cheynewallace/tabby v1.1.1 github.com/spf13/cobra v1.5.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index abd8547..19a1c67 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,5 @@ -github.com/appclacks/go-types v0.0.0-20230401151938-70e500ff5d8e h1:q6F3f7rKacyM3KLHHOETUAVbfa0sZXcUVKy8ULbglJU= -github.com/appclacks/go-types v0.0.0-20230401151938-70e500ff5d8e/go.mod h1:ULkbKlyVigBCY+eSEV0scorq+akwJlVbdnLI5xI8IwU= -github.com/appclacks/go-types v0.0.0-20230412203547-193f76f5534c h1:I7lIy2VALaTMr+MMCLaoscCJIlHkAQRfk+zETxnca2o= -github.com/appclacks/go-types v0.0.0-20230412203547-193f76f5534c/go.mod h1:ULkbKlyVigBCY+eSEV0scorq+akwJlVbdnLI5xI8IwU= -github.com/appclacks/go-types v0.0.0-20230509204234-07f206f7c4af h1:Du12cHfa7Gvv2f2XDQXxtat2vZ65IGnOmSrAjvyDJqU= -github.com/appclacks/go-types v0.0.0-20230509204234-07f206f7c4af/go.mod h1:ULkbKlyVigBCY+eSEV0scorq+akwJlVbdnLI5xI8IwU= -github.com/appclacks/go-types v0.0.0-20230510191813-4ccfbeee3e7c h1:3pByBZlbOlA23fFCDhWnh0UfCbLBlDzdjWOxHJ7QBF0= -github.com/appclacks/go-types v0.0.0-20230510191813-4ccfbeee3e7c/go.mod h1:ULkbKlyVigBCY+eSEV0scorq+akwJlVbdnLI5xI8IwU= -github.com/appclacks/go-types v0.0.0-20230514202307-77b895c55c7e h1:bw0mnSpPTUEAMa1vGqAF/+fXA7RTCxoby/cIRg6ETy4= -github.com/appclacks/go-types v0.0.0-20230514202307-77b895c55c7e/go.mod h1:ULkbKlyVigBCY+eSEV0scorq+akwJlVbdnLI5xI8IwU= +github.com/appclacks/go-types v0.0.0-20230701132920-beebbdd4d0ee h1:fqC3uBkZc33S3XAxHmZzcUfmzoGR3GLalryD8YJq4Qw= +github.com/appclacks/go-types v0.0.0-20230701132920-beebbdd4d0ee/go.mod h1:ULkbKlyVigBCY+eSEV0scorq+akwJlVbdnLI5xI8IwU= github.com/cheynewallace/tabby v1.1.1 h1:JvUR8waht4Y0S3JF17G6Vhyt+FRhnqVCkk8l4YrOU54= github.com/cheynewallace/tabby v1.1.1/go.mod h1:Pba/6cUL8uYqvOc9RkyvFbHGrQ9wShyrn6/S/1OYVys= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= diff --git a/vendor/github.com/appclacks/go-types/healthcheck_http.go b/vendor/github.com/appclacks/go-types/healthcheck_http.go index 945f1fa..739b261 100644 --- a/vendor/github.com/appclacks/go-types/healthcheck_http.go +++ b/vendor/github.com/appclacks/go-types/healthcheck_http.go @@ -5,6 +5,7 @@ type HealthcheckHTTPDefinition struct { Target string `json:"target" validate:"required,max=255,min=1"` Method string `json:"method" validate:"required,oneof=GET POST PUT DELETE HEAD"` Port uint `json:"port" validate:"required,max=65535,min=1"` + Host string `json:"host,omitempty"` Redirect bool `json:"redirect"` Query map[string]string `json:"query,omitempty" validate:"max=20"` Body string `json:"body,omitempty"` diff --git a/vendor/modules.txt b/vendor/modules.txt index 7989e87..e4d9554 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/appclacks/go-types v0.0.0-20230514202307-77b895c55c7e +# github.com/appclacks/go-types v0.0.0-20230701132920-beebbdd4d0ee ## explicit; go 1.19 github.com/appclacks/go-types # github.com/cheynewallace/tabby v1.1.1