git

package
v0.0.1-prerelease9 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	AnnotationGitBaseRefKey     = "dev.getglu.git.base_ref"
	AnnotationGitHeadSHAKey     = "dev.getglu.git.head_sha"
	AnnotationProposalNumberKey = "dev.getglu.git.proposal.number"
	AnnotationProposalURLKey    = "dev.getglu.git.proposal.url"
)

Variables

View Source
var (
	// ErrProposalNotFound is returned when a proposal cannot be located
	ErrProposalNotFound = errors.New("proposal not found")
)

Functions

func ProposeChanges

func ProposeChanges[R Resource](opts ProposalOption) containers.Option[Phase[R]]

ProposeChanges configures the phase to propose the change (via PR or MR) as opposed to directly integrating it into the target trunk branch.

func WithLogger

func WithLogger[R Resource](log typed.PhaseLogger[R]) containers.Option[Phase[R]]

WithLogger sets of the reflog on the phase for tracking history

Types

type Branched

type Branched interface {
	Branch(phase core.Descriptor) string
}

Branched is a resource which exposes an alternative base branch on which the resource should be based.

type Phase

type Phase[R Resource] struct {
	// contains filtered or unexported fields
}

Phase is a Git storage backed phase implementation. It is used to manage the state of a resource as represented in a target Git repository.

func New

func New[R Resource](
	ctx context.Context,
	pipeline string,
	meta core.Metadata,
	newFn func() R,
	repo *git.Repository,
	proposer Proposer,
	opts ...containers.Option[Phase[R]],
) (*Phase[R], error)

New constructs and configures a new phase.

func (*Phase[R]) Branches

func (p *Phase[R]) Branches() []string

func (*Phase[A]) Descriptor

func (p *Phase[A]) Descriptor() core.Descriptor

Descriptor returns the phases descriptor.

func (*Phase[R]) Get

func (p *Phase[R]) Get(ctx context.Context) (core.Resource, error)

func (*Phase[R]) GetResource

func (p *Phase[R]) GetResource(ctx context.Context) (R, error)

func (*Phase[R]) History

func (p *Phase[R]) History(ctx context.Context) ([]core.State, error)

History returns the history of the phase (given a log has been configured).

func (*Phase[R]) Notify

func (p *Phase[R]) Notify(ctx context.Context, refs map[string]string) error

func (*Phase[R]) Rollback

func (p *Phase[R]) Rollback(ctx context.Context, version uuid.UUID) (*core.Result, error)

Rollback updates the state of the phase to a previous known version in history.

func (*Phase[R]) Update

func (p *Phase[R]) Update(ctx context.Context, to R, opts ...containers.Option[typed.UpdateOptions]) (*core.Result, error)

type Proposal

type Proposal struct {
	BaseRevision string
	BaseBranch   string
	Branch       string
	HeadRevision string
	Digest       string
	Title        string
	Body         string

	Annotations map[string]string
}

Proposal contains the fields necessary to propose a resource update to a Repository.

type ProposalOption

type ProposalOption struct {
	Labels []string
}

ProposalOption configures calls to create proposals

type Proposer

type Proposer interface {
	GetCurrentProposal(_ context.Context, baseBranch, branchPrefix string) (*Proposal, error)
	CreateProposal(context.Context, *Proposal, ProposalOption) error
	MergeProposal(context.Context, *Proposal) error
	CloseProposal(context.Context, *Proposal) error
}

Proposer is a type which can be used to create and manage proposals.

type Resource

type Resource interface {
	core.Resource
	ReadFrom(context.Context, core.Descriptor, fs.Filesystem) error
	WriteTo(context.Context, core.Descriptor, fs.Filesystem) error
}

Resource is a core.Resource with additional constraints which are required for reading from and writing to a filesystem.

Jump to

Keyboard shortcuts

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