package mock

import "github.com/oslokommune/okctl/pkg/api/mock"

Package mock provides mocks for use with tests

Index

Constants

const (
	// DefaultAWSAccountID is a default aws account id used in mocks
	DefaultAWSAccountID = "123456789012"
	// DefaultCidr is a default cidr used in mocks
	DefaultCidr = "192.168.0.0/20"
	// DefaultRegion is a default aws region used in mocks
	DefaultRegion = "eu-west-1"
	// DefaultVersion is the default EKS kubernetes version
	DefaultVersion = "1.18"
	// DefaultAvailabilityZone is a default aws availability zone used in mocks
	DefaultAvailabilityZone = "eu-west-1a"
	// DefaultClusterName is a default eks cluster name used in mocks
	DefaultClusterName = "test-cluster-pro"
	// DefaultVpcID is a default aws vpc id used in mocks
	DefaultVpcID = "vpc-0e9801d129EXAMPLE"
	// DefaultPublicSubnetID is a default aws public subnet id used in mocks
	DefaultPublicSubnetID = "subnet-0bb1c79de3EXAMPLE"
	// DefaultPublicSubnetCidr is a default public subnet cidr used in mocks
	DefaultPublicSubnetCidr = "192.168.1.0/24"
	// DefaultPrivateSubnetID is a default private aws subnet id used in mocks
	DefaultPrivateSubnetID = "subnet-8EXAMPLE"
	// DefaultPrivateSubnetCidr is a default private subnet cidr used in mocks
	DefaultPrivateSubnetCidr = "192.168.2.0/24"
	// DefaultVpcStackName is the default stack name for a vpc
	DefaultVpcStackName = "test-vpc-pro"
	// DefaultVpcCloudFormationTemplate is a default cloud formation template
	DefaultVpcCloudFormationTemplate = "something"
	// DefaultUserDataDir is a default path for the user data directory
	DefaultUserDataDir = "/home/johndoe/.okctl"
	// DefaultKubectlBinaryDir is a default path to the directory containing the kubectl executable
	DefaultKubectlBinaryDir = DefaultUserDataDir + "/binaries/kubectl/1.16.8/linux/amd64"
	// DefaultAwsIamAuthenticatorDir  is a default path to the directory containing the aws-iam-authenticator executable
	DefaultAwsIamAuthenticatorDir = DefaultUserDataDir + "/binaries/aws-iam-authenticator/0.5.1/linux/amd64"
	// DefaultKubeConfigPath is the default path for the kubeconfig
	DefaultKubeConfigPath = "/cluster/kubeconfig"
	// DefaultKubeConfigContent is the default content of kubeconfig
	DefaultKubeConfigContent = "meh"
	// DefaultPolicyARN is the default ARN of some policy
	DefaultPolicyARN = "arn:aws:iam::123456789012:policy/somePolicy"
	// DefaultDomainName is the default domain name
	DefaultDomainName = "test.oslo.systems"
	// DefaultClusterSecurityGroupIDValue is the default domain name
	DefaultClusterSecurityGroupIDValue = "sg-2430fjm0fgCLUSTER"
)

Variables

var ErrBad = fmt.Errorf("something bad")

ErrBad just defines a mocked error

Functions

func DefaultCluster

func DefaultCluster() *api.Cluster

DefaultCluster returns an api cluster definition with defaults set

func DefaultClusterConfig

func DefaultClusterConfig() *v1alpha5.ClusterConfig

DefaultClusterConfig returns a cluster config with defaults set

func DefaultClusterCreateOpts

func DefaultClusterCreateOpts() api.ClusterCreateOpts

DefaultClusterCreateOpts returns options for creating a cluster with defaults set

func DefaultClusterDeleteOpts

func DefaultClusterDeleteOpts() api.ClusterDeleteOpts

DefaultClusterDeleteOpts returns options for deleting a cluster with defaults set

func DefaultClusterSecurityGroupID

func DefaultClusterSecurityGroupID() *api.ClusterSecurityGroupID

