diff --git a/CHANGELOG.md b/CHANGELOG.md index 23ea2ec8f2..011f9ee6af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## [Unreleased] -- No changes yet. +- Fix `buf beta registry webhook create` and `buf beta registry webhook list` to emit proto JSON output. ## [v1.71.0] - 2026-06-16 diff --git a/cmd/buf/internal/command/beta/registry/webhook/webhookcreate/webhookcreate.go b/cmd/buf/internal/command/beta/registry/webhook/webhookcreate/webhookcreate.go index 6abb629635..471e3461c4 100644 --- a/cmd/buf/internal/command/beta/registry/webhook/webhookcreate/webhookcreate.go +++ b/cmd/buf/internal/command/beta/registry/webhook/webhookcreate/webhookcreate.go @@ -16,7 +16,6 @@ package webhookcreate import ( "context" - "encoding/json" "fmt" "buf.build/go/app/appcmd" @@ -26,6 +25,7 @@ import ( "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" "github.com/bufbuild/buf/private/pkg/connectclient" + "github.com/bufbuild/buf/private/pkg/protoencoding" "github.com/spf13/pflag" ) @@ -135,7 +135,7 @@ func run( if err != nil { return err } - webhookJSON, err := json.MarshalIndent(resp.Msg.GetWebhook(), "", "\t") + webhookJSON, err := protoencoding.NewJSONMarshaler(nil, protoencoding.JSONMarshalerWithIndent()).Marshal(resp.Msg) if err != nil { return err } diff --git a/cmd/buf/internal/command/beta/registry/webhook/webhooklist/webhooklist.go b/cmd/buf/internal/command/beta/registry/webhook/webhooklist/webhooklist.go index 99ca1d717e..e3b1bace95 100644 --- a/cmd/buf/internal/command/beta/registry/webhook/webhooklist/webhooklist.go +++ b/cmd/buf/internal/command/beta/registry/webhook/webhooklist/webhooklist.go @@ -16,7 +16,6 @@ package webhooklist import ( "context" - "encoding/json" "buf.build/go/app/appcmd" "buf.build/go/app/appext" @@ -25,6 +24,7 @@ import ( "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" "github.com/bufbuild/buf/private/pkg/connectclient" + "github.com/bufbuild/buf/private/pkg/protoencoding" "github.com/spf13/pflag" ) @@ -117,7 +117,7 @@ func run( _, _ = container.Stdout().Write([]byte("[]")) return nil } - webhooksJSON, err := json.MarshalIndent(resp.Msg.GetWebhooks(), "", "\t") + webhooksJSON, err := protoencoding.NewJSONMarshaler(nil, protoencoding.JSONMarshalerWithIndent()).Marshal(resp.Msg) if err != nil { return err }