serverlessrepo

package
v1.1.2 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

Serverless Application Repository

Parity grade: B · SDK aws-sdk-go-v2/service/serverlessapplicationrepository@v1.30.11 · last audited 2026-07-13 (07f98c0e)

Coverage

Metric Value
Operations audited 14 (14 ok)
Feature families 2 (2 ok)
Known gaps 2
Deferred items 0
Resource leaks clean
Known gaps
  • CreateCloudFormationChangeSet's TemplateId request field is accepted but not validated against an existing CreateCloudFormationTemplate record (bd: none filed -- low value, no client-visible breakage since gopherstack always succeeds rather than wrongly rejecting)
  • ListApplicationVersions summaries include a non-wire "resourcesSupported" key not present in the real VersionSummary shape; non-breaking (extra JSON fields are ignored by aws-sdk-go-v2's generated deserializer) but inaccurate if something inspects raw JSON. Left unfixed this pass since 3 existing tests assert its presence and no functional benefit accrues from removing it (bd: none filed).

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrApplicationNotFound is returned when an application does not exist.
	ErrApplicationNotFound = awserr.New("NotFoundException", awserr.ErrNotFound)
	// ErrApplicationAlreadyExists is returned when an application already exists.
	ErrApplicationAlreadyExists = awserr.New("ConflictException", awserr.ErrConflict)
	// ErrTemplateNotFound is returned when a CloudFormation template does not exist.
	ErrTemplateNotFound = awserr.New("NotFoundException", awserr.ErrNotFound)
	// ErrVersionAlreadyExists is returned when an application version already exists.
	ErrVersionAlreadyExists = awserr.New("ConflictException", awserr.ErrConflict)
	// ErrValidation is returned when a request contains an invalid or missing parameter.
	ErrValidation = awserr.New("BadRequestException", awserr.ErrInvalidParameter)
)
View Source
var ErrNilAppContext = errors.New("nil AppContext passed to ServerlessRepo Provider.Init")

ErrNilAppContext is returned by Init when a nil AppContext is passed.

Functions

This section is empty.

Types

type Application

type Application struct {
	CreationTime      time.Time `json:"creationTime"`
	LicenseURL        string    `json:"licenseUrl,omitempty"`
	Name              string    `json:"name"`
	Description       string    `json:"description,omitempty"`
	Author            string    `json:"author,omitempty"`
	HomePageURL       string    `json:"homePageUrl,omitempty"`
	ApplicationID     string    `json:"applicationId"`
	ReadmeURL         string    `json:"readmeUrl,omitempty"`
	SpdxLicenseID     string    `json:"spdxLicenseId,omitempty"`
	SourceCodeURL     string    `json:"sourceCodeUrl,omitempty"`
	SemanticVersion   string    `json:"semanticVersion,omitempty"`
	VerifiedAuthorURL string    `json:"verifiedAuthorUrl,omitempty"`
	Labels            []string  `json:"labels,omitempty"`
	IsVerifiedAuthor  bool      `json:"isVerifiedAuthor"`
}

Application represents an AWS Serverless Application Repository application.

type ApplicationDependency

type ApplicationDependency struct {
	ApplicationID   string `json:"applicationId"`
	SemanticVersion string `json:"semanticVersion"`
}

ApplicationDependency represents a nested application dependency.

type ApplicationPolicyStatement

type ApplicationPolicyStatement struct {
	StatementID     string   `json:"statementId,omitempty"`
	Actions         []string `json:"actions"`
	Principals      []string `json:"principals"`
	PrincipalOrgIDs []string `json:"principalOrgIDs,omitempty"`
}

ApplicationPolicyStatement represents a policy statement for an application.

type ApplicationVersion

type ApplicationVersion struct {
	CreationTime         time.Time `json:"creationTime"`
	ApplicationID        string    `json:"applicationId"`
	SemanticVersion      string    `json:"semanticVersion"`
	SourceCodeURL        string    `json:"sourceCodeUrl,omitempty"`
	SourceCodeArchiveURL string    `json:"sourceCodeArchiveUrl,omitempty"`
	TemplateURL          string    `json:"templateUrl,omitempty"`
	// AppName identifies the owning application. It exists purely so the
	// flattened store.Table[ApplicationVersion] (see store_setup.go; this
	// collection was previously nested appName -> semanticVersion -> *version)
	// can derive its composite "appName#semanticVersion" key from the value
	// alone -- SemanticVersion is unique only within an application, not
	// globally. It is not part of the Serverless Application Repository wire
	// API, hence json:"-".
	AppName              string                `json:"-"`
	ParameterDefinitions []ParameterDefinition `json:"parameterDefinitions"`
	RequiredCapabilities []string              `json:"requiredCapabilities"`
	ResourcesSupported   bool                  `json:"resourcesSupported"`
}

