codestarconnections

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 24 Imported by: 0

README

CodeStar Connections

Parity grade: A · SDK aws-sdk-go-v2/service/codestarconnections@v1.35.15 · last audited 2026-07-13 (3f6a5e93)

Coverage

Metric Value
Operations audited 27 (26 ok, 1 partial)
Feature families 3 (3 ok)
Known gaps 3
Deferred items 1
Resource leaks clean
Known gaps
  • GetResourceSyncStatus does not populate optional DesiredState/LatestSuccessfulSync (types.Revision) fields — would require simulating actual git repo content/SHAs, out of scope for this pass (bd: file follow-up)
  • CreateConnection with a HostArn referencing a nonexistent host is accepted without validation (real CreateConnection documents ResourceUnavailableException for a bad host ARN); left unfixed this pass because an existing test (TestAudit2_Connection_HostArnIncludedWhenSet) intentionally exercises an arbitrary un-created HostArn and the real trigger condition (existence vs. malformed-ARN-format) could not be confirmed without live AWS access (bd: file follow-up)
  • CreateConnection/CreateHost duplicate-name rejection (ErrAlreadyExists, InvalidInputException) has no direct confirmation in the real per-op error lists (which show only LimitExceededException/ResourceNotFoundException/ResourceUnavailableException for CreateConnection and only LimitExceededException for CreateHost) — left as-is since the Connection type doc explicitly states "Connection names must be unique in an Amazon Web Services account", and InvalidInputException is the most plausible untyped/common-error bucket; not changed for lack of stronger evidence
Deferred
  • PullRequestComment field (CreateSyncConfiguration/UpdateSyncConfiguration/SyncConfiguration) — present in current AWS API docs but NOT in the pinned aws-sdk-go-v2@v1.35.15 SDK's types/serializers/deserializers; correctly omitted to match the SDK version actually vendored by this repo

More

Documentation

Overview

Package codestarconnections provides an in-memory implementation of the AWS CodeStar Connections service.

Index

Constants

View Source
const (
	ConnectionStatusAvailable = "AVAILABLE"
	ConnectionStatusPending   = "PENDING"
	ConnectionStatusError     = "ERROR"
)

Connection status values.

View Source
const (
	HostStatusAvailable           = "AVAILABLE"
	HostStatusPending             = "PENDING"
	HostStatusVPCConfigDeleting   = "VPC_CONFIG_DELETING"
	HostStatusVPCConfigFailed     = "VPC_CONFIG_FAILED"
	HostStatusVPCConfigInProgress = "VPC_CONFIG_IN_PROGRESS"
)

Host status values.

View Source
const (
	SyncStatusSucceeded  = "SUCCEEDED"
	SyncStatusFailed     = "FAILED"
	SyncStatusInProgress = "IN_PROGRESS"
	SyncStatusQueued     = "QUEUED"
)

Sync status values.

View Source
const (
	SyncBlockerStatusActive   = "ACTIVE"
	SyncBlockerStatusResolved = "RESOLVED"
)

SyncBlocker status values.

View Source
const (
	SyncBlockerTypeAutomated = "AUTOMATED"
	SyncBlockerTypeManual    = "MANUAL"
)

SyncBlocker type values.

Variables

View Source
var (
	// ErrNotFound is returned when a requested resource does not exist.
	ErrNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound)
	// ErrAlreadyExists is returned when a connection or host with the same name
	// already exists. The real CreateConnection/CreateHost operations do not
	// document a dedicated typed exception for this, so it maps to the generic
	// InvalidInputException (see handler.go's error switch).
	ErrAlreadyExists = awserr.New("InvalidInputException", awserr.ErrAlreadyExists)
	// ErrResourceAlreadyExists is returned when a repository link or sync
	// configuration with the same identity already exists. Unlike
	// ErrAlreadyExists above, the real CreateRepositoryLink/CreateSyncConfiguration
	// operations both register a dedicated ResourceAlreadyExistsException for
	// this case (confirmed against aws-sdk-go-v2's per-op error deserializers).
	ErrResourceAlreadyExists = awserr.New("ResourceAlreadyExistsException", awserr.ErrAlreadyExists)
	// ErrValidation is returned when input validation fails.
	ErrValidation = awserr.New("ValidationException", awserr.ErrInvalidParameter)
	// ErrResourceInUse is returned when a host cannot be deleted because a
	// connection still references it. The real DeleteHost operation does not
	// document a dedicated typed exception for this either, so it maps to the
	// generic ConflictException ("two conflicting operations... on the same
	// resource"), which at least exists in the real service's error catalog
	// (unlike a fabricated "ResourceInUseException", which does not).
	ErrResourceInUse = awserr.New("ConflictException", awserr.ErrConflict)
	// ErrSyncConfigStillExists is returned when a repository link cannot be
	// deleted because a sync configuration still references it. The real
	// DeleteRepositoryLink operation documents SyncConfigurationStillExistsException
	// for exactly this case.
	ErrSyncConfigStillExists = awserr.New("SyncConfigurationStillExistsException", awserr.ErrConflict)
	// ErrSyncBlockerNotFound is returned by UpdateSyncBlocker when the blocker ID
	// does not exist (or was created in a different region). The real operation
	// documents SyncBlockerDoesNotExistException for this case; it does NOT
	// resolve unknown IDs gracefully.
	ErrSyncBlockerNotFound = awserr.New("SyncBlockerDoesNotExistException", awserr.ErrNotFound)
)
View Source
var ErrNilAppContext = errors.New("AppContext is required")

