internal

package
v0.0.4-rc9 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsPath

func AbsPath(path string) string

func DescImage

func DescImage(r string) (v1.Image, name.Reference, error)

func ExecCmd

func ExecCmd(command string, dryRun bool) (string, string, error)

func FailOnError

func FailOnError(err error)

func FindCodeChange

func FindCodeChange(repository *git.Repository, fromHash plumbing.Hash, pathes []string) ([]plumbing.Hash, error)

FindCodeChange returns:

  • the latest ancestor commit for which the source code has changed, then list of following commits for which the source code has not changed
  • an error if any

func FormatTags

func FormatTags(tags *map[plumbing.Hash]*plumbing.Reference) map[string]string

FormatTags convert a map of tags to a map of human readable tags

func GetImageEnVarPrefix

func GetImageEnVarPrefix(image string) (string, error)

func GetRepoRoot

func GetRepoRoot(gitRepo *git.Repository) (string, error)

func GitSemverTagMap

func GitSemverTagMap(repo git.Repository) (*map[plumbing.Hash]*plumbing.Reference, error)

GitSemverTagMap ...

func HasDiff

func HasDiff(current *object.Commit, ancestor *object.Commit, root string, pathes []string) (bool, error)

func Infof

func Infof(format string, args ...interface{})

Infof should be used to describe the example commands that are about to run.

func IsDirty

func IsDirty(s git.Status) bool

IsDirty returns true if all the files are in Unmodified or Untracked status.

func IsFileInSourcePathes

func IsFileInSourcePathes(root string, filePath string, sourcePathes []string) (bool, error)

IsFileInSourcePathes checks if the given file path is in one of the given subdirectories If subdirectories is empty, it returns true becuase the file path must be in the root directory

func IsPathInSubdirectory

func IsPathInSubdirectory(absFilePath, absSubdirectory string) (bool, error)

IsPathInSubdirectory checks if the given file path is in the given subdirectory all paths must be absolute or function will have non-deterministic behavior

func LastDir

func LastDir(permalink string) (string, error)

LastDir returns the last element of URL path

func ListTags

func ListTags(src string) ([]string, error)

func NewCoreProject

func NewCoreProject(repository_path string, forcedBranch string) (Project, ProjConfig, error)

func TestGetVersion

func TestGetVersion(t *testing.T)

func TestUpgradeTag

func TestUpgradeTag(t *testing.T)

func Warnf

func Warnf(format string, args ...interface{})

Warnf should be used to display a warning

Types

type DepConfig

type DepConfig struct {
	Url     string     `mapstructure:"url" default:""`
	Clone   bool       `mapstructure:"clone" default:"false"`
	Image   string     `mapstructure:"image" default:""`
	Pull    bool       `mapstructure:"pull" default:"false"`
	Package string     `mapstructure:"package" default:""`
	Labels  labels.Set `mapstructure:"labels"`
}

type Dependency

type Dependency struct {
	Clone   bool
	Git     *Git
	Image   string
	Pull    bool
	Package string
}

func (*Dependency) GetImageName

func (dep *Dependency) GetImageName(imageRegistry string) (string, error)

func (*Dependency) String

func (dep *Dependency) String() string

type Git

type Git struct {
	InPlace        bool
	RemoteTags     []string
	RemoteBranches []string
	Url            string
	Repository     *git.Repository
	// Hash for the HEAD of the remote work branch
	RemoteHash string
	WorkBranch string
}

func NewGit

func NewGit(dir string) (*Git, error)

func (*Git) CloneOrOpen

func (gitObj *Git) CloneOrOpen(destBasePath string, singleBranch bool) error

CloneOrOpen clones a git repository or opens it if it already exists destBasePath is the base path where the repository will be cloned, if empty a temporary directory is created if singleBranch is true, only the work branch is cloned

func (*Git) CreateBranch

func (repo *Git) CreateBranch(branchName string) error

func (*Git) GetBranch

func (g *Git) GetBranch() (string, error)

func (*Git) GetEnVarPrefix

func (gitObj *Git) GetEnVarPrefix() (string, error)

func (*Git) GetHeadRevision

func (g *Git) GetHeadRevision() (*GitRevision, error)

GetHeadRevision the reference as 'git describe ' will do

func (*Git) GetName

func (gitObj *Git) GetName() (string, error)

func (*Git) GetRevision

func (g *Git) GetRevision(hash plumbing.Hash) (*GitRevision, error)

