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
- type AccessLevelMetadata
- type ClientOpt
- type ClientProvider
- type Config
- type GroupReadWriter
- func (rw *GroupReadWriter) Descendants(ctx context.Context, groupID string) ([]*groupsync.User, error)
- func (rw *GroupReadWriter) GetGroup(ctx context.Context, groupID string) (*groupsync.Group, error)
- func (rw *GroupReadWriter) GetMembers(ctx context.Context, groupID string) ([]groupsync.Member, error)
- func (rw *GroupReadWriter) GetUser(ctx context.Context, userID string) (*groupsync.User, error)
- func (rw *GroupReadWriter) SetMembers(ctx context.Context, groupID string, members []groupsync.Member) error
- type Opt
Constants ¶
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 ¶
func (m *AccessLevelMetadata) Combine(other groupsync.MappingMetadata) groupsync.MappingMetadata
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 ¶
func WithUserAgent ¶
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.
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 ¶
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 ¶
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 ¶
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.