Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnknownType = fmt.Errorf("%s: gitlab type", errs.ErrInvalidValue)
)
Functions ¶
func ClientNewContext ¶
ClientNewContext returns a new context.Context that carries the provided Client.
This function embeds the specified GitLab client into the given context, allowing it to be retrieved later in the execution flow. It's particularly useful for passing around client information across different layers of an application.
Types ¶
type Client ¶
type Client interface {
GitlabClient(ctx context.Context) *g.Client
Valid(ctx context.Context) bool
Metadata(ctx context.Context) (*g.Metadata, error)
CurrentTokenInfo(ctx context.Context) (*models.TokenConfig, error)
RotateCurrentToken(ctx context.Context) (newToken *models.TokenConfig, oldToken *models.TokenConfig, err error)
CreatePersonalAccessToken(ctx context.Context, username string, userId int, name string, expiresAt time.Time, scopes []string) (*models.TokenPersonal, error)
CreateGroupAccessToken(ctx context.Context, groupId string, name string, expiresAt time.Time, scopes []string, accessLevel t.AccessLevel) (*models.TokenGroup, error)
CreateProjectAccessToken(ctx context.Context, projectId string, name string, expiresAt time.Time, scopes []string, accessLevel t.AccessLevel) (*models.TokenProject, error)
RevokePersonalAccessToken(ctx context.Context, tokenId int) error
RevokeProjectAccessToken(ctx context.Context, tokenId int, projectId string) error
RevokeGroupAccessToken(ctx context.Context, tokenId int, groupId string) error
GetUserIdByUsername(ctx context.Context, username string) (int, error)
GetGroupIdByPath(ctx context.Context, path string) (int, error)
GetProjectIdByPath(ctx context.Context, path string) (int, error)
CreateGroupServiceAccountAccessToken(ctx context.Context, group string, groupId string, userId int, name string, expiresAt time.Time, scopes []string) (*models.TokenGroupServiceAccount, error)
CreateUserServiceAccountAccessToken(ctx context.Context, username string, userId int, name string, expiresAt time.Time, scopes []string) (*models.TokenUserServiceAccount, error)
RevokeUserServiceAccountAccessToken(ctx context.Context, token string) error
RevokeGroupServiceAccountAccessToken(ctx context.Context, token string) error
CreatePipelineProjectTriggerAccessToken(ctx context.Context, path, name string, projectId int, description string, expiresAt *time.Time) (*models.TokenPipelineProjectTrigger, error)
RevokePipelineProjectTriggerAccessToken(ctx context.Context, projectId int, tokenId int) error
CreateProjectDeployToken(ctx context.Context, path string, projectId int, name string, expiresAt *time.Time, scopes []string) (et *models.TokenProjectDeploy, err error)
RevokeProjectDeployToken(ctx context.Context, projectId, deployTokenId int) (err error)
CreateGroupDeployToken(ctx context.Context, path string, groupId int, name string, expiresAt *time.Time, scopes []string) (et *models.TokenGroupDeploy, err error)
RevokeGroupDeployToken(ctx context.Context, groupId, deployTokenId int) (err error)
}
func ClientFromContext ¶
ClientFromContext extracts the GitLab Client from the provided context.
This function attempts to retrieve a Client from the given context. If it was not present or if it cannot be asserted as a Client, the returned Client will be nil and the boolean will be false.
type Type ¶
type Type string
Type defines a string-based type to represent specific categories or modes, such as "saas" or "self-managed". This is the Gitlab Type
const ( // TypeSaaS represents the "saas" type, indicating the software-as-a-service mode for GitLab deployments. TypeSaaS Type = "saas" // TypeDedicated represents the "dedicated" type, indicating a dedicated mode for GitLab deployments. TypeDedicated Type = "dedicated" // TypeSelfManaged represents the "self-managed" type, indicating a self-hosted mode for GitLab deployments. TypeSelfManaged Type = "self-managed" // TypeUnknown represents an uninitialized or unknown GitLab deployment type, used as a default fallback value. TypeUnknown = Type("") )
func TypeParse ¶
TypeParse attempts to parse the given string into a valid GitLab Type. Returns the corresponding Type and nil error if successful, or TypeUnknown and an error if parsing fails.