Documentation
¶
Index ¶
- func IsForbidden(err error) bool
- func IsNotFound(err error) bool
- type APIError
- type Client
- func (c *Client) CreatePipelineSchedule(description, ref, cron, cronTimezone string, active bool) (*PipelineSchedule, error)
- func (c *Client) CreatePipelineScheduleVariable(scheduleID int, key, value, variableType string) error
- func (c *Client) DeletePipelineSchedule(scheduleID int) error
- func (c *Client) DeletePipelineScheduleVariable(scheduleID int, key string) error
- func (c *Client) DeleteRunner(runnerID int) error
- func (c *Client) GetPipelineSchedule(scheduleID int) (*PipelineSchedule, error)
- func (c *Client) GetRunnerDetails(runnerID int) (*RunnerDetails, error)
- func (c *Client) GetRunnerJobExecutionStatus(runnerID int) (string, error)
- func (c *Client) GetRunnerJobs(runnerID int, status string, limit int) ([]Job, error)
- func (c *Client) ListJobs(w io.Writer, start time.Time) ([]Job, error)
- func (c *Client) ListPipelineSchedules() ([]PipelineSchedule, error)
- func (c *Client) ListProjectJobsForRunner(runnerID, limit int) ([]Job, error)
- func (c *Client) ListProjectRunningJobs() ([]Job, error)
- func (c *Client) ListRunners(tagFilters string, typeFilters string) ([]Runner, error)
- func (c *Client) PauseRunner(runnerID int) error
- func (c *Client) TakeOwnershipPipelineSchedule(scheduleID int) (*PipelineSchedule, error)
- func (c *Client) UnpauseRunner(runnerID int) error
- func (c *Client) UpdatePipelineSchedule(scheduleID int, description, ref, cron, cronTimezone string, active bool) error
- func (c *Client) UpdatePipelineScheduleVariable(scheduleID int, key, value, variableType string) error
- type Job
- type PipelineSchedule
- type PipelineScheduleVariable
- type Runner
- type RunnerDetails
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsForbidden ¶
IsForbidden reports whether the error is a GitLab 403 response.
func IsNotFound ¶
IsNotFound reports whether the error is a GitLab 404 response.
Types ¶
type APIError ¶
APIError is returned for GitLab API responses with a non-success status code, so callers can distinguish e.g. 403 (missing permission) from 404 (not found) and act on it.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a GitLab API client
func (*Client) CreatePipelineSchedule ¶
func (c *Client) CreatePipelineSchedule(description, ref, cron, cronTimezone string, active bool) (*PipelineSchedule, error)
CreatePipelineSchedule creates a new pipeline schedule owned by the token's user. Requires the Developer role and access to the (possibly protected) ref.
func (*Client) CreatePipelineScheduleVariable ¶
func (c *Client) CreatePipelineScheduleVariable(scheduleID int, key, value, variableType string) error
CreatePipelineScheduleVariable creates a new variable on a pipeline schedule. GitLab authorizes this with update_pipeline_schedule, which only the schedule owner (or an instance administrator) holds, so this fails with 403 for schedules owned by other users. Ownership is never changed by this call.
func (*Client) DeletePipelineSchedule ¶
DeletePipelineSchedule deletes a pipeline schedule. Unlike updates this only requires the Maintainer role, not schedule ownership.
func (*Client) DeletePipelineScheduleVariable ¶
DeletePipelineScheduleVariable deletes a variable from a pipeline schedule. Like DeletePipelineSchedule this only requires the Maintainer role, not schedule ownership.
func (*Client) DeleteRunner ¶
DeleteRunner deletes a runner by ID from the GitLab instance. Note: This requires admin or owner permissions for the runner.
func (*Client) GetPipelineSchedule ¶
func (c *Client) GetPipelineSchedule(scheduleID int) (*PipelineSchedule, error)
GetPipelineSchedule retrieves a single pipeline schedule including its variables. Reading the variables of a schedule owned by another user works with the Maintainer role or above and does not require taking ownership; for callers below Maintainer that do not own the schedule, GitLab omits the variables field and Variables is nil.
func (*Client) GetRunnerDetails ¶
func (c *Client) GetRunnerDetails(runnerID int) (*RunnerDetails, error)
GetRunnerDetails fetches detailed information about a specific runner by ID. This endpoint is runner-scoped: for group runners it requires the Owner role on the owning namespace, so a project Maintainer receives a 403. Callers that only have Maintainer access should treat failures as non-fatal and fall back to the data returned by ListRunners.
func (*Client) GetRunnerJobExecutionStatus ¶
GetRunnerJobExecutionStatus returns the runner's aggregate job execution status ("active" or "idle") via the GraphQL API. Unlike the REST jobs endpoint, this field reflects the runner as a whole and is not scoped to the projects the caller can access, so it reports whether a shared (instance or group) runner is currently busy even for a project Maintainer. The returned value is lowercased; an empty string means the API did not report a status.
func (*Client) GetRunnerJobs ¶
GetRunnerJobs retrieves jobs for a specific runner with optional status filter. status can be "running", "success", "failed", "canceled", or empty for all
func (*Client) ListPipelineSchedules ¶
func (c *Client) ListPipelineSchedules() ([]PipelineSchedule, error)
ListPipelineSchedules retrieves all pipeline schedules of the project. The list endpoint does not include variables; use GetPipelineSchedule for a single schedule with its variables.
func (*Client) ListProjectJobsForRunner ¶
ListProjectJobsForRunner returns up to limit of the project's most recent jobs that ran on the given runner. Unlike GetRunnerJobs it is scoped to the project rather than the runner, so it works for a project Maintainer on shared runners it does not own; the trade-off is that only this project's jobs are visible. The jobs endpoint cannot filter by runner, so the candidate pages are fetched concurrently and scanning is capped to bound the number of API requests on busy projects; fewer than limit jobs may be returned.
func (*Client) ListProjectRunningJobs ¶
ListProjectRunningJobs returns the currently running jobs for the configured project. It is scoped to the project (which the caller can read as a Maintainer or above), so it surfaces jobs running on shared runners the caller does not own, unlike the runner-scoped GetRunnerJobs which requires the runner's group Owner role. Each returned job carries the runner it executes on.
func (*Client) ListRunners ¶
ListRunners retrieves all runners for a gitlab project. all enabled runners for the project are listed.
func (*Client) PauseRunner ¶
PauseRunner pauses a runner by ID.
func (*Client) TakeOwnershipPipelineSchedule ¶
func (c *Client) TakeOwnershipPipelineSchedule(scheduleID int) (*PipelineSchedule, error)
TakeOwnershipPipelineSchedule makes the token's user the owner of the schedule and returns the updated schedule. Requires the Maintainer role. This is one-way: GitLab has no way to assign ownership to another user, so the previous owner can only get the schedule back by taking ownership themselves. From this call on, the schedule runs with the new owner's permissions.
func (*Client) UnpauseRunner ¶
UnpauseRunner unpauses a runner by ID.
func (*Client) UpdatePipelineSchedule ¶
func (c *Client) UpdatePipelineSchedule(scheduleID int, description, ref, cron, cronTimezone string, active bool) error
UpdatePipelineSchedule updates the schedule's fields. Like the variable modification calls it requires the schedule owner's token (or instance admin) and returns 403 otherwise; ownership is never changed by this call.
func (*Client) UpdatePipelineScheduleVariable ¶
func (c *Client) UpdatePipelineScheduleVariable(scheduleID int, key, value, variableType string) error
UpdatePipelineScheduleVariable updates the value of an existing pipeline schedule variable. Like CreatePipelineScheduleVariable it requires the schedule owner's token (or instance admin) and returns 403 otherwise; ownership is never changed by this call. Returns 404 if the variable does not exist on the schedule.
type Job ¶
type Job struct {
ID int `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
Duration float64 `json:"duration"`
Pipeline struct {
ID int `json:"id"`
} `json:"pipeline"`
Branch string `json:"ref"`
URL string `json:"web_url"`
Runner *struct {
ID int `json:"id"`
Description string `json:"description"`
} `json:"runner,omitempty"`
}
Job represents a GitLab CI job
type PipelineSchedule ¶
type PipelineSchedule struct {
ID int `json:"id"`
Description string `json:"description"`
Ref string `json:"ref"`
Cron string `json:"cron"`
CronTimezone string `json:"cron_timezone"`
Active bool `json:"active"`
NextRunAt time.Time `json:"next_run_at"`
Owner struct {
Username string `json:"username"`
Name string `json:"name"`
} `json:"owner"`
Variables []PipelineScheduleVariable `json:"variables"`
}
PipelineSchedule represents a GitLab pipeline schedule. Variables are only populated by GetPipelineSchedule, and only when the caller has the Maintainer role or above (or owns the schedule); GitLab omits the field otherwise, which is reflected here as a nil slice.
type PipelineScheduleVariable ¶
type PipelineScheduleVariable struct {
Key string `json:"key"`
VariableType string `json:"variable_type"`
Value string `json:"value"`
Raw bool `json:"raw"`
}
PipelineScheduleVariable represents a variable of a pipeline schedule.
type Runner ¶
type Runner struct {
ID int `json:"id"`
Description string `json:"description"`
Active bool `json:"active"`
Paused bool `json:"paused"`
RunnerType string `json:"runner_type"`
Name string `json:"name,omitempty"`
Online bool `json:"online"`
Status string `json:"status"`
IPAddress string `json:"ip_address"`
}
Runner represents a GitLab CI runner
type RunnerDetails ¶
type RunnerDetails struct {
Active bool `json:"active"`
Paused bool `json:"paused"`
Architecture string `json:"architecture,omitempty"`
Description string `json:"description"`
ID int `json:"id"`
IPAddress string `json:"ip_address"`
RunnerType string `json:"runner_type"`
ContactedAt time.Time `json:"contacted_at"`
MaintenanceNote string `json:"maintenance_note,omitempty"`
Name string `json:"name,omitempty"`
Online bool `json:"online"`
Status string `json:"status"`
Platform string `json:"platform,omitempty"`
Projects []struct {
ID int `json:"id"`
Name string `json:"name"`
NameWithNamespace string `json:"name_with_namespace"`
Path string `json:"path"`
PathWithNamespace string `json:"path_with_namespace"`
} `json:"projects"`
Revision string `json:"revision,omitempty"`
TagList []string `json:"tag_list"`
Version string `json:"version,omitempty"`
AccessLevel string `json:"access_level"`
MaximumTimeout int `json:"maximum_timeout"`
}
RunnerDetails represents detailed information about a GitLab CI runner.