Changed the http field to path
This commit is contained in:
parent
7141b11c16
commit
bb7f29f023
|
@ -27,7 +27,7 @@ type ServiceCheck struct {
|
||||||
Name string
|
Name string
|
||||||
Type string
|
Type string
|
||||||
Script string
|
Script string
|
||||||
Http string
|
Path string
|
||||||
Protocol string
|
Protocol string
|
||||||
Interval time.Duration
|
Interval time.Duration
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
"github.com/hashicorp/nomad/nomad/structs"
|
"github.com/hashicorp/nomad/nomad/structs"
|
||||||
"log"
|
"log"
|
||||||
|
"path"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -180,7 +181,8 @@ func (c *ConsulClient) makeChecks(service *structs.Service, ip string, port int)
|
||||||
}
|
}
|
||||||
switch check.Type {
|
switch check.Type {
|
||||||
case structs.ServiceCheckHTTP:
|
case structs.ServiceCheckHTTP:
|
||||||
c.HTTP = fmt.Sprintf("%s://%s:%d/%s", check.Protocol, ip, port, check.Http)
|
baseUrl := fmt.Sprintf("%s://%s:%d", check.Protocol, ip, port)
|
||||||
|
c.HTTP = path.Join(baseUrl, check.Path)
|
||||||
case structs.ServiceCheckTCP:
|
case structs.ServiceCheckTCP:
|
||||||
c.TCP = fmt.Sprintf("%s:%d", ip, port)
|
c.TCP = fmt.Sprintf("%s:%d", ip, port)
|
||||||
case structs.ServiceCheckScript:
|
case structs.ServiceCheckScript:
|
||||||
|
|
|
@ -1009,7 +1009,7 @@ type ServiceCheck struct {
|
||||||
Name string // Name of the check, defaults to id
|
Name string // Name of the check, defaults to id
|
||||||
Type string // Type of the check - tcp, http, docker and script
|
Type string // Type of the check - tcp, http, docker and script
|
||||||
Script string // Script to invoke for script check
|
Script string // Script to invoke for script check
|
||||||
Http string // path of the health check url for http type check
|
Path string // path of the health check url for http type check
|
||||||
Protocol string // Protocol to use if check is http, defaults to http
|
Protocol string // Protocol to use if check is http, defaults to http
|
||||||
Interval time.Duration // Interval of the check
|
Interval time.Duration // Interval of the check
|
||||||
Timeout time.Duration // Timeout of the response from the check before consul fails the check
|
Timeout time.Duration // Timeout of the response from the check before consul fails the check
|
||||||
|
@ -1017,16 +1017,16 @@ type ServiceCheck struct {
|
||||||
|
|
||||||
func (sc *ServiceCheck) Validate() error {
|
func (sc *ServiceCheck) Validate() error {
|
||||||
t := strings.ToLower(sc.Type)
|
t := strings.ToLower(sc.Type)
|
||||||
if sc.Type == ServiceCheckHTTP && sc.Http == "" {
|
if t != ServiceCheckTCP && t != ServiceCheckHTTP {
|
||||||
|
return fmt.Errorf("Check with name %v has invalid check type: %s ", sc.Name, sc.Type)
|
||||||
|
}
|
||||||
|
if sc.Type == ServiceCheckHTTP && sc.Path == "" {
|
||||||
return fmt.Errorf("http checks needs the Http path information.")
|
return fmt.Errorf("http checks needs the Http path information.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if sc.Type == ServiceCheckScript && sc.Script == "" {
|
if sc.Type == ServiceCheckScript && sc.Script == "" {
|
||||||
return fmt.Errorf("Script checks need the script to invoke")
|
return fmt.Errorf("Script checks need the script to invoke")
|
||||||
}
|
}
|
||||||
if t != ServiceCheckTCP && t != ServiceCheckHTTP {
|
|
||||||
return fmt.Errorf("Check with name %v has invalid check type: %s ", sc.Name, sc.Type)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue