Skip to content

Commit

Permalink
chore: use GetSchema instead of PullSchema when getting full schema i…
Browse files Browse the repository at this point in the history
…n ftl schema diff (#3915)
  • Loading branch information
jvmakine authored Jan 7, 2025
1 parent 00df8ac commit b3a8ff3
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions frontend/cli/cmd_schema_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (

ftlv1 "github.com/block/ftl/backend/protos/xyz/block/ftl/v1"
"github.com/block/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect"
schemapb "github.com/block/ftl/common/protos/xyz/block/ftl/schema/v1"
"github.com/block/ftl/common/schema"
"github.com/block/ftl/internal/projectconfig"
"github.com/block/ftl/internal/terminal"
Expand Down Expand Up @@ -131,26 +130,13 @@ func localSchema(ctx context.Context, projectConfig projectconfig.Config) (*sche
}
return sch, nil
}

func schemaForURL(ctx context.Context, schemaClient ftlv1connect.SchemaServiceClient, url url.URL) (*schema.Schema, error) {
resp, err := schemaClient.PullSchema(ctx, connect.NewRequest(&ftlv1.PullSchemaRequest{}))
resp, err := schemaClient.GetSchema(ctx, connect.NewRequest(&ftlv1.GetSchemaRequest{}))
if err != nil {
return nil, fmt.Errorf("url %s: failed to pull schema: %w", url.String(), err)
}

pb := &schemapb.Schema{}
for resp.Receive() {
msg := resp.Msg()
pb.Modules = append(pb.Modules, msg.Schema)
if !msg.More {
break
}
}
if resp.Err() != nil {
return nil, fmt.Errorf("url %s: failed to receive schema: %w", url.String(), resp.Err())
return nil, fmt.Errorf("url %s: failed to get schema: %w", url.String(), err)
}

s, err := schema.FromProto(pb)
s, err := schema.FromProto(resp.Msg.Schema)
if err != nil {
return nil, fmt.Errorf("url %s: failed to parse schema: %w", url.String(), err)
}
Expand Down

0 comments on commit b3a8ff3

Please sign in to comment.