ErrNilAppContext is returned when Provider.Init is called with a nil AppContext.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	Tags             map[string]string `json:"tags,omitempty"`
	ConnectionName   string            `json:"connectionName"`
	ConnectionArn    string            `json:"connectionArn"`
	ConnectionStatus string            `json:"connectionStatus"`
	OwnerAccountID   string            `json:"ownerAccountId"`
	ProviderType     string            `json:"providerType"`
	HostArn          string            `json:"hostArn,omitempty"`
}

Connection represents an in-memory AWS CodeStar connection.

ConnectionArn already embeds its own region (arn:partition:service:region: account:resource, see regionFromARN), so Connection needs no hidden region field: store_setup.go's connections table is keyed directly by ConnectionArn and its byRegion/byName indexes derive region from the ARN.

type Handler

type Handler struct {
	Backend *InMemoryBackend
	// contains filtered or unexported fields
}

Handler is the Echo HTTP handler for CodeStar Connections operations.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a new CodeStar Connections handler backed by backend.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns all regions this handler instance handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation extracts the CodeStar Connections action from the X-Amz-Target header.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource extracts the primary resource identifier from the JSON request body.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations returns the list of supported operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler function for CodeStar Connections requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears the backend state (test helper).

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher returns a function that matches CodeStar Connections requests.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

Without this delegation, cli.go's setupPersistence type-asserts the service.Registerable value returned by Provider.Init (this Handler, not InMemoryBackend) against a Snapshot/Restore interface -- since Handler itself never exposed either method, InMemoryBackend.Snapshot/Restore (persistence.go) were dead code and this service was never actually persisted, despite implementing the Persistable contract.

type Host

type Host struct {
	Tags             map[string]string `json:"tags,omitempty"`
	VpcConfiguration *VpcConfiguration `json:"vpcConfiguration,omitempty"`
	Name             string            `json:"name"`
	HostArn          string            `json:"hostArn"`
	ProviderType     string            `json:"providerType"`
	ProviderEndpoint string            `json:"providerEndpoint"`
	Status           string            `json:"status"`
	StatusMessage    string            `json:"statusMessage,omitempty"`
}

Host represents an in-memory AWS CodeStar host.

Like Connection, HostArn already embeds its own region, so Host needs no hidden region field either.

type InMemoryBackend

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

InMemoryBackend is a thread-safe in-memory store for CodeStar Connections resources.

connections and hosts are "clean" store.Table collections (see store_setup.go): each is keyed directly by its own ARN, which already embeds its region, so region isolation falls out of the byRegion/byName indexes with no hidden fields needed. repositoryLinks, syncConfigurations, repositorySyncStatuses, resourceSyncStatuses, and syncBlockers are "dirty": their identity (RepositoryLinkID; ResourceName+SyncType; RepositoryLinkID+Branch+SyncType; ResourceName+SyncType; ID) carries no region of its own, and lookups for the first four are scoped by the caller's context region (not by any embedded ARN region), so each type carries an unexported region-qualifying field and is registered with a composite "region|id" key. connections/hosts are registered on registry; the five dirty tables are NOT (store.New only), so they are excluded from registry.ResetAll() and must be reset explicitly -- see Reset below and persistence.go's mixed clean/dirty Snapshot/Restore.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new backend for the given account and region.

func (*InMemoryBackend) AccountID

func (b *InMemoryBackend) AccountID() string

AccountID returns the account ID for this backend instance.

