diff --git a/backend/common/moduleconfig/config.go b/backend/common/moduleconfig/config.go index 888b9ecf30..1b7b758696 100644 --- a/backend/common/moduleconfig/config.go +++ b/backend/common/moduleconfig/config.go @@ -14,6 +14,7 @@ type ModuleConfig struct { Language string `toml:"language"` Module string `toml:"module"` Deploy []string `toml:"deploy"` + Schema string `toml:"schema"` } // LoadConfig from a directory. diff --git a/cmd/ftl/cmd_deploy.go b/cmd/ftl/cmd_deploy.go index e1f831dc11..7abd54038e 100644 --- a/cmd/ftl/cmd_deploy.go +++ b/cmd/ftl/cmd_deploy.go @@ -9,6 +9,7 @@ import ( "connectrpc.com/connect" "github.com/alecthomas/errors" "golang.org/x/exp/maps" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/timestamppb" "github.com/TBD54566975/ftl/backend/common/log" @@ -53,6 +54,37 @@ func (d *deployCmd) Run(ctx context.Context, client ftlv1connect.ControllerServi return errors.WithStack(err) } + module := schemapb.Module{ + Name: config.Module, + } + // TODO(worstell): clean up deploy cmd to handle language-specific stuff + if config.Language == "kotlin" { + schemaDirectory := config.Schema + schema, err := findFiles(d.Base, []string{schemaDirectory}) + if err != nil { + return errors.WithStack(err) + } + + if len(schema) != 1 { + return errors.Errorf("cannot define multiple module schemas") + } + + content, err := os.ReadFile(schema[0]) + if err != nil { + return errors.WithStack(err) + } + + err = proto.Unmarshal(content, &module) + if err != nil { + return errors.WithStack(err) + } + } + module.Runtime = &schemapb.ModuleRuntime{ + CreateTime: timestamppb.Now(), + Language: config.Language, + MinReplicas: d.Replicas, + } + logger.Infof("Uploading %d/%d files", len(gadResp.Msg.MissingDigests), len(files)) for _, missing := range gadResp.Msg.MissingDigests { file := filesByHash[missing] @@ -71,14 +103,7 @@ func (d *deployCmd) Run(ctx context.Context, client ftlv1connect.ControllerServi } resp, err := client.CreateDeployment(ctx, connect.NewRequest(&ftlv1.CreateDeploymentRequest{ // TODO(aat): Use real data for this. - Schema: &schemapb.Module{ - Name: config.Module, - Runtime: &schemapb.ModuleRuntime{ - CreateTime: timestamppb.Now(), - Language: config.Language, - MinReplicas: d.Replicas, - }, - }, + Schema: &module, Artefacts: slices.Map(maps.Values(filesByHash), func(a deploymentArtefact) *ftlv1.DeploymentArtefact { return a.DeploymentArtefact }), diff --git a/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/ModuleGenerator.kt b/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/ModuleGenerator.kt index 8072e603b4..336906529d 100644 --- a/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/ModuleGenerator.kt +++ b/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/ModuleGenerator.kt @@ -176,6 +176,7 @@ class ModuleGenerator() { module = "${module}" language = "kotlin" deploy = ["main", "classes", "dependency", "classpath.txt"] + schema = "generated-sources/ksp" """.trimIndent() )