Skip to content

Commit

Permalink
chore: revert changes to serializable objects
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Nov 23, 2022
1 parent a1b509e commit b780037
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 38 deletions.
11 changes: 3 additions & 8 deletions client/taskenv/services.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package taskenv

import (
"net/http"

"github.com/hashicorp/nomad/nomad/structs"
)

Expand Down Expand Up @@ -52,17 +50,14 @@ func InterpolateServices(taskEnv *TaskEnv, services []*structs.Service) []*struc
return interpolated
}

func interpolateMapStringSliceString(taskEnv *TaskEnv, orig map[string][]string) http.Header {
func interpolateMapStringSliceString(taskEnv *TaskEnv, orig map[string][]string) map[string][]string {
if len(orig) == 0 {
return nil
}

m := http.Header{}
m := make(map[string][]string, len(orig))
for k, vs := range orig {
for _, v := range taskEnv.ParseAndReplace(vs) {
m.Add(taskEnv.ReplaceEnv(k), v)
}

m[taskEnv.ReplaceEnv(k)] = taskEnv.ParseAndReplace(vs)
}
return m
}
Expand Down
10 changes: 4 additions & 6 deletions client/taskenv/services_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package taskenv

import (
"net/http"
"testing"
"time"

Expand Down Expand Up @@ -127,11 +126,10 @@ func TestInterpolate_interpolateMapStringSliceString(t *testing.T) {
})

t.Run("not nil", func(t *testing.T) {
expected := http.Header{}
expected.Add("a", "b")
expected.Add("bar", "blah")
expected.Add("bar", "c")
require.Equal(t, expected, interpolateMapStringSliceString(testEnv, map[string][]string{
require.Equal(t, map[string][]string{
"a": {"b"},
"bar": {"blah", "c"},
}, interpolateMapStringSliceString(testEnv, map[string][]string{
"a": {"b"},
"${foo}": {"${baz}", "c"},
}))
Expand Down
46 changes: 22 additions & 24 deletions nomad/structs/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
"strings"
"time"

"net/http"

"github.com/hashicorp/consul/api"
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/go-set"
Expand Down Expand Up @@ -55,28 +53,28 @@ const (
// The fields available depend on the service provider the check is being
// registered into.
type ServiceCheck struct {
Name string // Name of the check, defaults to a generated label
Type string // Type of the check - tcp, http, docker and script
Command string // Command is the command to run for script checks
Args []string // Args is a list of arguments for script checks
Path string // path of the health check url for http type check
Protocol string // Protocol to use if check is http, defaults to http
PortLabel string // The port to use for tcp/http checks
Expose bool // Whether to have Envoy expose the check path (connect-enabled group-services only)
AddressMode string // Must be empty, "alloc", "host", or "driver"
Interval time.Duration // Interval of the check
Timeout time.Duration // Timeout of the response from the check before consul fails the check
InitialStatus string // Initial status of the check
TLSSkipVerify bool // Skip TLS verification when Protocol=https
Method string // HTTP Method to use (GET by default)
Header http.Header // HTTP Headers for Consul to set when making HTTP checks
CheckRestart *CheckRestart // If and when a task should be restarted based on checks
GRPCService string // Service for GRPC checks
GRPCUseTLS bool // Whether or not to use TLS for GRPC checks
TaskName string // What task to execute this check in
SuccessBeforePassing int // Number of consecutive successes required before considered healthy
FailuresBeforeCritical int // Number of consecutive failures required before considered unhealthy
Body string // Body to use in HTTP check
Name string // Name of the check, defaults to a generated label
Type string // Type of the check - tcp, http, docker and script
Command string // Command is the command to run for script checks
Args []string // Args is a list of arguments for script checks
Path string // path of the health check url for http type check
Protocol string // Protocol to use if check is http, defaults to http
PortLabel string // The port to use for tcp/http checks
Expose bool // Whether to have Envoy expose the check path (connect-enabled group-services only)
AddressMode string // Must be empty, "alloc", "host", or "driver"
Interval time.Duration // Interval of the check
Timeout time.Duration // Timeout of the response from the check before consul fails the check
InitialStatus string // Initial status of the check
TLSSkipVerify bool // Skip TLS verification when Protocol=https
Method string // HTTP Method to use (GET by default)
Header map[string][]string // HTTP Headers for Consul to set when making HTTP checks
CheckRestart *CheckRestart // If and when a task should be restarted based on checks
GRPCService string // Service for GRPC checks
GRPCUseTLS bool // Whether or not to use TLS for GRPC checks
TaskName string // What task to execute this check in
SuccessBeforePassing int // Number of consecutive successes required before considered healthy
FailuresBeforeCritical int // Number of consecutive failures required before considered unhealthy
Body string // Body to use in HTTP check
OnUpdate string
}

Expand Down

0 comments on commit b780037

Please sign in to comment.