ApplicationVersion represents a version of a Serverless Application Repository application.

type CloudFormationChangeSet

type CloudFormationChangeSet struct {
	ApplicationID   string `json:"applicationId"`
	ChangeSetID     string `json:"changeSetId"`
	SemanticVersion string `json:"semanticVersion,omitempty"`
	StackID         string `json:"stackId"`
	// AppName identifies the owning application. It exists purely so the
	// flattened store.Table[CloudFormationChangeSet] (see store_setup.go;
	// this collection was previously nested appName -> changeSetID -> *cs)
	// can derive its composite "appName#changeSetID" key from the value
	// alone -- ChangeSetID is derived from a caller-supplied changeSetName/
	// stackName and is unique only within an application, not globally. It is
	// not part of the Serverless Application Repository wire API, hence
	// json:"-".
	AppName      string   `json:"-"`
	Capabilities []string `json:"capabilities,omitempty"`
	Tags         []Tag    `json:"tags,omitempty"`
}

CloudFormationChangeSet represents a CloudFormation change set for an application.

type CloudFormationTemplate

type CloudFormationTemplate struct {
	CreationTime    time.Time `json:"creationTime"`
	ExpirationTime  time.Time `json:"expirationTime"`
	ApplicationID   string    `json:"applicationId"`
	TemplateID      string    `json:"templateId"`
	SemanticVersion string    `json:"semanticVersion,omitempty"`
	Status          string    `json:"status"`
	TemplateURL     string    `json:"templateUrl,omitempty"`
	// AppName identifies the owning application. TemplateID is already
	// globally unique (it is generated as "<appName>-<unixNano>"), so it
	// remains the store.Table[CloudFormationTemplate] primary key (see
	// store_setup.go); AppName exists purely to drive the additive "byApp"
	// secondary index used for DeleteApplication's cascade delete. It is not
	// part of the Serverless Application Repository wire API, hence json:"-".
	AppName string `json:"-"`
}

CloudFormationTemplate represents a CloudFormation template for an application.

type CreateApplicationVersionOptions

type CreateApplicationVersionOptions struct {
	SourceCodeURL        string
	SourceCodeArchiveURL string
	TemplateURL          string
}

CreateApplicationVersionOptions contains optional AWS SAR version inputs.

type CreateCloudFormationChangeSetOptions

type CreateCloudFormationChangeSetOptions struct {
	Capabilities []string
	Tags         []Tag
}

CreateCloudFormationChangeSetOptions contains optional deployment metadata.

type Handler

type Handler struct {
	Backend   StorageBackend
	AccountID string
	Region    string
}

Handler is the HTTP handler for the AWS Serverless Application Repository REST API.

func NewHandler

func NewHandler(backend StorageBackend) *Handler

NewHandler creates a new Serverless Application Repository handler.

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 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 operation name from the HTTP method and request path.

func (*Handler) ExtractResource

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

ExtractResource extracts the resource identifier from the request.

func (*Handler) GetSupportedOperations

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

GetSupportedOperations returns the list of supported Serverless Application Repository operations.

func (*Handler) Handler

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

Handler returns the Echo handler function for Serverless Application Repository 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 handler's backend state.

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 Serverless Application Repository API requests. All path-based matches are gated on the SigV4 service name to prevent routing conflicts.

func (*Handler) Snapshot

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

Snapshot implements persistence.Persistable by delegating to the backend.

type InMemoryBackend

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

InMemoryBackend is an in-memory store for Serverless Application Repository resources.

applications is a "clean" store.Table (registered directly on registry -- see store_setup.go). appVersions, cfTemplates, and cfChangeSets are "dirty" tables: each was previously a map nested under appName, and each gained a hidden AppName field purely to key (and, for cfTemplates, index) itself -- see the doc comments on those fields in this file. Because that field is json:"-", persistence.go round-trips them through an ephemeral DTO registry instead of registry.SnapshotAll()/RestoreAll() directly.

appPolicies (map[string][]*ApplicationPolicyStatement) and appDependencies (map[string]map[string][]*ApplicationDependency) are left as plain maps: their values are slices, not *T, so they do not fit store.Table's keyed-by-identity-value shape. appPolicies is additionally order-sensitive (PutApplicationPolicy replaces the slice wholesale and GetApplicationPolicy returns it in that same order).

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new in-memory Serverless Application Repository backend.

func (*InMemoryBackend) AccountID

func (b *InMemoryBackend) AccountID() string

AccountID returns the AWS account ID this backend is configured for.

