github

package
v0.0.0-...-907143c Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReconcileTeams   recon.Type = "teams"
	ReconcileMembers recon.Type = "members"
)

Variables

This section is empty.

Functions

func NewGroupProvider

func NewGroupProvider(db Database) sdk.GroupProvider

func NewReconciler

func NewReconciler(db Database, gh API, olderThan time.Duration) recon.Reconciler

* The reconciler fetches new reconciliation work from the database and updates the corresponding item via the github API.

It returns true, if there was work to be done and false, if there was no open reconciliation work.

Types

type API

type API interface {
	ListTeams(org string) ([]Team, error)
	ListMembers(org string, team string) ([]Member, error)
}

* API is a simplified wrapper around the github api

func NewApi

func NewApi(c Cli) API

func NewDefaultApi

func NewDefaultApi(l Login) (API, error)

type Cli

type Cli interface {
	ListTeams(ctx context.Context, org string, opts *github.ListOptions) ([]*github.Team, *github.Response, error)
	ListTeamMembersBySlug(ctx context.Context, org string, slug string, opts *github.TeamListTeamMembersOptions) ([]*github.User, *github.Response, error)
}

* Cli is an interface wrapping the methods we need from the official client

func NewClient

func NewClient(c *http.Client) Cli

type Database

type Database interface {
	AcceptReconcileJob(olderThan time.Duration) (reconciliation.Job, bool)

	ListTeams() ([]Team, error)
	UpsertOrgTeams(org string, teams []Team) error
	GetTeam(guid string) (Team, error)
	UpdateTeamMembers(guid string, members []Member) error
}

func NewMongoDatabase

func NewMongoDatabase(l MongoLogin, org string) (Database, error)

type Login

type Login struct {
	AppId          int    `yaml:"appId"`
	InstallationId int    `yaml:"installationId"`
	PrivateKey     string `yaml:"privateKey"`
}

type Member

type Member struct {
	Guid string `bson:"guid"`
	Name string `bson:"name"`
}

type MongoLogin

type MongoLogin struct {
	Uri string
	DB  string
}

type Org

type Org struct {
	OrgInfo     `bson:",inline"`
	LastUpdated time.Time `bson:"lastUpdated"`
	Teams       []string
}

type OrgInfo

type OrgInfo struct {
	Guid string
}

type Team

type Team struct {
	TeamInfo    `bson:",inline"`
	LastUpdated time.Time `bson:"lastUpdated"`
	Members     []Member
}

type TeamInfo

type TeamInfo struct {
	Org  OrgInfo
	Guid string
	Name string
	Slug string
}

Jump to

Keyboard shortcuts

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