admin

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalid            = errors.New("invalid admin request")
	ErrSelfAdministration = errors.New("cannot remove your own administrator access")
	ErrFinalAdministrator = errors.New("cannot remove the final active administrator")
)
View Source
var ErrForbidden = errors.New("administrator access required")

Functions

This section is empty.

Types

type Delivery

type Delivery struct {
	ID             int64      `json:"id"`
	DeliveryID     string     `json:"delivery_id"`
	Event          string     `json:"event"`
	State          string     `json:"state"`
	ErrorCode      string     `json:"error_code"`
	InstallationID int64      `json:"installation_id"`
	ReceivedAt     time.Time  `json:"received_at"`
	ProcessedAt    *time.Time `json:"processed_at,omitempty"`
}

type GitHub

type GitHub struct {
	AppID                   int64          `json:"app_id"`
	WebURL                  string         `json:"web_url"`
	APIURL                  string         `json:"api_url"`
	UploadURL               string         `json:"upload_url"`
	GitURL                  string         `json:"git_url"`
	APIVersion              string         `json:"api_version"`
	PrivateKeyConfigured    bool           `json:"private_key_configured"`
	WebhookSecretConfigured bool           `json:"webhook_secret_configured"`
	CAConfigured            bool           `json:"ca_configured"`
	Installations           []Installation `json:"installations"`
	Truncated               bool           `json:"truncated"`
}

type GitHubClient

type GitHubClient interface {
	DefaultBranchSHA(context.Context, int64, string, string, string) (string, error)
	InstallationRepositories(context.Context, int64) ([]githubapp.Repository, error)
}

type GitHubConfig

type GitHubConfig struct {
	AppID                                                       int64
	WebURL, APIURL, UploadURL, GitURL, APIVersion               string
	PrivateKeyConfigured, WebhookSecretConfigured, CAConfigured bool
}

type Group

type Group struct {
	ID            int64   `json:"id"`
	ExternalID    string  `json:"external_id"`
	DisplayName   string  `json:"display_name"`
	Administrator bool    `json:"administrator"`
	RepositoryIDs []int64 `json:"repository_ids"`
	MemberCount   int     `json:"member_count"`
}

type IndexRequest

type IndexRequest struct {
	RepositoryID                 int64
	TargetSHA, TargetRef, Reason string
}

type Installation

type Installation struct {
	GitHubID     int64      `json:"github_id"`
	AccountLogin string     `json:"account_login"`
	AccountType  string     `json:"account_type"`
	Status       string     `json:"status"`
	SuspendedAt  *time.Time `json:"suspended_at,omitempty"`
}

type Job

