promote

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ready  = "Ready"
	Draft  = "Draft"
	Cancel = "Cancel"
)

Variables

View Source
var Separator = strings.Repeat("—", 80)

Functions

func IsPrerelease added in v0.34.2

func IsPrerelease(release *v1alpha1.Release) bool

Types

type ChangeType added in v0.34.2

type ChangeType string
const (
	ChangeTypeUpgrade   ChangeType = "Upgrade"
	ChangeTypeDowngrade ChangeType = "Downgrade"
	ChangeTypeUpdate    ChangeType = "Update"
)

type CommitInfo added in v0.31.4

type CommitInfo struct {
	Sha          string
	ShortSha     string
	Author       string
	GitHubAuthor string
	Message      string
	ShortMessage string
}

type EnvironmentReleaseInfo added in v0.38.0

type EnvironmentReleaseInfo struct {
	*v1alpha1.Release
	DisplayVersion string
	GitTag         string
	Links          map[string]string
}

type GitProvider

type GitProvider interface {
	CreateAndPushBranchWithFiles(branchName string, files []string, message string) error
	CheckoutMasterBranch() error
}

type InteractivePromptProvider

type InteractivePromptProvider struct {
	// contains filtered or unexported fields
}

func (*InteractivePromptProvider) ConfirmAutoMergePullRequest added in v0.22.0

func (*InteractivePromptProvider) ConfirmAutoMergePullRequest() (answer bool, err error)

func (*InteractivePromptProvider) ConfirmCreatingPromotionPullRequest

func (i *InteractivePromptProvider) ConfirmCreatingPromotionPullRequest(autoMerge, draft bool) (bool, error)

func (*InteractivePromptProvider) PrintBranchCreated

func (i *InteractivePromptProvider) PrintBranchCreated(branchName, message string)

func (*InteractivePromptProvider) PrintCanceled

func (i *InteractivePromptProvider) PrintCanceled()

func (*InteractivePromptProvider) PrintCompleted

func (i *InteractivePromptProvider) PrintCompleted()

func (*InteractivePromptProvider) PrintDraftPullRequestCreated added in v0.26.0

func (i *InteractivePromptProvider) PrintDraftPullRequestCreated(url string)

func (*InteractivePromptProvider) PrintEndPreview

func (i *InteractivePromptProvider) PrintEndPreview()

func (*InteractivePromptProvider) PrintNoPromotableEnvironmentFound

func (i *InteractivePromptProvider) PrintNoPromotableEnvironmentFound(environmentsFiltered bool)

func (*InteractivePromptProvider) PrintNoPromotableReleasesFound

func (i *InteractivePromptProvider) PrintNoPromotableReleasesFound(releasesFiltered bool, sourceEnv *v1alpha1.Environment, targetEnv *v1alpha1.Environment)

func (*InteractivePromptProvider) PrintPullRequestCreated

func (i *InteractivePromptProvider) PrintPullRequestCreated(url string)

func (*InteractivePromptProvider) PrintReleasePreview

func (i *InteractivePromptProvider) PrintReleasePreview(targetEnvName string, releaseName string, existingTargetFile, promotedFile *yml.File) error

func (*InteractivePromptProvider) PrintSelectedNonPromotableReleases added in v0.31.2

func (i *InteractivePromptProvider) PrintSelectedNonPromotableReleases(invalidReleases, targetEnvName string)

func (*InteractivePromptProvider) PrintSelectedReleasesAlreadyInSync

func (i *InteractivePromptProvider) PrintSelectedReleasesAlreadyInSync()

func (*InteractivePromptProvider) PrintStartPreview

func (i *InteractivePromptProvider) PrintStartPreview()

func (*InteractivePromptProvider) PrintUpdatingTargetRelease

func (i *InteractivePromptProvider) PrintUpdatingTargetRelease(targetEnvName, releaseName, releaseFilePath string, isCreating bool)

func (*InteractivePromptProvider) SelectCreatingPromotionPullRequest added in v0.26.0

func (i *InteractivePromptProvider) SelectCreatingPromotionPullRequest() (string, error)

func (*InteractivePromptProvider) SelectReleases

func (i *InteractivePromptProvider) SelectReleases(list cross.ReleaseList, maxColumnWidth int) (cross.ReleaseList, error)

func (*InteractivePromptProvider) SelectSourceEnvironment

func (i *InteractivePromptProvider) SelectSourceEnvironment(environments []*v1alpha1.Environment) (*v1alpha1.Environment, error)

func (*InteractivePromptProvider) SelectTargetEnvironment

func (i *InteractivePromptProvider) SelectTargetEnvironment(environments []*v1alpha1.Environment) (*v1alpha1.Environment, error)

type Opts

type Opts struct {
	// Catalog contains candidate environments and releases to promote.
	Catalog *catalog.Catalog

	// SourceEnv is the source environment to promote from.
	SourceEnv *v1alpha1.Environment

	// TargetEnv is the target environment to promote to.
	TargetEnv *v1alpha1.Environment

	// Releases are the already selected releases.
	// If there is more than one, no need to prompt the user to select releases.
	Releases []string

	ReleasesFiltered bool

	// NoPrompt means that the Promote function should avoid interactive prompts at all costs.
	NoPrompt bool

	// AutoMerge indicates if PR created needs the auto-merge label
	AutoMerge bool

	// Draft indicates if PR created needs to be draft
	Draft bool

	// SelectedEnvironments is the list of environments selected by the user interactively via `joy env select`.
	SelectedEnvironments []*v1alpha1.Environment

	// DryRun indicates if the promotion should be performed in dry-run mode
	DryRun bool

	// LocalOnly indicates if the promotion should only write the promotion changes to the working tree without creating a branch, commit or pull request.
	LocalOnly bool

	MaxColumnWidth int
}

