mock

package
v0.0.0-...-ae3a0a2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ACLAuthMethod

func ACLAuthMethod() *structs.ACLAuthMethod

func ACLBindingRule

func ACLBindingRule() *structs.ACLBindingRule

func ACLManagementToken

func ACLManagementToken() *structs.ACLToken

func ACLPolicy

func ACLPolicy() *structs.ACLPolicy

func ACLRole

func ACLRole() *structs.ACLRole

func ACLToken

func ACLToken() *structs.ACLToken

func AgentPolicy

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

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

func AllocForNodeWithoutReservedPort

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

func AllocNetworkStatus

func AllocNetworkStatus() *structs.AllocNetworkStatus

func AllocWithoutReservedPort

func AllocWithoutReservedPort() *structs.Allocation

func BatchAlloc

func BatchAlloc() *structs.Allocation

func BatchConnectAlloc

func BatchConnectAlloc() *structs.Allocation

BatchConnectAlloc is useful for testing task runner things.

func BatchConnectJob

func BatchConnectJob() *structs.Job

func BatchJob

func BatchJob() *structs.Job

func BlockedEval

func BlockedEval() *structs.Evaluation

func CSIPlugin

func CSIPlugin() *structs.CSIPlugin

func CSIPluginJob

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

func CSIVolume

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

func ConnectAlloc

func ConnectAlloc() *structs.Allocation

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

func ConnectIngressGatewayAlloc

func ConnectIngressGatewayAlloc(mode string) *structs.Allocation

func ConnectIngressGatewayJob

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

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

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

func ConnectNativeAlloc(mode string) *structs.Allocation

ConnectNativeAlloc creates an alloc with a connect native task.

func ConnectNativeJob

func ConnectNativeJob(mode string) *structs.Job

func ConnectSidecarTask

func ConnectSidecarTask() *structs.Task

func ConnectTerminatingGatewayJob

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

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

CreatePolicy creates a policy with the given name and rule.

func CreatePolicyAndToken

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

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

func Deployment() *structs.Deployment

func DrainNode

func DrainNode() *structs.Node

func Eval

func Eval() *structs.Evaluation

func Events

func Events(index uint64) *structs.Events

func HCL

func HCL() string

func HostVolumePolicy

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

func JobSummary(jobID string) *structs.JobSummary

func JobSysBatchSummary

func JobSysBatchSummary(jobID string) *structs.JobSummary

func JobWithScalingPolicy

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

func LifecycleAlloc

func LifecycleAlloc() *structs.Allocation

func LifecycleAllocFromTasks

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

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

func LifecycleAllocWithPoststartDeploy

func LifecycleAllocWithPoststartDeploy() *structs.Allocation

func LifecycleAllocWithPoststopDeploy

func LifecycleAllocWithPoststopDeploy() *structs.Allocation

func LifecycleInitTask

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

func LifecycleJob

func LifecycleJob() *structs.Job

func LifecycleJobWithPoststartDeploy

func LifecycleJobWithPoststartDeploy() *structs.Job

func LifecycleJobWithPoststopDeploy

func LifecycleJobWithPoststopDeploy() *structs.Job

func LifecycleMainTask

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

func LifecycleSideTask

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

func MaxParallelJob

func MaxParallelJob() *structs.Job

func MultiTaskGroupJob

func MultiTaskGroupJob() *structs.Job

func MultiregionJob

func MultiregionJob() *structs.Job

func Namespace

func Namespace() *structs.Namespace

func NamespacePolicy

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

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

func NewNetworkStatus(address string) structs.NetworkStatus

NewNetworkStatus creates a mock NetworkStatus based on address.

func Node

func Node() *structs.Node

func NodePolicy

func NodePolicy(policy string) string

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

func NvidiaNode

func NvidiaNode() *structs.Node

NvidiaNode returns a node with two instances of an Nvidia GPU

func PeriodicJob

func PeriodicJob() *structs.Job

func Plan

func Plan() *structs.Plan

func PlanResult

func PlanResult() *structs.PlanResult

func PluginPolicy

func PluginPolicy(policy string) string

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

func QuotaPolicy

func QuotaPolicy(policy string) string

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

func SITokenAccessor

func SITokenAccessor() *structs.SITokenAccessor

func ScalingPolicy

func ScalingPolicy() *structs.ScalingPolicy

func ServiceRegistrations

func ServiceRegistrations() []*structs.ServiceRegistration

ServiceRegistrations generates an array containing two unique service registrations.

func SysBatchAlloc

func SysBatchAlloc() *structs.Allocation

func SystemAlloc

func SystemAlloc() *structs.Allocation

func SystemBatchJob

func SystemBatchJob() *structs.Job

func SystemJob

func SystemJob() *structs.Job

func Variable

func Variable() *structs.VariableDecrypted

func VariableEncrypted

func VariableEncrypted() *structs.VariableEncrypted

func VariableLifecycleJob

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

func VariablePolicy

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

func VaultAccessor() *structs.VaultAccessor

Types

type CheckShim

type CheckShim struct{}

CheckShim is a mock implementation of checkstore.Shim

So far the implementation does nothing.

func (*CheckShim) Difference

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

func (*CheckShim) List

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

func (*CheckShim) Purge

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

func (*CheckShim) Remove

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

func (*CheckShim) Set

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

func (*CheckShim) Snapshot

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

type LifecycleTaskDef

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

type MockVariables

type MockVariables map[string]*structs.VariableDecrypted

func Variables

func Variables(minU, maxU uint8) MockVariables

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

func (MockVariables) List

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

func (MockVariables) ListPaths

func (svs MockVariables) ListPaths() []string

type MockVariablesEncrypted

type MockVariablesEncrypted map[string]*structs.VariableEncrypted

func VariablesEncrypted

func VariablesEncrypted(minU, maxU uint8) MockVariablesEncrypted

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

func (MockVariablesEncrypted) List

func (MockVariablesEncrypted) ListPaths

func (svs MockVariablesEncrypted) ListPaths() []string

type NetworkStatus

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

NetworkStatus is a mock implementation of structs.NetworkStatus

func (*NetworkStatus) NetworkStatus

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

type StateStore

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