From 56d5784e91eb4aa4421fbde5b7e8acdfcdc4e19a Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Tue, 8 Oct 2024 14:29:43 +1100 Subject: [PATCH] fix schema diff --- backend/controller/admin/local_client.go | 5 ++--- frontend/cli/cmd_schema_diff.go | 9 +++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/backend/controller/admin/local_client.go b/backend/controller/admin/local_client.go index eccd6d0887..9b2a9dcb7e 100644 --- a/backend/controller/admin/local_client.go +++ b/backend/controller/admin/local_client.go @@ -4,9 +4,6 @@ import ( "context" "fmt" - "github.com/alecthomas/types/either" - "github.com/alecthomas/types/optional" - "github.com/TBD54566975/ftl/internal/buildengine/languageplugin" cf "github.com/TBD54566975/ftl/internal/configuration" "github.com/TBD54566975/ftl/internal/configuration/manager" @@ -14,6 +11,8 @@ import ( "github.com/TBD54566975/ftl/internal/projectconfig" "github.com/TBD54566975/ftl/internal/schema" "github.com/TBD54566975/ftl/internal/watch" + "github.com/alecthomas/types/either" + "github.com/alecthomas/types/optional" ) // localClient reads and writes to local projectconfig files without making any network diff --git a/frontend/cli/cmd_schema_diff.go b/frontend/cli/cmd_schema_diff.go index f88a1e941a..168e6a4124 100644 --- a/frontend/cli/cmd_schema_diff.go +++ b/frontend/cli/cmd_schema_diff.go @@ -91,7 +91,6 @@ func (d *schemaDiffCmd) Run(ctx context.Context, currentURL *url.URL, projConfig } func localSchema(ctx context.Context, projectConfig projectconfig.Config) (*schema.Schema, error) { - pb := &schema.Schema{} errs := []error{} modules, err := watch.DiscoverModules(ctx, projectConfig.AbsModuleDirs()) if err != nil { @@ -140,13 +139,11 @@ func localSchema(ctx context.Context, projectConfig projectconfig.Config) (*sche } } - if len(errs) > 0 { + // we want schema even if there are errors as long as we have some modules + if len(sch.Modules) == 0 && len(errs) > 0 { return nil, fmt.Errorf("failed to read schema, possibly due to not building: %w", errors.Join(errs...)) } - if len(sch.Modules) == 0 { - return nil, errors.New("no modules found") - } - return pb, nil + return sch, nil } func schemaForURL(ctx context.Context, url url.URL) (*schema.Schema, error) {