func (*InMemoryBackend) AddApplicationDependencyInternal

func (b *InMemoryBackend) AddApplicationDependencyInternal(
	appName, semanticVersion string,
	dependency ApplicationDependency,
) error

AddApplicationDependencyInternal seeds a nested dependency for a version.

func (*InMemoryBackend) AddApplicationInternal

func (b *InMemoryBackend) AddApplicationInternal(name, description, author string) *Application

AddApplicationInternal creates an application directly in the backend, bypassing validation and HTTP. Useful for seeding test state.

func (*InMemoryBackend) AddVersionInternal

func (b *InMemoryBackend) AddVersionInternal(appName, semanticVersion string) *ApplicationVersion

AddVersionInternal creates a version directly in the backend, bypassing validation. Useful for seeding test state. The application must already exist.

func (*InMemoryBackend) CreateApplication

func (b *InMemoryBackend) CreateApplication(
	name string,
	description string,
	author string,
	sourceCodeURL string,
	semanticVersion string,
	labels []string,
	homePageURL string,
	licenseURL string,
	spdxLicenseID string,
) (*Application, error)

CreateApplication creates a new application.

func (*InMemoryBackend) CreateApplicationVersion

func (b *InMemoryBackend) CreateApplicationVersion(
	appName string,
	semanticVersion string,
	sourceCodeURL string,
	templateURL string,
) (*ApplicationVersion, error)

CreateApplicationVersion creates a new version for an application.

func (*InMemoryBackend) CreateApplicationVersionWithOptions

func (b *InMemoryBackend) CreateApplicationVersionWithOptions(
	appName string,
	semanticVersion string,
	opts CreateApplicationVersionOptions,
) (*ApplicationVersion, error)

CreateApplicationVersionWithOptions creates a version including optional archive metadata.

func (*InMemoryBackend) CreateCloudFormationChangeSet

func (b *InMemoryBackend) CreateCloudFormationChangeSet(
	appName string,
	stackName string,
	changeSetName string,
	semanticVersion string,
) (*CloudFormationChangeSet, error)

CreateCloudFormationChangeSet creates a new CloudFormation change set for an application.

func (*InMemoryBackend) CreateCloudFormationChangeSetWithOptions

func (b *InMemoryBackend) CreateCloudFormationChangeSetWithOptions(
	appName string,
	stackName string,
	changeSetName string,
	semanticVersion string,
	opts CreateCloudFormationChangeSetOptions,
) (*CloudFormationChangeSet, error)

CreateCloudFormationChangeSetWithOptions creates a deployment change set with request metadata.

func (*InMemoryBackend) CreateCloudFormationTemplate

func (b *InMemoryBackend) CreateCloudFormationTemplate(
	appName, semanticVersion string,
) (*CloudFormationTemplate, error)

CreateCloudFormationTemplate creates a new CloudFormation template for an application.

func (*InMemoryBackend) DeleteApplication

func (b *InMemoryBackend) DeleteApplication(name string) error

DeleteApplication deletes an application by name, cascading to every version, CloudFormation template, and CloudFormation change set owned by it. The byApp index results are cloned before the delete loops since deleting from the underlying table mutates the index's backing slice.

func (*InMemoryBackend) GetApplication

func (b *InMemoryBackend) GetApplication(name string) (*Application, error)

GetApplication returns an application by name.

func (*InMemoryBackend) GetApplicationPolicy

func (b *InMemoryBackend) GetApplicationPolicy(appName string) ([]*ApplicationPolicyStatement, error)

GetApplicationPolicy returns the policy statements for an application.

func (*InMemoryBackend) GetApplicationVersion

func (b *InMemoryBackend) GetApplicationVersion(appName, semanticVersion string) (*ApplicationVersion, error)

GetApplicationVersion returns a specific version of an application by semantic version string.

func (*InMemoryBackend) GetCloudFormationTemplate

func (b *InMemoryBackend) GetCloudFormationTemplate(appName, templateID string) (*CloudFormationTemplate, error)

GetCloudFormationTemplate returns a CloudFormation template by application name and template ID.

func (*InMemoryBackend) ListApplicationDependencies

func (b *InMemoryBackend) ListApplicationDependencies(
	appName, semanticVersion string,
) ([]*ApplicationDependency, error)

ListApplicationDependencies returns nested application dependencies for an application version.

func (*InMemoryBackend) ListApplicationVersions

func (b *InMemoryBackend) ListApplicationVersions(appName string) ([]*ApplicationVersion, error)

ListApplicationVersions returns all versions for an application sorted by semantic version.

func (*InMemoryBackend) ListApplications

func (b *InMemoryBackend) ListApplications() []*Application

ListApplications returns all applications sorted by name.

