pipelines

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractHostFromRepoURL

func ExtractHostFromRepoURL(repoURL string) (string, error)

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

func GenerateNetrc(repoURL, user, token string) (string, error)

GenerateNetrc generates a .netrc file content for Git authentication. The host is extracted from the repository URL.

func GitlabNetrc deprecated

func GitlabNetrc(user, token string) string

GitlabNetrc generates a .netrc file content for GitLab authentication (deprecated, use GenerateNetrc instead)

Deprecated: Use GenerateNetrc instead which extracts host from repo URL

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.

func NewConfig

func NewConfig(opts ...Option) Config

NewConfig constructs a Config instance using functional options.

Parameters:

  • opts: A variadic list of Option functions to apply to the Config.

Returns:

  • A Config instance with the applied options.

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 (*DaggerContainerAdapter) From

func (*DaggerContainerAdapter) WithEnvVariable

func (a *DaggerContainerAdapter) WithEnvVariable(name, value string) DaggerContainer

func (*DaggerContainerAdapter) WithExec

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

type DaggerFile interface {
	Contents(context.Context) (string, error)
}

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

func (*DaggerFileAdapter) Contents

func (a *DaggerFileAdapter) Contents(ctx context.Context) (string, error)

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

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

func WithBranch(branch string) Option

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

func WithBuildTag(tag string) Option

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

func WithCommitSHA(sha string) Option

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

func WithCoverage(percentage float64) Option

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

func WithEnv(env string) Option

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

func WithGitGitProtocol(gitProtocol string) Option

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

func WithGitRepo(repo, ref string) Option

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

func WithGitUserEmail(email string) Option

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

func WithGitUserName(name string) Option

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

func WithGoVersion(version string) Option

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

func WithOnlyBuild(onlyBuild bool) Option

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

func WithOnlyTest(onlyTest bool) Option

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

func WithRegistry(url, token string) Option

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

func WithRegistryUser(user string) Option

WithRegistryUser sets the Docker registry user.

Parameters:

  • user: The Docker registry user.

Returns:

  • An Option function to set the Docker registry user.

func WithSSHPrivateKey

func WithSSHPrivateKey(key string) Option

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

func WithSkipPush(skip bool) Option

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

func WithToken(token string) Option

WithToken sets a generic token for the Config.

Parameters:

  • token: The token to set.

Returns:

  • An Option function to set the token.

func WithVerbose

func WithVerbose(verbose bool) Option

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.

Jump to

Keyboard shortcuts

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