Documentation
¶
Overview ¶
Package pipelines provides adapters to convert real Dagger types to interfaces.
Package pipelines provides interfaces for Dagger types to enable mocking in tests.
Index ¶
- func ExtractHostFromRepoURL(repoURL string) (string, error)
- func GenerateNetrc(repoURL, user, token string) (string, error)
- func GitlabNetrc(user, token string) stringdeprecated
- type Config
- type DaggerAdapter
- type DaggerCacheVolume
- type DaggerCacheVolumeAdapter
- type DaggerClient
- type DaggerContainer
- type DaggerContainerAdapter
- func (a *DaggerContainerAdapter) File(path string) DaggerFile
- func (a *DaggerContainerAdapter) From(image string) DaggerContainer
- func (a *DaggerContainerAdapter) WithEnvVariable(name, value string) DaggerContainer
- func (a *DaggerContainerAdapter) WithExec(args []string, opts DaggerContainerWithExecOpts) DaggerContainer
- func (a *DaggerContainerAdapter) WithMountedCache(path string, cache DaggerCacheVolume) DaggerContainer
- func (a *DaggerContainerAdapter) WithMountedDirectory(path string, dir DaggerDirectory) DaggerContainer
- func (a *DaggerContainerAdapter) WithWorkdir(path string) DaggerContainer
- type DaggerContainerWithExecOpts
- type DaggerDirectory
- type DaggerDirectoryAdapter
- type DaggerFile
- type DaggerFileAdapter
- type DaggerHost
- type DaggerHostAdapter
- type DaggerHostDirectoryOpts
- type Option
- func WithBranch(branch string) Option
- func WithBuildTag(tag string) Option
- func WithCommitSHA(sha string) Option
- func WithCoverage(percentage float64) Option
- func WithEnv(env string) Option
- func WithGitGitProtocol(gitProtocol string) Option
- func WithGitRepo(repo, ref string) Option
- func WithGitUserEmail(email string) Option
- func WithGitUserName(name string) Option
- func WithGoVersion(version string) Option
- func WithOnlyBuild(onlyBuild bool) Option
- func WithOnlyTest(onlyTest bool) Option
- func WithRegistry(url, token string) Option
- func WithRegistryUser(user string) Option
- func WithSSHPrivateKey(key string) Option
- func WithSkipPush(skip bool) Option
- func WithToken(token string) Option
- func WithVerbose(verbose bool) Option
- type ReturnType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractHostFromRepoURL ¶
ExtractHostFromRepoURL extracts the host from a repository URL. Supports both HTTPS (https://github.com/user/repo.git) and SSH (git@github.com:user/repo.git) formats.
func GenerateNetrc ¶
GenerateNetrc generates a .netrc file content for Git authentication. The host is extracted from the repository URL.
func GitlabNetrc
deprecated
Types ¶
type Config ¶
type Config struct {
Env string // The environment in which the pipeline is running.
SkipPush bool // Indicates whether to skip the push stage.
OnlyTest bool // Indicates whether to run only the test stage.
OnlyBuild bool // Indicates whether to run only the build stage.
Verbose bool // Enables verbose logging.
GitRepo string // The Git repository URL.
GitRef string // The Git reference (e.g., branch or tag).
GitProtocol string // The Git GitProtocol ssh or https.
GitUserEmail string // The Git user email for commits.
GitUserName string // The Git user name for commits.
RegistryURL string // The Docker registry URL.
RegistryToken string // The Docker registry token.
Version string // The version of the application.
BuildTag string // The build tag for the application.
CommitSHA string // The commit SHA of the current build.
BranchName string // The name of the Git branch.
Token string // A generic token for authentication.
Coverage float64 // The test coverage percentage.
Image *dagger.Container
ImageRef string
ImageContainer *dagger.Container
ImageName string
RegistryUser string // gitlab-ci-token (in CI) or your username
RegistryPass string // CI_JOB_TOKEN (in CI) or your Personal Access Token
Registry string // Docker registry URL (e.g., registry.gitlab.com/my-org/my-project/service)
ImageTag string // Image tag (e.g., latest, sha, v1.2.3)
GoVersion string // Go version to use (e.g., 1.24.2)
JavaVersion string // Java version to use (e.g., 17)
SSHPrivateKey string // SSH private key for Git authentication
}
Config holds configuration values used across all pipelines.
Fields:
- Env: The environment in which the pipeline is running (e.g., dev, staging, prod).
- SkipPush: Indicates whether to skip the push stage.
- OnlyTest: Indicates whether to run only the test stage.
- OnlyBuild: Indicates whether to run only the build stage.
- Verbose: Enables verbose logging.
- GitRepo: The Git repository URL.
- GitRef: The Git reference (e.g., branch or tag).
- CIJobToken: The CI job token for authentication.
- RegistryURL: The Docker registry URL.
- RegistryToken: The Docker registry token.
- Version: The version of the application.
- BuildTag: The build tag for the application.
- CommitSHA: The commit SHA of the current build.
- BranchName: The name of the Git branch.
- Token: A generic token for authentication.
- Coverage: The test coverage percentage.
- GitUserEmail: The Git user email for commits.
- GitUserName: The Git user name for commits.
type DaggerAdapter ¶
type DaggerAdapter struct {
// contains filtered or unexported fields
}
DaggerAdapter adapts real Dagger types to our interfaces
func (*DaggerAdapter) CacheVolume ¶
func (a *DaggerAdapter) CacheVolume(name string) DaggerCacheVolume
func (*DaggerAdapter) Container ¶
func (a *DaggerAdapter) Container() DaggerContainer
func (*DaggerAdapter) GetRealClient ¶
func (a *DaggerAdapter) GetRealClient() *dagger.Client
GetRealClient returns the underlying real Dagger client for use with shared functions
func (*DaggerAdapter) Host ¶
func (a *DaggerAdapter) Host() DaggerHost
type DaggerCacheVolume ¶
type DaggerCacheVolume interface {
}
DaggerCacheVolume interface abstracts the dagger.CacheVolume to enable mocking
type DaggerCacheVolumeAdapter ¶
type DaggerCacheVolumeAdapter struct {
// contains filtered or unexported fields
}
DaggerCacheVolumeAdapter adapts dagger.CacheVolume to DaggerCacheVolume interface
type DaggerClient ¶
type DaggerClient interface {
Host() DaggerHost
Container() DaggerContainer
CacheVolume(string) DaggerCacheVolume
// GetRealClient returns the underlying real Dagger client (only for adapters)
GetRealClient() *dagger.Client
}
DaggerClient interface abstracts the dagger.Client to enable mocking
func NewDaggerAdapter ¶
func NewDaggerAdapter(client *dagger.Client) DaggerClient
NewDaggerAdapter creates a new adapter for a real Dagger client
type DaggerContainer ¶
type DaggerContainer interface {
From(string) DaggerContainer
WithMountedDirectory(string, DaggerDirectory) DaggerContainer
WithMountedCache(string, DaggerCacheVolume) DaggerContainer
WithWorkdir(string) DaggerContainer
WithEnvVariable(string, string) DaggerContainer
WithExec([]string, DaggerContainerWithExecOpts) DaggerContainer
File(string) DaggerFile
}
DaggerContainer interface abstracts the dagger.Container to enable mocking
type DaggerContainerAdapter ¶
type DaggerContainerAdapter struct {
// contains filtered or unexported fields
}
DaggerContainerAdapter adapts dagger.Container to DaggerContainer interface
func (*DaggerContainerAdapter) File ¶
func (a *DaggerContainerAdapter) File(path string) DaggerFile
func (*DaggerContainerAdapter) From ¶
func (a *DaggerContainerAdapter) From(image string) DaggerContainer
func (*DaggerContainerAdapter) WithEnvVariable ¶
func (a *DaggerContainerAdapter) WithEnvVariable(name, value string) DaggerContainer
func (*DaggerContainerAdapter) WithExec ¶
func (a *DaggerContainerAdapter) WithExec(args []string, opts DaggerContainerWithExecOpts) DaggerContainer
func (*DaggerContainerAdapter) WithMountedCache ¶
func (a *DaggerContainerAdapter) WithMountedCache(path string, cache DaggerCacheVolume) DaggerContainer
func (*DaggerContainerAdapter) WithMountedDirectory ¶
func (a *DaggerContainerAdapter) WithMountedDirectory(path string, dir DaggerDirectory) DaggerContainer
func (*DaggerContainerAdapter) WithWorkdir ¶
func (a *DaggerContainerAdapter) WithWorkdir(path string) DaggerContainer
type DaggerContainerWithExecOpts ¶
type DaggerContainerWithExecOpts struct {
RedirectStdout string
}
DaggerContainerWithExecOpts represents options for container exec operations
type DaggerDirectory ¶
type DaggerDirectory interface {
// GetRealDirectory returns the underlying real Dagger directory (only for adapters)
GetRealDirectory() *dagger.Directory
}
DaggerDirectory interface abstracts the dagger.Directory to enable mocking
type DaggerDirectoryAdapter ¶
type DaggerDirectoryAdapter struct {
// contains filtered or unexported fields
}
DaggerDirectoryAdapter adapts dagger.Directory to DaggerDirectory interface
func (*DaggerDirectoryAdapter) GetRealDirectory ¶
func (a *DaggerDirectoryAdapter) GetRealDirectory() *dagger.Directory
GetRealDirectory returns the underlying real Dagger directory for use with shared functions
type DaggerFile ¶
DaggerFile interface abstracts the dagger.File to enable mocking
type DaggerFileAdapter ¶
type DaggerFileAdapter struct {
// contains filtered or unexported fields
}
DaggerFileAdapter adapts dagger.File to DaggerFile interface
type DaggerHost ¶
type DaggerHost interface {
Directory(string, DaggerHostDirectoryOpts) DaggerDirectory
}
DaggerHost interface abstracts the dagger.Host to enable mocking
type DaggerHostAdapter ¶
type DaggerHostAdapter struct {
// contains filtered or unexported fields
}
DaggerHostAdapter adapts dagger.Host to DaggerHost interface
func (*DaggerHostAdapter) Directory ¶
func (a *DaggerHostAdapter) Directory(path string, opts DaggerHostDirectoryOpts) DaggerDirectory
type DaggerHostDirectoryOpts ¶
type DaggerHostDirectoryOpts struct {
Exclude []string
}
DaggerHostDirectoryOpts represents options for host directory operations
type Option ¶
type Option func(*Config)
Option represents a functional option for configuring Config.
A functional option is a function that modifies a Config instance.
func WithBranch ¶
WithBranch sets the branch name for the Config.
Parameters:
- branch: The branch name to set.
Returns:
- An Option function to set the branch name.
func WithBuildTag ¶
WithBuildTag sets the build tag for the Config.
Parameters:
- tag: The build tag to set.
Returns:
- An Option function to set the build tag.
func WithCommitSHA ¶
WithCommitSHA sets the commit SHA for the Config.
Parameters:
- sha: The commit SHA to set.
Returns:
- An Option function to set the commit SHA.
func WithCoverage ¶
WithCoverage sets the test coverage percentage for the Config.
Parameters:
- percentage: The test coverage percentage to set.
Returns:
- An Option function to set the test coverage percentage.
func WithEnv ¶
WithEnv sets the environment for the Config.
Parameters:
- env: The environment to set (e.g., dev, staging, prod).
Returns:
- An Option function to set the environment.
func WithGitGitProtocol ¶
WithGitGitProtocol sets the Git protocol (e.g., "ssh" or "https") for the Config.
Parameters:
- gitProtocol: The Git protocol to use ("ssh" or "https").
Returns:
- An Option function that sets the GitProtocol field in Config.
func WithGitRepo ¶
WithGitRepo sets the Git repository URL and reference for the Config.
Parameters:
- repo: The Git repository URL.
- ref: The Git reference (e.g., branch or tag).
Returns:
- An Option function to set the Git repository URL and reference.
func WithGitUserEmail ¶
WithGitUserEmail sets the Git user email for the Config.
Parameters:
- email: The Git user email to set.
Returns:
- An Option function to set the Git user email.
func WithGitUserName ¶
WithGitUserName sets the Git user name for the Config.
Parameters:
- name: The Git user name to set.
Returns:
- An Option function to set the Git user name.
func WithGoVersion ¶
WithGoVersion sets the Go version for the Config.
Parameters:
- version: The Go version to set (e.g., "1.24.2").
Returns:
- An Option function to set the Go version.
func WithOnlyBuild ¶
WithOnlyBuild sets the OnlyBuild flag for the Config.
Parameters:
- onlyBuild: A boolean indicating whether to run only the build stage.
Returns:
- An Option function to set the OnlyBuild flag.
func WithOnlyTest ¶
WithOnlyTest sets the OnlyTest flag for the Config.
Parameters:
- onlyTest: A boolean indicating whether to run only the test stage.
Returns:
- An Option function to set the OnlyTest flag.
func WithRegistry ¶
WithRegistry sets the Docker registry URL and token for the Config.
Parameters:
- url: The Docker registry URL.
- token: The Docker registry token.
Returns:
- An Option function to set the Docker registry URL and token.
func WithRegistryUser ¶
WithRegistryUser sets the Docker registry user.
Parameters:
- user: The Docker registry user.
Returns:
- An Option function to set the Docker registry user.
func WithSSHPrivateKey ¶
WithSSHPrivateKey sets the SSH private key for the Config.
Parameters:
- key: The SSH private key to set.
Returns:
- An Option function to set the SSH private key.
func WithSkipPush ¶
WithSkipPush sets the SkipPush flag for the Config.
Parameters:
- skip: A boolean indicating whether to skip the push stage.
Returns:
- An Option function to set the SkipPush flag.
func WithToken ¶
WithToken sets a generic token for the Config.
Parameters:
- token: The token to set.
Returns:
- An Option function to set the token.
func WithVerbose ¶
WithVerbose sets the Verbose flag for the Config.
Parameters:
- verbose: A boolean indicating whether to enable verbose logging.
Returns:
- An Option function to set the Verbose flag.
type ReturnType ¶
type ReturnType = []int
func ExitOk ¶
func ExitOk() ReturnType
func ExitOkOrTestFail ¶
func ExitOkOrTestFail() ReturnType
Directories
¶
| Path | Synopsis |
|---|---|
|
Package shared contiene utilidades y helpers para operaciones comunes en los pipelines.
|
Package shared contiene utilidades y helpers para operaciones comunes en los pipelines. |
|
Package test provides testing utilities and implementations for pipelines.
|
Package test provides testing utilities and implementations for pipelines. |