promote

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 29 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 GetCodeOwners added in v0.32.0

func GetCodeOwners(dir string) ([]string, error)

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 CommitMetadata added in v0.31.4

type CommitMetadata struct {
	Sha     string
	Author  string
	Message string
}

func GetCommitsMetadata added in v0.31.4

func GetCommitsMetadata(dir, from, to string) ([]*CommitMetadata, error)

type FileSystemYamlWriter

type FileSystemYamlWriter struct{}

func (*FileSystemYamlWriter) Write

func (w *FileSystemYamlWriter) Write(file *yml.File) error

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) (*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
}

type PerformOpts added in v0.31.4

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

type Promotion

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

func NewDefaultPromotion

func NewDefaultPromotion(catalogDir, gitHubOrganization, commitTemplate, pullRequestTemplate, repositoriesDir, joyCache, defaultGitTagTemplate string) *Promotion

func NewPromotion

func NewPromotion(prompt PromptProvider, gitProvider GitProvider, pullRequestProvider pr.PullRequestProvider, yamlWriter YamlWriter, commitTemplate string, pullRequestTemplate string, getProjectRepositoryFunc func(proj *v1alpha1.Project) string, getProjectSourceDirFunc func(proj *v1alpha1.Project) (string, error), getCommitsMetadataFunc func(projectDir string, from string, to string) ([]*CommitMetadata, error), getCommitsGitHubAuthorsFunc func(proj *v1alpha1.Project, fromTag string, toTag string) (map[string]string, error), getReleaseGitTagFunc func(release *v1alpha1.Release) (string, error), getCodeOwnersFunc func(projectDir string) ([]string, error)) *Promotion

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) (*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       ReleaseWithGitTag
	Target       ReleaseWithGitTag
	OlderGitTag  string
	NewerGitTag  string
	IsPrerelease bool
	// IsUpgrade is now deprecated and kept only temporarily while we transition to ChangeType
	IsUpgrade  bool
	ChangeType ChangeType
	Commits    []*CommitInfo
	Error      error
}

type ReleaseWithGitTag added in v0.31.4

type ReleaseWithGitTag struct {
	*v1alpha1.Release
	DisplayVersion string
	GitTag         string
}

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

type YamlWriter

type YamlWriter interface {
	Write(file *yml.File) error
}

Jump to

Keyboard shortcuts

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