executor

package
v0.0.0-...-e41232a Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferedWriter

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

BufferedWriter is a writer that decorates an writer, by buffering a copy of all written bytes.

func NewBufferedWriter

func NewBufferedWriter(writer io.Writer) *BufferedWriter

NewBufferedWriter creates BufferedWriter instance.

func (*BufferedWriter) Bytes

func (w *BufferedWriter) Bytes() []byte

Bytes returns the buffered data.

func (*BufferedWriter) Write

func (w *BufferedWriter) Write(data []byte) (int, error)

Write writes data to the stream and appends the contents of data to the internal buffer.

type Docker

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

func NewDocker

func NewDocker(executor os.CommandExecutor) *Docker

func (*Docker) Build

func (docker *Docker) Build(ctx context.Context, options *DockerBuildOptions) error

func (*Docker) Login

func (docker *Docker) Login(ctx context.Context, username, password, registryURL string) error

func (*Docker) NetworkGateway

func (docker *Docker) NetworkGateway(ctx context.Context, name string) (string, error)

func (*Docker) NetworkInspect

func (docker *Docker) NetworkInspect(ctx context.Context, name string) (*DockerNetwork, error)

func (*Docker) Pull

func (docker *Docker) Pull(ctx context.Context, image string) error

func (*Docker) Push

func (docker *Docker) Push(ctx context.Context, image string) error

func (*Docker) Tag

func (docker *Docker) Tag(ctx context.Context, oldImage, newImage string) error

type DockerBuildOptions

type DockerBuildOptions struct {
	Hosts      map[string]string
	BuildArgs  []string
	File       string
	Tag        string
	Target     string
	CacheFrom  []string
	ContextDir string
}

type DockerNetwork

type DockerNetwork struct {
	Name string `json:"Name"`
	ID   string `json:"Id"`
	IPAM struct {
		Driver string `json:"Driver"`
		Config []struct {
			Subnet  string `json:"Subnet"`
			Gateway string `json:"Gateway"`
		} `json:"Config"`
	} `json:"IPAM"`
}

type ExecuteLogger

type ExecuteLogger struct {
	os.OsExecutor
	// contains filtered or unexported fields
}

ExecuteLogger is os.OsExecutor decorator, that decorates the Execute method for real time debug logging.

func NewExecuteLogger

func NewExecuteLogger(osExecutor os.OsExecutor, log logger.Logger) *ExecuteLogger

func NewExecuteLoggerWithLogLevel

func NewExecuteLoggerWithLogLevel(osExecutor os.OsExecutor, log logger.Logger, logLevel logger.Level) *ExecuteLogger

func (*ExecuteLogger) Execute

func (c *ExecuteLogger) Execute(cmd string, arg []string, env []string, dir string) ([]byte, []byte, error)

func (*ExecuteLogger) ExecuteContext

func (c *ExecuteLogger) ExecuteContext(
	ctx context.Context,
	cmd string,
	arg []string,
	env []string,
	dir string,
) ([]byte, []byte, error)

type Git

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

func NewGit

func NewGit(executor os.CommandExecutor, url, dir string, env []string) *Git

func (*Git) Add

func (git *Git) Add(file string) error

func (*Git) CheckoutClean

func (git *Git) CheckoutClean() error

func (*Git) Clone

func (git *Git) Clone() error

func (*Git) CloneWithoutCheckout

func (git *Git) CloneWithoutCheckout() error

func (*Git) Commit

func (git *Git) Commit(message string) error

func (*Git) Config

func (git *Git) Config(ctx context.Context, key, value string) error

func (*Git) CreateAndSwitchToBranch

func (git *Git) CreateAndSwitchToBranch(ctx context.Context, name string) error

func (*Git) DeleteLocalBranch

func (git *Git) DeleteLocalBranch(ctx context.Context, name string) error

func (*Git) DeleteRemoteBranch

func (git *Git) DeleteRemoteBranch(ctx context.Context, name string) error

func (*Git) DisableSparseCheckout

func (git *Git) DisableSparseCheckout() error

func (*Git) EnableSparseCheckout

func (git *Git) EnableSparseCheckout() error

func (*Git) Fetch

func (git *Git) Fetch() error

func (*Git) GetCurrentHash

func (git *Git) GetCurrentHash() (string, error)

func (*Git) GetCurrentHashForPath

func (git *Git) GetCurrentHashForPath(path string) (string, error)

GetCurrentHashForPath hash of last git commit made. `path` can be an absolute or relative path. This is needed for mono-repositories, to make sure they only change when their content changes. However merge commits will not be the latest commit, since they include no content. The commit before the merge commit for the path will be the last.

func (*Git) GetURL

func (git *Git) GetURL() string

func (*Git) HasDiff

func (git *Git) HasDiff() (bool, error)

func (*Git) ListBranches

func (git *Git) ListBranches() ([]string, error)

func (*Git) ListTags

func (git *Git) ListTags() ([]string, error)

func (*Git) Pull

func (git *Git) Pull() error

