scm

package
v0.79.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWrongConfig is returned when a scm has missing attributes which are mandatory
	ErrWrongConfig = errors.New("wrong scm configuration")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Kind specifies the scm kind
	Kind string `yaml:",omitempty"`
	// Spec specifies the scm specification
	Spec interface{} `jsonschema:"type=object" yaml:",omitempty"`
	// Disabled is a setting used to disable the local git repository auto configuration
	Disabled bool
}

func (*Config) AutoGuess added in v0.28.0

func (c *Config) AutoGuess(configName, workingDir string, gitHandler gitgeneric.GitHandler) error

AutoGuess tries to fill the Config object receiver with the configuration auto-guessed from the provided directory It only returns an error if it fails "hard" (can't guess SCM, etc.).

func (Config) JSONSchema added in v0.23.0

func (Config) JSONSchema() *jschema.Schema

JSONSchema implements the json schema interface to generate the "scm" jsonschema

func (Config) Validate

func (c Config) Validate() error

Validate returns nil if the Config object is valid or a wrapped error of all the failed validations otherwise

type ConfigSpec added in v0.28.0

type ConfigSpec interface {
	Merge(interface{}) error
}

type MockScm

type MockScm struct {
	ScmHandler
	WorkingDir   string
	ChangedFiles []string
	Err          error
}

MockScm is a stub implementation of the `ScmHandler` interface to be used in our unit test suites.

func (*MockScm) GetChangedFiles

func (m *MockScm) GetChangedFiles(workingDir string) ([]string, error)

func (*MockScm) GetDirectory

func (m *MockScm) GetDirectory() (directory string)

type Scm

type Scm struct {
	Config     *Config
	Handler    ScmHandler
	PipelineID string
}

func New

func New(config *Config, pipelineID string) (Scm, error)

func (*Scm) GenerateSCM

func (s *Scm) GenerateSCM() error

GenerateSCM populates the receiver's attribute "s.Handler" with the SCM implementation based on the "s.Conf" content

type ScmHandler

type ScmHandler interface {
	Add(files []string) error
	Clone() (string, error)
	Checkout() error
	GetDirectory() (directory string)
	Commit(message string) error
	Clean() error
	Push() (bool, error)
	PushTag(tag string) error
	PushBranch(branch string) error
	GetChangedFiles(workingDir string) ([]string, error)
	IsRemoteBranchUpToDate() (bool, error)
	GetBranches() (sourceBranch, workingBranch, targetBranch string)
	GetURL() string
}

ScmHandler is an interface offering common functions for a source control manager like git or github

Jump to

Keyboard shortcuts

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