Files
spinifex/cmd/aws-model-coverage/main.go
T
joshsiv-mulga 6c48ab6b78 refactor: register the ECR control plane from its domain
domains/ecr/awsapi now registers the "ecr" AWS JSON 1.1 surface with the
ingress dispatch registry: action resolution, resource scope, authorisation
through the invocation, the composed capabilities and the success writer all
live with the domain. The awsgw role is the only serving composition point;
the gateway no longer imports the ECR API package and ECR leaves the legacy
service table, JSON error table and dispatch switch. The OCI /v2 route is
unchanged.

Operation coverage reads ECR's declared inventory, which the registration
uses verbatim; coverage.json is byte-identical.
2026-10-07 22:55:00 +10:00

80 lines
2.3 KiB
Go

package main
import (
"flag"
"fmt"
"os"
"github.com/mulgadc/predastore/s3api"
"github.com/mulgadc/spinifex/internal/awsmodel"
awsapi "github.com/mulgadc/spinifex/spinifex/domains/ecr/awsapi"
"github.com/mulgadc/spinifex/spinifex/gateway"
"github.com/mulgadc/spinifex/spinifex/ingress/aws/dispatch"
_ "github.com/mulgadc/bluebottle/pkg/fipsboot"
)
func main() {
outputDir := flag.String("out", "", "write one publishable page per service into this directory")
jsonOutput := flag.String("json", "", "write a machine-readable coverage inventory to this file")
flag.Parse()
coverages, err := compareAll()
if err != nil {
fail(err)
}
if *outputDir == "" && *jsonOutput == "" {
fmt.Print(awsmodel.RenderCoverageSummary(coverages))
return
}
if *outputDir != "" {
if err := awsmodel.WritePages(*outputDir, coverages); err != nil {
fail(err)
}
}
if *jsonOutput != "" {
if err := awsmodel.WriteCoverageJSON(*jsonOutput, coverages); err != nil {
fail(err)
}
}
}
func fail(err error) {
fmt.Fprintf(os.Stderr, "aws-model-coverage: %v\n", err)
os.Exit(1)
}
func compareAll() ([]awsmodel.OperationCoverage, error) {
// Registered services contribute their declared inventory, which needs no
// live dependencies; nothing here serves a request.
inventories := gateway.AWSOperationInventory(map[string]dispatch.Inventory{
awsapi.ServiceName: awsapi.OperationInventory(),
})
coverages := make([]awsmodel.OperationCoverage, 0, len(awsmodel.Services()))
for _, service := range awsmodel.Services() {
inventory, ok := inventories[string(service)]
var modelInventory awsmodel.DispatchInventory
switch {
case ok:
modelInventory = awsmodel.DispatchInventory{
Registered: inventory.Registered,
Stubbed: inventory.Stubbed,
Unsupported: inventory.Unsupported,
}
// Predastore serves the S3 REST surface, and names the operations each
// of its routes answers, so the comparison is the same one.
case service == awsmodel.S3:
modelInventory = awsmodel.DispatchInventory{Registered: s3api.Operations()}
default:
return nil, fmt.Errorf("no gateway inventory for %s", service)
}
coverage, err := awsmodel.CompareOperations(service, modelInventory)
if err != nil {
return nil, err
}
coverages = append(coverages, coverage)
}
return coverages, nil
}