func (*Git) Push

func (git *Git) Push(destination string, isForce bool) error

func (*Git) SetSparseCheckoutPaths

func (git *Git) SetSparseCheckoutPaths(paths []string) error

func (*Git) SwitchAndReset

func (git *Git) SwitchAndReset(branch string) error

func (*Git) SwitchToBranch

func (git *Git) SwitchToBranch(ctx context.Context, name string) error

type Helm

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

func NewHelm

func NewHelm(executor os.CommandExecutor) *Helm

func (*Helm) GetManifest

func (h *Helm) GetManifest(
	location string,
	name string,
	namespace string,
	values,
	stringValues *orderedmap.OrderedMap,
) (string, error)

GetManifest returns content of a "helm template" substituted manifest. Values and string values are maps of string keys to string values.

func (*Helm) Package

func (h *Helm) Package(dir, dest string) (string, error)

func (*Helm) ResetExecutor

func (h *Helm) ResetExecutor(commandExecutor os.CommandExecutor) os.CommandExecutor

type Kubectl

type Kubectl struct {
	GlobalOptions map[string]string
	// contains filtered or unexported fields
}

func NewKubectl

func NewKubectl(
	commandExecutor pkgOs.CommandExecutor,
	kubectlContext,
	kubernetesInternalDomain string,
) *Kubectl

func (*Kubectl) Apply

func (k *Kubectl) Apply(manifest string, namespace string) error

func (*Kubectl) ApplyConfigmap

func (k *Kubectl) ApplyConfigmap(name, namespace string, data map[string]string) error

func (*Kubectl) ApplyService

func (k *Kubectl) ApplyService(service *KubernetesService) error

func (*Kubectl) ClusterInfo

func (k *Kubectl) ClusterInfo() error

func (*Kubectl) Create

func (k *Kubectl) Create(manifest string) error

func (*Kubectl) Delete

func (k *Kubectl) Delete(manifest string) error

func (*Kubectl) DeleteAllResources

func (k *Kubectl) DeleteAllResources(namespace, resourceType string) error

func (*Kubectl) DeleteAllResourcesByLabel

func (k *Kubectl) DeleteAllResourcesByLabel(namespace string, labels map[string]string) error

func (*Kubectl) DeleteResource

func (k *Kubectl) DeleteResource(namespace, resourceType, resourceName string) error

func (*Kubectl) GetIngressHost

func (k *Kubectl) GetIngressHost(namespace, name string) (string, error)

func (*Kubectl) GetIngresses

func (k *Kubectl) GetIngresses(namespace string) ([]*KubernetesIngress, error)

func (*Kubectl) GetService

func (k *Kubectl) GetService(name, namespace string) (*KubernetesService, error)

func (*Kubectl) GetServiceAccountSecret

func (k *Kubectl) GetServiceAccountSecret(namespace, name, dataKeyName string) (string, error)

func (*Kubectl) GetServiceFQDN

func (k *Kubectl) GetServiceFQDN(namespace, serviceName string) (string, error)

func (*Kubectl) GetServiceMeta

func (k *Kubectl) GetServiceMeta(namespace, serviceName, key string) (string, error)

func (*Kubectl) GetServicePort

func (k *Kubectl) GetServicePort(namespace, serviceName, portName string) (string, error)

func (*Kubectl) GetServices

func (k *Kubectl) GetServices(namespace string) ([]*KubernetesService, error)

func (*Kubectl) GetToken

func (k *Kubectl) GetToken() ([]byte, error)

func (*Kubectl) JobStatus

func (k *Kubectl) JobStatus(name, namespace string) (KubernetesJobStatus, error)

func (*Kubectl) ResetExecutor

func (k *Kubectl) ResetExecutor(commandExecutor pkgOs.CommandExecutor) pkgOs.CommandExecutor

func (*Kubectl) RolloutStatus

func (k *Kubectl) RolloutStatus(timeout time.Duration, resource, namespace string) error

type KubectlIngressInfo

type KubectlIngressInfo struct {
	Spec struct {
		Rules []struct {
			Host string `json:"host"`
		} `json:"rules"`
	} `json:"spec"`
}

type KubectlInterface

type KubectlInterface interface {
	Apply(manifest string, namespace string) error
	Delete(manifest string) error
	Create(manifest string) error
	ClusterInfo() error
	GetToken() ([]byte, error)
	GetServiceAccountSecret(namespace, name, dataKeyName string) (string, error)
	GetIngressHost(namespace, name string) (string, error)
	GetServices(namespace string) ([]*KubernetesService, error)
	GetService(name, namespace string) (*KubernetesService, error)
	ApplyConfigmap(name, namespace string, data map[string]string) error
	ApplyService(service *KubernetesService) error
	GetServiceFQDN(namespace, serviceName string) (string, error)
	GetServiceMeta(namespace, serviceName, key string) (string, error)
	GetServicePort(namespace, serviceName, portName string) (string, error)
	GetIngresses(namespace string) ([]*KubernetesIngress, error)
	RolloutStatus(timeout time.Duration, resource, namespace string) error
	JobStatus(name, namespace string) (KubernetesJobStatus, error)
	DeleteResource(namespace, resourceType, resourceName string) error
	DeleteAllResources(namespace, resourceType string) error
	DeleteAllResourcesByLabel(namespace string, labels map[string]string) error
	ResetExecutor(commandExecutor pkgOs.CommandExecutor) pkgOs.CommandExecutor
}

