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

update compute descriptor to include dependencies and accept implicit project/locations #199

Merged
merged 1 commit into from
Jun 5, 2023
Merged
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
18 changes: 12 additions & 6 deletions cmd/registry-experimental/cmd/compute/descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,28 @@ func descriptorCommand() *cobra.Command {
Use: "descriptor",
Short: "Compute descriptors of API specs",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
c, err := connection.ActiveConfig()
if err != nil {
return err
}
pattern := c.FQName(args[0])

filter, err := cmd.Flags().GetString("filter")
if err != nil {
log.FromContext(ctx).WithError(err).Fatal("Failed to get filter from flags")
return err
}

client, err := connection.NewRegistryClient(ctx)
if err != nil {
log.FromContext(ctx).WithError(err).Fatal("Failed to get client")
return err
}
// Initialize task queue.
taskQueue, wait := tasks.WorkerPoolIgnoreError(ctx, 1)
defer wait()
// Generate tasks.
name := args[0]
if spec, err := names.ParseSpec(name); err == nil {
if spec, err := names.ParseSpec(pattern); err == nil {
err = visitor.ListSpecs(ctx, client, spec, filter, false, func(ctx context.Context, spec *rpc.ApiSpec) error {
taskQueue <- &computeDescriptorTask{
client: client,
Expand All @@ -71,9 +75,10 @@ func descriptorCommand() *cobra.Command {
return nil
})
if err != nil {
log.FromContext(ctx).WithError(err).Fatal("Failed to list specs")
return err
}
}
return nil
},
}
}
Expand Down Expand Up @@ -180,6 +185,7 @@ func generateDescriptorForDirectory(ctx context.Context, name string, root strin
args := []string{}
args = append(args, protos...)
args = append(args, "--proto_path=protos")
args = append(args, "--include_imports")
args = append(args, "--descriptor_set_out=proto.pb")
cmd := exec.Command("protoc", args...)
cmd.Dir = root
Expand Down