Documentation
¶
Overview ¶
Package gitlab provides utilities for GitLab API operations
Package gitlab provides utilities for GitLab API operations ¶
Package gitlab provides utilities for GitLab API operations ¶
Package gitlab provides utilities for GitLab API operations ¶
Package gitlab provides utilities for GitLab API operations
Index ¶
- Constants
- type BranchInfo
- type BranchManager
- func (bm *BranchManager) BranchExists(ctx context.Context, branchName string) (bool, error)
- func (bm *BranchManager) CreateBranch(ctx context.Context, branchName, ref string) (*BranchInfo, error)
- func (bm *BranchManager) DeleteBranch(ctx context.Context, branchName string) error
- func (bm *BranchManager) FindBranchesByTag(ctx context.Context, tag string) ([]*BranchInfo, error)
- func (bm *BranchManager) GenerateUniqueBranchName(ctx context.Context, prefix, tag string) (string, error)
- func (bm *BranchManager) GetBranch(ctx context.Context, branchName string) (*BranchInfo, error)
- func (bm *BranchManager) GetProtectedBranches(ctx context.Context) ([]*gitlab.ProtectedBranch, error)
- func (bm *BranchManager) ListBranches(ctx context.Context, search string, maxResults int) ([]*BranchInfo, error)
- type Client
- func (c *Client) GetBaseURL() string
- func (c *Client) GetGitLabClient() *gitlab.Client
- func (c *Client) GetProject(projectID interface{}) (*gitlab.Project, error)
- func (c *Client) GetRetryCount() int
- func (c *Client) GetTimeout() time.Duration
- func (c *Client) IsDebugEnabled() bool
- func (c *Client) IsHealthy() error
- func (c *Client) ResolveProjectID(projectIdentifier string) (int, error)
- type ConflictDetector
- type ConflictInfo
- type ConflictingMR
- type FileInfo
- type FileManager
- func (fm *FileManager) DeleteFile(ctx context.Context, filePath, branch, commitMessage string) error
- func (fm *FileManager) FileExists(ctx context.Context, filePath, branch string) (bool, error)
- func (fm *FileManager) GetFile(ctx context.Context, filePath, branch string) (*FileInfo, error)
- func (fm *FileManager) GetFileContent(ctx context.Context, filePath, branch string) (string, error)
- func (fm *FileManager) GetFileHistory(ctx context.Context, filePath, branch string, maxResults int) ([]*gitlab.Commit, error)
- func (fm *FileManager) UpdateFile(ctx context.Context, filePath string, opts *FileUpdateOptions) (*gitlab.FileInfo, error)
- func (fm *FileManager) UpdateFileContent(ctx context.Context, filePath string, opts *FileUpdateOptions) (*gitlab.FileInfo, error)
- func (fm *FileManager) UpdateYAMLTag(ctx context.Context, filePath, newTag, branch string, opts *FileUpdateOptions) (*gitlab.FileInfo, error)
- type FileUpdateOptions
- type ProjectInfo
- type ProjectManager
- func (pm *ProjectManager) GetProjectDefaultBranch(ctx context.Context, projectID int) (string, error)
- func (pm *ProjectManager) GetProjectInfo(ctx context.Context, projectID int) (*ProjectInfo, error)
- func (pm *ProjectManager) ListUserProjects(ctx context.Context, maxResults int) ([]*ProjectInfo, error)
- func (pm *ProjectManager) ResolveProjectIdentifier(ctx context.Context, identifier string) (int, error)
- func (pm *ProjectManager) ResolveProjectPath(ctx context.Context, projectPath string) (int, error)
- func (pm *ProjectManager) SearchProjects(ctx context.Context, query string, maxResults int) ([]*ProjectInfo, error)
- func (pm *ProjectManager) ValidateProjectExists(ctx context.Context, projectID int) (bool, error)
- type SimpleMergeRequestManager
- func (smr *SimpleMergeRequestManager) CreateMergeRequest(ctx context.Context, opts *SimpleMergeRequestOptions) (*gitlab.MergeRequest, error)
- func (smr *SimpleMergeRequestManager) GetMergeRequest(ctx context.Context, mrIID int) (*gitlab.MergeRequest, error)
- func (smr *SimpleMergeRequestManager) ListMergeRequests(ctx context.Context, state string) ([]*gitlab.BasicMergeRequest, error)
- type SimpleMergeRequestOptions
Constants ¶
const ( // Default branch prefixes DefaultBranchPrefix = "feature/" UpdateBranchPrefix = "update-tag/" // Branch name constraints MaxBranchNameLength = 100 MinBranchNameLength = 1 )
const ( // GitLab URLs DefaultGitLabURL = "https://gitlab.com" // API version and endpoints DefaultAPIVersion = "v4" ProjectsEndpoint = "/api/v4/projects" MergeRequestsEndpoint = "/api/v4/projects/%d/merge_requests" // Timeout and retry settings DefaultTimeout = 30 * time.Second MaxRetryAttempts = 3 RetryDelayBase = 1 * time.Second // Rate limiting DefaultRateLimitRPS = 10 MaxConcurrentReqs = 5 // Response size limits MaxResponseSize = 10 * 1024 * 1024 // 10MB )
const ( // Conflict detection constants MaxConflictCheckAttempts = 15 ConflictCheckInterval = 10 * time.Second DefaultWaitTimeout = 15 * time.Minute // MR states for conflict checking StateOpened = "opened" StateMerged = "merged" StateClosed = "closed" )
const ( // DefaultCommitMessage for file updates DefaultCommitMessage = "Update file via go-tag-updater" // MaxFileSize defines maximum file size for processing MaxFileSize = 1024 * 1024 // 1MB // DefaultBranch is the default branch name DefaultBranch = "main" )
const ( // Project resolution constants ProjectsAPIEndpoint = "/api/v4/projects" MaxProjectNameLength = 255 MinProjectIDValue = 1 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BranchInfo ¶
type BranchInfo struct { Name string Protected bool Default bool DevelopersCanPush bool DevelopersCanMerge bool Commit *gitlab.Commit WebURL string }
BranchInfo represents branch information
type BranchManager ¶
type BranchManager struct {
// contains filtered or unexported fields
}
BranchManager handles GitLab branch operations
func NewBranchManager ¶
func NewBranchManager(client *gitlab.Client, projectID interface{}) *BranchManager
NewBranchManager creates a new branch manager
func (*BranchManager) BranchExists ¶
BranchExists checks if a branch exists
func (*BranchManager) CreateBranch ¶
func (bm *BranchManager) CreateBranch(ctx context.Context, branchName, ref string) (*BranchInfo, error)
CreateBranch creates a new branch from a reference
func (*BranchManager) DeleteBranch ¶
func (bm *BranchManager) DeleteBranch(ctx context.Context, branchName string) error
DeleteBranch deletes a branch
func (*BranchManager) FindBranchesByTag ¶
func (bm *BranchManager) FindBranchesByTag(ctx context.Context, tag string) ([]*BranchInfo, error)
FindBranchesByTag finds branches that might be related to a specific tag
func (*BranchManager) GenerateUniqueBranchName ¶
func (bm *BranchManager) GenerateUniqueBranchName(ctx context.Context, prefix, tag string) (string, error)
GenerateUniqueBranchName generates a unique branch name with timestamp
func (*BranchManager) GetBranch ¶
func (bm *BranchManager) GetBranch(ctx context.Context, branchName string) (*BranchInfo, error)
GetBranch retrieves branch information
func (*BranchManager) GetProtectedBranches ¶
func (bm *BranchManager) GetProtectedBranches(ctx context.Context) ([]*gitlab.ProtectedBranch, error)
GetProtectedBranches lists protected branches
func (*BranchManager) ListBranches ¶
func (bm *BranchManager) ListBranches(ctx context.Context, search string, maxResults int) ([]*BranchInfo, error)
ListBranches lists branches with optional search filter
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the GitLab API client with additional functionality
func NewClientWithConfig ¶
func NewClientWithConfig(token, baseURL string, debug bool, timeout time.Duration, retryCount int) (*Client, error)
NewClientWithConfig creates a new GitLab client with custom configuration
func (*Client) GetBaseURL ¶
GetBaseURL returns the base URL of the GitLab instance
func (*Client) GetGitLabClient ¶
GetGitLabClient returns the underlying GitLab client
func (*Client) GetProject ¶
GetProject retrieves project information by ID or path
func (*Client) GetRetryCount ¶
GetRetryCount returns the configured retry count
func (*Client) GetTimeout ¶
GetTimeout returns the configured timeout
func (*Client) IsDebugEnabled ¶
IsDebugEnabled returns true if debug mode is enabled
type ConflictDetector ¶
type ConflictDetector struct {
// contains filtered or unexported fields
}
ConflictDetector handles merge request conflict detection and prevention
func NewConflictDetector ¶
func NewConflictDetector(client *gitlab.Client, projectID interface{}) *ConflictDetector
NewConflictDetector creates a new conflict detector
func (*ConflictDetector) CheckForConflicts ¶
func (cd *ConflictDetector) CheckForConflicts(ctx context.Context, sourceBranch, targetBranch, filePath string) (*ConflictInfo, error)
CheckForConflicts performs comprehensive conflict detection
func (*ConflictDetector) WaitForConflictsToResolve ¶
func (cd *ConflictDetector) WaitForConflictsToResolve(ctx context.Context, conflicts *ConflictInfo, maxWaitTime time.Duration) error
WaitForConflictsToResolve waits for conflicting merge requests to be resolved
type ConflictInfo ¶
type ConflictInfo struct { ConflictingMRs []ConflictingMR TotalConflicts int Recommendation string }
ConflictInfo contains information about conflicting merge requests
type ConflictingMR ¶
type ConflictingMR struct { ID int IID int Title string SourceBranch string TargetBranch string State string WebURL string CreatedAt *time.Time UpdatedAt *time.Time Author string ConflictType string // "same_branch", "same_file", "same_target" }
ConflictingMR represents a merge request that conflicts with our operation
type FileInfo ¶
type FileInfo struct { FilePath string Content string SHA string Size int64 Encoding string Branch string LastCommit *gitlab.Commit }
FileInfo represents file information
type FileManager ¶
type FileManager struct {
// contains filtered or unexported fields
}
FileManager handles repository file operations
func NewFileManager ¶
func NewFileManager(client *gitlab.Client, projectID interface{}) *FileManager
NewFileManager creates a new file manager
func (*FileManager) DeleteFile ¶
func (fm *FileManager) DeleteFile(ctx context.Context, filePath, branch, commitMessage string) error
DeleteFile deletes a file from repository
func (*FileManager) FileExists ¶
FileExists checks if a file exists in the repository
func (*FileManager) GetFileContent ¶
GetFileContent retrieves just the content of a file as a string
func (*FileManager) GetFileHistory ¶
func (fm *FileManager) GetFileHistory(ctx context.Context, filePath, branch string, maxResults int) ([]*gitlab.Commit, error)
GetFileHistory retrieves the commit history for a specific file
func (*FileManager) UpdateFile ¶
func (fm *FileManager) UpdateFile(ctx context.Context, filePath string, opts *FileUpdateOptions) (*gitlab.FileInfo, error)
UpdateFile updates file content in repository
func (*FileManager) UpdateFileContent ¶
func (fm *FileManager) UpdateFileContent(ctx context.Context, filePath string, opts *FileUpdateOptions) (*gitlab.FileInfo, error)
UpdateFileContent updates file content using the existing UpdateFile method
func (*FileManager) UpdateYAMLTag ¶
func (fm *FileManager) UpdateYAMLTag(ctx context.Context, filePath, newTag, branch string, opts *FileUpdateOptions) (*gitlab.FileInfo, error)
UpdateYAMLTag updates a tag value in a YAML file
type FileUpdateOptions ¶
type FileUpdateOptions struct { Branch string Content string CommitMessage string AuthorEmail string AuthorName string StartBranch string }
FileUpdateOptions contains options for file updates
type ProjectInfo ¶
type ProjectInfo struct { ID int Name string Path string PathWithNamespace string WebURL string DefaultBranch string Description string Visibility string CreatedAt string LastActivityAt string ForksCount int StarCount int }
ProjectInfo contains detailed project information
type ProjectManager ¶
type ProjectManager struct {
// contains filtered or unexported fields
}
ProjectManager handles GitLab project operations and resolution
func NewProjectManager ¶
func NewProjectManager(client *gitlab.Client) *ProjectManager
NewProjectManager creates a new project manager
func (*ProjectManager) GetProjectDefaultBranch ¶
func (pm *ProjectManager) GetProjectDefaultBranch(ctx context.Context, projectID int) (string, error)
GetProjectDefaultBranch returns the default branch for a project
func (*ProjectManager) GetProjectInfo ¶
func (pm *ProjectManager) GetProjectInfo(ctx context.Context, projectID int) (*ProjectInfo, error)
GetProjectInfo retrieves detailed project information
func (*ProjectManager) ListUserProjects ¶
func (pm *ProjectManager) ListUserProjects(ctx context.Context, maxResults int) ([]*ProjectInfo, error)
ListUserProjects lists projects accessible to the authenticated user
func (*ProjectManager) ResolveProjectIdentifier ¶
func (pm *ProjectManager) ResolveProjectIdentifier(ctx context.Context, identifier string) (int, error)
ResolveProjectIdentifier resolves project identifier to numeric ID Supports both numeric IDs and human-readable paths (group/subgroup/project)
func (*ProjectManager) ResolveProjectPath ¶
ResolveProjectPath resolves a human-readable project path to numeric ID Handles paths like "group/subgroup/project" or "user/project"
func (*ProjectManager) SearchProjects ¶
func (pm *ProjectManager) SearchProjects(ctx context.Context, query string, maxResults int) ([]*ProjectInfo, error)
SearchProjects searches for projects by name or path
func (*ProjectManager) ValidateProjectExists ¶
ValidateProjectExists checks if a project exists and is accessible
type SimpleMergeRequestManager ¶
type SimpleMergeRequestManager struct {
// contains filtered or unexported fields
}
SimpleMergeRequestManager handles basic GitLab merge request operations
func NewSimpleMergeRequestManager ¶
func NewSimpleMergeRequestManager(client *gitlab.Client, projectID interface{}) *SimpleMergeRequestManager
NewSimpleMergeRequestManager creates a new simple merge request manager
func (*SimpleMergeRequestManager) CreateMergeRequest ¶
func (smr *SimpleMergeRequestManager) CreateMergeRequest(ctx context.Context, opts *SimpleMergeRequestOptions) (*gitlab.MergeRequest, error)
CreateMergeRequest creates a new merge request with basic options
func (*SimpleMergeRequestManager) GetMergeRequest ¶
func (smr *SimpleMergeRequestManager) GetMergeRequest(ctx context.Context, mrIID int) (*gitlab.MergeRequest, error)
GetMergeRequest retrieves merge request by IID
func (*SimpleMergeRequestManager) ListMergeRequests ¶
func (smr *SimpleMergeRequestManager) ListMergeRequests(ctx context.Context, state string) ([]*gitlab.BasicMergeRequest, error)
ListMergeRequests lists merge requests with basic filtering