Skip to content

Commit

Permalink
renamed stanza to block for consistency with other projects (#15941)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkazmierczak authored Jan 30, 2023
1 parent dc77354 commit 949a6f6
Show file tree
Hide file tree
Showing 164 changed files with 853 additions and 854 deletions.
2 changes: 1 addition & 1 deletion .release/ci.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ event "fossa-scan" {
}

## These are promotion and post-publish events
## they should be added to the end of the file after the verify event stanza.
## they should be added to the end of the file after the verify event block.

event "trigger-staging" {
// This event is dispatched by the bob trigger-promotion command // and is required - do not delete.
Expand Down
6 changes: 3 additions & 3 deletions acl/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

const (
// The following levels are the only valid values for the `policy = "read"` stanza.
// The following levels are the only valid values for the `policy = "read"` block.
// When policies are merged together, the most privilege is granted, except for deny
// which always takes precedence and supersedes.
PolicyDeny = "deny"
Expand All @@ -20,7 +20,7 @@ const (

const (
// The following are the fine-grained capabilities that can be granted within a namespace.
// The Policy stanza is a short hand for granting several of these. When capabilities are
// The Policy block is a short hand for granting several of these. When capabilities are
// combined we take the union of all capabilities. If the deny capability is present, it
// takes precedence and overwrites all other capabilities.

Expand Down Expand Up @@ -54,7 +54,7 @@ var (

const (
// The following are the fine-grained capabilities that can be granted for a volume set.
// The Policy stanza is a short hand for granting several of these. When capabilities are
// The Policy block is a short hand for granting several of these. When capabilities are
// combined we take the union of all capabilities. If the deny capability is present, it
// takes precedence and overwrites all other capabilities.

Expand Down
8 changes: 4 additions & 4 deletions api/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (c *Consul) MergeNamespace(namespace *string) {
}
}

// ConsulConnect represents a Consul Connect jobspec stanza.
// ConsulConnect represents a Consul Connect jobspec block.
type ConsulConnect struct {
Native bool `hcl:"native,optional"`
Gateway *ConsulGateway `hcl:"gateway,block"`
Expand All @@ -59,7 +59,7 @@ func (cc *ConsulConnect) Canonicalize() {
}

// ConsulSidecarService represents a Consul Connect SidecarService jobspec
// stanza.
// block.
type ConsulSidecarService struct {
Tags []string `hcl:"tags,optional"`
Port string `hcl:"port,optional"`
Expand Down Expand Up @@ -133,7 +133,7 @@ func (st *SidecarTask) Canonicalize() {
}
}

// ConsulProxy represents a Consul Connect sidecar proxy jobspec stanza.
// ConsulProxy represents a Consul Connect sidecar proxy jobspec block.
type ConsulProxy struct {
LocalServiceAddress string `mapstructure:"local_service_address" hcl:"local_service_address,optional"`
LocalServicePort int `mapstructure:"local_service_port" hcl:"local_service_port,optional"`
Expand Down Expand Up @@ -197,7 +197,7 @@ func (c *ConsulMeshGateway) Copy() *ConsulMeshGateway {
}
}

// ConsulUpstream represents a Consul Connect upstream jobspec stanza.
// ConsulUpstream represents a Consul Connect upstream jobspec block.
type ConsulUpstream struct {
DestinationName string `mapstructure:"destination_name" hcl:"destination_name,optional"`
DestinationNamespace string `mapstructure:"destination_namespace" hcl:"destination_namespace,optional"`
Expand Down
2 changes: 1 addition & 1 deletion api/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ type SchedulerSetConfigurationResponse struct {
}

// SchedulerAlgorithm is an enum string that encapsulates the valid options for a
// SchedulerConfiguration stanza's SchedulerAlgorithm. These modes will allow the
// SchedulerConfiguration block's SchedulerAlgorithm. These modes will allow the
// scheduler to be user-selectable.
type SchedulerAlgorithm string

Expand Down
2 changes: 1 addition & 1 deletion api/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ type TaskEvent struct {
}

// CSIPluginType is an enum string that encapsulates the valid options for a
// CSIPlugin stanza's Type. These modes will allow the plugin to be used in
// CSIPlugin block's Type. These modes will allow the plugin to be used in
// different ways by the client.
type CSIPluginType string

Expand Down
4 changes: 2 additions & 2 deletions api/tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ func TestTaskGroup_Merge_Update(t *testing.T) {
}
job.Canonicalize()

// Merge and canonicalize part of an update stanza
// Merge and canonicalize part of an update block
tg := &TaskGroup{
Name: pointerOf("foo"),
Update: &UpdateStrategy{
Expand Down Expand Up @@ -743,7 +743,7 @@ func TestTaskGroup_Canonicalize_MigrateStrategy(t *testing.T) {
}
}

// TestSpread_Canonicalize asserts that the spread stanza is canonicalized correctly
// TestSpread_Canonicalize asserts that the spread block is canonicalized correctly
func TestSpread_Canonicalize(t *testing.T) {
testutil.Parallel(t)

Expand Down
2 changes: 1 addition & 1 deletion client/allocrunner/consul_grpc_sock_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (
// consulGRPCSocketHook creates Unix sockets to allow communication from inside a
// netns to Consul gRPC endpoint.
//
// Noop for allocations without a group Connect stanza using bridge networking.
// Noop for allocations without a group Connect block using bridge networking.
type consulGRPCSocketHook struct {
logger hclog.Logger

Expand Down
2 changes: 1 addition & 1 deletion client/allocrunner/network_manager_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func netModeToIsolationMode(netMode string) drivers.NetIsolationMode {
func newNetworkConfigurator(log hclog.Logger, alloc *structs.Allocation, config *clientconfig.Config) (NetworkConfigurator, error) {
tg := alloc.Job.LookupTaskGroup(alloc.TaskGroup)

// Check if network stanza is given
// Check if network block is given
if len(tg.Networks) == 0 {
return &hostNetworkConfigurator{}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion client/allocrunner/taskrunner/connect_native_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (h *connectNativeHook) hostEnv(env map[string]string) map[string]string {
func (h *connectNativeHook) maybeSetSITokenEnv(dir, task string, env map[string]string) error {
if _, exists := env["CONSUL_HTTP_TOKEN"]; exists {
// Consul token was already set - typically by using the Vault integration
// and a template stanza to set the environment. Ignore the SI token as
// and a template block to set the environment. Ignore the SI token as
// the configured token takes precedence.
return nil
}
Expand Down
10 changes: 5 additions & 5 deletions client/allocrunner/taskrunner/connect_native_hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

func getTestConsul(t *testing.T) *consultest.TestServer {
testConsul, err := consultest.NewTestServerConfigT(t, func(c *consultest.TestServerConfig) {
c.Peering = nil // fix for older versions of Consul (<1.13.0) that don't support peering
c.Peering = nil // fix for older versions of Consul (<1.13.0) that don't support peering
if !testing.Verbose() { // disable consul logging if -v not set
c.Stdout = ioutil.Discard
c.Stderr = ioutil.Discard
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestConnectNativeHook_tlsEnv(t *testing.T) {
},
}

// existing config from task env stanza
// existing config from task env block
taskEnv := map[string]string{
"CONSUL_CACERT": "fakeCA.pem",
"CONSUL_CLIENT_CERT": "fakeCert.pem",
Expand Down Expand Up @@ -490,7 +490,7 @@ func TestTaskRunner_ConnectNativeHook_shareTLS(t *testing.T) {
request := &interfaces.TaskPrestartRequest{
Task: tg.Tasks[0],
TaskDir: allocDir.NewTaskDir(tg.Tasks[0].Name),
TaskEnv: taskenv.NewEmptyTaskEnv(), // nothing set in env stanza
TaskEnv: taskenv.NewEmptyTaskEnv(), // nothing set in env block
}
require.NoError(t, request.TaskDir.Build(false, nil))

Expand Down Expand Up @@ -620,7 +620,7 @@ func TestTaskRunner_ConnectNativeHook_shareTLS_override(t *testing.T) {
request := &interfaces.TaskPrestartRequest{
Task: tg.Tasks[0],
TaskDir: allocDir.NewTaskDir(tg.Tasks[0].Name),
TaskEnv: taskEnv, // env stanza is configured w/ non-default tls configs
TaskEnv: taskEnv, // env block is configured w/ non-default tls configs
}
require.NoError(t, request.TaskDir.Build(false, nil))

Expand All @@ -634,7 +634,7 @@ func TestTaskRunner_ConnectNativeHook_shareTLS_override(t *testing.T) {
require.True(t, response.Done)

// Assert environment variable for CONSUL_HTTP_SSL is set, because it was
// the only one not overridden by task env stanza config
// the only one not overridden by task env block config
require.NotEmpty(t, response.Env)
require.Equal(t, map[string]string{
"CONSUL_HTTP_SSL": "true",
Expand Down
18 changes: 9 additions & 9 deletions client/allocrunner/taskrunner/task_runner_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (tr *TaskRunner) initHooks() {
newDeviceHook(tr.devicemanager, hookLogger),
}

// If the task has a CSI stanza, add the hook.
// If the task has a CSI block, add the hook.
if task.CSIPluginConfig != nil {
tr.runnerHooks = append(tr.runnerHooks, newCSIPluginSupervisorHook(
&csiPluginSupervisorHookConfig{
Expand All @@ -86,14 +86,14 @@ func (tr *TaskRunner) initHooks() {
// If Vault is enabled, add the hook
if task.Vault != nil {
tr.runnerHooks = append(tr.runnerHooks, newVaultHook(&vaultHookConfig{
vaultStanza: task.Vault,
client: tr.vaultClient,
events: tr,
lifecycle: tr,
updater: tr,
logger: hookLogger,
alloc: tr.Alloc(),
task: tr.taskName,
vaultBlock: task.Vault,
client: tr.vaultClient,
events: tr,
lifecycle: tr,
updater: tr,
logger: hookLogger,
alloc: tr.Alloc(),
task: tr.taskName,
}))
}

Expand Down
30 changes: 15 additions & 15 deletions client/allocrunner/taskrunner/vault_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ func (tr *TaskRunner) updatedVaultToken(token string) {
}

type vaultHookConfig struct {
vaultStanza *structs.Vault
client vaultclient.VaultClient
events ti.EventEmitter
lifecycle ti.TaskLifecycle
updater vaultTokenUpdateHandler
logger log.Logger
alloc *structs.Allocation
task string
vaultBlock *structs.Vault
client vaultclient.VaultClient
events ti.EventEmitter
lifecycle ti.TaskLifecycle
updater vaultTokenUpdateHandler
logger log.Logger
alloc *structs.Allocation
task string
}

type vaultHook struct {
// vaultStanza is the vault stanza for the task
vaultStanza *structs.Vault
// vaultBlock is the vault block for the task
vaultBlock *structs.Vault

// eventEmitter is used to emit events to the task
eventEmitter ti.EventEmitter
Expand Down Expand Up @@ -97,7 +97,7 @@ type vaultHook struct {
func newVaultHook(config *vaultHookConfig) *vaultHook {
ctx, cancel := context.WithCancel(context.Background())
h := &vaultHook{
vaultStanza: config.vaultStanza,
vaultBlock: config.vaultBlock,
client: config.client,
eventEmitter: config.events,
lifecycle: config.lifecycle,
Expand Down Expand Up @@ -239,9 +239,9 @@ OUTER:
h.future.Set(token)

if updatedToken {
switch h.vaultStanza.ChangeMode {
switch h.vaultBlock.ChangeMode {
case structs.VaultChangeModeSignal:
s, err := signals.Parse(h.vaultStanza.ChangeSignal)
s, err := signals.Parse(h.vaultBlock.ChangeSignal)
if err != nil {
h.logger.Error("failed to parse signal", "error", err)
h.lifecycle.Kill(h.ctx,
Expand All @@ -252,7 +252,7 @@ OUTER:
}

event := structs.NewTaskEvent(structs.TaskSignaling).SetTaskSignal(s).SetDisplayMessage("Vault: new Vault token acquired")
if err := h.lifecycle.Signal(event, h.vaultStanza.ChangeSignal); err != nil {
if err := h.lifecycle.Signal(event, h.vaultBlock.ChangeSignal); err != nil {
h.logger.Error("failed to send signal", "error", err)
h.lifecycle.Kill(h.ctx,
structs.NewTaskEvent(structs.TaskKilling).
Expand All @@ -268,7 +268,7 @@ OUTER:
case structs.VaultChangeModeNoop:
fallthrough
default:
h.logger.Error("invalid Vault change mode", "mode", h.vaultStanza.ChangeMode)
h.logger.Error("invalid Vault change mode", "mode", h.vaultBlock.ChangeMode)
}

// We have handled it
Expand Down
4 changes: 2 additions & 2 deletions client/serviceregistration/nsd/nsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ServiceRegistrationHandler struct {
cfg *ServiceRegistrationHandlerCfg

// checkWatcher watches checks of services in the Nomad service provider,
// and restarts associated tasks in accordance with their check_restart stanza.
// and restarts associated tasks in accordance with their check_restart block.
checkWatcher serviceregistration.CheckWatcher

// registrationEnabled tracks whether this handler is enabled for
Expand Down Expand Up @@ -57,7 +57,7 @@ type ServiceRegistrationHandlerCfg struct {
RPCFn func(method string, args, resp interface{}) error

// CheckWatcher watches checks of services in the Nomad service provider,
// and restarts associated tasks in accordance with their check_restart stanza.
// and restarts associated tasks in accordance with their check_restart block.
CheckWatcher serviceregistration.CheckWatcher
}

Expand Down
4 changes: 2 additions & 2 deletions client/serviceregistration/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ type WorkloadServices struct {
ProviderNamespace string

// Restarter allows restarting the task or task group depending on the
// check_restart stanzas.
// check_restart blocks.
Restarter WorkloadRestarter

// Services and checks to register for the task.
Services []*structs.Service

// Networks from the task's resources stanza.
// Networks from the task's resources block.
// TODO: remove and use Ports
Networks structs.Networks

Expand Down
4 changes: 2 additions & 2 deletions command/agent/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func (c *Command) IsValidConfig(config, cmdConfig *Config) bool {
}

if err := config.Client.Artifact.Validate(); err != nil {
c.Ui.Error(fmt.Sprintf("client.artifact stanza invalid: %v", err))
c.Ui.Error(fmt.Sprintf("client.artifact block invalid: %v", err))
return false
}

Expand Down Expand Up @@ -1191,7 +1191,7 @@ func (c *Command) startupJoin(config *Config) error {
new = len(config.Server.ServerJoin.StartJoin)
}
if old != 0 && new != 0 {
return fmt.Errorf("server_join and start_join cannot both be defined; prefer setting the server_join stanza")
return fmt.Errorf("server_join and start_join cannot both be defined; prefer setting the server_join block")
}

// Nothing to do
Expand Down
2 changes: 1 addition & 1 deletion command/agent/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func TestIsValidConfig(t *testing.T) {
},
},
},
err: "client.artifact stanza invalid: http_read_timeout must be > 0",
err: "client.artifact block invalid: http_read_timeout must be > 0",
},
}

Expand Down
6 changes: 3 additions & 3 deletions command/agent/consul/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
func newConnect(serviceID string, info structs.AllocInfo, serviceName string, nc *structs.ConsulConnect, networks structs.Networks, ports structs.AllocatedPorts) (*api.AgentServiceConnect, error) {
switch {
case nc == nil:
// no connect stanza means there is no connect service to register
// no connect block means there is no connect service to register
return nil, nil

case nc.IsGateway():
Expand Down Expand Up @@ -57,7 +57,7 @@ func newConnectGateway(connect *structs.ConsulConnect) *api.AgentServiceConnectP

var envoyConfig map[string]interface{}

// Populate the envoy configuration from the gateway.proxy stanza, if
// Populate the envoy configuration from the gateway.proxy block, if
// such configuration is provided.
if proxy := connect.Gateway.Proxy; proxy != nil {
envoyConfig = make(map[string]interface{})
Expand Down Expand Up @@ -94,7 +94,7 @@ func newConnectGateway(connect *structs.ConsulConnect) *api.AgentServiceConnectP

func connectSidecarRegistration(serviceID string, info structs.AllocInfo, css *structs.ConsulSidecarService, networks structs.Networks, ports structs.AllocatedPorts) (*api.AgentServiceRegistration, error) {
if css == nil {
// no sidecar stanza means there is no sidecar service to register
// no sidecar block means there is no sidecar service to register
return nil, nil
}

Expand Down
6 changes: 3 additions & 3 deletions command/agent/consul/service_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const (

// Additional Consul ACLs required
// - Consul Template: key:read
// Used in tasks with template stanza that use Consul keys.
// Used in tasks with template block that use Consul keys.

// CatalogAPI is the consul/api.Catalog API used by Nomad.
//
Expand Down Expand Up @@ -1120,8 +1120,8 @@ func (c *ServiceClient) serviceRegs(
Port: port,
Meta: meta,
TaggedAddresses: taggedAddresses,
Connect: connect, // will be nil if no Connect stanza
Proxy: gateway, // will be nil if no Connect Gateway stanza
Connect: connect, // will be nil if no Connect block
Proxy: gateway, // will be nil if no Connect Gateway block
Checks: make([]*api.AgentServiceCheck, 0, len(service.Checks)),
}
ops.regServices = append(ops.regServices, serviceReg)
Expand Down
2 changes: 1 addition & 1 deletion command/agent/job_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (s *HTTPServer) jobUpdate(resp http.ResponseWriter, req *http.Request,
if args.Job.Type != nil && *args.Job.Type == api.JobTypeSystem {
for _, tg := range args.Job.TaskGroups {
if tg.Scaling != nil {
return nil, CodedError(400, "Task groups with job type system do not support scaling stanzas")
return nil, CodedError(400, "Task groups with job type system do not support scaling blocks")
}
}
}
Expand Down
Loading

0 comments on commit 949a6f6

Please sign in to comment.