Documentation
¶
Index ¶
- Variables
- type CleanupContext
- type CleanupService
- type Color
- type CommitOptions
- type GitRepository
- type GitRepositoryStore
- type GitURL
- type Label
- type LabelSet
- type LabelStore
- type Path
- type Permissions
- type PullRequest
- func (pr *PullRequest) AttachLabels(labels LabelSet) error
- func (pr *PullRequest) ChangeDescription(title, body string) error
- func (pr *PullRequest) GetBody() string
- func (pr *PullRequest) GetLabels() LabelSet
- func (pr *PullRequest) GetNumber() *PullRequestNumber
- func (pr *PullRequest) GetTitle() string
- func (pr *PullRequest) SetNumber(nr *PullRequestNumber) error
- type PullRequestNumber
- type PullRequestStore
- type PushOptions
- type RenderContext
- type RenderResult
- type RenderService
- type RenderServiceInstrumentation
- type RenderServiceInstrumentationFactory
- type Template
- type TemplateEngine
- type TemplateStore
- type ValueStore
- type Values
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidArgument = errors.New("invalid argument")
ErrInvalidArgument is an error that indicates that a particular field is invalid.
var ErrKeyNotFound = errors.New("key not found")
ErrKeyNotFound is an error that indicates that a particular key was not found.
Functions ¶
This section is empty.
Types ¶
type CleanupContext ¶
type CleanupContext struct {
Repository *GitRepository
ValueStore ValueStore
// contains filtered or unexported fields
}
type CleanupService ¶
type CleanupService struct{}
func NewCleanupService ¶
func NewCleanupService() *CleanupService
func (*CleanupService) CleanupUnwantedFiles ¶
func (s *CleanupService) CleanupUnwantedFiles(ctx CleanupContext) error
type Color ¶
type Color string
Color is a 6-digit uppercase hexadecimal string value with '#' prefix
func (Color) CheckValue ¶
type CommitOptions ¶
type GitRepository ¶
type GitRepository struct {
RootDir Path
URL *GitURL
PullRequest *PullRequest
Labels LabelSet
CommitBranch string
DefaultBranch string
}
func NewGitRepository ¶
func NewGitRepository(u *GitURL, root Path) *GitRepository
func (*GitRepository) SetLabels ¶
func (r *GitRepository) SetLabels(labels LabelSet) error
type GitRepositoryStore ¶
type GitRepositoryStore interface {
FetchGitRepositories() ([]*GitRepository, error)
Clone(repository *GitRepository) error
Checkout(repository *GitRepository) error
Fetch(repository *GitRepository) error
Reset(repository *GitRepository) error
Pull(repository *GitRepository) error
Add(repository *GitRepository) error
Commit(repository *GitRepository, options CommitOptions) error
Diff(repository *GitRepository) (string, error)
Push(repository *GitRepository, options PushOptions) error
}
type GitURL ¶
GitURL is the same as url.URL but with additional helper methods.
func (*GitURL) GetFullName ¶
GetFullName returns the hostname (or host:port) joined by GetNamespace and GetRepositoryName delimited by slashes.
func (*GitURL) GetNamespace ¶
GetNamespace returns the middle element(s) of the Git URL. Depending on the Git hosting service, this name may contain multiple slashes. Any leading "/" is removed.
func (*GitURL) GetRepositoryName ¶
GetRepositoryName returns the last element of the Git URL. Strips the name from any .git extensions in the URL.
type Label ¶
type LabelSet ¶
type LabelSet []Label
func (LabelSet) CheckForDuplicates ¶
func (LabelSet) CheckForEmptyLabelNames ¶
func (LabelSet) Merge ¶
Merge returns a new copy of LabelSet that contains the Label from other if they are missing in the original slice, and replaces existing ones. A label to replace is determined by equality of LabelSet.FindLabelByName.
No validation checks are performed. The original order is not preserved. Duplicates are removed from the result.
type LabelStore ¶
type Path ¶
type Path string
func NewFilePath ¶
func (Path) Delete ¶
func (p Path) Delete()
Delete removes the path (and possibly all children if it's a directory), ignoring any errors. If you need error handling, use os.RemoveAll directly.
func (Path) DirExists ¶
DirExists returns true if the path exists in the local file system and is a directory.
func (Path) FileExists ¶
FileExists returns true if the path exists in the local file system and is a file.
type Permissions ¶
func (Permissions) FileMode ¶
func (p Permissions) FileMode() fs.FileMode
type PullRequest ¶
type PullRequest struct {
CommitBranch string
BaseBranch string
// contains filtered or unexported fields
}
func NewPullRequest ¶
func NewPullRequest( number *PullRequestNumber, title, body, commitBranch, baseBranch string, labels LabelSet, ) (*PullRequest, error)
func (*PullRequest) AttachLabels ¶
func (pr *PullRequest) AttachLabels(labels LabelSet) error
func (*PullRequest) ChangeDescription ¶
func (pr *PullRequest) ChangeDescription(title, body string) error
func (*PullRequest) GetBody ¶
func (pr *PullRequest) GetBody() string
func (*PullRequest) GetLabels ¶
func (pr *PullRequest) GetLabels() LabelSet
func (*PullRequest) GetNumber ¶
func (pr *PullRequest) GetNumber() *PullRequestNumber
func (*PullRequest) GetTitle ¶
func (pr *PullRequest) GetTitle() string
func (*PullRequest) SetNumber ¶
func (pr *PullRequest) SetNumber(nr *PullRequestNumber) error
type PullRequestNumber ¶
type PullRequestNumber int
func NewPullRequestNumber ¶
func NewPullRequestNumber(nr *int) *PullRequestNumber
func (*PullRequestNumber) Int ¶
func (nr *PullRequestNumber) Int() *int
func (PullRequestNumber) String ¶
func (nr PullRequestNumber) String() string
type PullRequestStore ¶
type PullRequestStore interface {
// FindMatchingPullRequest returns the PullRequest that has the same branch as GitRepository.CommitBranch.
// If not found, it returns nil without error.
FindMatchingPullRequest(repository *GitRepository) (*PullRequest, error)
// EnsurePullRequest creates or updates the GitRepository.PullRequest in the repository.
// * This operation does not alter any properties of existing labels.
// * Existing labels are left untouched, but any extraneous labels are removed.
// * Title and Body are updated.
// * Existing Commit and Base branches are left untouched.
//
// The first error encountered aborts the operation.
EnsurePullRequest(repository *GitRepository) error
}
type PushOptions ¶
type PushOptions struct {
Force bool
}
type RenderContext ¶
type RenderContext struct {
Repository *GitRepository
ValueStore ValueStore
TemplateStore TemplateStore
Engine TemplateEngine
// contains filtered or unexported fields
}
type RenderResult ¶
type RenderResult string
func (RenderResult) WriteToFile ¶
func (r RenderResult) WriteToFile(path Path, permissions Permissions) error
type RenderService ¶
type RenderService struct {
// contains filtered or unexported fields
}
func NewRenderService ¶
func NewRenderService(analyticsFactory RenderServiceInstrumentationFactory) *RenderService
func (*RenderService) RenderTemplates ¶
func (s *RenderService) RenderTemplates(ctx RenderContext) error
type RenderServiceInstrumentation ¶
type RenderServiceInstrumentation interface {
// FetchedTemplatesFromStore logs a message indicating that fetching templates from TemplateStore was successful, but only if fetchErr is nil.
// Returns fetchErr unmodified for method chaining.
FetchedTemplatesFromStore(fetchErr error) error
// FetchedValuesForTemplate logs a message indicating that fetching Values from ValueStore was successful but only if fetchErr is nil.
// Returns fetchErr unmodified for method chaining.
FetchedValuesForTemplate(fetchErr error, template *Template) error
// AttemptingToRenderTemplate logs a message indicating that the actual rendering is about to begin.
AttemptingToRenderTemplate(template *Template)
WrittenRenderResultToFile(template *Template, targetPath Path, writeErr error) error
}
type RenderServiceInstrumentationFactory ¶
type RenderServiceInstrumentationFactory interface {
// NewRenderServiceInstrumentation creates a new RenderServiceInstrumentation instance using the given GitRepository as context.
NewRenderServiceInstrumentation(repository *GitRepository) RenderServiceInstrumentation
}
type Template ¶
type Template struct {
RelativePath Path
FilePermissions Permissions
}
func NewTemplate ¶
func NewTemplate(relPath Path, perms Permissions) *Template
func (*Template) Render ¶
func (t *Template) Render(values Values, engine TemplateEngine) (RenderResult, error)
type TemplateEngine ¶
type TemplateEngine interface {
Execute(template *Template, values Values) (RenderResult, error)
}
type TemplateStore ¶
type ValueStore ¶
type ValueStore interface {
// FetchValuesForTemplate retrieves the Values for the given template.
FetchValuesForTemplate(template *Template, repository *GitRepository) (Values, error)
// FetchUnmanagedFlag returns true if the given template should not be rendered.
// The implementation may return ErrKeyNotFound if the flag is undefined, as the boolean 'false' is ambiguous.
FetchUnmanagedFlag(template *Template, repository *GitRepository) (bool, error)
// FetchTargetPath returns an alternative output path for the given template relative to the Git repository.
// An empty string indicates that there is no alternative path configured.
FetchTargetPath(template *Template, repository *GitRepository) (Path, error)
// FetchFilesToDelete returns a slice of Path that should be deleted in the Git repository.
// The paths are relative to the Git root directory.
FetchFilesToDelete(repository *GitRepository) ([]Path, error)
}
Source Files
¶
- cleanup_service.go
- color.go
- errors.go
- gitrepository.go
- gitrepository_store.go
- label.go
- label_store.go
- labelset.go
- path.go
- pullrequest.go
- pullrequest_store.go
- pullrequestnumber.go
- render_service.go
- render_service_analytics.go
- renderresult.go
- template.go
- template_engine.go
- template_store.go
- url.go
- value_store.go
- values.go