gitlab

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseID

func ParseID(id interface{}) (string, error)

Helper function to accept and format both the project ID or name as project identifier for all API calls.

Types

type Client

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

Client is a wrapper around the GitLab specific implementation of scm.Client interface

func NewClient

func NewClient(ctx context.Context) (*Client, error)

NewClient creates a new GitLab client

func (*Client) ApplyStep added in v0.3.0

func (c *Client) ApplyStep(ctx context.Context, evalContext scm.EvalContext, update *scm.UpdateMergeRequestOptions, step scm.EvaluationActionStep) error

func (*Client) EvalContext

func (client *Client) EvalContext(ctx context.Context) (scm.EvalContext, error)

EvalContext creates a new evaluation context for GitLab specific usage

func (*Client) FindMergeRequestsForPeriodicEvaluation added in v0.12.0

func (client *Client) FindMergeRequestsForPeriodicEvaluation(ctx context.Context, filters scm.MergeRequestListFilters) ([]scm.PeriodicEvaluationMergeRequest, error)

FindMergeRequestsForPeriodicEvaluation will find all Merge Requests legible for periodic re-evaluation.

func (*Client) Labels

func (client *Client) Labels() scm.LabelClient

Labels returns a client target at managing labels/tags

func (*Client) MergeRequests

func (client *Client) MergeRequests() scm.MergeRequestClient

MergeRequests returns a client target at managing merge/pull requests

func (*Client) Start added in v0.7.0

func (client *Client) Start(ctx context.Context) error

Start pipeline

func (*Client) Stop added in v0.7.0

func (client *Client) Stop(ctx context.Context, err error) error

Stop pipeline

type LabelClient

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

func NewLabelClient

func NewLabelClient(client *Client) *LabelClient

func (*LabelClient) Create

func (client *LabelClient) Create(ctx context.Context, opt *scm.CreateLabelOptions) (*scm.Label, *scm.Response, error)

func (*LabelClient) List

func (client *LabelClient) List(ctx context.Context) ([]*scm.Label, error)

func (*LabelClient) Update

func (client *LabelClient) Update(ctx context.Context, opt *scm.UpdateLabelOptions) (*scm.Label, *scm.Response, error)

type MergeRequestClient

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

func NewMergeRequestClient

func NewMergeRequestClient(client *Client) *MergeRequestClient

func (*MergeRequestClient) GetRemoteConfig added in v0.4.0

func (client *MergeRequestClient) GetRemoteConfig(ctx context.Context, filename, ref string) (io.Reader, error)

func (*MergeRequestClient) List added in v0.3.0

func (*MergeRequestClient) Update

type PeriodicEvaluationBlobNode added in v0.12.0

type PeriodicEvaluationBlobNode struct {
	Blob string `graphql:"rawBlob"`
}

type PeriodicEvaluationMergeRequestNode added in v0.12.0

type PeriodicEvaluationMergeRequestNode struct {
	IID string `graphql:"iid"`
	SHA string `graphql:"diffHeadSha"`
}

type PeriodicEvaluationProjectNode added in v0.12.0

type PeriodicEvaluationProjectNode struct {
	// FullPath is the complete group + project slug / project identifier for a Project in GitLab
	FullPath string `graphql:"fullPath"`

	// MergeRequests contains up to 100 merge requests, sorted by oldest update/last change first
	MergeRequests graphqlNodesOf[PeriodicEvaluationMergeRequestNode] `graphql:"mergeRequests(first: 100, state: opened, not: {labels: $mr_ignore_labels}, sort: UPDATED_ASC)"`

	// Repository contains information about the git repository
	Repository PeriodicEvaluationRepository `graphql:"repository"`
}

type PeriodicEvaluationRepository added in v0.12.0

type PeriodicEvaluationRepository struct {
	// Blobs contains a single (optional) node with the content of the ".scm-config.yml" file
	// read from the projects default branch at the time of reading
	Blobs graphqlNodesOf[PeriodicEvaluationBlobNode] `graphql:"blobs(paths: [$scm_config_file_path])"`
}

type PeriodicEvaluationResult added in v0.12.0

type PeriodicEvaluationResult struct {
	// Projects contains first 100 projects that matches the filtering conditions
	Projects graphqlNodesOf[PeriodicEvaluationProjectNode] `graphql:"projects(first: 100, membership: $project_membership, withMergeRequestsEnabled: true, topics: $project_topics)"`
}

PeriodicEvaluationResult structs maps to the GraphQL query used to find Merge Requests that should be periodically evaluated.

It roughly matches this GraphQL query (via Go structs and field tags)

query($project_topics: [String!], $config_file: String! = ".scm-engine.yml", $project_membership: Boolean, $mr_ignore_labels: [String!]) {
  projects(first: 100, membership: $project_membership, withMergeRequestsEnabled: true, topics: $project_topics) {
    nodes {
      fullPath
      repository {
        blobs(paths: $config_file) {
          nodes {
            rawBlob
          }
        }
      }
      mergeRequests(first: 100, state: opened, not: {labels: $mr_ignore_labels}, sort: UPDATED_ASC) {
        nodes {
          iid
          diffHeadSha
        }
      }
    }
  }
}

Jump to

Keyboard shortcuts

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