type Job struct {
	ID           int64     `json:"id"`
	RepositoryID int64     `json:"repository_id"`
	Repository   string    `json:"repository"`
	TargetSHA    string    `json:"target_sha"`
	TargetRef    string    `json:"target_ref"`
	Reason       string    `json:"reason"`
	State        string    `json:"state"`
	ErrorCode    string    `json:"error_code"`
	Attempt      int       `json:"attempt"`
	MaxAttempts  int       `json:"max_attempts"`
	Priority     int       `json:"priority"`
	RunAfter     time.Time `json:"run_after"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type JobCursor

type JobCursor struct {
	UpdatedAt time.Time
	ID        int64
}

type Overview

type Overview struct {
	Repositories  map[string]int64 `json:"repositories"`
	Jobs          map[string]int64 `json:"jobs"`
	Deliveries    map[string]int64 `json:"deliveries"`
	SCIPUploads   int64            `json:"scip_uploads"`
	Dependencies  int64            `json:"dependencies"`
	Installations int64            `json:"installations"`
}

type Repository

type Repository struct {
	ID             int64      `json:"id"`
	GitHubID       int64      `json:"github_id"`
	InstallationID int64      `json:"installation_id"`
	Name           string     `json:"name"`
	DefaultBranch  string     `json:"default_branch"`
	DesiredSHA     string     `json:"desired_sha"`
	IndexedSHA     string     `json:"indexed_sha"`
	Status         string     `json:"status"`
	ErrorCode      string     `json:"error_code"`
	WebURL         string     `json:"web_url"`
	Enabled        bool       `json:"enabled"`
	Private        bool       `json:"private"`
	Archived       bool       `json:"archived"`
	LastIndexedAt  *time.Time `json:"last_indexed_at,omitempty"`
}

type RepositoryCursor

type RepositoryCursor struct{ Name string }

RepositoryCursor identifies the last repository of a page by full name.

type SCIPDependency

type SCIPDependency struct {
	RepositoryID int64  `json:"repository_id"`
	Repository   string `json:"repository"`
	Source       string `json:"source"`
	Relation     string `json:"relation"`
	PURL         string `json:"purl"`
	Manager      string `json:"manager"`
	Name         string `json:"name"`
	Version      string `json:"version"`
}

type SCIPUpload

type SCIPUpload struct {
	ID             int64     `json:"id"`
	RepositoryID   int64     `json:"repository_id"`
	Repository     string    `json:"repository"`
	Commit         string    `json:"commit"`
	ProjectRoot    string    `json:"project_root"`
	IndexerName    string    `json:"indexer_name"`
	IndexerVersion string    `json:"indexer_version"`
	UploadedAt     time.Time `json:"uploaded_at"`
}

type Service

type Service struct {
	Store        Store
	Audit        audit.Recorder
	GitHub       GitHubClient
	ReconcileAll func(context.Context) error
	Config       GitHubConfig
	MaxItems     int
}

func (*Service) AuditEvents

func (service *Service) AuditEvents(ctx context.Context, principal authn.Principal) ([]audit.Event, bool, error)

func (*Service) Deliveries

func (service *Service) Deliveries(ctx context.Context, principal authn.Principal) ([]Delivery, bool, error)

func (*Service) GitHubInfo

func (service *Service) GitHubInfo(ctx context.Context, principal authn.Principal) (GitHub, error)

func (*Service) Group

func (service *Service) Group(ctx context.Context, principal authn.Principal, id int64) (Group, error)

func (*Service) Groups

func (service *Service) Groups(ctx context.Context, principal authn.Principal) ([]Group, bool, error)

func (*Service) Jobs

func (service *Service) Jobs(ctx context.Context, principal authn.Principal, cursor *JobCursor) ([]Job, bool, error)

func (*Service) Overview

func (service *Service) Overview(ctx context.Context, principal authn.Principal) (Overview, error)

func (*Service) Reconcile

func (service *Service) Reconcile(ctx context.Context, principal authn.Principal) error

func (*Service) RecordDeniedMutation

func (service *Service) RecordDeniedMutation(ctx context.Context, principal authn.Principal)

func (*Service) Reindex

func (service *Service) Reindex(ctx context.Context, principal authn.Principal, githubID int64) error

func (*Service) ReplaceGroupAccess

func (service *Service) ReplaceGroupAccess(ctx context.Context, principal authn.Principal, id int64, administrator bool, repositoryIDs []int64) error

func (*Service) ReplaceUserAccess

func (service *Service) ReplaceUserAccess(ctx context.Context, principal authn.Principal, id int64, administrator bool, repositoryIDs []int64) error

func (*Service) Repositories

func (service *Service) Repositories(ctx context.Context, principal authn.Principal, cursor *RepositoryCursor) ([]Repository, bool, error)

func (*Service) Retry

func (service *Service) Retry(ctx context.Context, principal authn.Principal, id int64) error

func (*Service) RevokeUserCredentials

func (service *Service) RevokeUserCredentials(ctx context.Context, principal authn.Principal, id int64) error

func (*Service) SCIPDependencies

func (service *Service) SCIPDependencies(ctx context.Context, principal authn.Principal) ([]SCIPDependency, bool, error)

func (*Service) SCIPUploads

func (service *Service) SCIPUploads(ctx context.Context, principal authn.Principal) ([]SCIPUpload, bool, error)

func (*Service) SuspendUser

func (service *Service) SuspendUser(ctx context.Context, principal authn.Principal, id int64, suspended bool) error

func (*Service) User

func (service *Service) User(ctx context.Context, principal authn.Principal, id int64) (User, error)

func (*Service) Users

func (service *Service) Users(ctx context.Context, principal authn.Principal) ([]User, bool, error)

type Store

type Store interface {
	AuditEvents(context.Context, int) ([]audit.Event, bool, error)
	AdminUsers(context.Context, int) ([]User, bool, error)
	AdminUser(context.Context, int64) (User, error)
	AdminGroups(context.Context, int) ([]Group, bool, error)
	AdminGroup(context.Context, int64) (Group, error)
	SuspendAdminUser(context.Context, int64, int64, bool) error
	ReplaceAdminUserAccess(context.Context, int64, int64, bool, []int64) error
	ReplaceAdminGroupAccess(context.Context, int64, int64, bool, []int64) error
	RevokeAdminUserCredentials(context.Context, int64) error
	AdminOverview(context.Context, int64, []int64) (Overview, error)
	AdminRepositories(context.Context, int64, []int64, int, *RepositoryCursor) ([]Repository, bool, error)
	AdminJobs(context.Context, int64, []int64, int, *JobCursor) ([]Job, bool, error)
	AdminSCIPUploads(context.Context, int64, []int64, int) ([]SCIPUpload, bool, error)
	AdminSCIPDependencies(context.Context, int64, []int64, int) ([]SCIPDependency, bool, error)
	AdminDeliveries(context.Context, int64, []int64, int) ([]Delivery, bool, error)
	AdminGitHub(context.Context, int64, []int64, GitHubConfig, int) (GitHub, error)
	AdminRepository(context.Context, int64, []int64, int64) (repository.Repository, error)
	AnyAuthorizedRepository(context.Context, int64) (repository.Repository, error)
	EnqueueAdminIndex(context.Context, IndexRequest) error
	RetryAdminJob(context.Context, int64, []int64, int64) error
	ReconcileAdminRepositories(context.Context, int64, []int64, []githubapp.Repository) error
	// contains filtered or unexported methods
}

type User

type User struct {
	ID                  int64   `json:"id"`
	ExternalID          string  `json:"external_id"`
	UserName            string  `json:"user_name"`
	DisplayName         string  `json:"display_name"`
	Source              string  `json:"source"`
	SCIMActive          bool    `json:"scim_active"`
	Suspended           bool    `json:"suspended"`
	Administrator       bool    `json:"administrator"`
	RepositoryIDs       []int64 `json:"repository_ids"`
	DirectAdministrator bool    `json:"direct_administrator"`
	DirectRepositoryIDs []int64 `json:"direct_repository_ids"`
	GitHubRepositoryIDs []int64 `json:"github_repository_ids"`
}

Jump to

Keyboard shortcuts

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