type PerformOpts added in v0.31.4

type PerformOpts struct {
	// contains filtered or unexported fields
}

type Promotion

type Promotion struct {
	PromptProvider      PromptProvider
	GitProvider         GitProvider
	PullRequestProvider pr.PullRequestProvider
	YamlWriter          yml.Writer
	CommitTemplate      string
	PullRequestTemplate string
	InfoProvider        info.Provider
	LinksProvider       links.Provider
}

func (*Promotion) Promote

func (p *Promotion) Promote(opts Opts) (string, error)

Promote prompts user to select source and target environments and releases to promote and creates a pull request, returning its URL if any.

type PromotionInfo added in v0.31.4

type PromotionInfo struct {
	SourceEnvironment *v1alpha1.Environment
	TargetEnvironment *v1alpha1.Environment
	Releases          []*ReleaseInfo
	Error             error
}

type PromptProvider

type PromptProvider interface {
	// SelectSourceEnvironment prompts user to select source environment to promote from.
	SelectSourceEnvironment(environments []*v1alpha1.Environment) (*v1alpha1.Environment, error)

	// SelectTargetEnvironment prompts user to select target environment to promote to.
	SelectTargetEnvironment(environments []*v1alpha1.Environment) (*v1alpha1.Environment, error)

	// SelectReleases prompts user to select releases to promote.
	SelectReleases(list cross.ReleaseList, maxColumnWidth int) (cross.ReleaseList, error)

	// ConfirmCreatingPromotionPullRequest prompts user to confirm whether to continue creating promotion pull request
	// or abort.
	ConfirmCreatingPromotionPullRequest(autoMerge, draft bool) (bool, error)

	// SelectCreatingPromotionPullRequest prompts user to select state of promotion PR
	// or abort.
	SelectCreatingPromotionPullRequest() (string, error)

	// ConfirmAutoMergePullRequest prompts user to confirm whether to auto-merge promotion PR or not
	ConfirmAutoMergePullRequest() (bool, error)

	// PrintNoPromotableReleasesFound prints message that no promotable releases were found for given
	// source and target environments or potentially none because release filtering was applied.
	PrintNoPromotableReleasesFound(releasesFiltered bool, sourceEnv *v1alpha1.Environment, targetEnv *v1alpha1.Environment)

	// PrintNoPromotableEnvironmentFound prints message that no promotable environments were found
	// or potentially none because environment filtering was applied.
	PrintNoPromotableEnvironmentFound(environmentsFiltered bool)

	// PrintStartPreview starts the preview of release promotion diffs.
	PrintStartPreview()

	// PrintReleasePreview prints the diff for promotion of a given release.
	PrintReleasePreview(targetEnvName string, releaseName string, existingTargetFile, promotedFile *yml.File) error

	// PrintEndPreview ends the preview of release promotion diffs.
	PrintEndPreview()

	// PrintUpdatingTargetRelease prints message that target release file is being updated or created.
	PrintUpdatingTargetRelease(targetEnvName, releaseName, releaseFilePath string, isCreating bool)

	// PrintBranchCreated prints message that a new promotion branch was created and promotion changes were committed
	// and pushed.
	PrintBranchCreated(branchName, message string)

	// PrintDraftPullRequestCreated prints message that a new promotion draft pull request was created.
	PrintDraftPullRequestCreated(url string)

	// PrintPullRequestCreated prints message that a new promotion pull request was created.
	PrintPullRequestCreated(url string)

	// PrintCanceled prints message that promotion was canceled and no pull request was created.
	PrintCanceled()

	// PrintCompleted prints message that the whole promotion operation was completed.
	PrintCompleted()

	// PrintSelectedNonPromotableReleases prints message that non-promotable releases were selected.
	PrintSelectedNonPromotableReleases(invalidReleases, targetEnvName string)
}

type ReleaseInfo added in v0.31.4

type ReleaseInfo struct {
	Name         string
	Project      *v1alpha1.Project
	CodeOwners   []string
	Repository   string
	Source       EnvironmentReleaseInfo
	Target       EnvironmentReleaseInfo
	OlderGitTag  string
	NewerGitTag  string
	IsPrerelease bool
	ChangeType   ChangeType
	Commits      []*CommitInfo
	Error        error
}

type ShellGitProvider

type ShellGitProvider struct {
	// contains filtered or unexported fields
}

func NewShellGitProvider

func NewShellGitProvider(dir string) *ShellGitProvider

func (*ShellGitProvider) CheckoutMasterBranch

func (g *ShellGitProvider) CheckoutMasterBranch() error

func (*ShellGitProvider) CreateAndPushBranchWithFiles

func (g *ShellGitProvider) CreateAndPushBranchWithFiles(branchName string, files []string, message string) error

Jump to

Keyboard shortcuts

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