integration

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 16 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

Overview

Package integration is the machine API for ticket trackers (Tracklines): a flag per ticket that is created in the first environment, toggled, promoted along the environment chain, and archived when done. The tracker decides which board column triggers which call; every call here is idempotent.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("not found")
	ErrNoEnvironment = errors.New("agent has no environments")
	ErrNameTaken     = errors.New("flag name already used in that environment")
)

Functions

This section is empty.

Types

type AgentEnvironment

type AgentEnvironment struct {
	EnvironmentId string `json:"environment_id"`
	Name          string `json:"name"`
	Level         int    `json:"level"`
	Production    bool   `json:"production"`
}

type AgentFlag

type AgentFlag struct {
	Name   string      `json:"name"`
	Ticket string      `json:"ticket,omitempty"`
	States []FlagState `json:"states"`
}

AgentFlag is one flag across the agent's environments; States only lists environments it is in.

type AgentFlags

type AgentFlags struct {
	AgentId      string             `json:"agent_id"`
	Environments []AgentEnvironment `json:"environments"`
	Flags        []AgentFlag        `json:"flags"`
}

type AgentInfo

type AgentInfo struct {
	ProjectId    string             `json:"project_id"`
	ProjectName  string             `json:"project_name"`
	AgentId      string             `json:"agent_id"`
	AgentName    string             `json:"agent_name"`
	Environments []AgentEnvironment `json:"environments"`
}

type EnvironmentState

type EnvironmentState struct {
	EnvironmentId string `json:"environment_id"`
	Name          string `json:"name"`
	Level         int    `json:"level"`
	Present       bool   `json:"present"`
	Enabled       bool   `json:"enabled"`
	Production    bool   `json:"production"`
	// Rollout and Rules decide who gets the flag while it is enabled (100 and none = everyone); see flags.Decide.
	Rollout int          `json:"rollout"`
	Rules   []flags.Rule `json:"rules"`
	// contains filtered or unexported fields
}

type FlagChange added in v0.16.2

type FlagChange struct {
	Enabled *bool
	Rollout *int
	Rules   *[]flags.Rule
}

FlagChange is what a PATCH changes in one environment; nil fields stay as they are.

func (FlagChange) Valid added in v0.16.2

func (c FlagChange) Valid() error

Valid checks the change has something in it and is in bounds, the same bounds as the dashboard's.

type FlagState

type FlagState struct {
	EnvironmentId string       `json:"environment_id"`
	FlagId        string       `json:"flag_id"`
	Enabled       bool         `json:"enabled"`
	Rollout       int          `json:"rollout"`
	Rules         []flags.Rule `json:"rules"`
	// users served the flag on/off in the last 7 days (the server's own decisions)
	ServedOn  int `json:"served_on"`
	ServedOff int `json:"served_off"`
}

FlagState is one flag in one environment; FlagId is what the per-flag dashboard routes take.

type System

type System struct {
	Config *ConfigBuilder.Config
}

func NewSystem

func NewSystem(cfg *ConfigBuilder.Config) *System

func (*System) AgentFlagsHandler

func (s *System) AgentFlagsHandler(w http.ResponseWriter, r *http.Request)

AgentFlagsHandler: GET /agent/{agentId}/flags (dashboard user), the flag-first view of an agent.

func (*System) ArchiveAgentFlag

func (s *System) ArchiveAgentFlag(ctx context.Context, companyId, agentId, name string) error

ArchiveAgentFlag archives the agent's flag with this name in every environment.

func (*System) ArchiveAgentFlagHandler

func (s *System) ArchiveAgentFlagHandler(w http.ResponseWriter, r *http.Request)

ArchiveAgentFlagHandler: DELETE /agent/{agentId}/flags/{name} (dashboard user), removes a flag from every environment.

func (*System) ArchiveFlag

func (s *System) ArchiveFlag(w http.ResponseWriter, r *http.Request)

ArchiveFlag: DELETE /integration/tickets/{ticket}/flag; 204 even when there was nothing to archive.

func (*System) ArchiveTicketFlag

func (s *System) ArchiveTicketFlag(ctx context.Context, companyId, ticket string) error

ArchiveTicketFlag archives the ticket's flag in every environment; nothing to archive is not an error.

