gitlab

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package gitlab provides GitLab API client for MR integration

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindTerraCIComment

func FindTerraCIComment(notes []*gitlab.Note) *gitlab.Note

FindTerraCIComment finds an existing terraci comment in the GitLab notes

Types

type Client

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

Client wraps the official GitLab client

func NewClient

func NewClient(baseURL, token string) *Client

NewClient creates a new GitLab API client

func NewClientFromEnv

func NewClientFromEnv() *Client

NewClientFromEnv creates a client from GitLab CI environment variables

func (*Client) AddMRLabels

func (c *Client) AddMRLabels(projectID string, mrIID int64, labels []string) error

AddMRLabels adds labels to an MR

func (*Client) BaseURL

func (c *Client) BaseURL() string

BaseURL returns the GitLab instance base URL

func (*Client) CreateMRNote

func (c *Client) CreateMRNote(projectID string, mrIID int64, body string) (*gitlab.Note, error)

CreateMRNote creates a new note on an MR

func (*Client) GetMRNotes

func (c *Client) GetMRNotes(projectID string, mrIID int64) ([]*gitlab.Note, error)

GetMRNotes retrieves all notes for an MR

func (*Client) HasToken

func (c *Client) HasToken() bool

HasToken returns true if a token is configured

func (*Client) UpdateMRNote

func (c *Client) UpdateMRNote(projectID string, mrIID, noteID int64, body string) (*gitlab.Note, error)

UpdateMRNote updates an existing note on an MR

type MRContext

type MRContext struct {
	ProjectID    string
	ProjectPath  string
	MRIID        int64
	SourceBranch string
	TargetBranch string
	PipelineID   string
	JobID        string
	CommitSHA    string
	InMR         bool
}

MRContext contains information about the current MR context

func DetectMRContext

func DetectMRContext() *MRContext

DetectMRContext detects if we're running in a GitLab MR pipeline

type MRService

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

MRService handles MR-related operations

func NewMRService

func NewMRService(cfg *config.MRConfig, client *Client, ctx *MRContext) *MRService

NewMRService creates a new MR service with injected dependencies.

func NewMRServiceFromEnv added in v0.6.5

func NewMRServiceFromEnv(cfg *config.MRConfig) *MRService

NewMRServiceFromEnv creates a new MR service with dependencies from environment.

func (*MRService) IsEnabled

func (s *MRService) IsEnabled() bool

IsEnabled returns true if MR integration is enabled

func (*MRService) UpsertComment

func (s *MRService) UpsertComment(plans []ci.ModulePlan, policySummary *ci.PolicySummary) error

UpsertComment creates or updates the terraci comment on the MR

Jump to

Keyboard shortcuts

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