gitlab

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package gitlab provides syncers and utilities allowing Team Link to sync to GitLab.

Copyright 2024 The Authors (see AUTHORS file)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// DefaultCacheDuration is the default time to live for the user and group caches.
	// We don't expect user info (e.g. username etc.) nor group info (group name etc.)
	// to change frequently so a time to live of 1 day is the default.
	DefaultCacheDuration = time.Hour * 24
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLevelMetadata

type AccessLevelMetadata struct {
	AccessLevel gitlab.AccessLevelValue
}

AccessLevelMetadata holds an access level for a GitLab user being added to a target group.

func (*AccessLevelMetadata) Combine

Combine calculates the access level for a Gitlab user being added to a target group by taking the maximum access level granted to the user via a mapping from a source group.

type ClientOpt

type ClientOpt func(client *gitlab.Client)

func WithUserAgent

func WithUserAgent(userAgent string) ClientOpt

WithUserAgent sets the user agent on generated GitLab clients.

type ClientProvider

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

ClientProvider provides a GitLab client.

func NewGitLabClientProvider

func NewGitLabClientProvider(instanceURL string, keyProvider credentials.KeyProvider, httpClient *http.Client, opts ...ClientOpt) *ClientProvider

NewGitLabClientProvider creates a new GitLabClientProvider.

func (*ClientProvider) Client

func (g *ClientProvider) Client(ctx context.Context) (*gitlab.Client, error)

Client returns a GitLab client initialized with a PAT.

type Config

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

Config is the configuration for GroupReadWriter.

type GroupReadWriter

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

GroupReadWriter provides read and write access to GitLab groups.

func NewGroupReadWriter

func NewGroupReadWriter(clientProvider *ClientProvider, opts ...Opt) *GroupReadWriter

NewGroupReadWriter creates a GroupReadWriter.

func (*GroupReadWriter) Descendants

func (rw *GroupReadWriter) Descendants(ctx context.Context, groupID string) ([]*groupsync.User, error)

Descendants retrieve all users (children, recursively) of the GitLab group with the given ID. The ID is the group's integer ID.

func (*GroupReadWriter) GetGroup

func (rw *GroupReadWriter) GetGroup(ctx context.Context, groupID string) (*groupsync.Group, error)

GetGroup retrieves the GitLab group with the given ID. The ID is the GitLab group's integer ID.

func (*GroupReadWriter) GetMembers

func (rw *GroupReadWriter) GetMembers(ctx context.Context, groupID string) ([]groupsync.Member, error)

GetMembers retrieves the direct members (and optionally subgroups) of the GitLab group with given ID. The ID is the GitLab group's integer ID.

func (*GroupReadWriter) GetUser

func (rw *GroupReadWriter) GetUser(ctx context.Context, userID string) (*groupsync.User, error)

GetUser retrieves the GitLab user with the given ID. The ID is the GitLab user's login.

func (*GroupReadWriter) SetMembers

func (rw *GroupReadWriter) SetMembers(ctx context.Context, groupID string, members []groupsync.Member) error

SetMembers replaces the members of the GitLab group with the given ID with the given members. The ID is the group's integer ID. Any members of the GitLab group not found in the given members list will be removed. Likewise, any members of the given list that are not currently members of the group will be added.

type Opt

type Opt func(writer *Config)

Opt is a configuration option for GroupReadWriter.

func WithCacheDuration

func WithCacheDuration(duration time.Duration) Opt

WithCacheDuration set the time to live for the user and group cache entries.

func WithoutSubGroupsAsMembers

func WithoutSubGroupsAsMembers() Opt

WithoutSubGroupsAsMembers toggles off treating subgroups as members of their parent group. When this option is used GroupReadWriter.GetMembers will only return user members of the group. Similarly, GroupReadWriter.SetMembers will only consider user members when setting members.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL