Skip to content

Commit

Permalink
feat: support extracting a module config from the local environment
Browse files Browse the repository at this point in the history
This is intended primarily for local development/testing. Currently now this
will load from ftl-project.toml and environment variables, but at some
point the envars will be removed.
  • Loading branch information
alecthomas committed Apr 25, 2024
1 parent b34507d commit e2a8063
Show file tree
Hide file tree
Showing 18 changed files with 806 additions and 631 deletions.
9 changes: 7 additions & 2 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema"
"github.com/TBD54566975/ftl/backend/schema"
frontend "github.com/TBD54566975/ftl/frontend"
"github.com/TBD54566975/ftl/go-runtime/modulecontext"
"github.com/TBD54566975/ftl/internal/cors"
"github.com/TBD54566975/ftl/internal/log"
ftlmaps "github.com/TBD54566975/ftl/internal/maps"
Expand Down Expand Up @@ -647,14 +648,18 @@ func (s *Service) GetModuleContext(ctx context.Context, req *connect.Request[ftl
if err != nil {
return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("could not get active schemas: %w", err))
}
schema, ok := slices.Find(schemas, func(s *schema.Module) bool { return s.Name == req.Msg.Module })
module, ok := slices.Find(schemas, func(s *schema.Module) bool { return s.Name == req.Msg.Module })
if !ok {
return nil, connect.NewError(connect.CodeNotFound, fmt.Errorf("module %q not found", req.Msg.Module))
}
response, err := moduleContextToProto(ctx, schema)
moduleContext, err := modulecontext.FromEnvironment(ctx, module.Name)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("could not get module context: %w", err))
}
response, err := moduleContext.ToProto(ctx)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("could not marshal module context: %w", err))
}
return connect.NewResponse(response), nil
}

Expand Down
51 changes: 0 additions & 51 deletions backend/controller/module_context.go

This file was deleted.

52 changes: 0 additions & 52 deletions backend/controller/module_context_test.go

This file was deleted.

Loading

0 comments on commit e2a8063

Please sign in to comment.