github

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package github collects an organization's team/member/repo/CODEOWNERS topology from the GitHub GraphQL API (CODEOWNERS file contents via REST) into a canonical, JSON-serializable model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps go-gh clients. raw fetches file contents with the raw Accept header (for CODEOWNERS). gql is used for all data collection queries.

func NewClient

func NewClient() (*Client, error)

NewClient builds a Client using the same auth as `gh` (token + host).

type Collaborator added in v0.4.0

type Collaborator struct {
	Login      string `json:"login"`
	Permission string `json:"permission"` // admin|maintain|push|triage|pull
}

type Member

type Member struct {
	Login string `json:"login"`
	Role  string `json:"role"` // "maintainer" | "member"
}

type Options

type Options struct {
	Members    bool
	Codeowners bool
}

Options controls what Collect gathers.

type Org

type Org struct {
	Org         string      `json:"org"`
	CollectedAt string      `json:"collected_at"`
	Teams       []Team      `json:"teams"`
	Repos       []OrgRepo   `json:"repos"`
	Members     []OrgMember `json:"members"`
}

Org is the canonical, hand-editable data model. Its JSON shape matches the legacy /gh-org-chart cache so existing <org>-org.json files remain readable.

func Collect

func Collect(c *Client, org string, opts Options) (*Org, error)

Collect gathers the org's teams, direct members (with role), and repos via a single nested, paginated GraphQL query.

type OrgMember added in v0.4.0

type OrgMember struct {
	Login string `json:"login"`
	Role  string `json:"role"` // "admin" (owner) | "member"
}

type OrgRepo added in v0.4.0

type OrgRepo struct {
	Name          string         `json:"name"` // full name, "owner/repo"
	Archived      bool           `json:"archived"`
	Fork          bool           `json:"fork"`
	Collaborators []Collaborator `json:"collaborators,omitempty"`
}

OrgRepo is the org-wide repo record. Team grants for a repo continue to live under Teams[].Repos; Collaborators holds only DIRECT grants (a user added straight to the repo, not via a team or org membership).

type Repo

type Repo struct {
	Name           string   `json:"name"` // full name, "owner/repo"
	Archived       bool     `json:"archived"`
	Permission     string   `json:"permission"` // admin|maintain|push|triage|pull
	CodeownerPaths []string `json:"codeowner_paths,omitempty"`
}

type Team

type Team struct {
	Slug        string   `json:"slug"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Parent      *string  `json:"parent"` // parent team slug, or null
	Members     []Member `json:"members"`
	Repos       []Repo   `json:"repos"`
}

Jump to

Keyboard shortcuts

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