deployable

package
v0.0.0-...-cce75fc Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTempKubeConfigFile

func GetTempKubeConfigFile(name string) string

GetTempKubeConfigFile returns where the temp kubeConfigFile for deploy should be stored

func NewEnvStepper

func NewEnvStepper(filename string) *envStepper

Types

type ConfigMapHandler

type ConfigMapHandler interface {
	UpdateEnvsFromCommands(context.Context, string, string, []string) error
	AddPhaseDuration(context.Context, string, string, string, time.Duration) error
}

ConfigMapHandler defines the operations to handle the ConfigMap with the information related to the development environment

type DeployParameters

type DeployParameters struct {
	Name         string
	Namespace    string
	ManifestPath string
	Deployable   Entity
	Variables    []string
}

DeployParameters represents the parameters for deploying a remote entity

type DeployRunner

type DeployRunner struct {
	Proxy              ProxyInterface
	Kubeconfig         KubeConfigHandler
	ConfigMapHandler   ConfigMapHandler
	Executor           executor.ManifestExecutor
	K8sClientProvider  okteto.K8sClientProviderWithLogger
	Fs                 afero.Fs
	DivertDeployer     DivertDeployer
	GetExternalControl func(cfg *rest.Config) ExternalResourceInterface

	TempKubeconfigFile string
	// contains filtered or unexported fields
}

DeployRunner is responsible for running the commands defined in a manifest, deploy the divert information and deploy external resources. This DeployRunner has the common functionality to deal with the mentioned resources when deploy is run locally or remotely. As this runs also in the remote, it should NEVER build any kind of image or execute some logic that might differ from local.

func NewDeployRunnerForLocal

func NewDeployRunnerForLocal(
	ctx context.Context,
	name string,
	runWithoutBash bool,
	manifestPathFlag string,
	cmapHandler ConfigMapHandler,
	k8sProvider okteto.K8sClientProviderWithLogger,
	portGetter PortGetterFunc,
	k8sLogger *io.K8sLogger,
) (*DeployRunner, error)

NewDeployRunnerForLocal initializes a runner for a local environment. The main difference with the remote initialization is that the name might be empty in the local runner and it has to be inferred.

func NewDeployRunnerForRemote

func NewDeployRunnerForRemote(
	name string,
	runWithoutBash bool,
	cmapHandler ConfigMapHandler,
	k8sProvider okteto.K8sClientProviderWithLogger,
	portGetter PortGetterFunc,
	k8sLogger *io.K8sLogger,
) (*DeployRunner, error)

NewDeployRunnerForRemote initializes a runner for a remote environment

func (*DeployRunner) CleanUp

func (r *DeployRunner) CleanUp(ctx context.Context, err error)

CleanUp cleans up the resources created by the runner to avoid to leave any temporal resource

func (*DeployRunner) RunDeploy

func (r *DeployRunner) RunDeploy(ctx context.Context, params DeployParameters) error

RunDeploy deploys the deployable received with DeployParameters

type DestroyParameters

type DestroyParameters struct {
	Name         string
	Namespace    string
	Deployable   Entity
	Variables    []string
	ForceDestroy bool
}

DestroyParameters represents the parameters for destroying a remote entity

type DestroyRunner

type DestroyRunner struct {
	Executor executor.ManifestExecutor
}

DestroyRunner is responsible for running the commands defined in a manifest when destroying a dev environment This DestroyRunner has the common functionality to deal with the custom commands when destroy is run locally or remotely. As this runs also in the remote, it should NEVER build any kind of image or execute some logic that might differ from local.

func (*DestroyRunner) CleanUp

func (dr *DestroyRunner) CleanUp(err error)

func (*DestroyRunner) RunDestroy

func (dr *DestroyRunner) RunDestroy(params DestroyParameters) error

RunDestroy executes the custom commands received as part of DestroyParameters

type DivertDeployer

type DivertDeployer interface {
	Deploy(ctx context.Context) error
}

DivertDeployer defines the operations to deploy the divert section of a deployable

type Entity

type Entity struct {
	External externalresource.Section
	Divert   *model.DivertDeploy
	Commands []model.DeployCommand
}

Entity represents a set of resources that can be deployed by the runner

type ExternalResourceInterface

type ExternalResourceInterface interface {
	Deploy(ctx context.Context, name string, ns string, externalInfo *externalresource.ExternalResource) error
}

ExternalResourceInterface defines the operations to work with external resources

type KubeConfig

type KubeConfig struct{}

KubeConfig refers to a KubeConfig object

func NewKubeConfig

func NewKubeConfig() *KubeConfig

NewKubeConfig creates a new kubeconfig

func (*KubeConfig) GetCMDAPIConfig

func (*KubeConfig) GetCMDAPIConfig() (*clientcmdapi.Config, error)

func (*KubeConfig) Modify

func (k *KubeConfig) Modify(port int, sessionToken, destKubeconfigFile string) error

Modify modifies the kubeconfig object to inject the proxy

func (*KubeConfig) Read

func (k *KubeConfig) Read() (*rest.Config, error)

Read reads a kubeconfig from an apiConfig

type KubeConfigHandler

type KubeConfigHandler interface {
	Read() (*rest.Config, error)
	Modify(port int, sessionToken, destKubeconfigFile string) error
}

KubeConfigHandler defines the operations to handle the kubeconfig file needed to deal with the local Kubernetes proxy

type PortGetterFunc

type PortGetterFunc func(string) (int, error)

PortGetterFunc is a function that retrieves a free port the port for specified interface

type Proxy

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

Proxy refers to a proxy configuration

func NewProxy

func NewProxy(kubeconfig KubeConfigHandler, portGetter PortGetterFunc) (*Proxy, error)

NewProxy creates a new proxy

func (*Proxy) GetPort

func (p *Proxy) GetPort() int

GetPort retrieves the port configured for the proxy

func (*Proxy) GetToken

func (p *Proxy) GetToken() string

GetToken Retrieves the token configured for the proxy

func (*Proxy) SetDivert

func (p *Proxy) SetDivert(driver divert.Driver)

SetDivert sets the divert driver

func (*Proxy) SetName

func (p *Proxy) SetName(name string)

SetName sets the name to be in the deployed-by label name is sanitized when passing the parameter

func (*Proxy) Shutdown

func (p *Proxy) Shutdown(ctx context.Context) error

Shutdown stops the proxy server

func (*Proxy) Start

func (p *Proxy) Start()

Start starts the proxy server

type ProxyInterface

type ProxyInterface interface {
	Start()
	Shutdown(ctx context.Context) error
	GetPort() int
	GetToken() string
	SetName(name string)
	SetDivert(driver divert.Driver)
}

ProxyInterface defines the different operations to work with the proxy run by Okteto

type TestParameters

type TestParameters struct {
	Name         string
	Namespace    string
	DevEnvName   string
	Deployable   Entity
	Variables    []string
	ForceDestroy bool
}

TestParameters represents the parameters for destroying a remote entity

type TestRunner

type TestRunner struct {
	Executor         executor.ManifestExecutor
	Fs               afero.Fs
	GetDevEnvEnviron func(devEnvName, namespace string) (map[string]string, error)
	SetDevEnvEnviron func(devEnvName, namespace string, vars []string) error
}

TestRunner is responsible for running the commands defined in a manifest when running tests

func (*TestRunner) RunTest

func (dr *TestRunner) RunTest(params TestParameters) error

RunTest executes the custom commands received as part of TestParameters

Jump to

Keyboard shortcuts

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