codeconnections

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 25 Imported by: 0

README

CodeConnections

Parity grade: A · SDK aws-sdk-go-v2/service/codeconnections@v1.10.22 · last audited 2026-07-23 (749ff939+wt)

Coverage

Metric Value
Operations audited 27 (27 ok)
Feature families 5 (5 ok)
Known gaps 1
Deferred items 0
Resource leaks clean
Known gaps
  • CreateConnection/CreateHost reject duplicate ConnectionName/Name with ResourceAlreadyExistsException, but neither op's real error list (botocore codeconnections/2023-12-01/service-2.json) includes ResourceAlreadyExistsException at all (CreateConnection: [LimitExceededException, ResourceNotFoundException, ResourceUnavailableException]; CreateHost: [LimitExceededException] only) -- despite the Connection/Host struct doc comments both stating names 'must be unique in an Amazon Web Services account'. This is a genuine ambiguity in AWS's own published model (doc text implies enforcement, the per-op error list contradicts it) that cannot be resolved without live AWS access. Left unchanged this pass: the existing duplicate-rejection behavior has substantial test coverage (TestConnectionNameUniqueness, TestErrAlreadyExistsMapping, TestCreateHostNameUniqueness) and matches the codestarconnections precedent; ripping it out on a single ambiguous signal risked a worse regression than leaving it. (bd: file follow-up requiring live-AWS confirmation)

More

Documentation

Index

Constants

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

SyncBlocker status values (real AWS BlockerStatus enum).

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 resource already exists.
	ErrAlreadyExists = awserr.New("ResourceAlreadyExistsException", awserr.ErrConflict)
	// ErrValidation is returned when input validation fails. The real
	// aws-sdk-go-v2/service/codeconnections@v1.10.22 types/errors.go has no
	// ValidationException type at all (its modeled exception set is
	// AccessDeniedException/ConcurrentModificationException/
	// ConditionalCheckFailedException/ConflictException/
	// InternalServerException/InvalidInputException/LimitExceededException/
	// ResourceAlreadyExistsException/ResourceNotFoundException/
	// ResourceUnavailableException/RetryLatestCommitFailedException/
	// SyncBlockerDoesNotExistException/SyncConfigurationStillExistsException/
	// ThrottlingException/UnsupportedOperationException/
	// UnsupportedProviderTypeException/UpdateOutOfSyncException --
	// InvalidInputException is the real type for malformed/missing-required-
	// field input, confirmed against every mutating op's error list in
	// botocore's codeconnections/2023-12-01/service-2.json (e.g.
	// CreateSyncConfiguration, ListRepositorySyncDefinitions,
	// GetResourceSyncStatus all list InvalidInputException, none list
	// ValidationException).
	ErrValidation = awserr.New("InvalidInputException", awserr.ErrInvalidParameter)
	// ErrResourceInUse is returned when a host cannot be deleted because a
	// connection still references it ("Before you delete a host, all
	// connections associated to the host must be deleted."). A previous
	// audit pass used ConflictException here on the theory that "no
	// dedicated typed error is documented for this case" -- but DeleteHost's
	// real, complete error list (botocore codeconnections/2023-12-01/
	// service-2.json) is exactly [ResourceNotFoundException,
	// ResourceUnavailableException]; ConflictException is not a possible
	// error for this operation at all. ResourceUnavailableException is the
	// correct real type (its doc note also covers the sibling "host cannot
	// be deleted while VPC_CONFIG_INITIALIZING/VPC_CONFIG_DELETING" case,
	// the same "host not currently deletable" family as this one).
	ErrResourceInUse = awserr.New("ResourceUnavailableException", 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)
)

Functions

This section is empty.

Types

type Connection

type Connection struct {
	Tags           map[string]string `json:"tags,omitempty"`
	CreatedAt      time.Time         `json:"createdAt"`
	ConnectionName string            `json:"connectionName"`
	ConnectionArn  string            `json:"connectionArn"`
	HostArn        string            `json:"hostArn,omitempty"`
	OwnerAccountID string            `json:"ownerAccountID"`
	ProviderType   string            `json:"providerType"`
	Status         string            `json:"status"`
}

Connection represents an AWS CodeConnections 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 AWS CodeConnections operations (JSON 1.0 protocol).

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a new CodeConnections handler with a pre-built dispatch table.

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 CodeConnections 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 CodeConnections operation name 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 CodeConnections operations.

func (*Handler) Handler

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

Handler returns the Echo handler function for CodeConnections 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 AWS CodeConnections JSON 1.0 requests.

func (*Handler) Snapshot

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

Snapshot implements persistence.Persistable by delegating to the backend.

This delegation is required: cli.go's setupPersistence type-asserts the service.Registerable value returned by Provider.Init (the Handler, not InMemoryBackend) against a Snapshot/Restore interface -- since Handler itself never exposed either method before this fix, InMemoryBackend. Snapshot/Restore existed but were never reachable through the registered service, so CodeConnections state was silently never persisted.

type Host

