Help us shape the future of Go! Take the 2026 Go Developer Survey

connections

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const GitHubAPI = "https://api.github.com"
View Source
const PlatformAuthKind = "github_app_platform"

Variables

View Source
var ErrCatalogUnavailable = errors.New("model catalog unavailable")
View Source
var ErrInUse = errors.New("connection is in use")
View Source
var ErrManaged = errors.New("connection is managed by a GitHub App setup")
View Source
var ErrRepositoryEndpoint = errors.New("API address is a repository URL")
View Source
var ErrRevoked = errors.New("connection revoked")
View Source
var ErrRunnerRequired = errors.New("enrol a runner in this organisation before approving a private route")

Functions

func RepositoryEndpoint

func RepositoryEndpoint(provider, endpoint string) bool

Types

type CatalogItem

type CatalogItem struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Disabled bool   `json:"disabled,omitempty"`
	Reason   string `json:"reason,omitempty"`
}

type CatalogRequest

type CatalogRequest struct {
	Provider string          `json:"provider"`
	Endpoint string          `json:"endpoint"`
	Secret   string          `json:"secret"`
	Settings CatalogSettings `json:"settings"`
}

func (CatalogRequest) GoString

func (r CatalogRequest) GoString() string

func (CatalogRequest) LogValue

func (r CatalogRequest) LogValue() slog.Value

func (CatalogRequest) MarshalJSON

func (r CatalogRequest) MarshalJSON() ([]byte, error)

func (CatalogRequest) String

func (r CatalogRequest) String() string

type CatalogSettings

type CatalogSettings struct {
	Model        string `json:"model,omitempty"`
	Profile      string `json:"profile,omitempty"`
	AuthKind     string `json:"auth_kind"`
	BillingRoute string `json:"billing_route"`
	CAPEM        string `json:"ca_pem,omitempty"`
}

type Cataloger

type Cataloger func(context.Context, Resolved) ([]CatalogItem, error)

type Connection

type Connection struct {
	ID                string                       `json:"id"`
	OrgID             string                       `json:"org_id"`
	Kind              string                       `json:"kind"`
	Provider          string                       `json:"provider"`
	Name              string                       `json:"name"`
	Endpoint          string                       `json:"endpoint"`
	Settings          Settings                     `json:"settings"`
	State             string                       `json:"state"`
	Reason            string                       `json:"reason"`
	Capabilities      map[string]domain.Capability `json:"capabilities"`
	ServerVersion     string                       `json:"server_version"`
	VerifiedAt        *time.Time                   `json:"verified_at"`
	KeyConfirmedAt    *time.Time                   `json:"key_confirmed_at,omitempty"`
	CredentialVersion int64                        `json:"credential_version"`
	Version           int64                        `json:"version"`
	Route             *Route                       `json:"private_route,omitempty"`
	SecretID          *string                      `json:"-"`
}

type CreateRequest

type CreateRequest struct {
	Kind         string   `json:"kind"`
	Provider     string   `json:"provider"`
	Name         string   `json:"name"`
	Endpoint     string   `json:"endpoint"`
	Settings     Settings `json:"settings"`
	Secret       string   `json:"secret"`
	PrivateRoute *Route   `json:"private_route,omitempty"`
}

func (CreateRequest) GoString

func (r CreateRequest) GoString() string

func (CreateRequest) LogValue

func (r CreateRequest) LogValue() slog.Value

func (CreateRequest) MarshalJSON

func (r CreateRequest) MarshalJSON() ([]byte, error)

func (CreateRequest) String

func (r CreateRequest) String() string

type InUseError

type InUseError struct {
	Repositories, Runs, Calls int
}

func (*InUseError) Error

func (e *InUseError) Error() string

func (*InUseError) Is

func (e *InUseError) Is(target error) bool

type PlatformApp

type PlatformApp struct {
	AppID         string
	PrivateKeyPEM []byte
}

func (PlatformApp) GoString

func (p PlatformApp) GoString() string

func (PlatformApp) LogValue

func (p PlatformApp) LogValue() slog.Value

func (PlatformApp) String

func (p PlatformApp) String() string

type ProbeAuthorization

type ProbeAuthorization func(context.Context, ProbeCall) error

type ProbeCall

type ProbeCall func(context.Context, pgx.Tx, Resolved) (ProbeResult, error)

type ProbeResult

type ProbeResult struct {
	Capabilities  map[string]domain.Capability `json:"capabilities"`
	ServerVersion string                       `json:"server_version"`
	State         string                       `json:"state"`
	Reason        string                       `json:"reason"`
}

