Documentation ¶
Index ¶
- Constants
- Variables
- func BuildImage(dctx, dfile, nameAndTag string) error
- func BuildImageOnce(once *sync.Once, dctx, dfile, nameAndTag string) error
- func DefaultNetwork(once *sync.Once) error
- func DefaultTCLabels() map[string]string
- func DefaultTCName(name string) string
- func GetHost(container tc.Container) (string, error)
- func HostDockerInternal() string
- func IsDockerRunning() bool
- func Load[X any](t *testing.T) (*X, error)
- func MapTheSamePort(port string) nat.PortMap
- func NewPromtail() error
- func RenderTemplate(tmpl string, data interface{}) (string, error)
- func RunCommandDir(dir, name string, args ...string) error
- func Store[T any](cfg *T) error
- func WriteAllContainersLogs(dir string) error
- type AWSSecret
- type AWSSecretsManager
- type Config
- type DockerClient
- type JSONStrDuration
- type ValidationError
Constants ¶
const ( EnvVarTestConfigs = "CTF_CONFIGS" EnvVarAWSSecretsManager = "CTF_AWS_SECRETS_MANAGER" // EnvVarCI this is a default env variable many CI runners use so code can detect we run in CI EnvVarCI = "CI" )
const ( OutputFieldNameTOML = "out" OutputFieldName = "Out" OverridesFieldName = "Overrides" )
const (
DefaultCTFLogsDir = "logs/docker"
)
const (
DefaultConfigDir = "."
)
const (
EnvVarIgnoreCriticalLogs = "CTF_IGNORE_CRITICAL_LOGS"
)
const (
EnvVarLogLevel = "CTF_LOG_LEVEL"
)
Variables ¶
var ( // Secrets is a singleton AWS Secrets Manager // Loaded once on start inside Load and is safe to call concurrently Secrets *AWSSecretsManager DefaultNetworkName string AllowedEmptyConfigurationFields = []string{OutputFieldName, OverridesFieldName} )
var (
L zerolog.Logger
)
var (
PathRoot = filepath.Join(filepath.Dir(b), ".")
)
Functions ¶
func BuildImage ¶ added in v0.3.1
func BuildImageOnce ¶ added in v0.2.13
func DefaultNetwork ¶ added in v0.1.1
func DefaultTCLabels ¶
func DefaultTCName ¶
func HostDockerInternal ¶ added in v0.2.10
func HostDockerInternal() string
HostDockerInternal returns host.docker.internal that works both locally and in GHA
func IsDockerRunning ¶ added in v0.1.6
func IsDockerRunning() bool
func MapTheSamePort ¶
func NewPromtail ¶ added in v0.1.6
func NewPromtail() error
func RenderTemplate ¶
func RunCommandDir ¶ added in v0.3.1
RunCommandDir executes a command in some directory and prints the output
func WriteAllContainersLogs ¶ added in v0.2.11
WriteAllContainersLogs writes all Docker container logs to the default logs directory
Types ¶
type AWSSecret ¶
type AWSSecret string
AWSSecret is a wrapper preventing accidental printing or marshalling
func (AWSSecret) GoString ¶
The GoString method is used to print values passed as an operand to a %#v format.
func (AWSSecret) MarshalJSON ¶
MarshalJSON Marshaler is the interface implemented by types that can marshal themselves into valid JSON.
func (AWSSecret) MarshalText ¶
MarshalText encodes the receiver into UTF-8-encoded text and returns the result.
type AWSSecretsManager ¶
type AWSSecretsManager struct { Client *secretsmanager.Client RequestTimeout time.Duration // contains filtered or unexported fields }
AWSSecretsManager is an AWS Secrets Manager service wrapper
func NewAWSSecretsManager ¶
func NewAWSSecretsManager(requestTimeout time.Duration) (*AWSSecretsManager, error)
NewAWSSecretsManager create a new connection to AWS Secrets Manager
func (*AWSSecretsManager) CreateSecret ¶
func (sm *AWSSecretsManager) CreateSecret(key string, val string, override bool) error
CreateSecret creates a specific secret by key
func (*AWSSecretsManager) GetSecret ¶
func (sm *AWSSecretsManager) GetSecret(key string) (AWSSecret, error)
GetSecret gets a specific secret by key
func (*AWSSecretsManager) RemoveSecret ¶
func (sm *AWSSecretsManager) RemoveSecret(key string, noRecovery bool) error
RemoveSecret removes a specific secret by key
type DockerClient ¶ added in v0.2.7
type DockerClient struct {
// contains filtered or unexported fields
}
DockerClient wraps a Docker API client and provides convenience methods
func NewDockerClient ¶ added in v0.2.7
func NewDockerClient() (*DockerClient, error)
NewDockerClient creates a new instance of DockerClient
func (*DockerClient) CopyFile ¶ added in v0.2.7
func (dc *DockerClient) CopyFile(containerName, sourceFile, targetPath string) error
CopyFile copies a file into a container by name
type JSONStrDuration ¶ added in v0.1.1
JSONStrDuration is JSON friendly duration that can be parsed from "1h2m0s" Go format
func (*JSONStrDuration) MarshalJSON ¶ added in v0.1.1
func (d *JSONStrDuration) MarshalJSON() ([]byte, error)
func (*JSONStrDuration) UnmarshalJSON ¶ added in v0.1.1
func (d *JSONStrDuration) UnmarshalJSON(b []byte) error