func (*System) CompanyForToken

func (s *System) CompanyForToken(ctx context.Context, raw string) (string, error)

CompanyForToken returns the public company id for a raw token, or "" when it is unknown.

func (*System) CreateFlag

func (s *System) CreateFlag(w http.ResponseWriter, r *http.Request)

CreateFlag: PUT /integration/tickets/{ticket}/flag {"agent_id","name"}; 201 when created, 200 when it already existed.

func (*System) CreateTicketFlag

func (s *System) CreateTicketFlag(ctx context.Context, companyId, ticket, agentId, name string) (*TicketFlag, bool, error)

CreateTicketFlag creates the flag, off, in the agent's first environment. If the ticket already has a flag it is returned unchanged (created=false), so retries are safe.

func (*System) CreateToken

func (s *System) CreateToken(ctx context.Context, companyId, name string) (string, error)

CreateToken returns the raw token; only its hash is stored, so it cannot be shown again.

func (*System) CreateTokenHandler

func (s *System) CreateTokenHandler(w http.ResponseWriter, r *http.Request)

CreateTokenHandler: POST /company/integration-token {"name"} (dashboard user); the token is only returned here.

func (*System) DeleteToken

func (s *System) DeleteToken(ctx context.Context, companyId, tokenId string) error

func (*System) DeleteTokenHandler

func (s *System) DeleteTokenHandler(w http.ResponseWriter, r *http.Request)

DeleteTokenHandler: DELETE /company/integration-token/{tokenId}

func (*System) GetAgentFlags

func (s *System) GetAgentFlags(ctx context.Context, companyId, agentId string) (*AgentFlags, error)

GetAgentFlags returns every flag of the agent grouped by name, with its state per environment.

func (*System) GetFlag

func (s *System) GetFlag(w http.ResponseWriter, r *http.Request)

GetFlag: GET /integration/tickets/{ticket}/flag

func (*System) GetTicketFlag

func (s *System) GetTicketFlag(ctx context.Context, companyId, ticket string) (*TicketFlag, error)

func (*System) ListAgents

func (s *System) ListAgents(ctx context.Context, companyId string) ([]AgentInfo, error)

func (*System) ListAgentsHandler

func (s *System) ListAgentsHandler(w http.ResponseWriter, r *http.Request)

ListAgentsHandler: GET /integration/agents, for a tracker's settings picker.

func (*System) ListTokens

func (s *System) ListTokens(ctx context.Context, companyId string) ([]Token, error)

func (*System) ListTokensHandler

func (s *System) ListTokensHandler(w http.ResponseWriter, r *http.Request)

ListTokensHandler: GET /company/integration-tokens

func (*System) MCPHandler

func (s *System) MCPHandler() http.Handler

MCPHandler serves /mcp (streamable HTTP, stateless) for the integration token's company.

func (*System) PromoteFlag

func (s *System) PromoteFlag(w http.ResponseWriter, r *http.Request)

PromoteFlag: POST /integration/tickets/{ticket}/flag/promote[?to=production]

func (*System) PromoteTicketFlag

func (s *System) PromoteTicketFlag(ctx context.Context, companyId, ticket string, toProduction bool) (*TicketFlag, error)

PromoteTicketFlag adds the flag, off, to the next environment after the deepest one it is in, or to every remaining environment when toProduction is set. Already at production is a no-op.

func (*System) SetFlag

func (s *System) SetFlag(w http.ResponseWriter, r *http.Request)

SetFlag: PATCH /integration/tickets/{ticket}/flag {"environment_id", "enabled"?, "rollout"?, "rules"?}; at least one of the three. Rules replace the environment's rules ([] clears them).

func (*System) SetTicketFlag

func (s *System) SetTicketFlag(ctx context.Context, companyId, ticket, environmentId string, c FlagChange) error

type TicketFlag

type TicketFlag struct {
	Ticket       string             `json:"ticket"`
	Name         string             `json:"name"`
	AgentId      string             `json:"agent_id"`
	Environments []EnvironmentState `json:"environments"`
	// contains filtered or unexported fields
}

type Token

type Token struct {
	Id        int       `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
}

Jump to

Keyboard shortcuts

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