nomad,client: apply smaller PR suggestions

Apply smaller suggestions like doc strings, variable names, etc.

Co-Authored-By: Nick Ethier <nethier@hashicorp.com>
Co-Authored-By: Michael Schurter <mschurter@hashicorp.com>
This commit is contained in:
Seth Hoenig 2020-01-15 08:41:23 -06:00
parent 78a7d1e426
commit be7c671919
4 changed files with 8 additions and 6 deletions

View File

@ -141,7 +141,7 @@ func (h *envoyBootstrapHook) Prestart(ctx context.Context, req *interfaces.TaskP
err = cmd.Run()
// Close bootstrap.json
_ = fd.Close()
fd.Close()
if err == nil {
// Happy path! Bootstrap was created, exit.
@ -157,7 +157,7 @@ func (h *envoyBootstrapHook) Prestart(ctx context.Context, req *interfaces.TaskP
// occurs, and (b) the file will either be rewritten on
// retry or eventually garbage collected if the task
// fails.
_ = os.Remove(bootstrapFilePath)
os.Remove(bootstrapFilePath)
// ExitErrors are recoverable since they indicate the
// command was runnable but exited with a unsuccessful
@ -249,12 +249,12 @@ func (e envoyBootstrapArgs) args() []string {
"-sidecar-for", e.sidecarFor,
}
if e.siToken != "" {
arguments = append(arguments, []string{"-token", e.siToken}...)
arguments = append(arguments, "-token", e.siToken)
}
return arguments
}
// maybeLoadSIToken reads the SI token saved to disk in the secretes directory
// maybeLoadSIToken reads the SI token saved to disk in the secrets directory
// by the service identities prestart hook. This envoy bootstrap hook blocks
// until the sids hook completes, so if the SI token is required to exist (i.e.
// Consul ACLs are enabled), it will be in place by the time we try to read it.

View File

@ -130,6 +130,8 @@ type envoyConfig struct {
} `json:"dynamic_resources"`
}
// TestEnvoyBootstrapHook_with_SI_token asserts the bootstrap file written for
// Envoy contains a Consul SI token.
func TestEnvoyBootstrapHook_with_SI_token(t *testing.T) {
t.Parallel()
testutil.RequireConsul(t)

View File

@ -18,7 +18,7 @@ import (
const (
// the name of this hook, used in logs
sidsHookName = "consul_sids"
sidsHookName = "consul_si_token"
// sidsBackoffBaseline is the baseline time for exponential backoff when
// attempting to retrieve a Consul SI token

View File

@ -105,7 +105,7 @@ const (
serviceNameWildcard = "*"
)
func (_ *consulACLsAPI) allowsServiceWrite(task string, cp *ConsulPolicy) bool {
func (cp *ConsulPolicy) allowsServiceWrite(task string) bool {
for _, service := range cp.Services {
name := strings.ToLower(service.Name)
policy := strings.ToLower(service.Policy)