func (*InMemoryBackend) AddConnectionInternal

func (b *InMemoryBackend) AddConnectionInternal(conn *Connection)

AddConnectionInternal seeds a connection directly for testing.

func (*InMemoryBackend) AddHostInternal

func (b *InMemoryBackend) AddHostInternal(host *Host)

AddHostInternal seeds a host directly for testing.

func (*InMemoryBackend) AddRepositoryLinkInternal

func (b *InMemoryBackend) AddRepositoryLinkInternal(ctx context.Context, link *RepositoryLink)

AddRepositoryLinkInternal seeds a repository link directly for testing.

func (*InMemoryBackend) CreateConnection

func (b *InMemoryBackend) CreateConnection(
	ctx context.Context,
	name, providerType, hostArn string,
	tags map[string]string,
) (*Connection, error)

CreateConnection creates a new CodeStar connection.

func (*InMemoryBackend) CreateHost

func (b *InMemoryBackend) CreateHost(
	ctx context.Context,
	name, providerType, providerEndpoint string,
	vpcConfig *VpcConfiguration,
	tags map[string]string,
) (*Host, error)

CreateHost creates a new CodeStar host.

func (b *InMemoryBackend) CreateRepositoryLink(
	ctx context.Context,
	connectionArn, ownerID, repoName, encryptionKeyArn string,
) (*RepositoryLink, error)

CreateRepositoryLink creates a new repository link.

func (*InMemoryBackend) CreateSyncBlocker

func (b *InMemoryBackend) CreateSyncBlocker(
	ctx context.Context,
	resourceName, syncType, blockerType, createdReason string,
) (*SyncBlocker, error)

CreateSyncBlocker creates a new sync blocker for a resource (test helper + internal use).

func (*InMemoryBackend) CreateSyncConfiguration

func (b *InMemoryBackend) CreateSyncConfiguration(
	ctx context.Context,
	branch, configFile, repositoryLinkID, resourceName, roleArn, syncType string,
) (*SyncConfiguration, error)

CreateSyncConfiguration creates a new sync configuration.

func (*InMemoryBackend) CreateSyncConfigurationFull

func (b *InMemoryBackend) CreateSyncConfigurationFull(
	ctx context.Context,
	branch, configFile, repositoryLinkID, resourceName, roleArn, syncType,
	publishDeploymentStatus, triggerResourceUpdateOn string,
) (*SyncConfiguration, error)

CreateSyncConfigurationFull creates a sync configuration with optional PublishDeploymentStatus and TriggerResourceUpdateOn.

func (*InMemoryBackend) DeleteConnection

func (b *InMemoryBackend) DeleteConnection(_ context.Context, connectionArn string) error

DeleteConnection removes a connection by ARN.

func (*InMemoryBackend) DeleteHost

func (b *InMemoryBackend) DeleteHost(ctx context.Context, hostArn string) error

DeleteHost removes a host by ARN. Returns ErrResourceInUse if any connection references the host.

func (b *InMemoryBackend) DeleteRepositoryLink(ctx context.Context, repositoryLinkID string) error

DeleteRepositoryLink removes a repository link by ID. Returns ErrResourceInUse if sync configs reference it.

func (*InMemoryBackend) DeleteSyncConfiguration

func (b *InMemoryBackend) DeleteSyncConfiguration(ctx context.Context, resourceName, syncType string) error

DeleteSyncConfiguration removes a sync configuration.

func (*InMemoryBackend) GetConnection

func (b *InMemoryBackend) GetConnection(_ context.Context, connectionArn string) (*Connection, error)

GetConnection returns a connection by ARN.

func (*InMemoryBackend) GetHost

func (b *InMemoryBackend) GetHost(_ context.Context, hostArn string) (*Host, error)

GetHost returns a host by ARN.

func (b *InMemoryBackend) GetRepositoryLink(ctx context.Context, repositoryLinkID string) (*RepositoryLink, error)

GetRepositoryLink retrieves a repository link by ID.

func (*InMemoryBackend) GetRepositorySyncStatus

func (b *InMemoryBackend) GetRepositorySyncStatus(
	ctx context.Context,
	repositoryLinkID, branch, syncType string,
) (*RepositorySyncStatus, error)

GetRepositorySyncStatus returns the latest sync status for a repository link and branch.

func (*InMemoryBackend) GetResourceSyncStatus

func (b *InMemoryBackend) GetResourceSyncStatus(
	ctx context.Context,
	resourceName, syncType string,
) (*ResourceSyncStatus, error)