DefaultClusterSecurityGroupID returns a default cluster security group ID

func DefaultClusterSecurityGroupIDGetOpts

func DefaultClusterSecurityGroupIDGetOpts() api.ClusterSecurityGroupIDGetOpts

DefaultClusterSecurityGroupIDGetOpts returns options for getting a cluster security group ID with defaults set

func DefaultID

func DefaultID() api.ID

DefaultID returns an ID initialised with defaults

func DefaultKubeConfig

func DefaultKubeConfig() *api.KubeConfig

DefaultKubeConfig returns an initialised kubeconfig

func DefaultPrivateSubnets

func DefaultPrivateSubnets() map[string]v1alpha5.ClusterNetwork

DefaultPrivateSubnets returns a map of private subnets with defaults set

func DefaultPublicSubnets

func DefaultPublicSubnets() map[string]v1alpha5.ClusterNetwork

DefaultPublicSubnets returns a map of public subnets with defaults set

func DefaultVpc

func DefaultVpc() *api.Vpc

DefaultVpc returns a vpc with defaults set

func DefaultVpcCreateOpts

func DefaultVpcCreateOpts() api.CreateVpcOpts

DefaultVpcCreateOpts returns options for creating a vpc with defaults set

func DefaultVpcDeleteOpts

func DefaultVpcDeleteOpts() api.DeleteVpcOpts

DefaultVpcDeleteOpts returns options for deleting a vpc with defaults set

func DefaultVpcPrivateSubnets

func DefaultVpcPrivateSubnets() []api.VpcSubnet

DefaultVpcPrivateSubnets returns a list of private subnets with defaults set

func DefaultVpcPublicSubnets

func DefaultVpcPublicSubnets() []api.VpcSubnet

DefaultVpcPublicSubnets returns a list of public subnets with defaults set

Types

type ClusterConfigStore

type ClusterConfigStore struct {
	SaveClusterConfigFn   func(*v1alpha5.ClusterConfig) error
	DeleteClusterConfigFn func(env string) error
	GetClusterConfigFn    func(env string) (*v1alpha5.ClusterConfig, error)
}

ClusterConfigStore provides a mock for the cluster config store

func NewGoodClusterConfigStore

func NewGoodClusterConfigStore() *ClusterConfigStore

NewGoodClusterConfigStore returns a cluster config store that will succeed

func (*ClusterConfigStore) DeleteClusterConfig

func (c *ClusterConfigStore) DeleteClusterConfig(env string) error

DeleteClusterConfig invokes the mocked delete cluster config function

func (*ClusterConfigStore) GetClusterConfig

func (c *ClusterConfigStore) GetClusterConfig(env string) (*v1alpha5.ClusterConfig, error)

GetClusterConfig invokes the mocked get cluster config function

func (*ClusterConfigStore) SaveClusterConfig

func (c *ClusterConfigStore) SaveClusterConfig(config *v1alpha5.ClusterConfig) error

SaveClusterConfig invokes the mocked save cluster config function

type ClusterExe

type ClusterExe struct {
	CreateClusterFn func(opts api.ClusterCreateOpts) (*api.Cluster, error)
	DeleteClusterFn func(opts api.ClusterDeleteOpts) error
}

ClusterExe provides a mock for the cluster exe interface

func NewBadClusterExe

func NewBadClusterExe() *ClusterExe

NewBadClusterExe returns a cluster exe that will fail

func NewGoodClusterExe

func NewGoodClusterExe() *ClusterExe

NewGoodClusterExe returns a cluster exe that will succeed

func (*ClusterExe) CreateCluster

func (c *ClusterExe) CreateCluster(opts api.ClusterCreateOpts) (*api.Cluster, error)

CreateCluster invokes the mocked create cluster function

func (*ClusterExe) DeleteCluster

func (c *ClusterExe) DeleteCluster(opts api.ClusterDeleteOpts) error

DeleteCluster invokes the mocked delete cluster function

type ClusterService