GetRevision returns the reference as 'git checkout <hash> && git describe ' would do

func (*Git) GetRoot

func (git *Git) GetRoot() (string, error)

func (*Git) GoInstall

func (git *Git) GoInstall() error

func (*Git) HasBranch

func (gitObj *Git) HasBranch(branchname string) (bool, string, error)

HasBranch returns true if the branch exists in the repository and the hash of the branch HEAD it works for local and remote repositories

func (*Git) IsGoModule

func (git *Git) IsGoModule() (bool, error)

func (*Git) LsRemote

func (gitObj *Git) LsRemote() error

LsRemote returns branches and tag of a remote repository https://github.com/go-git/go-git/blob/master/_examples/ls-remote/main.go

func (*Git) MainBranch

func (gitObj *Git) MainBranch() (string, string, error)

func (*Git) OpenIfExists

func (gitObj *Git) OpenIfExists(destBasePath string) error

func (*Git) TaggedCommit

func (repo *Git) TaggedCommit(filename string, message string, tag string, annotatedTag bool, author object.Signature) (*plumbing.Hash, *plumbing.Reference, error)

type GitRevision

type GitRevision struct {
	Tag     string
	Counter int
	Hash    string
	Dirty   bool
	Branch  string
}

func (*GitRevision) GetVersion

func (rev *GitRevision) GetVersion() string

GetVersion returns the reference as 'git describe ' will do except that tag is the latest semver annotated tag

func (*GitRevision) IsRelease

func (rev *GitRevision) IsRelease() bool

func (*GitRevision) UpgradeTag

func (rev *GitRevision) UpgradeTag() (string, error)

type Image

type Image struct {
	InRegistry        bool
	Registry          string
	Name              string
	Tag               string
	TemporaryRegistry string
}

func (Image) Desc

func (i Image) Desc() (v1.Image, name.Reference, error)

func (Image) String

func (i Image) String() string

func (Image) Url

func (i Image) Url() string

type ProjConfig

type ProjConfig struct {
	Registry     string      `mapstructure:"registry" default:""`
	Dependencies []DepConfig `mapstructure:"dependencies"`
	SourcePathes []string    `mapstructure:"sourcePathes"`
}

func NewConfig

func NewConfig(repositoryPath string) (ProjConfig, error)

NewConfig reads ciux config file to buld a Config struct it uses repositoryPath if not null or current directory

type Project

type Project struct {
	GitMain       *Git
	SourcePathes  []string
	ImageRegistry string
	Image         Image
	Dependencies  []*Dependency
	// Required for github actions, which fetch a single commit by default
	ForcedBranch      string
	TemporaryRegistry string
	LabelSelector     string
}

func NewProject

func NewProject(repository_path string, forcedBranch string, mainProjectOnly bool, labelSelector string) (Project, error)

NewProject creates a new Project struct It reads the repository_path/.ciux.yaml configuration file and retrieve the work branch for all dependencies

func (*Project) AddInPlaceDepsSources

func (p *Project) AddInPlaceDepsSources(basePath string) error

func (*Project) CheckDepImages

func (p *Project) CheckDepImages() ([]name.Reference, error)

func (*Project) GetGits

func (p *Project) GetGits() []*Git

func (*Project) GetImageName

func (project *Project) GetImageName(suffix string, checkRegistry bool) error

GetImageName compute the name and tag for the project image

it checks the git repository for changes
a suffix can be added to image name
image existence in the registry can be checked

func (*Project) InstallGoModules

func (p *Project) InstallGoModules() (string, error)

func (*Project) RetrieveDepsSources

func (p *Project) RetrieveDepsSources(basePath string) error

func (*Project) String

func (p *Project) String() string

func (*Project) WriteOutConfig

func (p *Project) WriteOutConfig() (string, error)

WriteOutConfig writes out the shell configuration file used be the CI/CD pipeline

type SemVer

type SemVer struct {
	Prefix        string
	Major         int
	Minor         int
	Patch         int
	Prerelease    []string
	BuildMetadata []string
}

SemVer ...

func SemVerParse

func SemVerParse(str string) *SemVer

SemVerParse ...

func (SemVer) Equal

func (v SemVer) Equal(v2 SemVer) bool

Equal ...

func (SemVer) ParseReleaseCandidate

func (v SemVer) ParseReleaseCandidate() (int, error)

func (SemVer) String

func (v SemVer) String() string

String ...

Jump to

Keyboard shortcuts

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