Documentation
¶
Index ¶
- Variables
- type Application
- type ApplicationDependency
- type ApplicationPolicyStatement
- type ApplicationVersion
- type CloudFormationChangeSet
- type CloudFormationTemplate
- type CreateApplicationVersionOptions
- type CreateCloudFormationChangeSetOptions
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type InMemoryBackend
- func (b *InMemoryBackend) AccountID() string
- func (b *InMemoryBackend) AddApplicationDependencyInternal(appName, semanticVersion string, dependency ApplicationDependency) error
- func (b *InMemoryBackend) AddApplicationInternal(name, description, author string) *Application
- func (b *InMemoryBackend) AddVersionInternal(appName, semanticVersion string) *ApplicationVersion
- func (b *InMemoryBackend) CreateApplication(name string, description string, author string, sourceCodeURL string, ...) (*Application, error)
- func (b *InMemoryBackend) CreateApplicationVersion(appName string, semanticVersion string, sourceCodeURL string, ...) (*ApplicationVersion, error)
- func (b *InMemoryBackend) CreateApplicationVersionWithOptions(appName string, semanticVersion string, opts CreateApplicationVersionOptions) (*ApplicationVersion, error)
- func (b *InMemoryBackend) CreateCloudFormationChangeSet(appName string, stackName string, changeSetName string, semanticVersion string) (*CloudFormationChangeSet, error)
- func (b *InMemoryBackend) CreateCloudFormationChangeSetWithOptions(appName string, stackName string, changeSetName string, semanticVersion string, ...) (*CloudFormationChangeSet, error)
- func (b *InMemoryBackend) CreateCloudFormationTemplate(appName, semanticVersion string) (*CloudFormationTemplate, error)
- func (b *InMemoryBackend) DeleteApplication(name string) error
- func (b *InMemoryBackend) GetApplication(name string) (*Application, error)
- func (b *InMemoryBackend) GetApplicationPolicy(appName string) ([]*ApplicationPolicyStatement, error)
- func (b *InMemoryBackend) GetApplicationVersion(appName, semanticVersion string) (*ApplicationVersion, error)
- func (b *InMemoryBackend) GetCloudFormationTemplate(appName, templateID string) (*CloudFormationTemplate, error)
- func (b *InMemoryBackend) ListApplicationDependencies(appName, semanticVersion string) ([]*ApplicationDependency, error)
- func (b *InMemoryBackend) ListApplicationVersions(appName string) ([]*ApplicationVersion, error)
- func (b *InMemoryBackend) ListApplications() []*Application
- func (b *InMemoryBackend) PutApplicationPolicy(appName string, statements []*ApplicationPolicyStatement) ([]*ApplicationPolicyStatement, error)
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetApplicationReadmeURL(name, readmeURL string) (*Application, error)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) UnshareApplication(appName, _ string) error
- func (b *InMemoryBackend) UpdateApplication(name, description, author, homePageURL, readmeURL string) (*Application, error)
- func (b *InMemoryBackend) UpdateApplicationLabels(name string, labels []string) (*Application, error)
- type ParameterDefinition
- type Provider
- type StorageBackend
- type Tag
Constants ¶
This section is empty.
Variables ¶
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) )
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 {
// TemplateID, if non-empty, is the UUID returned by a prior CreateCloudFormationTemplate
// call for the same application. When set, it is cross-validated against that application's
// recorded templates.
TemplateID string
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 ¶
ChaosOperations returns all operations that can be fault-injected.
func (*Handler) ChaosRegions ¶
ChaosRegions returns all regions this handler handles.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase AWS service name for fault rule matching.
func (*Handler) ExtractOperation ¶
ExtractOperation extracts the operation name from the HTTP method and request path.
func (*Handler) ExtractResource ¶
ExtractResource extracts the resource identifier from the request.
func (*Handler) GetSupportedOperations ¶
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 ¶
MatchPriority returns the routing priority.
func (*Handler) RouteMatcher ¶
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.
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) 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"`
AllowedPattern string `json:"allowedPattern,omitempty"`
ConstraintDescription string `json:"constraintDescription,omitempty"`
ReferencedByResources []string `json:"referencedByResources"`
AllowedValues []string `json:"allowedValues,omitempty"`
MaxLength int `json:"maxLength,omitempty"`
MaxValue int `json:"maxValue,omitempty"`
MinLength int `json:"minLength,omitempty"`
MinValue int `json:"minValue,omitempty"`
NoEcho bool `json:"noEcho,omitempty"`
}
ParameterDefinition represents a CloudFormation parameter definition for an application version. Matches aws-sdk-go-v2/service/serverlessapplicationrepository/types.ParameterDefinition field-for-field; gopherstack never derives non-empty parameter definitions from a template (that requires parsing the AWS SAM template body, which is out of scope), so this shape is exercised only via the always-empty slice CreateApplicationVersion/GetApplication return, but is kept fully field-accurate for callers seeding state directly.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for AWS Serverless Application Repository.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the Serverless Application Repository service backend and handler.
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)
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.
Source Files
¶
- application_dependencies.go
- application_policy.go
- application_versions.go
- applications.go
- cloud_formation.go
- errors.go
- handler.go
- handler_application_dependencies.go
- handler_application_policy.go
- handler_application_versions.go
- handler_applications.go
- handler_cloud_formation.go
- interfaces.go
- models.go
- persistence.go
- provider.go
- store.go
- store_setup.go
- tags.go