type Host struct {
	Tags             map[string]string `json:"tags,omitempty"`
	CreatedAt        time.Time         `json:"createdAt"`
	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 AWS CodeConnections host (infrastructure endpoint).

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 the in-memory store for AWS CodeConnections 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 for Get/Delete/List/duplicate-name checks falls out of the byRegion/byName secondary indexes below, which derive their group key from the ARN. Both are registered directly on registry. repositoryLinks and syncConfigurations are "dirty": their own identity (RepositoryLinkID; ResourceName+SyncType) carries no region of its own, and lookups are scoped by the caller's context region rather than by any ARN, so each carries an unexported region-qualifying field and is registered with a composite "region|id" key (see regionKey). They are built with store.New only -- deliberately NOT store.Register-ed onto registry -- so registry.ResetAll()/SnapshotAll()/RestoreAll() never touch them directly; see Reset below and persistence.go's mixed clean/dirty Snapshot/Restore.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new in-memory CodeConnections backend.

func (*InMemoryBackend) AddConnectionInternal

func (b *InMemoryBackend) AddConnectionInternal(_ context.Context, conn *Connection)

AddConnectionInternal seeds a connection directly for testing.

func (*InMemoryBackend) AddHostInternal

func (b *InMemoryBackend) AddHostInternal(_ context.Context, 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 connection.

func (*InMemoryBackend) CreateHost

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

CreateHost creates a new host.

func (b *InMemoryBackend) CreateRepositoryLink(
	ctx context.Context,
	connectionArn, ownerID, repoName, encryptionKeyArn string,
	tags map[string]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,
	publishDeploymentStatus, triggerResourceUpdateOn, pullRequestComment string,
) (*SyncConfiguration, error)

CreateSyncConfiguration creates a new sync configuration.

func (*InMemoryBackend) DeleteConnection

func (b *InMemoryBackend) DeleteConnection(ctx 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. The real operation documents that all connections associated to a host must be deleted before the host itself can be deleted.

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

DeleteRepositoryLink removes a repository link by ID.

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(
	ctx context.Context,
	connectionArn string,
) (*Connection, error)

GetConnection retrieves a connection by ARN. The lookup is scoped to the caller's request region -- an ARN created in one region is not visible from another, matching the old per-region map's isolation.

func (*InMemoryBackend) GetHost

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

GetHost retrieves a host by ARN, scoped to the caller's request region (see GetConnection).

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, _, _ string,
) (*RepositorySyncStatus, error)

GetRepositorySyncStatus returns a stub 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 sync status for an AWS resource: the latest sync attempt (LatestSync), the resource's desired state (DesiredState), and the latest successful attempt (LatestSuccessfulSync), mirroring the real GetResourceSyncStatusOutput shape. Because this backend does not simulate actual git-repo content/history, every attempt is synthesized as an immediately-successful sync whose Initial/Target/Desired revisions all reflect the resource's current sync configuration.

func (*InMemoryBackend) GetSyncBlockerSummary

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

GetSyncBlockerSummary returns the real 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, 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 repository link's sync configurations. Real AWS docs state that "for CFN_STACK_SYNC the parent and target resource are the same".

func (*InMemoryBackend) ListSyncConfigurations

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

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

func (*InMemoryBackend) ListTagsForResource

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

ListTagsForResource returns the tags for a connection or host.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the AWS region this backend is configured for.

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) 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(
	ctx context.Context,
	resourceArn string,
	tags map[string]string,
) error

TagResource adds or updates tags on a connection or host.

func (*InMemoryBackend) UntagResource

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

UntagResource removes tags from a connection or host.

func (*InMemoryBackend) UpdateHost

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

UpdateHost updates the provider endpoint 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), returns ErrSyncBlockerNotFound -- the real 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,
	publishDeploymentStatus, triggerResourceUpdateOn, pullRequestComment string,
) (*SyncConfiguration, error)

UpdateSyncConfiguration updates fields on an existing sync configuration.

type Provider

type Provider struct{}

Provider implements service.Provider for AWS CodeConnections.

func (*Provider) Init

Init initializes the CodeConnections service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type RepositoryLink struct {
	Tags              map[string]string `json:"tags,omitempty"`
	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 AWS CodeConnections repository link.

type RepositorySyncDefinition

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

RepositorySyncDefinition describes a mapping from a repository branch to an Amazon Web Services resource that is being synced from that branch.

type RepositorySyncStatus

type RepositorySyncStatus struct {
	StartedAt time.Time
	Status    string
	Events    []SyncEvent
}

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

type ResourceSyncAttempt added in v1.2.0

type ResourceSyncAttempt struct {
	StartedAt       time.Time
	Status          string
	Target          string
	InitialRevision Revision
	TargetRevision  Revision
	Events          []SyncEvent
}

ResourceSyncAttempt mirrors the real ResourceSyncAttempt type used for both GetResourceSyncStatusOutput.LatestSync and .LatestSuccessfulSync (real wire-required members: Events/InitialRevision/StartedAt/Status/Target/ TargetRevision).

type ResourceSyncStatus

type ResourceSyncStatus struct {
	LatestSuccessfulSync *ResourceSyncAttempt
	DesiredState         Revision
	LatestSync           ResourceSyncAttempt
}

ResourceSyncStatus mirrors GetResourceSyncStatusOutput: the latest sync attempt for an AWS resource, its desired state, and (when available) the latest successful attempt.

type Revision added in v1.2.0

type Revision struct {
	Branch         string
	Directory      string
	OwnerID        string
	ProviderType   string
	RepositoryName string
	Sha            string
}

Revision mirrors AWS CodeConnections' Revision type: the state of an AWS resource as declared by its linked repository at a specific commit (real aws-sdk-go-v2/service/codeconnections@v1.10.22 types.Revision -- Branch/ Directory/OwnerId/ProviderType/RepositoryName/Sha are all required wire members).

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"`
	// PullRequestComment mirrors the real SyncConfiguration/
	// CreateSyncConfigurationInput/UpdateSyncConfigurationInput
	// PullRequestComment member (aws-sdk-go-v2/service/codeconnections@
	// v1.10.22 types.PullRequestComment, ENABLED|DISABLED) -- present in this
	// service's pinned SDK but previously never implemented here.
	PullRequestComment string `json:"pullRequestComment,omitempty"`
	// contains filtered or unexported fields
}

SyncConfiguration represents an AWS CodeConnections 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.

Jump to

Keyboard shortcuts

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