github

package
v0.0.0-...-23d6978 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const IDSep = ":"

Variables

This section is empty.

Functions

This section is empty.

Types

type AppTokenSource

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

func NewAppTokenSource

func NewAppTokenSource(keyProvider KeyProvider, appID string, appOpts ...githubauth.Option) *AppTokenSource

func (*AppTokenSource) TokenForOrg

func (s *AppTokenSource) TokenForOrg(ctx context.Context, orgID int64) (string, error)

type KeyProvider

type KeyProvider interface {
	Key(ctx context.Context) ([]byte, error)
}

KeyProvider provides a private key.

type Opt

type Opt func(writer *TeamReadWriter)

func WithoutSubTeamsAsMembers

func WithoutSubTeamsAsMembers() Opt

WithoutSubTeamsAsMembers toggles off treating subteams as members of their parent team. When this option is used TeamReadWriter.GetMembers will only return user members of the team. Similarly, TeamReadWriter.SetMembers will only consider user members when setting members.

type OrgTokenSource

type OrgTokenSource interface {
	// TokenForOrg returns a token that grants access to the given Org's resources.
	TokenForOrg(ctx context.Context, orgID int64) (string, error)
}

type TeamReadWriter

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

TeamReadWriter adheres to the groupsync.GroupReadWriter interface and provides mechanisms for manipulating GitHub Teams.

func NewTeamReadWriter

func NewTeamReadWriter(orgTokenSource OrgTokenSource, client *github.Client, opts ...Opt) *TeamReadWriter

NewTeamReadWriter creates a new TeamReadWriter. By default, TeamReadWriter considers subteams as members of their parent team and will treat them as such when executing calls to TeamReadWriter.GetMembers and TeamReadWriter.SetMembers. This behavior can be disabled by supply the WithoutSubTeamsAsMembers option, in which case only users will be considered as members of a team.

func (*TeamReadWriter) Descendants

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

Descendants retrieve all users (children, recursively) of the GitHub team with the given ID. The ID must be of the form 'orgID:teamID'.

func (*TeamReadWriter) GetGroup

func (g *TeamReadWriter) GetGroup(ctx context.Context, groupID string) (*groupsync.Group, error)

GetGroup retrieves the GitHub team with the given ID. The ID must be of the form 'orgID:teamID'.

func (*TeamReadWriter) GetMembers

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

GetMembers retrieves the direct members (children) of the GitHub team with given ID. The ID must be of the form 'orgID:teamID'.

func (*TeamReadWriter) GetUser

func (g *TeamReadWriter) GetUser(ctx context.Context, userID string) (*groupsync.User, error)

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

func (*TeamReadWriter) SetMembers

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

SetMembers replaces the members of the GitHub team with the given ID with the given members. The ID must be of the form 'orgID:teamID'. Any members of the GitHub team not found in the given members list will be removed. Likewise, any members of the given list that are not currently members of the team will be added.

Jump to

Keyboard shortcuts

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