env

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package env contains helpers to export a service's env vars with some substitution in order to replace docker-to-docker to host-to-docker addresses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildContainerName

func BuildContainerName(session *docker.Session, serviceName string) (string, error)

BuildContainerName from session id and service name fails if service is not registered in bake session.

func GetServiceEnvs

func GetServiceEnvs(session *docker.Session, serviceName string, extraRules ReplacementRuleList) (map[string]string, error)

GetServiceEnvs inspects docker container envs from given service If service does not exist (docker container should exist, it can be stopped), then it fails because there is no service to debug.

Types

type FullReplacementRule

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

FullReplacementRule replaces value by env name.

func NewFullReplacementRule

func NewFullReplacementRule(envName, value string) *FullReplacementRule

NewFullReplacementRule creates full replacement rule.

func (FullReplacementRule) Replace

func (f FullReplacementRule) Replace(_ string) string

Replace replaces old with new in the input string.

func (FullReplacementRule) Supports

func (f FullReplacementRule) Supports(name, _ string) bool

Supports by env name.

type ReplacementRule

type ReplacementRule interface {
	Replace(in string) (out string)
	Supports(envName, in string) bool
}

ReplacementRule replaces in string to out string.

type ReplacementRuleList

type ReplacementRuleList []ReplacementRule

ReplacementRuleList list of replacement rules.

func (ReplacementRuleList) Merge

Merge two lists of rules.

func (ReplacementRuleList) Replace

func (l ReplacementRuleList) Replace(envs map[string]string) map[string]string

Replace replaces envs by list.

type SubstrReplacementRule

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

SubstrReplacementRule string replacer.

func NewSubstrReplacement

func NewSubstrReplacement(old, change string) *SubstrReplacementRule

NewSubstrReplacement creates simple replacement.

func (SubstrReplacementRule) Replace

func (s SubstrReplacementRule) Replace(in string) string

Replace replaces old with new in the input string.

func (SubstrReplacementRule) Supports

func (s SubstrReplacementRule) Supports(_, in string) bool

Supports by finding old substring.

Jump to

Keyboard shortcuts

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