bob

package
v0.0.0-...-b7a57f2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BuildAllTargetName            = "all"
	BuildTargetwithdirsTargetName = "targetwithdirs"
	BuildAlwaysTargetName         = "always-build"

	BuildTargetDockerImageName     = "docker-image"
	BuildTargetDockerImagePlusName = "docker-image-plus"
	// BuildTargetBobTestImage intentionaly has a path separator
	// in the image name to assure temporary tar archive generation
	// works as intended (uses the image name as filename).
	BuildTargetBobTestImage     = "bob/testimage:latest"
	BuildTargetBobTestImagePlus = "bob/testimage/plus:latest"
)
View Source
const SecondLevelDir = "second-level"
View Source
const SecondLevelOpenapiProviderDir = "openapi-provider-project"
View Source
const ThirdLevelDir = "third-level"

Variables

View Source
var (
	ErrConfigFileDoesNotExist      = fmt.Errorf("config file does not exist")
	ErrRepoAlreadyAdded            = fmt.Errorf("repo already added")
	ErrRunDoesNotExist             = fmt.Errorf("run does not exist")
	ErrWorkspaceAlreadyInitialised = fmt.Errorf("bob Workspace Already Initialized")
	ErrTargetValidationFailed      = fmt.Errorf("target validation failed")
	ErrCouldNotFindTopLevelBobfile = fmt.Errorf("could not find top-level Bobfile")
	ErrInvalidVersion              = fmt.Errorf("invalid version")
	ErrInsecuredHTTPURL            = fmt.Errorf("insecured http url not supported")
	ErrInvalidScheme               = fmt.Errorf("invalid scheme")
	ErrInvalidGitUrl               = fmt.Errorf("invalid git url")
	ErrInvalidRepositoryName       = fmt.Errorf("invalid repository name")
)
View Source
var (
	ErrDuplicateProjectName = fmt.Errorf("duplicate project name")
)
View Source
var (
	ErrNoRebuildRequired = errors.New("no rebuild required")
)
View Source
var ErrNoValidURLToClone = fmt.Errorf("No valid URL to clone found.")
View Source
var Version = "0.0.0"

Functions

func AuthStore

func AuthStore(baseDir string) (s *auth.Store, err error)

func BuildinfoStore

func BuildinfoStore(baseDir string) (s buildinfostore.Store, err error)

func ConvertToLines

func ConvertToLines(output []byte) []string

ConvertToLines converts bytes into a list of strings separeted by newline

func CreatePlayground

func CreatePlayground(opts PlaygroundOptions) error

CreatePlayground creates a default playground to test bob workflows. projectName is used in the top-level bobfile

func DefaultAuthStore

func DefaultAuthStore() (s *auth.Store, err error)

func DefaultBuildinfoStore

func DefaultBuildinfoStore() (s buildinfostore.Store, err error)

func DefaultFilestore

func DefaultFilestore() (s store.Store, err error)

func DefaultNixBuilder

func DefaultNixBuilder() (_ *nixbuilder.NB, err error)

func Filestore

func Filestore(dir string) (s store.Store, err error)

func FprintCloneOutput

func FprintCloneOutput(reponame string, output []byte, success bool) *bytes.Buffer

FprintCloneOutput returns formatted output buffer with repository title from git clone output.

func FprintRepoTitle

func FprintRepoTitle(reponame string, maxlen int, success bool) *bytes.Buffer

FprintRepoTitle returns repo title buffer with success/error label

func MustDefaultBuildinfoStore

func MustDefaultBuildinfoStore() buildinfostore.Store

func MustDefaultFilestore

func MustDefaultFilestore() store.Store

func Name

func Name(repoURL string) (name string)

RepoName returns the base part of the repo as the name. Suffix excluded.

func NewBuilder

func NewBuilder(task string, aggregate *bobfile.Bobfile, f BuildFunc, nix *nixbuilder.NB) ctl.Builder

func NixBuilder

func NixBuilder(baseDir string) (_ *nixbuilder.NB, err error)

NixBuilder initialises a new nix builder object with the cache setup in the given location.

It's save to use the same base dir as for BuildinfoStore(), Filestore() and AuthStore().

func RepoName

func RepoName(repoURL *url.URL) (name string)

RepoName returns the base part of the repo as the name. Suffix excluded.

