Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GithubTrigger ¶
type GithubTrigger struct {
// GitHub webhook event, like push. See
// https://docs.github.com/en/webhooks/webhook-events-and-payloads for a list of
// all available events.
Event *string `json:"event,omitempty" yaml:"event,omitempty" mapstructure:"event,omitempty"`
// jq expressions to apply to the body of the webhook. If all expressions match
// the content of the webhook then a new run of the task is scheduled.
Filters []string `json:"filters,omitempty" yaml:"filters,omitempty" mapstructure:"filters,omitempty"`
// Key/value pairs to extract run data from the webhook payload. Key is the key to
// set in the run data and value is a jq expression.
RunData map[string]string `json:"runData,omitempty" yaml:"runData,omitempty" mapstructure:"runData,omitempty"`
}
type GitlabTrigger ¶
type GitlabTrigger struct {
// GitLab webhook event, like push. See
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html for a
// list of all available events.
Event *string `json:"event,omitempty" yaml:"event,omitempty" mapstructure:"event,omitempty"`
// jq expressions to apply to the body of the webhook. If all expressions match
// the content of the webhook then a new run of the task is scheduled.
Filters []string `json:"filters,omitempty" yaml:"filters,omitempty" mapstructure:"filters,omitempty"`
// Key/value pairs to extract run data from the webhook payload. Key is the key to
// set in the run data and value is a jq expression.
RunData map[string]string `json:"runData,omitempty" yaml:"runData,omitempty" mapstructure:"runData,omitempty"`
}
type Input ¶
type Input struct {
// Default value to use if no input has been set via the command-line.
Default *string `json:"default,omitempty" yaml:"default,omitempty" mapstructure:"default,omitempty"`
// Text that describes the input value.
Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
// Key that identifies the input. Set via the command-line to set the input value.
Name string `json:"name" yaml:"name" mapstructure:"name"`
// If not empty, a list of possible values for the input.
Options []string `json:"options,omitempty" yaml:"options,omitempty" mapstructure:"options,omitempty"`
// If not empty, a regular expression that validates the value of the input.
Validation *string `json:"validation,omitempty" yaml:"validation,omitempty" mapstructure:"validation,omitempty"`
}
A input allows customizing a task at runtime.
func (*Input) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type ReadResult ¶
func Read ¶
func Read(path string) ([]ReadResult, error)
Read return all Tasks from the file at `path`. It also calculates the hash of the file.
type RepositoryFilter ¶ added in v0.41.0
type RepositoryFilter struct {
// Match the host of a repository. Can be a regular expression.
Host string `json:"host,omitempty" yaml:"host,omitempty" mapstructure:"host,omitempty"`
// Match the name of a repository. Can be a regular expression.
Name string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"`
// Match the owner of a repository. Can be a regular expression.
Owner string `json:"owner,omitempty" yaml:"owner,omitempty" mapstructure:"owner,omitempty"`
// Reverse the matching condition.
Reverse bool `json:"reverse,omitempty" yaml:"reverse,omitempty" mapstructure:"reverse,omitempty"`
}
func (*RepositoryFilter) UnmarshalJSON ¶ added in v0.41.0
func (j *RepositoryFilter) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*RepositoryFilter) UnmarshalYAML ¶ added in v0.41.0
func (j *RepositoryFilter) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.
type Task ¶
type Task struct {
// Set to `false` to temporarily deactivate the task and prevent it from
// executing.
Active bool `json:"active,omitempty" yaml:"active,omitempty" mapstructure:"active,omitempty"`
// A list of usernames to set as assignees of a pull request.
Assignees []string `json:"assignees,omitempty" yaml:"assignees,omitempty" mapstructure:"assignees,omitempty"`
// Automatically close a pull request if it has been unmerged for the duration.
// Format is seconds. Set to `0`, the default, to deactivate.
AutoCloseAfter int `json:"autoCloseAfter,omitempty" yaml:"autoCloseAfter,omitempty" mapstructure:"autoCloseAfter,omitempty"`
// Merge a pull request automatically if all checks have passed and all approvals
// have been given.
AutoMerge bool `json:"autoMerge,omitempty" yaml:"autoMerge,omitempty" mapstructure:"autoMerge,omitempty"`
// If set, automatically merge the pull request after it has been open for the
// specified amount of time. Only applied if `autoMerge` is `true`. The value is a
// Go duration, like 5m or 1h.
AutoMergeAfter string `json:"autoMergeAfter,omitempty" yaml:"autoMergeAfter,omitempty" mapstructure:"autoMergeAfter,omitempty"`
// Allow auto-merging of pull requests within the given window. Only has an effect
// if `autoMerge=true`.
AutoMergeWindow string `json:"autoMergeWindow,omitempty" yaml:"autoMergeWindow,omitempty" mapstructure:"autoMergeWindow,omitempty"`
// The time zone to use when checking the `autoMergeWindow`. Defaults to the time
// zone of the system if unset.
AutoMergeWindowTimeZone string `` /* 130-byte string literal not displayed */
// If set, used as the name of the branch to commit changes to. Defaults to an
// auto-generated name if not set.
BranchName string `json:"branchName,omitempty" yaml:"branchName,omitempty" mapstructure:"branchName,omitempty"`
// Number of pull requests to create or merge (combined) in one run. Useful to
// reduce strain on a system caused by, for example, many CI/CD jobs created at
// the same time.
ChangeLimit int `json:"changeLimit,omitempty" yaml:"changeLimit,omitempty" mapstructure:"changeLimit,omitempty"`
// The message to use when committing changes. Defaults to `changes by Saturn` if
// not set.
CommitMessage string `json:"commitMessage,omitempty" yaml:"commitMessage,omitempty" mapstructure:"commitMessage,omitempty"`
// Create pull requests only. Don't attempt to update a pull request on a
// subsequent run.
CreateOnly bool `json:"createOnly,omitempty" yaml:"createOnly,omitempty" mapstructure:"createOnly,omitempty"`
// Inputs allows customizing a task at runtime.
Inputs []Input `json:"inputs,omitempty" yaml:"inputs,omitempty" mapstructure:"inputs,omitempty"`
// If `true`, keep the branch after a pull request has been merged.
KeepBranchAfterMerge bool `json:"keepBranchAfterMerge,omitempty" yaml:"keepBranchAfterMerge,omitempty" mapstructure:"keepBranchAfterMerge,omitempty"`
// List of labels to attach to a pull request.
Labels []string `json:"labels,omitempty" yaml:"labels,omitempty" mapstructure:"labels,omitempty"`
// The number of pull requests that can be open at the same time. 0 disables the
// feature.
MaxOpenPRs int `json:"maxOpenPRs,omitempty" yaml:"maxOpenPRs,omitempty" mapstructure:"maxOpenPRs,omitempty"`
// If `true`, no new pull request is being created if a previous pull request has
// been merged for this task.
MergeOnce bool `json:"mergeOnce,omitempty" yaml:"mergeOnce,omitempty" mapstructure:"mergeOnce,omitempty"`
// Key/value pairs to add as custom labels to the metric
// sb_server_task_run_success. Only available in server mode.
MetricLabels map[string]string `json:"metricLabels,omitempty" yaml:"metricLabels,omitempty" mapstructure:"metricLabels,omitempty"`
// The name of the task. Used as an identifier.
Name string `json:"name" yaml:"name" mapstructure:"name"`
// If set, used as the body of the pull request.
PrBody string `json:"prBody,omitempty" yaml:"prBody,omitempty" mapstructure:"prBody,omitempty"`
// If set, used as the title of the pull request.
PrTitle string `json:"prTitle,omitempty" yaml:"prTitle,omitempty" mapstructure:"prTitle,omitempty"`
// If `true`, push changes directly to the default branch, like "main". If
// `false`, create a pull request to submit changes.
PushToDefaultBranch bool `json:"pushToDefaultBranch,omitempty" yaml:"pushToDefaultBranch,omitempty" mapstructure:"pushToDefaultBranch,omitempty"`
// One or more filters to match repositories.
Repositories []RepositoryFilter `json:"repositories,omitempty" yaml:"repositories,omitempty" mapstructure:"repositories,omitempty"`
// A list of usernames to set as reviewers of the pull request.
Reviewers []string `json:"reviewers,omitempty" yaml:"reviewers,omitempty" mapstructure:"reviewers,omitempty"`
// One or more script statements to modify the content in a repository.
Script []string `json:"script,omitempty" yaml:"script,omitempty" mapstructure:"script,omitempty"`
// Path to the shell to execute the script. Searches $PATH if the value isn't an
// absolute path.
ScriptShell string `json:"scriptShell,omitempty" yaml:"scriptShell,omitempty" mapstructure:"scriptShell,omitempty"`
// Maximum time a script is allowed to run, in Go duration notation. Defaults to
// `1m`.
ScriptTimeout string `json:"scriptTimeout,omitempty" yaml:"scriptTimeout,omitempty" mapstructure:"scriptTimeout,omitempty"`
// Define when the task gets executed. Only relevant in server mode.
Trigger *TaskTrigger `json:"trigger,omitempty" yaml:"trigger,omitempty" mapstructure:"trigger,omitempty"`
}
func (*Task) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type TaskTrigger ¶
type TaskTrigger struct {
// Schedule a new run whenever the content of the task file and, optionally,
// additional files change.
Changes *TaskTriggerChanges `json:"changes,omitempty" yaml:"changes,omitempty" mapstructure:"changes,omitempty"`
// Trigger the task based on a cron schedule.
Cron *string `json:"cron,omitempty" yaml:"cron,omitempty" mapstructure:"cron,omitempty"`
// Execute the task when the server receives a webhook.
Webhook *TaskTriggerWebhook `json:"webhook,omitempty" yaml:"webhook,omitempty" mapstructure:"webhook,omitempty"`
}
Define when the task gets executed. Only relevant in server mode.
type TaskTriggerChanges ¶
type TaskTriggerChanges struct {
// Activate scheduling on changes. Defaults to `false`.
Active bool `json:"active,omitempty" yaml:"active,omitempty" mapstructure:"active,omitempty"`
// List of additional files to consider. If one of the files changes, a new run
// will be scheduled. The path of each file can be a path relative to the task
// file or an absolute path. Supports globbing.
Files []string `json:"files,omitempty" yaml:"files,omitempty" mapstructure:"files,omitempty"`
}
Schedule a new run whenever the content of the task file and, optionally, additional files change.
func (*TaskTriggerChanges) UnmarshalJSON ¶
func (j *TaskTriggerChanges) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*TaskTriggerChanges) UnmarshalYAML ¶
func (j *TaskTriggerChanges) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.
type TaskTriggerWebhook ¶
type TaskTriggerWebhook struct {
// Delay the execution of the task, in seconds, after the webhook has been
// received by the server.
Delay int `json:"delay,omitempty" yaml:"delay,omitempty" mapstructure:"delay,omitempty"`
// Execute the task when the server receives a webhook from GitHub.
Github []GithubTrigger `json:"github,omitempty" yaml:"github,omitempty" mapstructure:"github,omitempty"`
// Execute the task when the server receives a webhook from GitLab.
Gitlab []GitlabTrigger `json:"gitlab,omitempty" yaml:"gitlab,omitempty" mapstructure:"gitlab,omitempty"`
}
Execute the task when the server receives a webhook.
func (*TaskTriggerWebhook) UnmarshalJSON ¶
func (j *TaskTriggerWebhook) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*TaskTriggerWebhook) UnmarshalYAML ¶
func (j *TaskTriggerWebhook) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.