Documentation
¶
Index ¶
- Constants
- func BranchMatchesPattern(pattern, branchName string) bool
- func BuildGitlabID(id int, idType string) string
- func BuildVariableSafeConfID(protected, masked bool, ids ...string) string
- func CheckItemMatchToPatterns(item string, patterns []string) bool
- func ConvertCICDVariableToMap(variables []CICDVariable) map[string]string
- func CreateMergeRequestNote(projectID int, mrIID int, body string, token string, instanceURL string, ...) (*gitlab.Note, error)
- func CreateProjectBadge(projectID int, name, imageURL, linkURL, token, instanceURL string, ...) (*gitlab.ProjectBadge, error)
- func DetectMergeRequestIID() int
- func EnhanceProjectWithGraphQL(project *Project, token string, instanceURL string, ...) error
- func FetchGitlabFile(projectPath string, filePath string, ref string, token string, APIURL string, ...) ([]byte, error, error)
- func FetchGitlabGroup(id int, token string, APIURL string, conf *configuration.Configuration) (*gitlab.Group, error, error)
- func FetchGitlabInclude(include MergedCIConfResponseInclude, projectPath, token, APIURL, sha string, ...) ([]string, error)
- func FetchGitlabProject(id int, token string, APIURL string, conf *configuration.Configuration) (*gitlab.Project, error, error)
- func FetchLatestCommitSha(token, instanceURL, projectPath, branch string, ...) (string, error)
- func FetchProjectBranches(projectID int, token string, APIURL string, conf *configuration.Configuration) ([]string, error)
- func FetchProjectMRApprovalRules(projectID int, token string, APIURL string, conf *configuration.Configuration) ([]*gitlab.ProjectApprovalRule, error)
- func FetchProjectMRApprovalSettings(projectID int, token string, APIURL string, conf *configuration.Configuration) (*gitlab.ProjectApprovals, error)
- func FetchRepositoryBranches(client *gitlab.Client, projectID string, maxPage int) ([]*gitlab.Branch, error)
- func GetExtends(extendsInterface interface{}) ([]string, error)
- func GetFullGitlabCI(project *ProjectInfo, ref, token, url string, ...) (*GitlabCIConf, *GitlabCIConf, *MergedCIConfResponse, string, string, error)
- func GetFullPathAndName(id int, token string, instanceUrl string, conf *configuration.Configuration) (string, string, error)
- func GetGitlabInstanceVersion(token, APIURL string, conf *configuration.Configuration) (string, error)
- func GetGraphQLClient(url string, conf *configuration.Configuration) *graphql.Client
- func GetGroupFullPath(groupID int, token string, APIURL string, conf *configuration.Configuration) (string, error)
- func GetHTTPClient(conf *configuration.Configuration) *http.Client
- func GetImageName(imageInterface interface{}) (string, error)
- func GetMapKeys(m map[string]string) []string
- func GetNewGitlabClient(token string, instanceUrl string, conf *configuration.Configuration) (*gitlab.Client, error)
- func GetScriptLines(scriptInterface interface{}) []string
- func GetVariableValue(valueInterface interface{}) (string, error)
- func IsGitlabInstanceEnterprise(token, APIURL string, conf *configuration.Configuration) (bool, error)
- func IsOnDefaultBranchCI() bool
- func IsRunningInCI() bool
- func IsUpToDate(version, latestVersion string, latestRefs []string) bool
- func IsUsingLatest(version string, latestRefs []string) bool
- func IsVersionGreaterOrEqual(version, requiredVersion string) bool
- func ListMergeRequestNotes(projectID int, mrIID int, token string, instanceURL string, ...) ([]*gitlab.Note, error)
- func ListProjectBadges(projectID int, token string, instanceURL string, ...) ([]*gitlab.ProjectBadge, error)
- func ParseDefaultImage(conf *GitlabCIConf) (string, error)
- func ParseGitlabID(idString string) (int, error)
- func ParseGlobalVariables(conf *GitlabCIConf) (map[string]string, error)
- func ParseJobVariables(job *GitlabJob) (map[string]string, error)
- func RemoveGitRefFromURL(rawURL string) (string, error)
- func RemoveVersionInRawLink(raw string) string
- func ReplaceVariable(input string, ...) string
- func ReplaceVariableFromEnv(input string) string
- func RepoHasFolder(projectPath string, folderPath string, token string, APIURL string, ...) bool
- func ResolveLocalIncludes(content []byte, repoRoot string) ([]byte, error)
- func SearchTags(projectPath string, token string, APIURL string, ...) ([]string, error, error)
- func UpdateMergeRequestNote(projectID int, mrIID int, noteID int, body string, token string, ...) (*gitlab.Note, error)
- func UpdateProjectBadge(projectID int, badgeID int, name, imageURL, linkURL, token, instanceURL string, ...) (*gitlab.ProjectBadge, error)
- func WrapTransportWithRetry(transport http.RoundTripper, conf *configuration.Configuration) http.RoundTripper
- type Artifacts
- type Branch
- type BranchProtection
- type BranchProtectionAccessLevel
- type CICDVariable
- func GetGitlabInstanceVariables(token string, instanceUrl string, conf *configuration.Configuration) ([]CICDVariable, error)
- func GetGitlabProjectInheritedVariables(fullPath string, token string, instanceUrl string, ...) ([]CICDVariable, error)
- func GetGitlabProjectVariables(fullPath string, token string, instanceUrl string, ...) ([]CICDVariable, error)
- type CICDVariableConf
- type CICDVariableSource
- type CICatalogResource
- type CICatalogResourceVersion
- type CIComponent
- type CIConfDefault
- type CIConfVariable
- type Cache
- type Environment
- type Except
- type GitlabCIConf
- type GitlabJob
- type GitlabMemberInfo
- type Group
- type GroupMetadataNode
- type GroupProjectsResponse
- type Image
- type Include
- type IncludeOrigin
- type IncludeOriginWithoutRef
- type InstanceGroupsResponse
- type InstanceProjectsResponse
- type MergedCIConfResponse
- type MergedCIConfResponseInclude
- type Only
- type PageInfo
- type Project
- type ProjectBranchesResponse
- type ProjectInfo
- type ProjectLanguage
- type ProjectMetadataNode
- type Resource
- type Resources
- type RetryConfig
- type Rule
- type SecurityPolicyProject
- type Service
- type StringOrSlice
- type Workflow
Constants ¶
const ( AccessLevelNo = 0 AccessLevelMinimal = 5 AccessLevelGuest = 10 AccessLevelPlanner = 15 AccessLevelReporter = 20 AccessLevelDeveloper = 30 AccessLevelMaintainer = 40 AccessLevelOwner = 50 AccessLevelAdmin = 60 )
Access level constants for GitLab
const ( NoText = "No access" MinimalText = "Minimal access" GuestText = "Guest" PlannerText = "Planner" ReporterText = "Reporter" DeveloperText = "Developer" MaintainerText = "Maintainer" OwnerText = "Owner" AdminText = "Admin" )
Access level text descriptions
const ( IncludeFile = "file" IncludeRemote = "remote" )
const (
// PlumberBadgeName is the name used for Plumber project badges
PlumberBadgeName = "Plumber"
)
Variables ¶
This section is empty.
Functions ¶
func BranchMatchesPattern ¶
BranchMatchesPattern checks if a branch name matches a pattern using wildcard matching Supports * wildcard for pattern matching (e.g., "*production*", "release/*")
func BuildGitlabID ¶
Build gitLab GraphQL ID string
func BuildVariableSafeConfID ¶
func CheckItemMatchToPatterns ¶
CheckItemMatchToPatterns detects if a string matches at least one of the patterns using wildcard lib (not regex) Examples: "3.2*" matches "3.2-rc-buster", "3.22"
"*-dev" matches "1.0-dev", "feature-dev"
func ConvertCICDVariableToMap ¶
func ConvertCICDVariableToMap(variables []CICDVariable) map[string]string
func CreateMergeRequestNote ¶ added in v0.1.42
func CreateMergeRequestNote(projectID int, mrIID int, body string, token string, instanceURL string, conf *configuration.Configuration) (*gitlab.Note, error)
CreateMergeRequestNote creates a new note (comment) on a merge request
func CreateProjectBadge ¶ added in v0.1.42
func CreateProjectBadge(projectID int, name, imageURL, linkURL, token, instanceURL string, conf *configuration.Configuration) (*gitlab.ProjectBadge, error)
CreateProjectBadge creates a new badge on a project
func DetectMergeRequestIID ¶ added in v0.1.42
func DetectMergeRequestIID() int
DetectMergeRequestIID checks if we are running inside a GitLab CI merge request pipeline and returns the merge request IID. Returns 0 if not in a CI merge request context.
GitLab CI sets CI_MERGE_REQUEST_IID only for merge request pipelines (pipelines triggered by `rules: - if: $CI_MERGE_REQUEST_IID` or `only: merge_requests`).
func EnhanceProjectWithGraphQL ¶
func EnhanceProjectWithGraphQL(project *Project, token string, instanceURL string, conf *configuration.Configuration) error
EnhanceProjectWithGraphQL adds additional data from GraphQL API This can get information not available via REST
func FetchGitlabFile ¶
func FetchGitlabFile(projectPath string, filePath string, ref string, token string, APIURL string, conf *configuration.Configuration) ([]byte, error, error)
FetchGitlabFile retrieves a file from a GitLab project using its path
func FetchGitlabGroup ¶
func FetchGitlabGroup(id int, token string, APIURL string, conf *configuration.Configuration) (*gitlab.Group, error, error)
FetchGitlabGroup retrieves a group from GitLab using its ID The first error returned is error from GitLab API response if any
func FetchGitlabInclude ¶
func FetchGitlabInclude(include MergedCIConfResponseInclude, projectPath, token, APIURL, sha string, conf *configuration.Configuration, inputs map[string]interface{}, stages []string) ([]string, error)
FetchGitlabInclude retrieves all jobs from a CI conf include
func FetchGitlabProject ¶
func FetchGitlabProject(id int, token string, APIURL string, conf *configuration.Configuration) (*gitlab.Project, error, error)
FetchGitlabProject retrieves a project from GitLab using its ID
func FetchLatestCommitSha ¶ added in v0.1.33
func FetchLatestCommitSha(token, instanceURL, projectPath, branch string, conf *configuration.Configuration) (string, error)
FetchLatestCommitSha gets the latest commit SHA for a given branch. Exported wrapper around fetchLatestCommitSha for use outside the gitlab package.
func FetchProjectBranches ¶
func FetchProjectBranches(projectID int, token string, APIURL string, conf *configuration.Configuration) ([]string, error)
FetchProjectBranches retrieves all branches for a project
func FetchProjectMRApprovalRules ¶
func FetchProjectMRApprovalRules(projectID int, token string, APIURL string, conf *configuration.Configuration) ([]*gitlab.ProjectApprovalRule, error)
FetchProjectMRApprovalRules retrieves MR approval rules for a project
func FetchProjectMRApprovalSettings ¶
func FetchProjectMRApprovalSettings(projectID int, token string, APIURL string, conf *configuration.Configuration) (*gitlab.ProjectApprovals, error)
FetchProjectMRApprovalSettings retrieves MR approval settings for a project
func FetchRepositoryBranches ¶
func FetchRepositoryBranches(client *gitlab.Client, projectID string, maxPage int) ([]*gitlab.Branch, error)
FetchRepositoryBranches fetches all branches from a repository, respecting a maxPage limit
func GetExtends ¶
GetExtends gets the extends entry and returns a slice of string with all extends
func GetFullGitlabCI ¶
func GetFullGitlabCI(project *ProjectInfo, ref, token, url string, conf *configuration.Configuration) (*GitlabCIConf, *GitlabCIConf, *MergedCIConfResponse, string, string, error)
GetFullGitlabCI retrieves the full GitLab CI configuration for a project
func GetFullPathAndName ¶
func GetFullPathAndName(id int, token string, instanceUrl string, conf *configuration.Configuration) (string, string, error)
GetFullPathAndName returns the full path and full name of a project using its ID
func GetGitlabInstanceVersion ¶
func GetGitlabInstanceVersion(token, APIURL string, conf *configuration.Configuration) (string, error)
GetGitlabInstanceVersion fetches the GitLab instance version
func GetGraphQLClient ¶
func GetGraphQLClient(url string, conf *configuration.Configuration) *graphql.Client
GetGraphQLClient creates a GraphQL client with retry logic
func GetGroupFullPath ¶
func GetGroupFullPath(groupID int, token string, APIURL string, conf *configuration.Configuration) (string, error)
GetGroupFullPath returns gitlab group fullPath from id
func GetHTTPClient ¶
func GetHTTPClient(conf *configuration.Configuration) *http.Client
GetHTTPClient creates a simple HTTP client with retry logic
func GetImageName ¶
GetImageName gets the image name from an interface parsed from gitlab ci file
func GetMapKeys ¶
GetMapKeys returns the keys of a string map as a slice (for safe logging without values)
func GetNewGitlabClient ¶
func GetNewGitlabClient(token string, instanceUrl string, conf *configuration.Configuration) (*gitlab.Client, error)
GetNewGitlabClient returns a new GitLab client for API requests
func GetScriptLines ¶ added in v0.1.52
func GetScriptLines(scriptInterface interface{}) []string
GetScriptLines extracts script lines from a script field (string or []interface{}). Returns nil for nil input. Multi-line strings are split on newline boundaries.
func GetVariableValue ¶
GetVariableValue gets the variable value from an interface parsed from gitlab ci file
func IsGitlabInstanceEnterprise ¶
func IsGitlabInstanceEnterprise(token, APIURL string, conf *configuration.Configuration) (bool, error)
IsGitlabInstanceEnterprise checks if the GitLab instance is enterprise edition
func IsOnDefaultBranchCI ¶ added in v0.1.42
func IsOnDefaultBranchCI() bool
IsOnDefaultBranchCI checks if the current CI pipeline is running on the project's default branch by comparing CI_COMMIT_BRANCH to CI_DEFAULT_BRANCH. Only call this when IsRunningInCI() returns true.
func IsRunningInCI ¶
func IsRunningInCI() bool
IsRunningInCI checks if the code is running inside a GitLab CI environment by checking if the CI environment variable is set to "true"
func IsUpToDate ¶
Return if a template is up to date
func IsUsingLatest ¶
Return if a template is using a latest ref
func IsVersionGreaterOrEqual ¶
IsVersionGreaterOrEqual compares GitLab version strings Returns true if the given version is greater than or equal to the required version
func ListMergeRequestNotes ¶ added in v0.1.42
func ListMergeRequestNotes(projectID int, mrIID int, token string, instanceURL string, conf *configuration.Configuration) ([]*gitlab.Note, error)
ListMergeRequestNotes retrieves all notes (comments) on a merge request
func ListProjectBadges ¶ added in v0.1.42
func ListProjectBadges(projectID int, token string, instanceURL string, conf *configuration.Configuration) ([]*gitlab.ProjectBadge, error)
ListProjectBadges retrieves all badges for a project
func ParseDefaultImage ¶
func ParseDefaultImage(conf *GitlabCIConf) (string, error)
ParseDefaultImage parses the default image from a GitLab CI configuration
func ParseGlobalVariables ¶
func ParseGlobalVariables(conf *GitlabCIConf) (map[string]string, error)
ParseGlobalVariables parses global variables of a GitLab CI conf
func ParseJobVariables ¶
ParseJobVariables parses job variables from a GitLab CI conf
func RemoveGitRefFromURL ¶
RemoveGitRefFromURL removes git refs (commits, branches, tags) from a URL
func RemoveVersionInRawLink ¶
Return an uniq id for a template data
func ReplaceVariable ¶
func ReplaceVariable(input string, project, group, instance, job, defaultJob, predefined map[string]string) string
ReplaceVariable replaces variables in the input string recursively up to 5 levels
func ReplaceVariableFromEnv ¶
ReplaceVariableFromEnv replaces variables in the input string using environment variables This is used when running in CI mode where all variables are available in the environment
func RepoHasFolder ¶
func RepoHasFolder(projectPath string, folderPath string, token string, APIURL string, conf *configuration.Configuration) bool
RepoHasFolder tests if a folder exists in a gitlab repository
func ResolveLocalIncludes ¶ added in v0.1.41
ResolveLocalIncludes pre-processes a local CI configuration to inline include:local entries from the local filesystem. Other include types (component, template, project, remote) are preserved for GitLab's ciConfig API to resolve server-side.
If the YAML cannot be parsed or no local includes are found, the original content is returned unchanged. If a local include file cannot be read, it is left in the include list for GitLab to resolve from the remote repository.
func SearchTags ¶
func SearchTags(projectPath string, token string, APIURL string, conf *configuration.Configuration) ([]string, error, error)
SearchTags gets all tags of a project
func UpdateMergeRequestNote ¶ added in v0.1.42
func UpdateMergeRequestNote(projectID int, mrIID int, noteID int, body string, token string, instanceURL string, conf *configuration.Configuration) (*gitlab.Note, error)
UpdateMergeRequestNote updates an existing note (comment) on a merge request
func UpdateProjectBadge ¶ added in v0.1.42
func UpdateProjectBadge(projectID int, badgeID int, name, imageURL, linkURL, token, instanceURL string, conf *configuration.Configuration) (*gitlab.ProjectBadge, error)
UpdateProjectBadge updates an existing badge on a project
func WrapTransportWithRetry ¶
func WrapTransportWithRetry(transport http.RoundTripper, conf *configuration.Configuration) http.RoundTripper
WrapTransportWithRetry wraps an existing http.RoundTripper with retry logic
Types ¶
type Artifacts ¶
type Artifacts struct {
// NOTE: this type must be verified if we need to use it !
// See https://docs.gitlab.com/ee/ci/yaml/#rules
Paths []string `yaml:"paths,omitempty"`
When string `yaml:"when,omitempty"`
Name string `yaml:"name,omitempty"`
Untracked bool `yaml:"untracked,omitempty"`
}
type BranchProtection ¶
type BranchProtection struct {
ProtectionPattern string `json:"protectionPattern"`
AllowForcePush bool `json:"allowForcePush"`
CodeOwnerApprovalRequired bool `json:"codeOwnerApprovalRequired"`
MinPushAccessLevel int `json:"minPushAccessLevel"`
MinMergeAccessLevel int `json:"minMergeAccessLevel"`
PushAccessLevels []BranchProtectionAccessLevel `json:"pushAccessLevels"`
MergeAccessLevels []BranchProtectionAccessLevel `json:"mergeAccessLevels"`
}
func FetchBranchProtections ¶
func FetchBranchProtections(projectID int, token string, APIURL string, conf *configuration.Configuration) ([]BranchProtection, error)
FetchBranchProtections retrieves branch protection settings for a project
func FetchProjectBranchData ¶
func FetchProjectBranchData(projectPath string, token string, APIURL string, conf *configuration.Configuration) ([]string, []BranchProtection, error)
FetchProjectBranchData fetches branches and their protection settings
type CICDVariable ¶
type CICDVariable struct {
Name string `json:"name"`
Type string `json:"type"`
Environment string `json:"environment"`
Protected bool `json:"protected"`
Masked bool `json:"masked"`
Hidden bool `json:"hidden"`
Value string `json:"value"`
}
Data of Gitlab projects and groups variables
func GetGitlabInstanceVariables ¶
func GetGitlabInstanceVariables(token string, instanceUrl string, conf *configuration.Configuration) ([]CICDVariable, error)
GetGitlabInstanceVariables returns all instance variables
func GetGitlabProjectInheritedVariables ¶
func GetGitlabProjectInheritedVariables(fullPath string, token string, instanceUrl string, conf *configuration.Configuration) ([]CICDVariable, error)
GetGitlabProjectInheritedVariables returns all project inherited variables
func GetGitlabProjectVariables ¶
func GetGitlabProjectVariables(fullPath string, token string, instanceUrl string, conf *configuration.Configuration) ([]CICDVariable, error)
GetGitlabProjectVariables returns all project variables
type CICDVariableConf ¶
type CICDVariableSource ¶
type CICatalogResource ¶
type CICatalogResource struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Topics []string `json:"topics"`
VerificationLevel string `json:"verificationLevel"`
VisibilityLevel string `json:"visibilityLevel"`
StarCount int `json:"starCount"`
Icon string `json:"icon"`
FullPath string `json:"fullPath"`
Last30DayUsageCount int `json:"last30DayUsageCount"`
LatestReleasedAt string `json:"latestReleasedAt"`
WebPath string `json:"webPath"`
Versions []CICatalogResourceVersion `json:"versions"`
}
func GetGitlabCIComponentResources ¶
func GetGitlabCIComponentResources(isGroup bool, token string, instanceUrl string, conf *configuration.Configuration) ([]CICatalogResource, error)
GetGitlabCIComponentResources fetches all CI component resources from GitLab
type CICatalogResourceVersion ¶
type CICatalogResourceVersion struct {
Name string `json:"name"`
Path string `json:"path"`
Components []CIComponent `json:"components"`
}
type CIComponent ¶
type CIConfDefault ¶
type CIConfDefault struct {
Image interface{} `yaml:"image,omitempty"`
}
type CIConfVariable ¶
type Cache ¶
type Cache struct {
// NOTE: this type must be verified if we need to use it !
// See https://docs.gitlab.com/ee/ci/yaml/#rules
Key interface{} `yaml:"key,omitempty"`
Paths []string `yaml:"paths,omitempty"`
Policy string `yaml:"policy,omitempty"`
When string `yaml:"when,omitempty"`
Untracked bool `yaml:"untracked,omitempty"`
}
type Environment ¶
type Environment struct {
// NOTE: this type must be verified if we need to use it !
// See https://docs.gitlab.com/ee/ci/yaml/#rules
Name map[string]string `yaml:",inline"`
URL string `yaml:"url,omitempty"`
}
type Except ¶
type Except struct {
// NOTE: this type must be verified if we need to use it !
// See https://docs.gitlab.com/ee/ci/yaml/#rules
Refs []string `yaml:"refs,omitempty"`
Kinds []string `yaml:"kinds,omitempty"`
Variables map[string]string `yaml:"variables,omitempty"`
}
type GitlabCIConf ¶
type GitlabCIConf struct {
Image interface{} `yaml:"image,omitempty"`
GlobalVariables map[string]interface{} `yaml:"variables,omitempty"`
Stages []string `yaml:"stages,omitempty"`
BeforeScript interface{} `yaml:"before_script,omitempty"`
AfterScript interface{} `yaml:"after_script,omitempty"`
DefaultScript interface{} `yaml:"script,omitempty"`
Default CIConfDefault `yaml:"default,omitempty"`
Spec interface{} `yaml:"spec,omitempty"`
Include []interface{} `yaml:"include,omitempty"` // Can be list of string or list of include
GitlabJobs map[string]interface{} `yaml:",inline"` // Can be a string or a map[string]GitlabJob
Workflow interface{} `yaml:"workflow,omitempty"`
Cache interface{} `yaml:"cache,omitempty"`
}
GitLab CI Configuration
func ParseGitlabCI ¶
func ParseGitlabCI(fileContent []byte) (*GitlabCIConf, error)
ParseGitlabCI parses a .gitlab-ci.yml file
type GitlabJob ¶
type GitlabJob struct {
Script interface{} `yaml:"script,omitempty"` // Can be both multi lines or one literal block scalar
BeforeScript interface{} `yaml:"before_script,omitempty"` // Can be both multi lines or one literal block scalar
AfterScript interface{} `yaml:"after_script,omitempty"` // Can be both multi lines or one literal block scalar
Stage string `yaml:"stage,omitempty"`
Image interface{} `yaml:"image,omitempty"`
Services interface{} `yaml:"services,omitempty"` // Can be both a list of string or a list of Serive
Only interface{} `yaml:"only,omitempty"`
Except interface{} `yaml:"except,omitempty"`
Variables map[string]interface{} `yaml:"variables,omitempty"`
Cache interface{} `yaml:"cache,omitempty"`
Dependencies interface{} `yaml:"dependencies,omitempty"`
Needs interface{} `yaml:"needs,omitempty"`
Rules interface{} `yaml:"rules,omitempty"`
Artifacts interface{} `yaml:"artifacts,omitempty"`
Environment interface{} `yaml:"environment,omitempty"`
When interface{} `yaml:"when,omitempty"`
AllowFailure interface{} `yaml:"allow_failure,omitempty"`
Extends interface{} `yaml:"extends,omitempty"`
}
func ParseGitlabCIJob ¶
ParseGitlabCIJob parses a job from GitLab CI conf
type GitlabMemberInfo ¶
type GitlabMemberInfo struct {
ID int `json:"id"`
Name string `json:"name"` // GitLab username (@username)
DisplayedName string `json:"displayedName"` // GitLab display name (e.g., "John Doe")
Email string `json:"email"`
AvatarURL string `json:"avatarUrl"`
AccessLevel int `json:"accessLevel"`
}
Common struct for GitLab members (both project and group members)
func FetchGroupMembers ¶
func FetchGroupMembers(groupID int, token string, APIURL string, conf *configuration.Configuration) ([]GitlabMemberInfo, error)
FetchGroupMembers retrieves all members of a group
func FetchProjectMembers ¶
func FetchProjectMembers(projectID int, token string, APIURL string, conf *configuration.Configuration) ([]GitlabMemberInfo, error)
FetchProjectMembers retrieves all members of a project
type Group ¶
type Group struct {
IdOnPlatform int `json:"idOnPlatform" validate:"required,number"`
GroupIdOnPlatform int `json:"groupIdOnPlatform" validate:"number"`
Path string `json:"path" validate:"required,max=300"`
Name string `json:"name" validate:"required,max=300"`
Visibility string `json:"visibility" validate:"required,max=50"`
CreatedAt time.Time `json:"createdAt"`
}
Data of a GitLab group
type GroupMetadataNode ¶
type GroupProjectsResponse ¶
type GroupProjectsResponse struct {
Group struct {
Projects struct {
Nodes []ProjectMetadataNode
PageInfo PageInfo
}
}
}
Gitlab GraphQL response of query to get all projects of a group with metadata
type Image ¶
type Image struct {
Name string `yaml:"name,omitempty"`
Entrypoint []string `yaml:"entrypoint,omitempty"`
PullPolicy StringOrSlice `yaml:"pull_policy,omitempty"`
}
type IncludeOrigin ¶
type IncludeOrigin struct {
IncludeOriginWithoutRef
Raw string `json:"raw"`
Ref string `json:"ref"`
}
type IncludeOriginWithoutRef ¶
type InstanceGroupsResponse ¶
type InstanceGroupsResponse struct {
Groups struct {
Nodes []GroupMetadataNode
PageInfo PageInfo
}
}
Gitlab GraphQL response of query to get all groups of an instance with metadata
type InstanceProjectsResponse ¶
type InstanceProjectsResponse struct {
Projects struct {
Nodes []ProjectMetadataNode
PageInfo PageInfo
}
}
Gitlab GraphQL response of query to get all projects of an instance with metadata
type MergedCIConfResponse ¶
type MergedCIConfResponse struct {
CiConfig struct {
MergedYaml string `json:"mergedYaml"`
Errors []string `json:"errors"`
Warnings []interface{} `json:"warnings"`
Status string `json:"status"`
Includes []MergedCIConfResponseInclude `json:"includes"`
Stages struct {
Nodes []struct {
Name string `json:"name"`
Groups struct {
Nodes []struct {
Name string `json:"name"`
Size int `json:"size"`
Jobs struct {
Nodes []struct {
Name string `json:"name"`
Script []string `json:"script"`
} `json:"nodes"`
} `json:"jobs"`
} `json:"nodes"`
} `json:"groups"`
} `json:"nodes"`
} `json:"stages"`
} `json:"ciConfig"`
}
Gitlab GraphQL response of merged CI conf
func FetchGitlabMergedCIConf ¶
func FetchGitlabMergedCIConf(projectPath string, confContent string, sha string, userToken string, instanceUrl string, conf *configuration.Configuration) (MergedCIConfResponse, error)
FetchGitlabMergedCIConf gets merged version of a GitLab CI configuration
type MergedCIConfResponseInclude ¶
type MergedCIConfResponseInclude struct {
Location string `json:"location,omitempty"`
Raw string `json:"raw,omitempty"`
Blob string `json:"blob,omitempty"` // Contains version-specific reference (e.g., blob SHA) - critical for cache key differentiation
ContextProject string `json:"contextProject,omitempty"`
Type string `json:"type,omitempty"`
Extra struct {
Project string `json:"project,omitempty"`
Ref string `json:"ref,omitempty"`
} `json:"extra,omitempty"`
}
type Only ¶
type Only struct {
// NOTE: this type must be verified if we need to use it !
// See https://docs.gitlab.com/ee/ci/yaml/#rules
Refs []string `yaml:"refs,omitempty"`
Kinds []string `yaml:"kinds,omitempty"`
Variables map[string]string `yaml:"variables,omitempty"`
}
type Project ¶
type Project struct {
IdOnPlatform int `json:"idOnPlatform" validate:"required,number"`
GroupIdOnPlatform int `json:"groupIdOnPlatform" validate:"required,number"`
Path string `json:"path" validate:"required,max=300"`
Name string `json:"name" validate:"required,max=300"`
Visibility string `json:"visibility" validate:"required,max=50"`
DefaultBranch string `json:"defaultBranch" validate:"max=100"`
CiConfPath string `json:"ciConfPath" validate:"required,max=100"`
LastActivityAt time.Time `json:"lastActivityAt" validate:"required"`
Archived bool `json:"archived"`
LatestHeadCommitSha string `json:"latestHeadCommitSha"`
IsCatalogResource bool `json:"isCatalogResource"`
//Note: IsOfficialCatalogResource is not returned by gitlab, we set it ourselves
IsOfficialCatalogResource bool `json:"isOfficialCatalogResource"`
Languages []ProjectLanguage `json:"languages"`
CreatedAt time.Time `json:"createdAt" validate:"required"`
}
Data of a GitLab project
func FetchProjectByID ¶
func FetchProjectByID(projectID int, token string, instanceURL string, conf *configuration.Configuration) (*Project, error)
FetchProjectByID fetches project information using its GitLab ID
func FetchProjectDetails ¶
func FetchProjectDetails(projectPath string, token string, instanceURL string, conf *configuration.Configuration) (*Project, error)
FetchProjectDetails fetches complete project information from GitLab API and returns a Project struct populated with all available data
func (*Project) GetCIPredefinedVariables ¶
GetCIPredefinedVariables returns CI predefined variables based on project info These would normally be available in GitLab CI jobs
func (*Project) ToProjectInfo ¶
func (p *Project) ToProjectInfo() *ProjectInfo
ToProjectInfo converts Project to the simpler ProjectInfo struct used by collectors
type ProjectBranchesResponse ¶
type ProjectBranchesResponse struct {
Project struct {
Repository struct {
BranchNames []string
}
}
}
Gitlab GrapQL response of query to get all branches of a project
type ProjectInfo ¶
type ProjectInfo struct {
ID int // Project ID on GitLab
Path string
CiConfPath string
DefaultBranch string // The actual default branch from GitLab (e.g., "main")
AnalyzeBranch string // The branch to analyze (from --branch flag, defaults to DefaultBranch)
LatestHeadCommitSha string
Archived bool
NotFound bool
IsGroup bool // True if organization is a group (vs instance-wide)
}
ProjectInfo contains basic project information for CI analysis
type ProjectLanguage ¶
type ProjectLanguage struct {
Name string `json:"name"`
}
ProjectLanguage represents a programming language used in a project
type ProjectMetadataNode ¶
type ProjectMetadataNode struct {
ID string
CreatedAt time.Time
NameWithNamespace string
FullPath string
Visibility string
CiConfigPathOrDefault string
Repository struct {
RootRef string
Tree struct {
LastCommit struct {
Sha string
}
}
}
Group struct {
ID string
}
LastActivityAt time.Time
Archived bool
IsCatalogResource bool
Languages []struct {
Name string `json:"name"`
Share float64 `json:"share"`
}
}
type RetryConfig ¶
type RetryConfig struct {
MaxRetries int
InitialBackoff time.Duration
MaxBackoff time.Duration
BackoffFactor float64
}
RetryConfig holds the configuration for retry logic
func DefaultRetryConfig ¶
func DefaultRetryConfig(conf *configuration.Configuration) *RetryConfig
DefaultRetryConfig returns the default retry configuration
type Rule ¶
type Rule struct {
// NOTE: this type must be updated if we need to use it !
// See https://docs.gitlab.com/ee/ci/yaml/#rules
If string `yaml:"if"`
ChangesFrom []string `yaml:"changes"`
When string `yaml:"when"`
AllowFailure bool `yaml:"allow_failure"`
}
type SecurityPolicyProject ¶
type StringOrSlice ¶
type StringOrSlice []string
StringOrSlice is a type that can unmarshal from either a string or a slice of strings This is needed for GitLab CI fields like pull_policy that support both formats:
- pull_policy: "always"
- pull_policy: [if-not-present, always]
- pull_policy:
- if-not-present
- always
func (*StringOrSlice) UnmarshalYAML ¶
func (s *StringOrSlice) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements yaml.v2 Unmarshaler interface
type Workflow ¶
type Workflow struct {
// NOTE: this type must be verified if we need to use it !
// See https://docs.gitlab.com/ee/ci/yaml/#rules
Rules interface{} `yaml:"rules,omitempty"`
}