type Prober

type Prober func(context.Context, Resolved) (ProbeResult, error)

type Resolved

type Resolved struct {
	Protection      *Resolved         `json:"-"`
	CheckPublishers map[string]string `json:"-"`
	Connection      Connection
	Secret          string       `json:"-"`
	Client          *http.Client `json:"-"`
}

func (Resolved) GoString

func (r Resolved) GoString() string

func (Resolved) LogValue

func (r Resolved) LogValue() slog.Value

func (Resolved) String

func (r Resolved) String() string

type Route

type Route struct {
	RunnerID   string     `json:"runner_id"`
	Host       string     `json:"host"`
	CIDRs      []string   `json:"cidrs"`
	ApprovedAt time.Time  `json:"approved_at"`
	RevokedAt  *time.Time `json:"revoked_at,omitempty"`
}

type RunnerCheck

type RunnerCheck func(context.Context, pgx.Tx, string, string) error

type Service

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

func New

func New(db *store.Store, identity *auth.Service, vault *secrets.Vault, development bool) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, session auth.Session, orgID string, r CreateRequest, requestID string) (Connection, error)

func (*Service) CreateManagedTx

func (s *Service) CreateManagedTx(ctx context.Context, tx pgx.Tx, a domain.Actor, c *Connection, secret, requestID string) error

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, session auth.Session, orgID, id string, expected int64, requestID string) error

func (*Service) Get

func (s *Service) Get(ctx context.Context, session auth.Session, orgID, id string) (Connection, error)

func (*Service) List

func (s *Service) List(ctx context.Context, session auth.Session, orgID, kind string, limit int, cursor string) (domain.Page[Connection], error)

func (*Service) MetadataTx

func (s *Service) MetadataTx(ctx context.Context, tx pgx.Tx, orgID, id string) (Connection, error)

func (*Service) ModelCatalog

func (s *Service) ModelCatalog(ctx context.Context, session auth.Session, orgID string, r CatalogRequest) ([]CatalogItem, error)

func (*Service) Register

func (s *Service) Register(kind, provider string, probe Prober)

func (*Service) RegisterCatalog

func (s *Service) RegisterCatalog(catalog Cataloger)

func (*Service) RegisterPrivateProbe

func (s *Service) RegisterPrivateProbe(probe PrivateProber)

func (*Service) RegisterRunnerCheck

func (s *Service) RegisterRunnerCheck(check RunnerCheck)

func (*Service) ResolveTx

func (s *Service) ResolveTx(ctx context.Context, tx pgx.Tx, orgID, id, runnerID string) (Resolved, error)

func (*Service) Revoke

func (s *Service) Revoke(ctx context.Context, session auth.Session, orgID, id string, expected int64, requestID string) (Connection, error)

func (*Service) Rewrap

func (s *Service) Rewrap(ctx context.Context, session auth.Session, orgID, id string, expected int64, requestID string) (Connection, error)

func (*Service) Rotate

func (s *Service) Rotate(ctx context.Context, session auth.Session, orgID, id string, expected int64, value, requestID string) (Connection, error)

func (*Service) SetPlatformApp

func (s *Service) SetPlatformApp(app PlatformApp)

func (*Service) SetRoute

func (s *Service) SetRoute(ctx context.Context, session auth.Session, orgID, id string, expected int64, route *Route, requestID string) (Connection, error)

func (*Service) Test

func (s *Service) Test(ctx context.Context, session auth.Session, orgID, id string, expected int64, requestID string) (Connection, error)

func (*Service) Update

func (s *Service) Update(ctx context.Context, session auth.Session, orgID, id string, expected int64, name, namespace string, requestID string) (Connection, error)

type Settings

type Settings struct {
	Namespace      string   `json:"namespace,omitempty"`
	Model          string   `json:"model,omitempty"`
	Profile        string   `json:"profile,omitempty"`
	AuthKind       string   `json:"auth_kind"`
	BillingRoute   string   `json:"billing_route"`
	AppID          string   `json:"app_id,omitempty"`
	InstallationID string   `json:"installation_id,omitempty"`
	RuntimeVersion string   `json:"runtime_version,omitempty"`
	CAPEM          string   `json:"ca_pem,omitempty"`
	AllowedModels  []string `json:"allowed_models,omitempty"`
	Managed        string   `json:"managed,omitempty"`
	WebhookPending bool     `json:"webhook_pending,omitempty"`
}

func (Settings) GitHubApp

func (s Settings) GitHubApp() bool

Jump to

Keyboard shortcuts

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