utils

package
v0.1.2-0...-95f5875 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Overview

traefik functions related to deployment

Index

Constants

View Source
const (
	TraefikHTTPPort  = 80
	TraefikHTTPSPort = 443
)
View Source
const (
	ContainerHealthyStatus    = "healthy"
	ContainerStateWaitSeconds = 120
	TypeContainer             = "container"
)
View Source
const CGroupFile = "/proc/self/cgroup"
View Source
const DockerLogHeaderLength = 8
View Source
const TraefikTrue = "true"

Variables

View Source
var (
	ErrInsufficientRoutingRules = errors.New("no enough configuration was provided for the container to be routable")
	ErrExposedPortNotFound      = errors.New("selected port was provided as exposed port")
	ErrInvalidUploadLimit       = errors.New("invalid value provided for uploadLimit")
)

Functions

func ContainerCommand

func ContainerCommand(ctx context.Context, command *common.ContainerCommandRequest) error

func ContainerInspect

func ContainerInspect(ctx context.Context, request *agent.ContainerInspectRequest) (string, error)

func ContainerStateStream

func ContainerStateStream(ctx context.Context, prefix string, sendInitalStates bool) (*grpc.ContainerStatusStream, error)

func CopyToContainer

func CopyToContainer(ctx context.Context, name string, meta v1.UploadFileData, fileHeader *multipart.FileHeader) error

func DeleteContainerByPrefixAndName

func DeleteContainerByPrefixAndName(ctx context.Context, prefix, name string) error

func DeleteContainers

func DeleteContainers(ctx context.Context, request *common.DeleteContainersRequest) error

func DeployImage

func DeployImage(ctx context.Context,
	dog *dogger.DeploymentLogger,
	deployImageRequest *v1.DeployImageRequest,
	versionData *v1.VersionData,
) error

func DeploySharedSecrets

func DeploySharedSecrets(ctx context.Context,
	prefix string,
	secrets map[string]string,
) error

func DraftRelease

func DraftRelease(instance string, versionData v1.VersionData, deployResponse v1.DeployVersionResponse, cfg *config.Configuration)

DraftRelease writes release information to disk Into the instance folder @release directory, file with a release name yml extension the file containing release data

func EnvMapToSlice

func EnvMapToSlice(envs map[string]string) []string

EnvMapToSlice converts key:value map into ["key=value"] array

func ExecTraefik

func ExecTraefik(ctx context.Context, traefikDeployReq TraefikDeployRequest, cfg *config.Configuration) error

func FindVolumeInMountMap

func FindVolumeInMountMap(name string, mountMap map[string]mount.Mount) *mount.Mount

func GetContainerByPrefixAndName

func GetContainerByPrefixAndName(ctx context.Context, cli client.APIClient, prefix, name string) (*types.Container, error)

func GetImageLabels

func GetImageLabels(expandedImageName string) (map[string]string, error)

func GetOrganizationLabel

func GetOrganizationLabel(labels map[string]string, key string) (string, bool)

func GetOwnContainer

func GetOwnContainer(ctx context.Context, cli client.APIClient) (*types.Container, error)

func GetOwnContainerImage

func GetOwnContainerImage(cli client.APIClient) (*types.ImageInspect, error)

func GetRules

func GetRules(containerConfig *v1.ContainerConfig, instanceConfig *v1.InstanceConfig, cfg *config.Configuration) []string

serviceName container-name.container-pre-name.ingress.host is default

func GetTraefikLabels

func GetTraefikLabels(
	instanceConfig *v1.InstanceConfig,
	containerConfig *v1.ContainerConfig,
	cfg *config.Configuration,
) (map[string]string, error)

generating container labels for traefik if Expose is provided we bind 80 and the given (domainName or (containerName + prefix)) + RootDomain

func MergeStringMapToUniqueSlice

func MergeStringMapToUniqueSlice(src, dest map[string]string) []string

Merging map `a` to map `b`. Keys in map `b` has precedence, if key occurs in both.

func MergeStringMapUnique

func MergeStringMapUnique(src, dest map[string]string) map[string]string

func MountListToMap

func MountListToMap(in []mount.Mount) map[string]mount.Mount

func ParseCGroupFile

func ParseCGroupFile() (string, error)

func PreflightChecks

func PreflightChecks()

func SecretList

func SecretList(ctx context.Context, prefix, name string) ([]string, error)

func SetOrganizationLabel

func SetOrganizationLabel(key, value string) (map[string]string, error)

generating dyrector.io specific labels for containers org.dyrectorio is our official label prefix

func WatchContainersByPrefix

func WatchContainersByPrefix(ctx context.Context,
	cli client.APIClient,
	prefix string,
	initialStates []types.Container,
) (*grpc.ContainerStatusStream, error)

func WithInitContainers

func WithInitContainers(dc dockerbuilder.Builder, containerConfig *v1.ContainerConfig,
	dog *dogger.DeploymentLogger, envMap map[string]string, cfg *config.Configuration,
)

func WriteContainerFile

func WriteContainerFile(ctx context.Context, cli *client.Client,
	cont, filename string, meta v1.UploadFileData, fileSize int64, data io.Reader,
) error

Types

type DockerContainerLogReader

type DockerContainerLogReader struct {
	EventChannel chan grpc.ContainerLogEvent
	Reader       io.ReadCloser

	grpc.ContainerLogReader
}

func (*DockerContainerLogReader) Close

func (dockerReader *DockerContainerLogReader) Close() error

func (*DockerContainerLogReader) Next

func (dockerReader *DockerContainerLogReader) Next() <-chan grpc.ContainerLogEvent

type DockerVersion

type DockerVersion struct {
	ServerVersion string
	ClientVersion string
}

type InitContainerConfig

type InitContainerConfig struct {
	ParentName string
	MountMap   map[string]mount.Mount
	EnvList    map[string]string
	Networks   []string
}

type PrefixFile

type PrefixFile struct {
	DataRoot string
	Prefix   string
	FileName string
}

func NewSecretsPrefixFile

func NewSecretsPrefixFile(dataRoot, prefix string) PrefixFile

func NewSharedEnvPrefixFile

func NewSharedEnvPrefixFile(dataRoot, prefix string) PrefixFile

func (*PrefixFile) ReadVariables

func (pf *PrefixFile) ReadVariables() (map[string]string, error)

func (*PrefixFile) WriteVariables

func (pf *PrefixFile) WriteVariables(in map[string]string) error

type PrefixFileParamError

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

func NewErrPrefixFileParamEmpty

func NewErrPrefixFileParamEmpty(param string) PrefixFileParamError

func (PrefixFileParamError) Error

func (e PrefixFileParamError) Error() string

type ReleaseContainer

type ReleaseContainer struct {
	Image      string
	Tag        string
	Successful bool
}

type ReleaseDoc

type ReleaseDoc struct {
	Version      string
	ReleaseNotes string
	Date         time.Time
	Containers   []ReleaseContainer
}

func GetVersions

func GetVersions(instance string, cfg *config.Configuration) ([]ReleaseDoc, error)

type TraefikDeployRequest

type TraefikDeployRequest struct {
	LogLevel string `json:"logLevel"`
	AcmeMail string `json:"acmeMail" binding:"required_if=TLS true"`
	Port     uint16 `json:"port"`
	TLSPort  uint16 `json:"tlsPort"`
	TLS      bool   `json:"TLS"`
}

type UnknownContainerError

type UnknownContainerError struct{}

func (*UnknownContainerError) Error

func (err *UnknownContainerError) Error() string

Jump to

Keyboard shortcuts

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