Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommitInput ¶
type CommitInput struct { Repo string // e.g. my-org/my-repo Filename string // relative path to the file in the repository Branch string // e.g. main NewBranchName string // e.g. feature-update-image BranchGenerateName string // e.g. update-image- CommitMessage string // This is used for the commit when updating the file }
CommitInput is used to configure the commit and pull request.
type ContentUpdater ¶
ContentUpdater takes an existing body, it should transform it, and return the updated body.
func ReplaceContents ¶
func ReplaceContents(b []byte) ContentUpdater
ReplaceContents is a ContentUpdater that replaces the content of file with the provided body.
func UpdateYAML ¶
func UpdateYAML(key string, newValue interface{}) ContentUpdater
UpdateYAML is a ContentUpdater that updates a YAML file using a key and new value, they key can be a dotted path.
UpdateYAML("test.value", []string{"test", "value"})
type GitUpdater ¶
type GitUpdater interface { ApplyUpdateToFile(ctx context.Context, input CommitInput, f ContentUpdater) (string, error) CreatePR(ctx context.Context, input PullRequestInput) (*scm.PullRequest, error) }
GitUpdater defines the way to apply changes to files in Git.
type PullRequestInput ¶
type PullRequestInput struct { SourceBranch string // e.g. 'main' NewBranch string Repo string // e.g. my-org/my-repo Title string Body string }
PullRequestInput provides configuration for the PullRequest to be opened.
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater can update a Git repo with an updated version of a file.
func (*Updater) ApplyUpdateToFile ¶
func (u *Updater) ApplyUpdateToFile(ctx context.Context, input CommitInput, f ContentUpdater) (string, error)
ApplyUpdateToFile does the job of fetching the existing file, passing it to a user-provided function, and optionally creating a PR.
func (*Updater) CreatePR ¶
func (u *Updater) CreatePR(ctx context.Context, input PullRequestInput) (*scm.PullRequest, error)
type UpdaterFunc ¶
type UpdaterFunc func(u *Updater)
UpdaterFunc is an option for for creating new Updaters.
func NameGenerator ¶
func NameGenerator(g names.Generator) UpdaterFunc
NameGenerator is an option func for the Updater creation function.