integration

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package integration models tenant-scoped external CI/CD connections and provider-neutral build provenance.

Index

Constants

View Source
const (
	MaxConfigBytes       = 32 << 10
	MaxCredentialBytes   = 16 << 10
	MaxPipelines         = 1000
	MaxBindingsPerPoll   = 100
	MaxRunsPerPoll       = 200
	MaxRequestsPerPoll   = 250
	MaxBytesPerPoll      = 32 << 20
	MaxOperationErrors   = 20
	MaxOperationErrorLen = 256
	DefaultPollInterval  = 5 * time.Minute
)

Variables

View Source
var ErrOperationBudgetExceeded = errors.New("integration operation budget exceeded")

Functions

func BoundedErrors

func BoundedErrors(errorsIn []string) []string

func CanonicalEndpoint

func CanonicalEndpoint(raw string) (string, error)

func CanonicalExternalKey

func CanonicalExternalKey(raw string) (string, error)

func ConsumeOperationBytes

func ConsumeOperationBytes(ctx context.Context, count int64) error

func ConsumeOperationRequest

func ConsumeOperationRequest(ctx context.Context) error

func DecodeConfig

func DecodeConfig(raw json.RawMessage) (map[string]any, error)

func IsRetryable

func IsRetryable(err error) bool

func PermanentError

func PermanentError(err error) error

func RetryableError

func RetryableError(err error) error

func SortDescriptors

func SortDescriptors(descriptors []ProviderDescriptor)

func WithOperationBudget

func WithOperationBudget(ctx context.Context, maxRequests int, maxBytes int64) context.Context

WithOperationBudget attaches an aggregate provider request/response budget to every adapter call made for one integration operation.

Types

type Adapter

type Adapter interface {
	Descriptor() ProviderDescriptor
}

type Binding

