mock

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2022 License: MPL-2.0 Imports: 14 Imported by: 125

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ACLManagementToken added in v0.7.0

func ACLManagementToken() *structs.ACLToken

func ACLPolicy added in v0.7.0

func ACLPolicy() *structs.ACLPolicy

func ACLRole added in v1.4.0

func ACLRole() *structs.ACLRole

func ACLToken added in v0.7.0

func ACLToken() *structs.ACLToken

func AgentPolicy added in v0.7.0

func AgentPolicy(policy string) string

AgentPolicy is a helper for generating the hcl for a given agent policy.

func Alloc

func Alloc() *structs.Allocation

func AllocForNode added in v1.0.16

func AllocForNode(n *structs.Node) *structs.Allocation

func AllocForNodeWithoutReservedPort added in v1.0.16

func AllocForNodeWithoutReservedPort(n *structs.Node) *structs.Allocation

func AllocNetworkStatus added in v1.0.0

func AllocNetworkStatus() *structs.AllocNetworkStatus

func AllocWithoutReservedPort added in v1.0.16

func AllocWithoutReservedPort() *structs.Allocation

func BatchAlloc added in v0.8.0

func BatchAlloc() *structs.Allocation

func BatchConnectAlloc added in v0.10.4

func BatchConnectAlloc() *structs.Allocation

BatchConnectAlloc is useful for testing task runner things.

func BatchConnectJob added in v0.10.4

func BatchConnectJob() *structs.Job

func BatchJob added in v0.8.0

func BatchJob() *structs.Job

func BlockedEval added in v1.1.0

func BlockedEval() *structs.Evaluation

func CSIPlugin added in v0.11.0

func CSIPlugin() *structs.CSIPlugin

func CSIPluginJob added in v1.1.13

func CSIPluginJob(pluginType structs.CSIPluginType, pluginID string) *structs.Job

func CSIVolume added in v0.11.0

func CSIVolume(plugin *structs.CSIPlugin) *structs.CSIVolume

func ConnectAlloc added in v0.10.0

func ConnectAlloc() *structs.Allocation

ConnectAlloc adds a Connect proxy sidecar group service to mock.Alloc.

func ConnectIngressGatewayAlloc added in v0.12.4

func ConnectIngressGatewayAlloc(mode string) *structs.Allocation

func ConnectIngressGatewayJob added in v0.12.4

func ConnectIngressGatewayJob(mode string, inject bool) *structs.Job

ConnectIngressGatewayJob creates a structs.Job that contains the definition of a Consul Ingress Gateway service. The mode is the name of the network mode assumed by the task group. If inject is true, a corresponding Task is set on the group's Tasks (i.e. what the job would look like after job mutation).

func ConnectJob added in v0.10.0

func ConnectJob() *structs.Job

ConnectJob adds a Connect proxy sidecar group service to mock.Job.

Note this does *not* include the Job.Register mutation that inserts the associated Sidecar Task (nor the hook that configures envoy as the default).

func ConnectMeshGatewayJob added in v1.1.1

func ConnectMeshGatewayJob(mode string, inject bool) *structs.Job

ConnectMeshGatewayJob creates a structs.Job that contains the definition of a Consul Mesh Gateway service. The mode is the name of the network mode assumed by the task group. If inject is true, a corresponding task is set on the group's Tasks (i.e. what the job would look like after job mutation).

func ConnectNativeAlloc added in v0.12.2

func ConnectNativeAlloc(mode string) *structs.Allocation

ConnectNativeAlloc creates an alloc with a connect native task.

func ConnectNativeJob added in v0.12.2

func ConnectNativeJob(mode string) *structs.Job

func ConnectSidecarTask added in v1.0.0

func ConnectSidecarTask() *structs.Task

func ConnectTerminatingGatewayJob added in v1.1.1

func ConnectTerminatingGatewayJob(mode string, inject bool) *structs.Job

ConnectTerminatingGatewayJob creates a structs.Job that contains the definition of a Consul Terminating Gateway service. The mode is the name of the network mode assumed by the task group. If inject is true, a corresponding task is set on the group's Tasks (i.e. what the job would look like after mutation).

func CreatePolicy added in v0.7.0

func CreatePolicy(t testing.T, state StateStore, index uint64, name, rule string)

CreatePolicy creates a policy with the given name and rule.

func CreatePolicyAndToken added in v0.7.0

