Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support extracting a module config from the local environment #1331

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like configs, secrets and DSNs are now discovered without needing the declarations from a module. So the db query to find module can be skipped

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this module var is only used to get the module name, which can just get directly from the req

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah another thing on my mind: when should a deployment fail if a config/secret/DSN is missing. I think that was the other reason i was getting the module, so that we could fail earlier.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it should fail at startup.

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