From 15a6ebfefe60dfec2ed114c2dcf39cbe964bbbce Mon Sep 17 00:00:00 2001 From: Denise Li Date: Tue, 2 Jul 2024 16:08:05 -0400 Subject: [PATCH] feat: introduce `types.ftl.go` to register sumtypes, which fixes encoding in unit tests (#1909) Fixes https://github.com/TBD54566975/ftl/issues/1577 This change introduces a new generated file `types.ftl.go` in the user-defined package itself to make sure sumtype registrations get called when running unit tests. Notes: * This change also includes a subpackage `subpackage` in the test data that is not yet unit tested. Unit tests should be added (identical to the parent package's unit tests) after https://github.com/TBD54566975/ftl/issues/1903 is resolved. Some work will also need to be done to extend the `types.ftl.go` generation to working on subpackages. * This works by extending the existing logic operating on `mainModuleContext`, which means that code now generates not only just the literal `main` package, but also the conceptual _main_ package's additional artifacts. I couldn't come up with a name that would be better, so it's left as-is in this PR, but please let me know if you think of something better. --- backend/schema/encoding.go | 3 + buildengine/testdata/alpha/types.ftl.go | 3 + buildengine/testdata/another/types.ftl.go | 17 ++ buildengine/testdata/other/types.ftl.go | 26 +++ common/moduleconfig/moduleconfig.go | 25 ++- .../compile/build-template/types.ftl.go.tmpl | 17 ++ go-runtime/compile/build.go | 49 +++-- .../compile/testdata/named/types.ftl.go | 3 + .../compile/testdata/namedext/types.ftl.go | 3 + go-runtime/compile/testdata/one/types.ftl.go | 24 +++ .../compile/testdata/parent/types.ftl.go | 3 + .../compile/testdata/pubsub/types.ftl.go | 3 + .../compile/testdata/subscriber/types.ftl.go | 3 + go-runtime/compile/testdata/two/types.ftl.go | 15 ++ go-runtime/ftl/ftl_integration_test.go | 8 + .../ftl/testdata/go/typeregistry/ftl.toml | 2 + .../ftl/testdata/go/typeregistry/go.mod | 62 ++++++ .../ftl/testdata/go/typeregistry/go.sum | 178 ++++++++++++++++++ .../go/typeregistry/subpackage/subpackage.go | 42 +++++ .../testdata/go/typeregistry/typeregistry.go | 42 +++++ .../go/typeregistry/typeregistry_test.go | 86 +++++++++ .../ftl/testdata/go/typeregistry/types.ftl.go | 14 ++ 22 files changed, 613 insertions(+), 15 deletions(-) create mode 100644 buildengine/testdata/alpha/types.ftl.go create mode 100644 buildengine/testdata/another/types.ftl.go create mode 100644 buildengine/testdata/other/types.ftl.go create mode 100644 go-runtime/compile/build-template/types.ftl.go.tmpl create mode 100644 go-runtime/compile/testdata/named/types.ftl.go create mode 100644 go-runtime/compile/testdata/namedext/types.ftl.go create mode 100644 go-runtime/compile/testdata/one/types.ftl.go create mode 100644 go-runtime/compile/testdata/parent/types.ftl.go create mode 100644 go-runtime/compile/testdata/pubsub/types.ftl.go create mode 100644 go-runtime/compile/testdata/subscriber/types.ftl.go create mode 100644 go-runtime/compile/testdata/two/types.ftl.go create mode 100644 go-runtime/ftl/testdata/go/typeregistry/ftl.toml create mode 100644 go-runtime/ftl/testdata/go/typeregistry/go.mod create mode 100644 go-runtime/ftl/testdata/go/typeregistry/go.sum create mode 100644 go-runtime/ftl/testdata/go/typeregistry/subpackage/subpackage.go create mode 100644 go-runtime/ftl/testdata/go/typeregistry/typeregistry.go create mode 100644 go-runtime/ftl/testdata/go/typeregistry/typeregistry_test.go create mode 100644 go-runtime/ftl/testdata/go/typeregistry/types.ftl.go diff --git a/backend/schema/encoding.go b/backend/schema/encoding.go index 15df8f0053..e506686de4 100644 --- a/backend/schema/encoding.go +++ b/backend/schema/encoding.go @@ -34,6 +34,9 @@ func EncodeComments(comments []string) string { w := &strings.Builder{} for _, c := range comments { + if c == "Code generated by FTL. DO NOT EDIT." { + continue + } space := "" // Empty lines should not have a trailing space. if c != "" { diff --git a/buildengine/testdata/alpha/types.ftl.go b/buildengine/testdata/alpha/types.ftl.go new file mode 100644 index 0000000000..75e46a44b2 --- /dev/null +++ b/buildengine/testdata/alpha/types.ftl.go @@ -0,0 +1,3 @@ +// Code generated by FTL. DO NOT EDIT. +package alpha + diff --git a/buildengine/testdata/another/types.ftl.go b/buildengine/testdata/another/types.ftl.go new file mode 100644 index 0000000000..cc9fc61e01 --- /dev/null +++ b/buildengine/testdata/another/types.ftl.go @@ -0,0 +1,17 @@ +// Code generated by FTL. DO NOT EDIT. +package another + +import "github.com/TBD54566975/ftl/go-runtime/ftl/reflection" + +func init() { + reflection.Register( + reflection.SumType[SecondTypeEnum]( + *new(One), + *new(Two), + ), + reflection.SumType[TypeEnum]( + *new(A), + *new(B), + ), + ) +} diff --git a/buildengine/testdata/other/types.ftl.go b/buildengine/testdata/other/types.ftl.go new file mode 100644 index 0000000000..c1e1d89f4b --- /dev/null +++ b/buildengine/testdata/other/types.ftl.go @@ -0,0 +1,26 @@ +// Code generated by FTL. DO NOT EDIT. +package other + +import "github.com/TBD54566975/ftl/go-runtime/ftl/reflection" + +func init() { + reflection.Register( + reflection.SumType[SecondTypeEnum]( + *new(A), + *new(B), + ), + reflection.SumType[TypeEnum]( + *new(MyBool), + *new(MyBytes), + *new(MyFloat), + *new(MyInt), + *new(MyTime), + *new(MyList), + *new(MyMap), + *new(MyString), + *new(MyStruct), + *new(MyOption), + *new(MyUnit), + ), + ) +} diff --git a/common/moduleconfig/moduleconfig.go b/common/moduleconfig/moduleconfig.go index 6f0ac68fdf..dddad51340 100644 --- a/common/moduleconfig/moduleconfig.go +++ b/common/moduleconfig/moduleconfig.go @@ -227,7 +227,7 @@ func replacementWatches(moduleDir, deployDir string) ([]string, error) { // findReplacedImports finds Go files with imports that are specified in the replacements. func findReplacedImports(moduleDir, deployDir string, replacements map[string]string) ([]string, error) { - var libPaths []string + libPaths := make(map[string]bool) err := filepath.WalkDir(moduleDir, func(path string, d os.DirEntry, err error) error { if err != nil { @@ -243,7 +243,7 @@ func findReplacedImports(moduleDir, deployDir string, replacements map[string]st for oldPath, newPath := range replacements { if strings.HasPrefix(imp, oldPath) { resolvedPath := filepath.Join(newPath, strings.TrimPrefix(imp, oldPath)) - libPaths = append(libPaths, resolvedPath) + libPaths[resolvedPath] = true break // Only add the library path once for each import match } } @@ -252,7 +252,26 @@ func findReplacedImports(moduleDir, deployDir string, replacements map[string]st return nil }) - return libPaths, err + return deduplicateLibPaths(libPaths), err +} + +func deduplicateLibPaths(libPaths map[string]bool) []string { + for maybeParentPath := range libPaths { + for path := range libPaths { + if maybeParentPath != path && strings.HasPrefix(path, maybeParentPath) { + libPaths[path] = false + } + } + } + + paths := []string{} + for path, shouldReturn := range libPaths { + if shouldReturn { + paths = append(paths, path) + } + } + + return paths } func parseImports(filePath string) ([]string, error) { diff --git a/go-runtime/compile/build-template/types.ftl.go.tmpl b/go-runtime/compile/build-template/types.ftl.go.tmpl new file mode 100644 index 0000000000..2b45c2fd05 --- /dev/null +++ b/go-runtime/compile/build-template/types.ftl.go.tmpl @@ -0,0 +1,17 @@ +// Code generated by FTL. DO NOT EDIT. +package {{.Name}} +{{if .LocalSumTypes }} +import "github.com/TBD54566975/ftl/go-runtime/ftl/reflection" + +func init() { + reflection.Register( +{{- range .LocalSumTypes}} + reflection.SumType[{{.Discriminator}}]( + {{- range .Variants}} + *new({{.Name}}), + {{- end}} + ), +{{- end}} + ) +} +{{- end}} diff --git a/go-runtime/compile/build.go b/go-runtime/compile/build.go index b3559490fe..e1012a747d 100644 --- a/go-runtime/compile/build.go +++ b/go-runtime/compile/build.go @@ -53,12 +53,13 @@ type goVerb struct { } type mainModuleContext struct { - GoVersion string - FTLVersion string - Name string - Verbs []goVerb - Replacements []*modfile.Replace - SumTypes []goSumType + GoVersion string + FTLVersion string + Name string + Verbs []goVerb + Replacements []*modfile.Replace + SumTypes []goSumType + LocalSumTypes []goSumType } type goSumType struct { @@ -185,12 +186,13 @@ func Build(ctx context.Context, moduleDir string, sch *schema.Schema, filesTrans goVerbs = append(goVerbs, goverb) } if err := internal.ScaffoldZip(buildTemplateFiles(), moduleDir, mainModuleContext{ - GoVersion: goModVersion, - FTLVersion: ftlVersion, - Name: result.Module.Name, - Verbs: goVerbs, - Replacements: replacements, - SumTypes: getSumTypes(result.Module, sch, result.NativeNames), + GoVersion: goModVersion, + FTLVersion: ftlVersion, + Name: result.Module.Name, + Verbs: goVerbs, + Replacements: replacements, + SumTypes: getSumTypes(result.Module, sch, result.NativeNames), + LocalSumTypes: getLocalSumTypes(result.Module), }, scaffolder.Exclude("^go.mod$"), scaffolder.Functions(funcs)); err != nil { return err } @@ -553,6 +555,29 @@ func writeSchemaErrors(config moduleconfig.ModuleConfig, errors []*schema.Error) return os.WriteFile(config.Abs().Errors, elBytes, 0600) } +func getLocalSumTypes(module *schema.Module) []goSumType { + sumTypes := make(map[string]goSumType) + for _, d := range module.Decls { + if e, ok := d.(*schema.Enum); ok && !e.IsValueEnum() { + variants := make([]goSumTypeVariant, 0, len(e.Variants)) + for _, v := range e.Variants { + variants = append(variants, goSumTypeVariant{ //nolint:forcetypeassert + Name: v.Name, + }) + } + sumTypes[e.Name] = goSumType{ + Discriminator: e.Name, + Variants: variants, + } + } + } + out := gomaps.Values(sumTypes) + slices.SortFunc(out, func(a, b goSumType) int { + return strings.Compare(a.Discriminator, b.Discriminator) + }) + return out +} + func getSumTypes(module *schema.Module, sch *schema.Schema, nativeNames NativeNames) []goSumType { sumTypes := make(map[string]goSumType) for _, d := range module.Decls { diff --git a/go-runtime/compile/testdata/named/types.ftl.go b/go-runtime/compile/testdata/named/types.ftl.go new file mode 100644 index 0000000000..705843cbe3 --- /dev/null +++ b/go-runtime/compile/testdata/named/types.ftl.go @@ -0,0 +1,3 @@ +// Code generated by FTL. DO NOT EDIT. +package named + diff --git a/go-runtime/compile/testdata/namedext/types.ftl.go b/go-runtime/compile/testdata/namedext/types.ftl.go new file mode 100644 index 0000000000..d08d78d1db --- /dev/null +++ b/go-runtime/compile/testdata/namedext/types.ftl.go @@ -0,0 +1,3 @@ +// Code generated by FTL. DO NOT EDIT. +package namedext + diff --git a/go-runtime/compile/testdata/one/types.ftl.go b/go-runtime/compile/testdata/one/types.ftl.go new file mode 100644 index 0000000000..e1c3e825de --- /dev/null +++ b/go-runtime/compile/testdata/one/types.ftl.go @@ -0,0 +1,24 @@ +// Code generated by FTL. DO NOT EDIT. +package one + +import "github.com/TBD54566975/ftl/go-runtime/ftl/reflection" + +func init() { + reflection.Register( + reflection.SumType[BlobOrList]( + *new(Blob), + *new(List), + ), + reflection.SumType[PrivateEnum]( + *new(ExportedStruct), + *new(PrivateStruct), + *new(WithoutDirectiveStruct), + ), + reflection.SumType[TypeEnum]( + *new(Option), + *new(InlineStruct), + *new(AliasedStruct), + *new(ValueEnum), + ), + ) +} diff --git a/go-runtime/compile/testdata/parent/types.ftl.go b/go-runtime/compile/testdata/parent/types.ftl.go new file mode 100644 index 0000000000..ab06f98540 --- /dev/null +++ b/go-runtime/compile/testdata/parent/types.ftl.go @@ -0,0 +1,3 @@ +// Code generated by FTL. DO NOT EDIT. +package parent + diff --git a/go-runtime/compile/testdata/pubsub/types.ftl.go b/go-runtime/compile/testdata/pubsub/types.ftl.go new file mode 100644 index 0000000000..d8ff9262c3 --- /dev/null +++ b/go-runtime/compile/testdata/pubsub/types.ftl.go @@ -0,0 +1,3 @@ +// Code generated by FTL. DO NOT EDIT. +package pubsub + diff --git a/go-runtime/compile/testdata/subscriber/types.ftl.go b/go-runtime/compile/testdata/subscriber/types.ftl.go new file mode 100644 index 0000000000..532a6f47ce --- /dev/null +++ b/go-runtime/compile/testdata/subscriber/types.ftl.go @@ -0,0 +1,3 @@ +// Code generated by FTL. DO NOT EDIT. +package subscriber + diff --git a/go-runtime/compile/testdata/two/types.ftl.go b/go-runtime/compile/testdata/two/types.ftl.go new file mode 100644 index 0000000000..78b9faf11a --- /dev/null +++ b/go-runtime/compile/testdata/two/types.ftl.go @@ -0,0 +1,15 @@ +// Code generated by FTL. DO NOT EDIT. +package two + +import "github.com/TBD54566975/ftl/go-runtime/ftl/reflection" + +func init() { + reflection.Register( + reflection.SumType[TypeEnum]( + *new(Scalar), + *new(List), + *new(Exported), + *new(WithoutDirective), + ), + ) +} diff --git a/go-runtime/ftl/ftl_integration_test.go b/go-runtime/ftl/ftl_integration_test.go index 75d336bc96..ed4d19a36a 100644 --- a/go-runtime/ftl/ftl_integration_test.go +++ b/go-runtime/ftl/ftl_integration_test.go @@ -49,3 +49,11 @@ func TestSchemaGenerate(t *testing.T) { in.FileContains("build/schema-generate/test.txt", "olleh"), ) } + +func TestTypeRegistryUnitTest(t *testing.T) { + in.Run(t, "", + in.CopyModule("typeregistry"), + in.Deploy("typeregistry"), + in.ExecModuleTest("typeregistry"), + ) +} diff --git a/go-runtime/ftl/testdata/go/typeregistry/ftl.toml b/go-runtime/ftl/testdata/go/typeregistry/ftl.toml new file mode 100644 index 0000000000..af07feff3e --- /dev/null +++ b/go-runtime/ftl/testdata/go/typeregistry/ftl.toml @@ -0,0 +1,2 @@ +module = "typeregistry" +language = "go" diff --git a/go-runtime/ftl/testdata/go/typeregistry/go.mod b/go-runtime/ftl/testdata/go/typeregistry/go.mod new file mode 100644 index 0000000000..3d0103d67b --- /dev/null +++ b/go-runtime/ftl/testdata/go/typeregistry/go.mod @@ -0,0 +1,62 @@ +module ftl/typeregistry + +go 1.22.2 + +toolchain go1.22.4 + +require ( + github.com/TBD54566975/ftl v1.1.5 + github.com/alecthomas/assert/v2 v2.10.0 +) + +require ( + connectrpc.com/connect v1.16.1 // indirect + connectrpc.com/grpcreflect v1.2.0 // indirect + connectrpc.com/otelconnect v0.7.0 // indirect + github.com/BurntSushi/toml v1.4.0 // indirect + github.com/TBD54566975/scaffolder v1.0.0 // indirect + github.com/alecthomas/atomic v0.1.0-alpha2 // indirect + github.com/alecthomas/concurrency v0.0.2 // indirect + github.com/alecthomas/participle/v2 v2.1.1 // indirect + github.com/alecthomas/repr v0.4.0 // indirect + github.com/alecthomas/types v0.16.0 // indirect + github.com/alessio/shellescape v1.4.2 // indirect + github.com/aws/aws-sdk-go-v2 v1.30.1 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.13 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.13 // indirect + github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.1 // indirect + github.com/aws/smithy-go v1.20.3 // indirect + github.com/benbjohnson/clock v1.3.5 // indirect + github.com/danieljoos/wincred v1.2.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/godbus/dbus/v5 v5.1.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/hexops/gotextdiff v1.0.3 // indirect + github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect + github.com/jackc/pgx/v5 v5.6.0 // indirect + github.com/jackc/puddle/v2 v2.2.1 // indirect + github.com/jpillora/backoff v1.0.0 // indirect + github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/multiformats/go-base36 v0.2.0 // indirect + github.com/puzpuzpuz/xsync/v3 v3.2.0 // indirect + github.com/swaggest/jsonschema-go v0.3.72 // indirect + github.com/swaggest/refl v1.3.0 // indirect + github.com/zalando/go-keyring v0.2.5 // indirect + go.opentelemetry.io/otel v1.27.0 // indirect + go.opentelemetry.io/otel/metric v1.27.0 // indirect + go.opentelemetry.io/otel/trace v1.27.0 // indirect + golang.org/x/crypto v0.24.0 // indirect + golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect + golang.org/x/mod v0.18.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect +) + +replace github.com/TBD54566975/ftl => ../../../../.. diff --git a/go-runtime/ftl/testdata/go/typeregistry/go.sum b/go-runtime/ftl/testdata/go/typeregistry/go.sum new file mode 100644 index 0000000000..3dcbbe661f --- /dev/null +++ b/go-runtime/ftl/testdata/go/typeregistry/go.sum @@ -0,0 +1,178 @@ +connectrpc.com/connect v1.16.1 h1:rOdrK/RTI/7TVnn3JsVxt3n028MlTRwmK5Q4heSpjis= +connectrpc.com/connect v1.16.1/go.mod h1:XpZAduBQUySsb4/KO5JffORVkDI4B6/EYPi7N8xpNZw= +connectrpc.com/grpcreflect v1.2.0 h1:Q6og1S7HinmtbEuBvARLNwYmTbhEGRpHDhqrPNlmK+U= +connectrpc.com/grpcreflect v1.2.0/go.mod h1:nwSOKmE8nU5u/CidgHtPYk1PFI3U9ignz7iDMxOYkSY= +connectrpc.com/otelconnect v0.7.0 h1:ZH55ZZtcJOTKWWLy3qmL4Pam4RzRWBJFOqTPyAqCXkY= +connectrpc.com/otelconnect v0.7.0/go.mod h1:Bt2ivBymHZHqxvo4HkJ0EwHuUzQN6k2l0oH+mp/8nwc= +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/TBD54566975/scaffolder v1.0.0 h1:QUFSy2wVzumLDg7IHcKC6AP+IYyqWe9Wxiu72nZn5qU= +github.com/TBD54566975/scaffolder v1.0.0/go.mod h1:auVpczIbOAdIhYDVSruIw41DanxOKB9bSvjf6MEl7Fs= +github.com/alecthomas/assert/v2 v2.10.0 h1:jjRCHsj6hBJhkmhznrCzoNpbA3zqy0fYiUcYZP/GkPY= +github.com/alecthomas/assert/v2 v2.10.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/atomic v0.1.0-alpha2 h1:dqwXmax66gXvHhsOS4pGPZKqYOlTkapELkLb3MNdlH8= +github.com/alecthomas/atomic v0.1.0-alpha2/go.mod h1:zD6QGEyw49HIq19caJDc2NMXAy8rNi9ROrxtMXATfyI= +github.com/alecthomas/concurrency v0.0.2 h1:Q3kGPtLbleMbH9lHX5OBFvJygfyFw29bXZKBg+IEVuo= +github.com/alecthomas/concurrency v0.0.2/go.mod h1:GmuQb/iHX7mbNtPlC/WDzEFxDMB0HYFer2Qda9QTs7w= +github.com/alecthomas/participle/v2 v2.1.1 h1:hrjKESvSqGHzRb4yW1ciisFJ4p3MGYih6icjJvbsmV8= +github.com/alecthomas/participle/v2 v2.1.1/go.mod h1:Y1+hAs8DHPmc3YUFzqllV+eSQ9ljPTk0ZkPMtEdAx2c= +github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= +github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/alecthomas/types v0.16.0 h1:o9+JSwCRB6DDaWDeR/Mg7v/zh3R+MlknM6DrnDyY7U0= +github.com/alecthomas/types v0.16.0/go.mod h1:Tswm0qQpjpVq8rn70OquRsUtFxbQKub/8TMyYYGI0+k= +github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0= +github.com/alessio/shellescape v1.4.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= +github.com/aws/aws-sdk-go-v2 v1.30.1 h1:4y/5Dvfrhd1MxRDD77SrfsDaj8kUkkljU7XE83NPV+o= +github.com/aws/aws-sdk-go-v2 v1.30.1/go.mod h1:nIQjQVp5sfpQcTc9mPSr1B0PaWK5ByX9MOoDadSN4lc= +github.com/aws/aws-sdk-go-v2/config v1.27.23 h1:Cr/gJEa9NAS7CDAjbnB7tHYb3aLZI2gVggfmSAasDac= +github.com/aws/aws-sdk-go-v2/config v1.27.23/go.mod h1:WMMYHqLCFu5LH05mFOF5tsq1PGEMfKbu083VKqLCd0o= +github.com/aws/aws-sdk-go-v2/credentials v1.17.23 h1:G1CfmLVoO2TdQ8z9dW+JBc/r8+MqyPQhXCafNZcXVZo= +github.com/aws/aws-sdk-go-v2/credentials v1.17.23/go.mod h1:V/DvSURn6kKgcuKEk4qwSwb/fZ2d++FFARtWSbXnLqY= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.9 h1:Aznqksmd6Rfv2HQN9cpqIV/lQRMaIpJkLLaJ1ZI76no= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.9/go.mod h1:WQr3MY7AxGNxaqAtsDWn+fBxmd4XvLkzeqQ8P1VM0/w= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.13 h1:5SAoZ4jYpGH4721ZNoS1znQrhOfZinOhc4XuTXx/nVc= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.13/go.mod h1:+rdA6ZLpaSeM7tSg/B0IEDinCIBJGmW8rKDFkYpP04g= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.13 h1:WIijqeaAO7TYFLbhsZmi2rgLEAtWOC1LhxCAVTJlSKw= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.13/go.mod h1:i+kbfa76PQbWw/ULoWnp51EYVWH4ENln76fLQE3lXT8= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 h1:hT8rVHwugYE2lEfdFE0QWVo81lF7jMrYJVDWI+f+VxU= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0/go.mod h1:8tu/lYfQfFe6IGnaOdrpVgEL2IrrDOf6/m9RQum4NkY= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 h1:dT3MqvGhSoaIhRseqw2I0yH81l7wiR2vjs57O51EAm8= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3/go.mod h1:GlAeCkHwugxdHaueRr4nhPuY+WW+gR8UjlcqzPr1SPI= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.15 h1:I9zMeF107l0rJrpnHpjEiiTSCKYAIw8mALiXcPsGBiA= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.15/go.mod h1:9xWJ3Q/S6Ojusz1UIkfycgD1mGirJfLLKqq3LPT7WN8= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.1 h1:ZoYRD8IJqPkzjBnpokiMNO6L/DQprtpVpD6k0YSaF5U= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.1/go.mod h1:GlRarZzIMl9VDi0mLQt+qQOuEkVFPnTkkjyugV1uVa8= +github.com/aws/aws-sdk-go-v2/service/sso v1.22.1 h1:p1GahKIjyMDZtiKoIn0/jAj/TkMzfzndDv5+zi2Mhgc= +github.com/aws/aws-sdk-go-v2/service/sso v1.22.1/go.mod h1:/vWdhoIoYA5hYoPZ6fm7Sv4d8701PiG5VKe8/pPJL60= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.1 h1:lCEv9f8f+zJ8kcFeAjRZsekLd/x5SAm96Cva+VbUdo8= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.1/go.mod h1:xyFHA4zGxgYkdD73VeezHt3vSKEG9EmFnGwoKlP00u4= +github.com/aws/aws-sdk-go-v2/service/sts v1.30.1 h1:+woJ607dllHJQtsnJLi52ycuqHMwlW+Wqm2Ppsfp4nQ= +github.com/aws/aws-sdk-go-v2/service/sts v1.30.1/go.mod h1:jiNR3JqT15Dm+QWq2SRgh0x0bCNSRP2L25+CqPNpJlQ= +github.com/aws/smithy-go v1.20.3 h1:ryHwveWzPV5BIof6fyDvor6V3iUL7nTfiTKXHiW05nE= +github.com/aws/smithy-go v1.20.3/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= +github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= +github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/bool64/dev v0.2.35 h1:M17TLsO/pV2J7PYI/gpe3Ua26ETkzZGb+dC06eoMqlk= +github.com/bool64/dev v0.2.35/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= +github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= +github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= +github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE= +github.com/danieljoos/wincred v1.2.0/go.mod h1:FzQLLMKBFdvu+osBrnFODiv32YGwCfx0SkRa/eYHgec= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= +github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= +github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= +github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= +github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= +github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438 h1:Dj0L5fhJ9F82ZJyVOmBx6msDp/kfd1t9GRfny/mfJA0= +github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY= +github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw= +github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= +github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= +github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= +github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= +github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= +github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/puzpuzpuz/xsync/v3 v3.2.0 h1:9AzuUeF88YC5bK8u2vEG1Fpvu4wgpM1wfPIExfaaDxQ= +github.com/puzpuzpuz/xsync/v3 v3.2.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= +github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= +github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= +github.com/swaggest/jsonschema-go v0.3.72 h1:IHaGlR1bdBUBPfhe4tfacN2TGAPKENEGiNyNzvnVHv4= +github.com/swaggest/jsonschema-go v0.3.72/go.mod h1:OrGyEoVqpfSFJ4Am4V/FQcQ3mlEC1vVeleA+5ggbVW4= +github.com/swaggest/refl v1.3.0 h1:PEUWIku+ZznYfsoyheF97ypSduvMApYyGkYF3nabS0I= +github.com/swaggest/refl v1.3.0/go.mod h1:3Ujvbmh1pfSbDYjC6JGG7nMgPvpG0ehQL4iNonnLNbg= +github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= +github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= +github.com/zalando/go-keyring v0.2.5 h1:Bc2HHpjALryKD62ppdEzaFG6VxL6Bc+5v0LYpN8Lba8= +github.com/zalando/go-keyring v0.2.5/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk= +go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= +go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= +go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik= +go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak= +go.opentelemetry.io/otel/sdk v1.27.0 h1:mlk+/Y1gLPLn84U4tI8d3GNJmGT/eXe3ZuOXN9kTWmI= +go.opentelemetry.io/otel/sdk v1.27.0/go.mod h1:Ha9vbLwJE6W86YstIywK2xFfPjbWlCuwPtMkKdz/Y4A= +go.opentelemetry.io/otel/sdk/metric v1.27.0 h1:5uGNOlpXi+Hbo/DRoI31BSb1v+OGcpv2NemcCrOL8gI= +go.opentelemetry.io/otel/sdk/metric v1.27.0/go.mod h1:we7jJVrYN2kh3mVBlswtPU22K0SA+769l93J6bsyvqw= +go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw= +go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 h1:LoYXNGAShUG3m/ehNk4iFctuhGX/+R1ZpfJ4/ia80JM= +golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= +golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= +golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI= +modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4= +modernc.org/libc v1.52.1 h1:uau0VoiT5hnR+SpoWekCKbLqm7v6dhRL3hI+NQhgN3M= +modernc.org/libc v1.52.1/go.mod h1:HR4nVzFDSDizP620zcMCgjb1/8xk2lg5p/8yjfGv1IQ= +modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= +modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= +modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= +modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU= +modernc.org/sqlite v1.30.1 h1:YFhPVfu2iIgUf9kuA1CR7iiHdcEEsI2i+yjRYHscyxk= +modernc.org/sqlite v1.30.1/go.mod h1:DUmsiWQDaAvU4abhc/N+djlom/L2o8f7gZ95RCvyoLU= +modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= +modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= +modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= +modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= diff --git a/go-runtime/ftl/testdata/go/typeregistry/subpackage/subpackage.go b/go-runtime/ftl/testdata/go/typeregistry/subpackage/subpackage.go new file mode 100644 index 0000000000..7410cbc3a6 --- /dev/null +++ b/go-runtime/ftl/testdata/go/typeregistry/subpackage/subpackage.go @@ -0,0 +1,42 @@ +package subpackage + +import ( + "context" + "ftl/builtin" + + "github.com/TBD54566975/ftl/go-runtime/ftl" // Import the FTL SDK. +) + +//ftl:enum +type StringsTypeEnum interface { + tag() +} + +type Single string + +func (Single) tag() {} + +type List []string + +func (List) tag() {} + +type Object struct { + S string +} + +func (Object) tag() {} + +type EchoRequest struct { + Strings StringsTypeEnum +} + +type EchoResponse struct { + Strings StringsTypeEnum +} + +//ftl:ingress POST /echo +func Echo(ctx context.Context, req builtin.HttpRequest[EchoRequest]) (builtin.HttpResponse[EchoResponse, string], error) { + return builtin.HttpResponse[EchoResponse, string]{ + Body: ftl.Some(EchoResponse{Strings: req.Body.Strings}), + }, nil +} diff --git a/go-runtime/ftl/testdata/go/typeregistry/typeregistry.go b/go-runtime/ftl/testdata/go/typeregistry/typeregistry.go new file mode 100644 index 0000000000..c392e799ec --- /dev/null +++ b/go-runtime/ftl/testdata/go/typeregistry/typeregistry.go @@ -0,0 +1,42 @@ +package typeregistry + +import ( + "context" + "ftl/builtin" + + "github.com/TBD54566975/ftl/go-runtime/ftl" // Import the FTL SDK. +) + +//ftl:enum +type StringsTypeEnum interface { + tag() +} + +type Single string + +func (Single) tag() {} + +type List []string + +func (List) tag() {} + +type Object struct { + S string +} + +func (Object) tag() {} + +type EchoRequest struct { + Strings StringsTypeEnum +} + +type EchoResponse struct { + Strings StringsTypeEnum +} + +//ftl:ingress POST /echo +func Echo(ctx context.Context, req builtin.HttpRequest[EchoRequest]) (builtin.HttpResponse[EchoResponse, string], error) { + return builtin.HttpResponse[EchoResponse, string]{ + Body: ftl.Some(EchoResponse{Strings: req.Body.Strings}), + }, nil +} diff --git a/go-runtime/ftl/testdata/go/typeregistry/typeregistry_test.go b/go-runtime/ftl/testdata/go/typeregistry/typeregistry_test.go new file mode 100644 index 0000000000..90286a5947 --- /dev/null +++ b/go-runtime/ftl/testdata/go/typeregistry/typeregistry_test.go @@ -0,0 +1,86 @@ +package typeregistry + +import ( + "ftl/builtin" + "testing" + + "github.com/TBD54566975/ftl/go-runtime/encoding" + "github.com/TBD54566975/ftl/go-runtime/ftl" + "github.com/TBD54566975/ftl/go-runtime/ftl/ftltest" + "github.com/alecthomas/assert/v2" +) + +func TestIngress(t *testing.T) { + testCases := []struct { + Name string + Input StringsTypeEnum + }{ + { + Name: "List", + Input: List([]string{"asdf", "qwerty"}), + }, + { + Name: "Single", + Input: Single("asdf"), + }, + { + Name: "Object", + Input: Object{S: "asdf"}, + }, + } + + ctx := ftltest.Context(ftltest.WithCallsAllowedWithinModule()) + + for _, test := range testCases { + t.Run(test.Name, func(t *testing.T) { + resp, err := ftl.Call(ctx, Echo, builtin.HttpRequest[EchoRequest]{ + Body: EchoRequest{Strings: test.Input}, + }) + assert.NoError(t, err) + assert.Equal(t, resp, builtin.HttpResponse[EchoResponse, string]{ + Body: ftl.Some(EchoResponse{Strings: test.Input}), + }) + }) + } +} + +func TestEncoding(t *testing.T) { + testCases := []struct { + Name string + Input StringsTypeEnum + Encoded string + }{ + { + Name: "List", + Input: List([]string{"asdf", "qwerty"}), + Encoded: `{"input":{"name":"List","value":["asdf","qwerty"]}}`, + }, + { + Name: "Single", + Input: Single("asdf"), + Encoded: `{"input":{"name":"Single","value":"asdf"}}`, + }, + { + Name: "Object", + Input: Object{S: "asdf"}, + Encoded: `{"input":{"name":"Object","value":{"s":"asdf"}}}`, + }, + } + + type jsonObj struct { + Input StringsTypeEnum + } + + for _, test := range testCases { + t.Run(test.Name, func(t *testing.T) { + input := jsonObj{test.Input} + jsonBytes, err := encoding.Marshal(input) + assert.NoError(t, err) + assert.Equal(t, string(jsonBytes), test.Encoded) + roundTripOut := jsonObj{} + err = encoding.Unmarshal(jsonBytes, &roundTripOut) + assert.NoError(t, err) + assert.Equal(t, roundTripOut, input) + }) + } +} diff --git a/go-runtime/ftl/testdata/go/typeregistry/types.ftl.go b/go-runtime/ftl/testdata/go/typeregistry/types.ftl.go new file mode 100644 index 0000000000..4fb4847817 --- /dev/null +++ b/go-runtime/ftl/testdata/go/typeregistry/types.ftl.go @@ -0,0 +1,14 @@ +// Code generated by FTL. DO NOT EDIT. +package typeregistry + +import "github.com/TBD54566975/ftl/go-runtime/ftl/reflection" + +func init() { + reflection.Register( + reflection.SumType[StringsTypeEnum]( + *new(Single), + *new(List), + *new(Object), + ), + ) +}