GetResourceSyncStatus returns the latest sync status for a resource.

func (*InMemoryBackend) GetSyncBlockerSummary

func (b *InMemoryBackend) GetSyncBlockerSummary(
	ctx context.Context,
	resourceName, syncType string,
) (*SyncBlockerSummary, error)

GetSyncBlockerSummary returns the sync blocker summary for a resource.

func (*InMemoryBackend) GetSyncConfiguration

func (b *InMemoryBackend) GetSyncConfiguration(
	ctx context.Context,
	resourceName, syncType string,
) (*SyncConfiguration, error)

GetSyncConfiguration retrieves a sync configuration by resource name and sync type.

func (*InMemoryBackend) ListConnections

func (b *InMemoryBackend) ListConnections(ctx context.Context, providerTypeFilter, hostArnFilter string) []*Connection

ListConnections returns all connections sorted by name, optionally filtered by provider type or host ARN.

func (*InMemoryBackend) ListHosts

func (b *InMemoryBackend) ListHosts(ctx context.Context) []*Host

ListHosts returns all hosts sorted by name.

func (b *InMemoryBackend) ListRepositoryLinks(ctx context.Context) []*RepositoryLink

ListRepositoryLinks returns all repository links sorted by ID.

func (*InMemoryBackend) ListRepositorySyncDefinitions

func (b *InMemoryBackend) ListRepositorySyncDefinitions(
	ctx context.Context,
	repositoryLinkID, syncType string,
) ([]RepositorySyncDefinition, error)

ListRepositorySyncDefinitions returns the sync definitions derived from the sync configurations linked to repositoryLinkID, optionally filtered by syncType. Directory is sourced from each sync configuration's ConfigFile (per AWS docs: "This value comes from creating or updating the config-file field of a sync-configuration"). For CFN_STACK_SYNC -- the only SyncType gopherstack supports -- AWS docs state "the parent and target resource are the same", so Parent and Target both equal ResourceName.

func (*InMemoryBackend) ListSyncConfigurations

func (b *InMemoryBackend) ListSyncConfigurations(
	ctx context.Context,
	repositoryLinkID, syncType string,
) []*SyncConfiguration

ListSyncConfigurations returns all sync configurations for a given repository link and sync type.

func (*InMemoryBackend) ListTagsForResource

func (b *InMemoryBackend) ListTagsForResource(_ context.Context, resourceArn string) (map[string]string, error)

ListTagsForResource returns the tags for a resource by ARN.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the default region for this backend instance.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all state in the backend.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) SetRepositorySyncStatus

func (b *InMemoryBackend) SetRepositorySyncStatus(
	ctx context.Context,
	repositoryLinkID, branch, syncType, status string,
	events []SyncEvent,
)

SetRepositorySyncStatus stores a sync status for a repository link/branch/syncType (test helper).

func (*InMemoryBackend) SetResourceSyncStatus

func (b *InMemoryBackend) SetResourceSyncStatus(
	ctx context.Context,
	resourceName, syncType, status string,
	events []SyncEvent,
)

SetResourceSyncStatus stores a sync status for a resource (test helper).

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(_ context.Context, resourceArn string, tags map[string]string) error

TagResource adds or updates tags on a resource.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(_ context.Context, resourceArn string, tagKeys []string) error

UntagResource removes tags from a resource.

func (*InMemoryBackend) UpdateHost

func (b *InMemoryBackend) UpdateHost(
	_ context.Context,
	hostArn, providerEndpoint string,
	vpcConfig *VpcConfiguration,
) error

UpdateHost updates the provider endpoint and optional VPC configuration for a host.

func (b *InMemoryBackend) UpdateRepositoryLink(
	ctx context.Context,
	repositoryLinkID, connectionArn, encryptionKeyArn string,
) (*RepositoryLink, error)

UpdateRepositoryLink updates the connection ARN or encryption key for a repository link.

func (*InMemoryBackend) UpdateSyncBlocker

func (b *InMemoryBackend) UpdateSyncBlocker(
	ctx context.Context,
	id, resolvedReason string,
) (*SyncBlockerSummary, error)

UpdateSyncBlocker resolves a sync blocker by ID. If the blocker ID is not found (or was created in a different region than the caller's context, matching the original map-based lookup's region scoping), returns ErrSyncBlockerNotFound -- the real UpdateSyncBlocker operation documents SyncBlockerDoesNotExistException for exactly this case, it does not resolve unknown IDs gracefully.