type KubectlSecretInfo

type KubectlSecretInfo struct {
	Data struct {
		CaCrt     string `json:"ca.crt"`
		Namespace string `json:"namespace"`
		Token     string `json:"token"`
	} `json:"data"`
}

type KubectlServiceAccountInfo

type KubectlServiceAccountInfo struct {
	Secrets []struct {
		Name string `json:"name"`
	} `json:"secrets"`
}

type KubernetesIngress

type KubernetesIngress struct {
	Metadata *KubernetesIngressMetadata `json:"metadata"`
	Spec     *KubernetesIngressSpec     `json:"spec"`
}

type KubernetesIngressFirstAddress

type KubernetesIngressFirstAddress struct {
	Host string `json:"host"`
}

type KubernetesIngressMetadata

type KubernetesIngressMetadata struct {
	Annotations map[string]string `json:"annotations"`
	Name        string            `json:"name"`
	Namespace   string            `json:"namespace"`
}

type KubernetesIngressRule

type KubernetesIngressRule struct {
	Host string `json:"host"`
}

type KubernetesIngressSpec

type KubernetesIngressSpec struct {
	Rules []*KubernetesIngressRule `json:"rules"`
}

type KubernetesIngressesResponse

type KubernetesIngressesResponse struct {
	Items []*KubernetesIngress `json:"items"`
}

type KubernetesJobStatus

type KubernetesJobStatus int
const (
	KubernetesJobStatusUnknown KubernetesJobStatus = iota
	KubernetesJobStatusActive
	KubernetesJobStatusComplete
	KubernetesJobStatusFailed
)

type KubernetesService

type KubernetesService struct {
	APIVersion string                     `json:"apiVersion"`
	Kind       string                     `json:"kind"`
	Metadata   *KubernetesServiceMetadata `json:"metadata"`
	Spec       *KubernetesServiceSpec     `json:"spec"`
}

type KubernetesServiceMetadata

type KubernetesServiceMetadata struct {
	Annotations map[string]string `json:"annotations"`
	Name        string            `json:"name"`
	Namespace   string            `json:"namespace"`
	Labels      map[string]string `json:"labels"`
}

type KubernetesServiceSpec

type KubernetesServiceSpec struct {
	ClusterIP             string                       `json:"clusterIP"`
	ExternalTrafficPolicy string                       `json:"externalTrafficPolicy"`
	Ports                 []*KubernetesServiceSpecPort `json:"ports"`
	Selector              map[string]string            `json:"selector"`
	SessionAffinity       string                       `json:"sessionAffinity"`
	Type                  string                       `json:"type"`
}

type KubernetesServiceSpecPort

type KubernetesServiceSpecPort struct {
	Name       string      `json:"name"`
	NodePort   json.Number `json:"nodePort"`
	Port       json.Number `json:"port"`
	Protocol   string      `json:"protocol"`
	TargetPort json.Number `json:"targetPort"`
}

type KubernetesServicesResponse

type KubernetesServicesResponse struct {
	Items []*KubernetesService `json:"items"`
}

type RealtimeStdoutExecutor

type RealtimeStdoutExecutor struct {
	os.OsExecutor
}

RealtimeStdoutExecutor is os.OsExecutor decorator, that decorates the Execute method by writing executed commands stdout and stderr to executor's Stdout and Stderr.

func NewRealtimeStdoutExecutor

func NewRealtimeStdoutExecutor(osExecutor os.OsExecutor) *RealtimeStdoutExecutor

NewRealtimeStdoutExecutor creates RealtimeStdoutExecutor instance.

func (*RealtimeStdoutExecutor) Execute

func (executor *RealtimeStdoutExecutor) Execute(
	cmd string,
	arg []string,
	env []string,
	dir string,
) ([]byte, []byte, error)

Execute executes a command.

func (*RealtimeStdoutExecutor) ExecuteContext

func (executor *RealtimeStdoutExecutor) ExecuteContext(
	ctx context.Context,
	cmd string,
	arg []string,
	env []string,
	dir string,
) ([]byte, []byte, error)

ExecuteContext executes a command within a context.

type RealtimeWriter

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

func NewRealtimeWriter

func NewRealtimeWriter(log logger.Logger, logLevel logger.Level) *RealtimeWriter

func (*RealtimeWriter) GetOutput

func (writer *RealtimeWriter) GetOutput() string

func (*RealtimeWriter) Write

func (writer *RealtimeWriter) Write(p []byte) (n int, err error)

Directories

Path Synopsis
kubernetes module

Jump to

Keyboard shortcuts

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