environment

package
v0.3.30 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 29 Imported by: 3

Documentation

Index

Constants

View Source
const (
	COVERAGE_DIR       string = "cover"
	FAILED_FUND_RETURN string = "FAILED_FUND_RETURN"
)
View Source
const (
	ErrInvalidOCI string = "OCI chart url should be in format oci://$ECR_URL/$ECR_REGISTRY_NAME/$CHART_NAME:[?$CHART_VERSION], was %s"
	ErrOCIPull    string = "failed to pull OCI repo: %s"
)

Variables

This section is empty.

Functions

func MkdirIfNotExists added in v0.2.54

func MkdirIfNotExists(dirName string) error

func NewRunner added in v0.3.0

func NewRunner(props *Props) func(root cdk8s.Chart) ConnectedChart

Types

type Artifacts

type Artifacts struct {
	Namespace string
	DBName    string
	Client    *client.K8sClient
	// contains filtered or unexported fields
}

Artifacts is an artifacts dumping structure that copies logs and database dumps for all deployed pods

func NewArtifacts

func NewArtifacts(client *client.K8sClient, namespace string) (*Artifacts, error)

NewArtifacts create new artifacts instance for provided environment

func (*Artifacts) DumpTestResult

func (a *Artifacts) DumpTestResult(testDir string, dbName string) error

DumpTestResult dumps all pods logs and db dump in a separate test dir

type Chart added in v0.3.0

type Chart struct {
	Props *Props
}

func (Chart) ExportData added in v0.3.0

func (m Chart) ExportData(e *Environment) error

func (Chart) GetName added in v0.3.0

func (m Chart) GetName() string

func (Chart) GetPath added in v0.3.0

func (m Chart) GetPath() string

func (Chart) GetProps added in v0.3.0

func (m Chart) GetProps() interface{}

func (Chart) GetValues added in v0.3.0

func (m Chart) GetValues() *map[string]interface{}

func (Chart) GetVersion added in v0.3.0

func (m Chart) GetVersion() string

func (Chart) IsDeploymentNeeded added in v0.3.0

func (m Chart) IsDeploymentNeeded() bool

type Config

type Config struct {
	// TTL is time to live for the environment, used with kube-janitor
	TTL time.Duration
	// JobImage an image to run environment as a job inside k8s
	JobImage string

	// NamespacePrefix is a static namespace prefix
	NamespacePrefix string
	// Namespace is full namespace name
	Namespace string
	// Labels is a set of labels applied to the namespace in a format of "key=value"
	Labels []string

	// Allow deployment to nodes with these olerances
	Tolerations []map[string]string
	// Restrict deployment to only nodes matching a particular node role
	NodeSelector map[string]string
	// ReadyCheckData is settings for readiness probes checks for all deployment components
	// checking that all pods are ready by default with 8 minutes timeout
	//	&client.ReadyCheckData{
	//		ReadinessProbeCheckSelector: "",
	//		Timeout:                     8 * time.Minute,
	//	}
	ReadyCheckData *client.ReadyCheckData
	// DryRun if true, app will just generate a manifest in local dir
	DryRun bool
	// InsideK8s used for long-running soak tests where you connect to env from the inside
	InsideK8s bool
	// NoManifestUpdate is a flag to skip manifest updating when connecting
	NoManifestUpdate bool

	// KeepConnection keeps connection until interrupted with a signal, useful when prototyping and debugging a new env
	KeepConnection bool
	// RemoveOnInterrupt automatically removes an environment on interrupt
	RemoveOnInterrupt bool
	// UpdateWaitInterval an interval to wait for deployment update started
	UpdateWaitInterval time.Duration

	// Test the testing library current Test struct
	Test *testing.T
	// contains filtered or unexported fields
}

Config is an environment common configuration, labels, annotations, connection types, readiness check, etc.

type ConnectedChart added in v0.2.3

type ConnectedChart interface {
	// IsDeploymentNeeded
	// true - we deploy/connect and expose environment data
	// false - we are using external environment, but still exposing data
	IsDeploymentNeeded() bool
	// GetName name of the deployed part
	GetName() string
	// GetPath get Helm chart path, repo or local path
	GetPath() string
	// GetVersion gets the chart's version, empty string if none is specified
	GetVersion() string
	// GetProps get code props if it's typed environment
	GetProps() interface{}
	// GetValues get values.yml props as map, if it's Helm
	GetValues() *map[string]interface{}
	// ExportData export deployment part data in the env
	ExportData(e *Environment) error
}