type Binding struct {
	ID            shared.ID `json:"id"`
	TenantID      shared.ID `json:"tenant_id"`
	IntegrationID shared.ID `json:"integration_id"`
	ProjectID     shared.ID `json:"project_id"`
	ExternalKey   string    `json:"external_key"`
	ExternalName  string    `json:"external_name"`
	Version       int       `json:"version"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

func (*Binding) Normalize

func (binding *Binding) Normalize() error

type Capability

type Capability string
const (
	CapabilityTestConnection Capability = "test_connection"
	CapabilityDiscover       Capability = "discover_pipelines"
	CapabilityReadRuns       Capability = "read_runs"
)

type ConnectionTester

type ConnectionTester interface {
	TestConnection(ctx context.Context) error
}

type CorrelationState

type CorrelationState string
const (
	CorrelationLinked    CorrelationState = "linked"
	CorrelationMissing   CorrelationState = "missing"
	CorrelationAmbiguous CorrelationState = "ambiguous"
)

type CredentialBundle

type CredentialBundle map[string]string

func (CredentialBundle) Clone

func (bundle CredentialBundle) Clone() CredentialBundle

type ExternalRun

type ExternalRun struct {
	ID                shared.ID        `json:"id"`
	TenantID          shared.ID        `json:"tenant_id"`
	IntegrationID     shared.ID        `json:"integration_id"`
	BindingID         shared.ID        `json:"binding_id,omitempty"`
	ProviderKey       string           `json:"provider_key"`
	PipelineKey       string           `json:"pipeline_key"`
	Number            string           `json:"number,omitempty"`
	URL               string           `json:"url,omitempty"`
	Lifecycle         RunLifecycle     `json:"lifecycle"`
	Result            RunResult        `json:"result"`
	Revision          string           `json:"revision,omitempty"`
	Branch            string           `json:"branch,omitempty"`
	AnalysisID        shared.ID        `json:"analysis_id,omitempty"`
	Correlation       CorrelationState `json:"correlation"`
	QueuedAt          *time.Time       `json:"queued_at,omitempty"`
	StartedAt         *time.Time       `json:"started_at,omitempty"`
	FinishedAt        *time.Time       `json:"finished_at,omitempty"`
	ProviderUpdatedAt time.Time        `json:"provider_updated_at"`
	CreatedAt         time.Time        `json:"created_at"`
	UpdatedAt         time.Time        `json:"updated_at"`
}

func (*ExternalRun) Normalize

func (run *ExternalRun) Normalize() error

type Factory

type Factory func(Integration, CredentialBundle) (Adapter, error)

type FieldDescriptor

type FieldDescriptor struct {
	Name        string    `json:"name"`
	Label       string    `json:"label"`
	Kind        FieldKind `json:"kind"`
	Required    bool      `json:"required"`
	Description string    `json:"description,omitempty"`
}

type FieldKind

type FieldKind string
const (
	FieldText     FieldKind = "text"
	FieldPassword FieldKind = "password"
	FieldBoolean  FieldKind = "boolean"
)

type Integration

type Integration struct {
	ID                   shared.ID       `json:"id"`
	TenantID             shared.ID       `json:"tenant_id"`
	Provider             Provider        `json:"provider"`
	Name                 string          `json:"name"`
	Endpoint             string          `json:"endpoint"`
	Config               json.RawMessage `json:"config"`
	AllowPrivateNetwork  bool            `json:"allow_private_network"`
	PollInterval         time.Duration   `json:"-"`
	Enabled              bool            `json:"enabled"`
	Archived             bool            `json:"archived"`
	Version              int             `json:"version"`
	ConnectionRevision   int             `json:"-"`
	CredentialRevision   int             `json:"-"`
	CredentialConfigured bool            `json:"credential_configured"`
	CreatedAt            time.Time       `json:"created_at"`
	UpdatedAt            time.Time       `json:"updated_at"`
}

func (Integration) Clone

func (item Integration) Clone() Integration

func (*Integration) Normalize

func (item *Integration) Normalize() error

type Operation

type Operation struct {
	ID                 shared.ID       `json:"id"`
	TenantID           shared.ID       `json:"tenant_id"`
	IntegrationID      shared.ID       `json:"integration_id"`
	Type               OperationType   `json:"type"`
	State              OperationState  `json:"state"`
	Checkpoint         string          `json:"checkpoint,omitempty"`
	Counts             OperationCounts `json:"counts"`
	Errors             []string        `json:"errors"`
	Pipelines          []Pipeline      `json:"pipelines,omitempty"`
	JobID              string          `json:"job_id"`
	Actor              string          `json:"actor"`
	ConnectionRevision int             `json:"-"`
	CredentialRevision int             `json:"-"`
	StartedAt          *time.Time      `json:"started_at,omitempty"`
	FinishedAt         *time.Time      `json:"finished_at,omitempty"`
	CreatedAt          time.Time       `json:"created_at"`
	UpdatedAt          time.Time       `json:"updated_at"`
}

func (Operation) Clone

func (operation Operation) Clone() Operation

type OperationCounts

type OperationCounts struct {
	Pipelines int `json:"pipelines"`
	Runs      int `json:"runs"`
	Linked    int `json:"linked"`
	Unlinked  int `json:"unlinked"`
	Errors    int `json:"errors"`
}

type OperationState

type OperationState string
const (
	OperationQueued    OperationState = "queued"
	OperationRunning   OperationState = "running"
	OperationSucceeded OperationState = "succeeded"
	OperationPartial   OperationState = "partial"
	OperationFailed    OperationState = "failed"
	OperationCancelled OperationState = "cancelled"
)

func (OperationState) Terminal

func (state OperationState) Terminal() bool

type OperationType

type OperationType string
const (
	OperationTest     OperationType = "test"
	OperationDiscover OperationType = "discover"
	OperationPoll     OperationType = "poll"
)

func (OperationType) Valid

func (operation OperationType) Valid() bool

type Pipeline

type Pipeline struct {
	ExternalKey string `json:"external_key"`
	Name        string `json:"name"`
	FullName    string `json:"full_name"`
	Kind        string `json:"kind"`
	URL         string `json:"url,omitempty"`
}

func (*Pipeline) Normalize

func (pipeline *Pipeline) Normalize() error

type PipelineDiscoverer

type PipelineDiscoverer interface {
	DiscoverPipelines(ctx context.Context, checkpoint string) (pipelines []Pipeline, nextCheckpoint string, err error)
}

type Provider

type Provider string

func NormalizeProvider

func NormalizeProvider(raw string) (Provider, error)

func (Provider) Valid

func (provider Provider) Valid() bool

type ProviderDescriptor

type ProviderDescriptor struct {
	Provider     Provider          `json:"provider"`
	Name         string            `json:"name"`
	Description  string            `json:"description"`
	Capabilities []Capability      `json:"capabilities"`
	ConfigFields []FieldDescriptor `json:"config_fields"`
	SecretFields []FieldDescriptor `json:"secret_fields"`
}

func (ProviderDescriptor) Supports

func (descriptor ProviderDescriptor) Supports(capability Capability) bool

func (ProviderDescriptor) Validate

func (descriptor ProviderDescriptor) Validate() error

func (ProviderDescriptor) ValidateConfig

func (descriptor ProviderDescriptor) ValidateConfig(config map[string]any) error

func (ProviderDescriptor) ValidateSecrets

func (descriptor ProviderDescriptor) ValidateSecrets(secrets map[string]string) error

type ProviderError

type ProviderError struct {
	// Err must contain a bounded, credential-free diagnostic suitable for an
	// integration operation history entry. Provider adapters are code-owned.
	Retryable bool
	Err       error
}

func (*ProviderError) Error

func (providerError *ProviderError) Error() string

func (*ProviderError) Unwrap

func (providerError *ProviderError) Unwrap() error

type Registry

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

Registry is code-owned. Runtime configuration can select a reviewed provider, but cannot upload or execute provider code.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Descriptor

func (registry *Registry) Descriptor(provider Provider) (ProviderDescriptor, error)

func (*Registry) Descriptors

func (registry *Registry) Descriptors() []ProviderDescriptor

func (*Registry) Register

func (registry *Registry) Register(descriptor ProviderDescriptor, factory Factory) error

func (*Registry) Resolve

func (registry *Registry) Resolve(item Integration, credentials CredentialBundle) (Adapter, error)

type RunLifecycle

type RunLifecycle string
const (
	RunQueued    RunLifecycle = "queued"
	RunRunning   RunLifecycle = "running"
	RunCompleted RunLifecycle = "completed"
)

type RunReader

type RunReader interface {
	ReadRuns(ctx context.Context, binding Binding, checkpoint string) (runs []ExternalRun, nextCheckpoint string, err error)
}

type RunResult

type RunResult string
const (
	ResultSuccess  RunResult = "success"
	ResultFailure  RunResult = "failure"
	ResultUnstable RunResult = "unstable"
	ResultAborted  RunResult = "aborted"
	ResultNotBuilt RunResult = "not_built"
	ResultUnknown  RunResult = "unknown"
)

Jump to

Keyboard shortcuts

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