func (*InMemoryBackend) PutApplicationPolicy

func (b *InMemoryBackend) PutApplicationPolicy(
	appName string,
	statements []*ApplicationPolicyStatement,
) ([]*ApplicationPolicyStatement, error)

PutApplicationPolicy sets the policy statements for an application.

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 backend state.

func (*InMemoryBackend) Restore

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

Restore loads backend state from a JSON snapshot.

func (*InMemoryBackend) SetApplicationReadmeURL

func (b *InMemoryBackend) SetApplicationReadmeURL(name, readmeURL string) (*Application, error)

SetApplicationReadmeURL stores readme metadata supplied during application creation.

func (*InMemoryBackend) Snapshot

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

Snapshot serialises the backend state to JSON.

func (*InMemoryBackend) UnshareApplication

func (b *InMemoryBackend) UnshareApplication(appName, _ string) error

UnshareApplication removes an application from an AWS Organization.

func (*InMemoryBackend) UpdateApplication

func (b *InMemoryBackend) UpdateApplication(
	name, description, author, homePageURL, readmeURL string,
) (*Application, error)

UpdateApplication updates the description or author of an existing application.

func (*InMemoryBackend) UpdateApplicationLabels

func (b *InMemoryBackend) UpdateApplicationLabels(name string, labels []string) (*Application, error)

UpdateApplicationLabels replaces labels supplied by UpdateApplication.

type ParameterDefinition

type ParameterDefinition struct {
	DefaultValue          string   `json:"defaultValue,omitempty"`
	Description           string   `json:"description,omitempty"`
	Name                  string   `json:"name"`
	Type                  string   `json:"type,omitempty"`
	ReferencedByResources []string `json:"referencedByResources"`
	AllowedValues         []string `json:"allowedValues,omitempty"`
	NoEcho                bool     `json:"noEcho,omitempty"`
}

ParameterDefinition represents a CloudFormation parameter definition for an application version.

type Provider

type Provider struct{}

Provider implements service.Provider for AWS Serverless Application Repository.

func (*Provider) Init

Init initializes the Serverless Application Repository service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type StorageBackend

type StorageBackend interface {
	// Application CRUD
	CreateApplication(
		name, description, author, sourceCodeURL, semanticVersion string,
		labels []string,
		homePageURL, licenseURL, spdxLicenseID string,
	) (*Application, error)
	SetApplicationReadmeURL(name, readmeURL string) (*Application, error)
	GetApplication(name string) (*Application, error)
	ListApplications() []*Application
	UpdateApplication(name, description, author, homePageURL, readmeURL string) (*Application, error)
	UpdateApplicationLabels(name string, labels []string) (*Application, error)
	DeleteApplication(name string) error

	// Application version operations
	CreateApplicationVersion(appName, semanticVersion, sourceCodeURL, templateURL string) (*ApplicationVersion, error)
	CreateApplicationVersionWithOptions(
		appName, semanticVersion string,
		opts CreateApplicationVersionOptions,
	) (*ApplicationVersion, error)
	GetApplicationVersion(appName, semanticVersion string) (*ApplicationVersion, error)
	ListApplicationVersions(appName string) ([]*ApplicationVersion, error)

	// CloudFormation template operations
	CreateCloudFormationTemplate(appName, semanticVersion string) (*CloudFormationTemplate, error)
	GetCloudFormationTemplate(appName, templateID string) (*CloudFormationTemplate, error)

	// CloudFormation change set operations
	CreateCloudFormationChangeSet(
		appName, stackName, changeSetName, semanticVersion string,
	) (*CloudFormationChangeSet, error)
	CreateCloudFormationChangeSetWithOptions(
		appName, stackName, changeSetName, semanticVersion string,
		opts CreateCloudFormationChangeSetOptions,
	) (*CloudFormationChangeSet, error)

	// Application policy operations
	GetApplicationPolicy(appName string) ([]*ApplicationPolicyStatement, error)
	PutApplicationPolicy(
		appName string,
		statements []*ApplicationPolicyStatement,
	) ([]*ApplicationPolicyStatement, error)

	// Application dependency operations
	ListApplicationDependencies(appName, semanticVersion string) ([]*ApplicationDependency, error)

	// Unshare application
	UnshareApplication(appName, organizationID string) error

	// Lifecycle
	Reset()
	Region() string
	AccountID() string
	Snapshot(ctx context.Context) []byte
	Restore(ctx context.Context, data []byte) error
}

StorageBackend is the interface for the Serverless Application Repository in-memory backend.

type Tag

type Tag struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Tag represents a CloudFormation tag passed while deploying an application.

Jump to

Keyboard shortcuts

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