ConnectedChart interface to interact both with cdk8s apps and helm charts

type CoverageProfileParams added in v0.2.54

type CoverageProfileParams struct {
	Force             bool     `form:"force" json:"force"`
	Service           []string `form:"service" json:"service"`
	Address           []string `form:"address" json:"address"`
	CoverFilePatterns []string `form:"coverfile" json:"coverfile"`
	SkipFilePatterns  []string `form:"skipfile" json:"skipfile"`
}

type Environment

type Environment struct {
	App             cdk8s.App
	CurrentManifest string

	Charts    []ConnectedChart  // All connected charts in the
	Cfg       *Config           // The environment specific config
	Client    *client.K8sClient // Client connecting to the K8s cluster
	Fwd       *client.Forwarder // Used to forward ports from local machine to the K8s cluster
	Artifacts *Artifacts
	Chaos     *client.Chaos

	URLs map[string][]string // General URLs of launched resources. Uses '_local' to delineate forwarded ports
	// contains filtered or unexported fields
}

Environment describes a launched test environment

func New

func New(cfg *Config) *Environment

New creates new environment

func (*Environment) AddChart added in v0.2.3

func (m *Environment) AddChart(f func(root cdk8s.Chart) ConnectedChart) *Environment

AddChart adds a chart to the deployment

func (*Environment) AddHelm added in v0.2.3

func (m *Environment) AddHelm(chart ConnectedChart) *Environment

func (*Environment) ClearCharts added in v0.2.26

func (m *Environment) ClearCharts()

ClearCharts recreates cdk8s app

func (*Environment) ClearCoverage added in v0.2.54

func (m *Environment) ClearCoverage() error

func (*Environment) Deploy

func (m *Environment) Deploy() error

Deploy deploy current manifest and check logs for readiness

func (*Environment) DumpLogs added in v0.2.25

func (m *Environment) DumpLogs(path string) error

DumpLogs dumps all logs into a file

func (*Environment) Manifest added in v0.2.53

func (m *Environment) Manifest() string

func (*Environment) ModifyHelm added in v0.2.26

func (m *Environment) ModifyHelm(name string, chart ConnectedChart) *Environment

ModifyHelm modifies helm chart in deployment

func (*Environment) PrintExportData added in v0.2.26

func (m *Environment) PrintExportData() error

PrintExportData prints export data

func (*Environment) PullOCIChart added in v0.3.27

func (m *Environment) PullOCIChart(chart ConnectedChart) (string, error)

PullOCIChart handles working with OCI format repositories https://helm.sh/docs/topics/registries/ API is not compatible between helm repos and OCI repos, so we download and untar the chart

func (*Environment) ResourcesSummary added in v0.2.24

func (m *Environment) ResourcesSummary(selector string) (map[string]map[string]string, error)

ResourcesSummary returns resources summary for selected pods as a map, used in reports

func (*Environment) RolloutStatefulSets added in v0.3.23

func (m *Environment) RolloutStatefulSets() error

RolloutStatefulSets applies "rollout statefulset" to all existing statefulsets in our namespace

func (*Environment) Run added in v0.2.3

func (m *Environment) Run() error

Run deploys or connects to already created environment

func (*Environment) SaveCoverage added in v0.2.54

func (m *Environment) SaveCoverage() error

func (*Environment) Shutdown

func (m *Environment) Shutdown() error

Shutdown environment, remove namespace

func (*Environment) UpdateManifest added in v0.3.26

func (m *Environment) UpdateManifest()

Update current manifest based on the cdk8s app state

func (*Environment) WillUseRemoteRunner added in v0.3.0

func (m *Environment) WillUseRemoteRunner() bool

BeforeTest sets the test name variable and determines if we need to start the remote runner

type Props added in v0.3.0

type Props struct {
	BaseName         string
	TargetNamespace  string
	Labels           *map[string]*string
	Image            string
	TestName         string
	NoManifestUpdate bool
}

Jump to

Keyboard shortcuts

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