Types

type B

type B struct {
	// Repositories to track.
	Repositories []Repo `yaml:"repositories"`
	// contains filtered or unexported fields
}

func Bob

func Bob(opts ...Option) (*B, error)

func BobWithBaseStoreDir

func BobWithBaseStoreDir(baseStoreDir string, opts ...Option) (*B, error)

BobWithBaseStoreDir initialises stores in the given directory

func (*B) Add

func (b *B) Add(rawurl string, plain bool) (err error)

Add, adds a repositoroy to a workspace.

Automatically tries to guess the contrary url (git@/https://) from the given rawurl. This behavior can be deactivated if plain is set to true. In case of a local path (file://) plain has no effect.

func (*B) Aggregate

func (b *B) Aggregate() (aggregate *bobfile.Bobfile, err error)

Aggregate determine and read Bobfiles recursively into memory and returns a single Bobfile containing all tasks & runs.

func (*B) AggregateSparse

func (b *B) AggregateSparse(omitRunTasks ...bool) (aggregate *bobfile.Bobfile, err error)

AggregateSparse reads Bobfile with the intent to gather task names. The returned bobfile is not ready to be executed with a playbook.

func (*B) AggregateWithNixDeps

func (b *B) AggregateWithNixDeps(taskName string) (aggregate *bobfile.Bobfile, err error)

AggregateWithNixDeps does aggregation together with evaluating nix dependecies. Nic dependencies are altering a tasks input hash. Use this function for building `bob inspect` cmds.

func (*B) ArtifactInspect

func (b *B) ArtifactInspect(artifactID string) (ai bobtask.ArtifactInfo, err error)

func (*B) ArtifactList

func (b *B) ArtifactList(ctx context.Context) (description string, err error)

ArtifactList list artifacts belonging to each tasks. Artifacts are matched by project & taskname as well as their input hash stored in the artifacts metadata if required.

func (*B) AuthContext

func (b *B) AuthContext(name string) (authCtx auth.Context, err error)

func (*B) AuthContexts

func (b *B) AuthContexts() ([]auth.Context, error)

func (*B) Build

func (b *B) Build(ctx context.Context, taskName string) (err error)

Build a task and it's dependencies.

func (B) Clean

func (b B) Clean() (err error)

func (B) CleanBuildInfoStore

func (b B) CleanBuildInfoStore() error

func (B) CleanLocalStore

func (b B) CleanLocalStore() error

func (B) CleanNixCache

func (b B) CleanNixCache() error

func (B) CleanNixShellCache

func (b B) CleanNixShellCache() error

func (*B) Clone

func (b *B) Clone(failFast bool, preferedProtocol ...string) (err error)

Clone repos which are not yet in the workspace. Uses priority urls ssh >> https >> file.

failFast will not prompt the user in case of an error. preferedProtocol accepts https or ssh.

TODO: it still happens that git prompts for user input in case of a missing password on https.

func (*B) CloneRepo

func (b *B) CloneRepo(repoURL string, failFast bool) (_ string, err error)

CloneRepo repo and sub repositories recursively. failFast will not prompt the user in case of an error.

func (*B) CreateAuthContext

func (b *B) CreateAuthContext(name, token string) (err error)

func (*B) CurrentAuthContext

func (b *B) CurrentAuthContext() (curr auth.Context, err error)

func (*B) DeleteAuthContext

func (b *B) DeleteAuthContext(name string) (err error)

func (*B) Dir

func (b *B) Dir() string

func (*B) GetBuildTasks

func (b *B) GetBuildTasks() (tasks []string, err error)

func (*B) GetRunTasks

func (b *B) GetRunTasks() (tasks []string, err error)

func (*B) Init

func (b *B) Init() (err error)

func (B) Install

func (b B) Install() (err error)

func (*B) Localstore

func (b *B) Localstore() store.Store

Localstore returns the local artifact store

func (*B) Nix

func (b *B) Nix() *nixbuilder.NB

func (*B) PrintVersionCompatibility

func (b *B) PrintVersionCompatibility(bobfile *bobfile.Bobfile)

func (*B) RepositoryNames

func (b *B) RepositoryNames() (names []string, err error)

func (*B) Run

func (b *B) Run(ctx context.Context, runTaskName string) (_ ctl.Commander, err error)

Run builds dependent tasks for a run cmd and starts it. A control is returned to interact with the run cmd.

Canceling the cmd from the outside must be done through the context.

FIXME: Forbid circular dependecys.

func (*B) SetCurrentAuthContext

func (b *B) SetCurrentAuthContext(name string) (err error)

func (*B) UpdateAuthContext

func (b *B) UpdateAuthContext(name string, token string) (err error)

func (*B) Verify

func (b *B) Verify(ctx context.Context) (err error)

func (B) WorkspaceFilePath

func (b B) WorkspaceFilePath() string

type BuildFunc

type BuildFunc func(_ context.Context, runname string, aggregate *bobfile.Bobfile, nix *nixbuilder.NB) error

type CloneSchema

type CloneSchema string
const (
	SSH   CloneSchema = "ssh"
	HTTPS CloneSchema = "https"
)

func (*CloneSchema) String

func (cs *CloneSchema) String() string

type GitProvider

type GitProvider struct {
	Name   string
	Domain string

	Parse Parser
}

type GitRepo

type GitRepo struct {
	Provider GitProvider

	// SSH stores git@
	SSH *GitURL
	// HTTPS stores https://
	HTTPS *GitURL
	// Local stores file://
	Local string
}

func Parse

func Parse(rawurl string) (repo *GitRepo, err error)

Parse a rawurl and return a GitRepo object containing the specific https and ssh protocol urls.

func ParseAzure

func ParseAzure(rawurl string) (repo *GitRepo, err error)

ParseAzure parses a git repo url and return the corresponding git & https protocol links corresponding to azure-devops domain specifications. https://xxx@dev.azure.com/xxx/Yyy/_git/zzz.zzz.zzz", git@ssh.dev.azure.com:v3/xxx/Yyy/zzz.zzz.zzz",

func ParseGeneral

func ParseGeneral(rawurl string) (repo *GitRepo, err error)

ParseGeneral parses a git repo url and return the corresponding git & https protocol links corresponding to most (github, gitlab) domain specifications.

github https://github.com/benchkram/bob.git git@github.com:benchkram/bob.git gitlab git@gitlab.com:gitlab-org/gitlab.git https://gitlab.com/gitlab-org/gitlab.git

func ParseLocal

func ParseLocal(rawurl string) (repo *GitRepo, err error)

func (*GitRepo) Name

func (gr *GitRepo) Name() string

Name of the repository, usually part after the last "/".

type GitURL

type GitURL struct {
	URL *url.URL
}

GitURL overlays `url.URL` to handle git clone urls correctly.

func FromURL

func FromURL(u *url.URL) *GitURL

func (*GitURL) String

func (g *GitURL) String() string

type Option

type Option func(b *B)

func WithAuthStore

func WithAuthStore(store *auth.Store) Option

func WithBuildinfoStore

func WithBuildinfoStore(store buildinfostore.Store) Option

func WithCachingEnabled

func WithCachingEnabled(enabled bool) Option

func WithDir

func WithDir(dir string) Option

func WithEnvVariables

func WithEnvVariables(env []string) Option

func WithFilestore

func WithFilestore(store store.Store) Option

func WithInsecure

func WithInsecure(allow bool) Option

func WithMaxParallel

func WithMaxParallel(maxParallel int) Option

func WithNixBuilder

func WithNixBuilder(nix *nixbuilder.NB) Option

func WithPullEnabled

func WithPullEnabled(enabled bool) Option

func WithPushEnabled

func WithPushEnabled(enabled bool) Option

func WithRemotestore

func WithRemotestore(store store.Store) Option

func WithRequireBobConfig

func WithRequireBobConfig() Option

WithRequireBobConfig forces bob to read the configuration from `.bob/config`. Currently only used by `bob clone` and `bob git ...

type Parser

type Parser func(string) (*GitRepo, error)

type Parsers

type Parsers map[string]Parser

func NewParsers

func NewParsers() Parsers

type PlaygroundOptions

type PlaygroundOptions struct {
	Dir                    string
	ProjectName            string
	ProjectNameSecondLevel string
	ProjectNameThirdLevel  string
}

type Repo

type Repo struct {
	Name string

	SSHUrl   string
	HTTPSUrl string
	LocalUrl string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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