type ClusterService struct {
	CreateClusterFn func(context.Context, api.ClusterCreateOpts) (*api.Cluster, error)
	DeleteClusterFn func(context.Context, api.ClusterDeleteOpts) error
}

ClusterService provides a mock for the cluster service interface

func NewBadClusterService

func NewBadClusterService() *ClusterService

NewBadClusterService returns a cluster service that will fail

func NewGoodClusterService

func NewGoodClusterService() *ClusterService

NewGoodClusterService returns a cluster service that will succeed

func (*ClusterService) CreateCluster

func (s *ClusterService) CreateCluster(ctx context.Context, opts api.ClusterCreateOpts) (*api.Cluster, error)

CreateCluster invokes a mocked function to create a cluster

func (*ClusterService) DeleteCluster

func (s *ClusterService) DeleteCluster(ctx context.Context, opts api.ClusterDeleteOpts) error

DeleteCluster invokes a mocked function to delete a cluster

type ClusterStore

type ClusterStore struct {
	SaveClusterFn   func(*api.Cluster) error
	DeleteClusterFn func(id api.ID) error
	GetClusterFn    func(id api.ID) (*api.Cluster, error)
}

ClusterStore provides a mock for the cluster store interface

func NewBadClusterStore

func NewBadClusterStore() *ClusterStore

NewBadClusterStore returns a cluster store that will fail

func NewGoodClusterStore

func NewGoodClusterStore() *ClusterStore

NewGoodClusterStore returns a cluster store that will succeed

func (*ClusterStore) DeleteCluster

func (c *ClusterStore) DeleteCluster(id api.ID) error

DeleteCluster invokes the mocked delete function

func (*ClusterStore) GetCluster

func (c *ClusterStore) GetCluster(id api.ID) (*api.Cluster, error)

GetCluster invokes the mocked get function

func (*ClusterStore) SaveCluster

func (c *ClusterStore) SaveCluster(cluster *api.Cluster) error

SaveCluster invokes the mocked save function

type KubeConfigStore

type KubeConfigStore struct {
	CreateKubeConfigFn func() (string, error)
	GetKubeConfigFn    func() (*api.KubeConfig, error)
	DeleteKubeConfigFn func() error
}

KubeConfigStore provides a mock for the kubeconfig store

func NewGoodKubeConfigStore

func NewGoodKubeConfigStore() *KubeConfigStore

NewGoodKubeConfigStore returns a store that succeeds

func (*KubeConfigStore) CreateKubeConfig

func (k *KubeConfigStore) CreateKubeConfig() (string, error)

CreateKubeConfig mocks the create

func (*KubeConfigStore) DeleteKubeConfig

func (k *KubeConfigStore) DeleteKubeConfig() error

DeleteKubeConfig mocks the delete

func (*KubeConfigStore) GetKubeConfig

func (k *KubeConfigStore) GetKubeConfig() (*api.KubeConfig, error)

GetKubeConfig mocks the get

type VpcCloud

type VpcCloud struct {
	CreateVpcFn func(opts api.CreateVpcOpts) (*api.Vpc, error)
	DeleteVpcFn func(opts api.DeleteVpcOpts) error
}

VpcCloud provides a mock for the cluster cloud interface

func NewBadVpcCloud

func NewBadVpcCloud() *VpcCloud

NewBadVpcCloud returns a cluster cloud that will fail

func NewGoodVpcCloud

func NewGoodVpcCloud() *VpcCloud

NewGoodVpcCloud returns a cluster cloud that will succeed

func (*VpcCloud) CreateVpc

func (c *VpcCloud) CreateVpc(opts api.CreateVpcOpts) (*api.Vpc, error)

CreateVpc invokes the mocked create cluster function

func (*VpcCloud) DeleteVpc

func (c *VpcCloud) DeleteVpc(opts api.DeleteVpcOpts) error

DeleteVpc invokes the mocked delete cluster function

Source Files

cluster_mock.go

Version
v0.0.106 (latest)
Published
Oct 21, 2022
Platform
linux/amd64
Imports
6 packages
Last checked
18 hours ago

Tools for package owners.