func (*InMemoryBackend) UpdateSyncConfiguration

func (b *InMemoryBackend) UpdateSyncConfiguration(
	ctx context.Context,
	resourceName, syncType, branch, configFile, repositoryLinkID, roleArn string,
) (*SyncConfiguration, error)

UpdateSyncConfiguration updates branch, config file, role ARN, or repository link for a sync configuration.

func (*InMemoryBackend) UpdateSyncConfigurationFull

func (b *InMemoryBackend) UpdateSyncConfigurationFull(
	ctx context.Context,
	resourceName, syncType, branch, configFile, repositoryLinkID, roleArn,
	publishDeploymentStatus, triggerResourceUpdateOn string,
) (*SyncConfiguration, error)

UpdateSyncConfigurationFull updates a sync configuration including optional publish/trigger fields.

type Provider

type Provider struct{}

Provider implements service.Provider for AWS CodeStar Connections.

func (*Provider) Init

Init initializes the CodeStar Connections service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type RepositoryLink struct {
	CreatedAt         time.Time `json:"createdAt"`
	ConnectionArn     string    `json:"connectionArn"`
	OwnerID           string    `json:"ownerID"`
	RepositoryName    string    `json:"repositoryName"`
	RepositoryLinkID  string    `json:"repositoryLinkID"`
	RepositoryLinkArn string    `json:"repositoryLinkArn"`
	ProviderType      string    `json:"providerType"`
	EncryptionKeyArn  string    `json:"encryptionKeyArn,omitempty"`
	// contains filtered or unexported fields
}

RepositoryLink represents an in-memory AWS CodeStar Connections repository link.

type RepositorySyncDefinition

type RepositorySyncDefinition struct {
	Branch    string
	Directory string
	Parent    string
	Target    string
}

RepositorySyncDefinition is a mapping from a repository branch to the AWS resource(s) being synced from that branch (see AWS docs for RepositorySyncDefinition).

type RepositorySyncStatus

type RepositorySyncStatus struct {
	StartedAt time.Time
	Status    string

	Events []SyncEvent
	// contains filtered or unexported fields
}

RepositorySyncStatus holds the latest sync attempt information for a repository link.

type ResourceSyncStatus

type ResourceSyncStatus struct {
	StartedAt time.Time
	Status    string

	Events []SyncEvent
	// contains filtered or unexported fields
}

ResourceSyncStatus holds the latest sync attempt for an AWS resource.

type SyncBlocker

type SyncBlocker struct {
	ID             string
	Type           string
	Status         string
	CreatedAt      time.Time
	CreatedReason  string
	ResolvedAt     *time.Time
	ResolvedReason string
	ResourceName   string
	SyncType       string
	// contains filtered or unexported fields
}

SyncBlocker represents a single sync blocker entry.

type SyncBlockerSummary

type SyncBlockerSummary struct {
	ResourceName       string
	ParentResourceName string
	LatestBlockers     []SyncBlocker
}

SyncBlockerSummary is a summary of sync blockers for a resource.

type SyncConfiguration

type SyncConfiguration struct {
	CreatedAt               time.Time `json:"createdAt"`
	Branch                  string    `json:"branch"`
	ConfigFile              string    `json:"configFile"`
	RepositoryLinkID        string    `json:"repositoryLinkID"`
	ResourceName            string    `json:"resourceName"`
	RoleArn                 string    `json:"roleArn"`
	SyncType                string    `json:"syncType"`
	OwnerID                 string    `json:"ownerID"`
	ProviderType            string    `json:"providerType"`
	RepositoryName          string    `json:"repositoryName"`
	PublishDeploymentStatus string    `json:"publishDeploymentStatus,omitempty"`
	TriggerResourceUpdateOn string    `json:"triggerResourceUpdateOn,omitempty"`
	// contains filtered or unexported fields
}

SyncConfiguration represents an in-memory AWS CodeStar Connections sync configuration.

type SyncEvent

type SyncEvent struct {
	Time       time.Time
	Event      string
	Type       string
	ExternalID string
}

SyncEvent is a single event in a sync attempt.

type VpcConfiguration

type VpcConfiguration struct {
	VpcID            string   `json:"VpcId"`
	TLSCertificate   string   `json:"TlsCertificate,omitempty"`
	SubnetIDs        []string `json:"SubnetIds"`
	SecurityGroupIDs []string `json:"SecurityGroupIds"`
}

VpcConfiguration holds the VPC connectivity settings for a host.

Jump to

Keyboard shortcuts

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