func CreatePolicyAndToken(t testing.T, state StateStore, index uint64, name, rule string) *structs.ACLToken

CreatePolicyAndToken creates a policy and then returns a token configured for just that policy. CreatePolicyAndToken uses the given index and index+1.

func CreateToken added in v0.7.0

func CreateToken(t testing.T, state StateStore, index uint64, policies []string) *structs.ACLToken

CreateToken creates a local, client token for the given policies

func Deployment added in v0.6.0

func Deployment() *structs.Deployment

func DrainNode added in v1.1.0

func DrainNode() *structs.Node

func Eval

func Eval() *structs.Evaluation

func Events added in v1.0.0

func Events(index uint64) *structs.Events

func HCL added in v0.8.2

func HCL() string

func HostVolumePolicy added in v0.10.0

func HostVolumePolicy(vol string, policy string, capabilities []string) string

HostVolumePolicy is a helper for generating the policy hcl for a given host-volume. Either policy or capabilities may be nil but not both.

func Job

func Job() *structs.Job

func JobSummary added in v0.4.1

func JobSummary(jobID string) *structs.JobSummary

func JobSysBatchSummary added in v1.2.0

func JobSysBatchSummary(jobID string) *structs.JobSummary

func JobWithScalingPolicy added in v0.11.0

func JobWithScalingPolicy() (*structs.Job, *structs.ScalingPolicy)

func LifecycleAlloc added in v0.11.0

func LifecycleAlloc() *structs.Allocation

func LifecycleAllocFromTasks added in v1.3.4

func LifecycleAllocFromTasks(tasks []LifecycleTaskDef) *structs.Allocation

LifecycleAllocFromTasks generates an Allocation with mock tasks that have the provided lifecycles.

func LifecycleAllocWithPoststartDeploy added in v1.1.13

func LifecycleAllocWithPoststartDeploy() *structs.Allocation

func LifecycleAllocWithPoststopDeploy added in v1.0.2

func LifecycleAllocWithPoststopDeploy() *structs.Allocation

func LifecycleInitTask added in v0.11.0

func LifecycleInitTask(resources structs.Resources, i int) *structs.Task

func LifecycleJob added in v0.11.0

func LifecycleJob() *structs.Job

func LifecycleJobWithPoststartDeploy added in v1.1.13

func LifecycleJobWithPoststartDeploy() *structs.Job

func LifecycleJobWithPoststopDeploy added in v1.0.2

func LifecycleJobWithPoststopDeploy() *structs.Job

func LifecycleMainTask added in v0.11.0

func LifecycleMainTask(resources structs.Resources, i int) *structs.Task

func LifecycleSideTask added in v0.11.0

func LifecycleSideTask(resources structs.Resources, i int) *structs.Task

func MaxParallelJob added in v0.10.0

func MaxParallelJob() *structs.Job

func MultiTaskGroupJob added in v1.1.13

func MultiTaskGroupJob() *structs.Job

func MultiregionJob added in v0.12.0

func MultiregionJob() *structs.Job

func Namespace added in v1.0.0

func Namespace() *structs.Namespace

func NamespacePolicy added in v0.7.0

func NamespacePolicy(namespace string, policy string, capabilities []string) string

NamespacePolicy is a helper for generating the policy hcl for a given namespace. Either policy or capabilities may be nil but not both.

func NamespacePolicyWithVariables added in v1.4.0

func NamespacePolicyWithVariables(namespace string, policy string, capabilities []string, svars map[string][]string) string

NamespacePolicyWithVariables is a helper for generating the policy hcl for a given namespace. Either policy or capabilities may be nil but not both.

func NewNetworkStatus added in v1.4.0

func NewNetworkStatus(address string) structs.NetworkStatus

NewNetworkStatus creates a mock NetworkStatus based on address.

func Node

func Node() *structs.Node

func NodePolicy added in v0.7.0

func NodePolicy(policy string) string

NodePolicy is a helper for generating the hcl for a given node policy.

func NvidiaNode added in v0.9.0

func NvidiaNode() *structs.Node

NvidiaNode returns a node with two instances of an Nvidia GPU

func PeriodicJob added in v0.3.0

func PeriodicJob() *structs.Job

func Plan

func Plan() *structs.Plan

func PlanResult

func PlanResult() *structs.PlanResult

func PluginPolicy added in v0.11.0

func PluginPolicy(policy string) string

