mr

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

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 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 Context

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

Context contains information about the current MR context.

func DetectContext

func DetectContext() *Context

DetectContext detects if we're running in a GitLab MR pipeline.

type Service

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

Service handles MR-related comment operations.

func NewService

func NewService(cfg *configpkg.MRConfig, client noteClient, ctx *Context) *Service

NewService creates a new MR service with injected dependencies.

func NewServiceFromEnv

func NewServiceFromEnv(cfg *configpkg.MRConfig) *Service

NewServiceFromEnv creates a new MR service with dependencies from environment.

func (*Service) IsEnabled

func (s *Service) IsEnabled() bool

IsEnabled returns true if MR integration is enabled.

func (*Service) UpsertComment

func (s *Service) UpsertComment(_ context.Context, body string) 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