codeconnections

package
v1.1.3 Latest Latest
Warning

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

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

README

CodeConnections

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

Coverage

Metric Value
Operations audited 27 (26 ok, 1 partial)
Feature families 3 (3 ok)
Known gaps 4
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, matches the identical codestarconnections gap)
  • CreateConnection with a HostArn referencing a nonexistent host is accepted without validation (real CreateConnection likely documents an unavailable-resource error for a bad host ARN, mirroring codestarconnections' identical deferred gap); left unfixed this pass because an existing test intentionally exercises an arbitrary un-created HostArn and the real trigger condition could not be confirmed without live AWS access (bd: file follow-up)
  • repositoryLinkItem (CreateRepositoryLink/GetRepositoryLink/UpdateRepositoryLink/ListRepositoryLinks response items) includes a "Tags" field, but the real RepositoryLinkInfo wire type (aws-sdk-go-v2/service/codeconnections/types.RepositoryLinkInfo) has no Tags member at all -- tags for a repository link are only ever returned via ListTagsForResource in the real API. This extra field is harmless to a real aws-sdk-go-v2 client (unrecognized JSON members are silently ignored by the deserializer) so it was left in place rather than risk breaking existing tests that assert on it; noted here so a future audit does not need to re-derive this finding (bd: file follow-up, low priority)
  • PullRequestComment (CreateSyncConfiguration/UpdateSyncConfiguration input, SyncConfiguration output) is present in this service's pinned SDK (aws-sdk-go-v2/service/codeconnections@v1.10.22 types.SyncConfiguration/CreateSyncConfigurationInput/UpdateSyncConfigurationInput) but not implemented here -- unlike codestarconnections, where the equivalent field was correctly deferred because it did NOT exist in that older service's pinned SDK version, this is a genuine missing field for codeconnections specifically (bd: file follow-up)
Deferred
  • ListRepositorySyncDefinitions pagination (NextToken) -- the real ListRepositorySyncDefinitionsOutput does support NextToken, but this was left unpaginated to match the established codestarconnections precedent for the same op; revisit both services together if this becomes a problem

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.
	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 documents
	// no dedicated typed error for this case ("Before you delete a host, all
	// connections associated to the host must be deleted."), so the closest
	// real, generic type is used instead of a fabricated name.
	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)
)

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 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 a stub latest sync status for a resource.

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 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 ResourceSyncStatus

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

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 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