Skip to content

Commit

Permalink
Add yaml format (#2470)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfus committed Nov 17, 2023
1 parent 11089b9 commit ee274b3
Show file tree
Hide file tree
Showing 48 changed files with 1,274 additions and 661 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

## [Unreleased]

- No changes yet.
- Add support for `yaml` format. All commands that take image inputs, output images,
or convert between message formats, now take `yaml` as a format, in addition to
the existing `binpb` and `txtpb` formats. Some examples:
- `buf build -o image.yaml`
- `buf ls-files image.yaml`
- `buf convert --type foo.Bar --from input.binpb --to output.yaml`
- The `yaml` and `json` formats now accept two new options: `use_proto_names` and
`use_enum_numbers`. This affects output serialization. Some examples:
- `buf convert --type foo.Bar --from input.binpb --to output.yaml#use_proto_names=true`
- `buf convert --type foo.Bar --from input.binpb --to -#format=yaml,use_enum_numbers=true`

## [v1.28.1] - 2023-11-15

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
connectrpc.com/otelconnect v0.6.0
github.com/bufbuild/protocompile v0.6.1-0.20231108163138-146b831231f7
github.com/bufbuild/protovalidate-go v0.4.1
github.com/bufbuild/protoyaml-go v0.1.6
github.com/docker/docker v24.0.7+incompatible
github.com/go-chi/chi/v5 v5.0.10
github.com/gofrs/flock v0.8.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ github.com/bufbuild/protocompile v0.6.1-0.20231108163138-146b831231f7 h1:1pUks8V
github.com/bufbuild/protocompile v0.6.1-0.20231108163138-146b831231f7/go.mod h1:9N39DyRmxAF5+5AjqXQKV6hyWDI0EeoX4TRMix2ZnPE=
github.com/bufbuild/protovalidate-go v0.4.1 h1:ye/8S72WbEklCeltPkSEeT8Eu1A7P/gmMsmapkwqTFk=
github.com/bufbuild/protovalidate-go v0.4.1/go.mod h1:+p5FXfOjSEgLz5WBDTOMPMdQPXqALEERbJZU7huDCtA=
github.com/bufbuild/protoyaml-go v0.1.6 h1:wcdVCJOepw2Xd1KC53RuXoXkk4bc25gbFceFKN8QaO0=
github.com/bufbuild/protoyaml-go v0.1.6/go.mod h1:zrn7hI6KzmuW6kb8E437j3NAI2jY60eImQgxTInvcT8=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand Down
16 changes: 11 additions & 5 deletions private/buf/bufcli/bufcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func NewWireImageReader(
) bufwire.ImageReader {
return bufwire.NewImageReader(
logger,
newFetchImageReader(logger, storageosProvider, runner),
newFetchMessageReader(logger, storageosProvider, runner),
)
}

Expand All @@ -506,9 +506,12 @@ func NewWireImageWriter(
// NewWireProtoEncodingReader returns a new ProtoEncodingReader.
func NewWireProtoEncodingReader(
logger *zap.Logger,
storageosProvider storageos.Provider,
runner command.Runner,
) bufwire.ProtoEncodingReader {
return bufwire.NewProtoEncodingReader(
logger,
newFetchMessageReader(logger, storageosProvider, runner),
)
}

Expand All @@ -518,6 +521,9 @@ func NewWireProtoEncodingWriter(
) bufwire.ProtoEncodingWriter {
return bufwire.NewProtoEncodingWriter(
logger,
buffetch.NewWriter(
logger,
),
)
}

Expand Down Expand Up @@ -1010,14 +1016,14 @@ func newFetchSourceReader(
)
}

// newFetchImageReader creates a new buffetch.ImageReader with the default HTTP client
// newFetchMessageReader creates a new buffetch.MessageReader with the default HTTP client
// and git cloner.
func newFetchImageReader(
func newFetchMessageReader(
logger *zap.Logger,
storageosProvider storageos.Provider,
runner command.Runner,
) buffetch.ImageReader {
return buffetch.NewImageReader(
) buffetch.MessageReader {
return buffetch.NewMessageReader(
logger,
storageosProvider,
defaultHTTPClient,
Expand Down
138 changes: 0 additions & 138 deletions private/buf/bufconvert/bufconvert.go

This file was deleted.

40 changes: 0 additions & 40 deletions private/buf/bufconvert/message_encoding_ref.go

This file was deleted.

19 changes: 0 additions & 19 deletions private/buf/bufconvert/usage.gen.go

This file was deleted.

Loading

0 comments on commit ee274b3

Please sign in to comment.