PluginPolicy is a helper for generating the hcl for a given plugin policy.

func QuotaPolicy added in v0.7.0

func QuotaPolicy(policy string) string

QuotaPolicy is a helper for generating the hcl for a given quota policy.

func SITokenAccessor added in v0.10.4

func SITokenAccessor() *structs.SITokenAccessor

func ScalingPolicy added in v0.11.0

func ScalingPolicy() *structs.ScalingPolicy

func ServiceRegistrations added in v1.3.0

func ServiceRegistrations() []*structs.ServiceRegistration

ServiceRegistrations generates an array containing two unique service registrations.

func SysBatchAlloc added in v1.2.0

func SysBatchAlloc() *structs.Allocation

func SystemAlloc added in v0.8.0

func SystemAlloc() *structs.Allocation

func SystemBatchJob added in v1.2.0

func SystemBatchJob() *structs.Job

func SystemJob added in v0.2.0

func SystemJob() *structs.Job

func Variable added in v1.4.0

func Variable() *structs.VariableDecrypted

func VariableEncrypted added in v1.4.0

func VariableEncrypted() *structs.VariableEncrypted

func VariableLifecycleJob added in v0.11.0

func VariableLifecycleJob(resources structs.Resources, main int, init int, side int) *structs.Job

func VariablePolicy added in v1.4.0

func VariablePolicy(svars map[string][]string) string

VariablePolicy is a helper for generating the policy hcl for a given variable block inside of a namespace.

func VaultAccessor added in v0.5.0

func VaultAccessor() *structs.VaultAccessor

Types

type CheckShim added in v1.4.0

type CheckShim struct{}

CheckShim is a mock implementation of checkstore.Shim

So far the implementation does nothing.

func (*CheckShim) Difference added in v1.4.0

func (s *CheckShim) Difference(allocID string, ids []structs.CheckID) []structs.CheckID

func (*CheckShim) List added in v1.4.0

func (s *CheckShim) List(allocID string) map[structs.CheckID]*structs.CheckQueryResult

func (*CheckShim) Purge added in v1.4.0

func (s *CheckShim) Purge(allocID string) error

func (*CheckShim) Remove added in v1.4.0

func (s *CheckShim) Remove(allocID string, ids []structs.CheckID) error

func (*CheckShim) Set added in v1.4.0

func (s *CheckShim) Set(allocID string, result *structs.CheckQueryResult) error

func (*CheckShim) Snapshot added in v1.4.0

func (s *CheckShim) Snapshot() map[string]string

type LifecycleTaskDef added in v1.3.4

type LifecycleTaskDef struct {
	Name      string
	RunFor    string
	ExitCode  int
	Hook      string
	IsSidecar bool
}

type MockVariables added in v1.4.0

type MockVariables map[string]*structs.VariableDecrypted

func Variables added in v1.4.0

func Variables(minU, maxU uint8) MockVariables

Variables returns a random number of variables between min and max inclusive.

func (MockVariables) List added in v1.4.0

func (svs MockVariables) List() []*structs.VariableDecrypted

func (MockVariables) ListPaths added in v1.4.0

func (svs MockVariables) ListPaths() []string

type MockVariablesEncrypted added in v1.4.0

type MockVariablesEncrypted map[string]*structs.VariableEncrypted

func VariablesEncrypted added in v1.4.0

func VariablesEncrypted(minU, maxU uint8) MockVariablesEncrypted

VariablesEncrypted returns a random number of variables between min and max inclusive.

func (MockVariablesEncrypted) List added in v1.4.0

func (MockVariablesEncrypted) ListPaths added in v1.4.0

func (svs MockVariablesEncrypted) ListPaths() []string

type NetworkStatus added in v1.4.0

type NetworkStatus struct {
	// contains filtered or unexported fields
}

NetworkStatus is a mock implementation of structs.NetworkStatus

func (*NetworkStatus) NetworkStatus added in v1.4.0

func (ns *NetworkStatus) NetworkStatus() *structs.AllocNetworkStatus

type StateStore added in v0.7.0

type StateStore interface {
	UpsertACLPolicies(msgType structs.MessageType, index uint64, policies []*structs.ACLPolicy) error
	UpsertACLTokens(msgType structs.MessageType, index uint64, tokens []*structs.ACLToken) error
}

StateStore defines the methods required from state.StateStore but avoids a circular dependency.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL