Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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) (*token.TokenConfig, error)
RotateCurrentToken(ctx context.Context) (newToken *token.TokenConfig, oldToken *token.TokenConfig, err error)
CreatePersonalAccessToken(ctx context.Context, username string, userId int64, name string, expiresAt time.Time, scopes []string) (*token.TokenPersonal, error)
CreateGroupAccessToken(ctx context.Context, groupId string, name string, expiresAt time.Time, scopes []string, accessLevel t.AccessLevel) (*token.TokenGroup, error)
CreateProjectAccessToken(ctx context.Context, projectId string, name string, expiresAt time.Time, scopes []string, accessLevel t.AccessLevel) (*token.TokenProject, error)
RevokePersonalAccessToken(ctx context.Context, tokenId int64) error
RevokeProjectAccessToken(ctx context.Context, tokenId int64, projectId string) error
RevokeGroupAccessToken(ctx context.Context, tokenId int64, groupId string) error
GetUserIdByUsername(ctx context.Context, username string) (int64, error)
GetGroupIdByPath(ctx context.Context, path string) (int64, error)
GetProjectIdByPath(ctx context.Context, path string) (int64, error)
CreateGroupServiceAccountAccessToken(ctx context.Context, group string, groupId string, userId int64, name string, expiresAt time.Time, scopes []string) (*token.TokenGroupServiceAccount, error)
CreateUserServiceAccountAccessToken(ctx context.Context, username string, userId int64, name string, expiresAt time.Time, scopes []string) (*token.TokenUserServiceAccount, error)
RevokeUserServiceAccountAccessToken(ctx context.Context, token string) error
RevokeGroupServiceAccountAccessToken(ctx context.Context, token string) error
CreatePipelineProjectTriggerAccessToken(ctx context.Context, path, name string, projectId int64, description string, expiresAt *time.Time) (*token.TokenPipelineProjectTrigger, error)
RevokePipelineProjectTriggerAccessToken(ctx context.Context, projectId int64, tokenId int64) error
CreateProjectDeployToken(ctx context.Context, path string, projectId int64, name string, expiresAt *time.Time, scopes []string) (et *token.TokenProjectDeploy, err error)
RevokeProjectDeployToken(ctx context.Context, projectId, deployTokenId int64) (err error)
CreateGroupDeployToken(ctx context.Context, path string, groupId int64, name string, expiresAt *time.Time, scopes []string) (et *token.TokenGroupDeploy, err error)
RevokeGroupDeployToken(ctx context.Context, groupId, deployTokenId int64) (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.
func NewGitlabClient ¶ added in v0.11.0
func NewGitlabClient(config *modelConfig.EntryConfig, httpClient *http.Client, logger hclog.Logger) (client Client, err error)
Click to show internal directories.
Click to hide internal directories.