rebase: bump github.com/google/fscrypt from 0.3.3 to 0.3.4

Bumps [github.com/google/fscrypt](https://github.com/google/fscrypt) from 0.3.3 to 0.3.4.
- [Release notes](https://github.com/google/fscrypt/releases)
- [Changelog](https://github.com/google/fscrypt/blob/master/NEWS.md)
- [Commits](https://github.com/google/fscrypt/compare/v0.3.3...v0.3.4)

---
updated-dependencies:
- dependency-name: github.com/google/fscrypt
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2023-02-20 14:30:55 +00:00
committed by mergify[bot]
parent 991c21f7fd
commit f84d43c6d1
13 changed files with 852 additions and 441 deletions

View File

@ -29,31 +29,39 @@ package metadata
import (
"io"
"github.com/golang/protobuf/jsonpb"
"google.golang.org/protobuf/encoding/protojson"
)
// WriteConfig outputs the Config data as nicely formatted JSON
func WriteConfig(config *Config, out io.Writer) error {
m := jsonpb.Marshaler{
EmitDefaults: true,
EnumsAsInts: false,
Indent: "\t",
OrigName: true,
m := protojson.MarshalOptions{
Multiline: true,
Indent: "\t",
UseProtoNames: true,
UseEnumNumbers: false,
EmitUnpopulated: true,
}
if err := m.Marshal(out, config); err != nil {
bytes, err := m.Marshal(config)
if err != nil {
return err
}
_, err := out.Write([]byte{'\n'})
if _, err = out.Write(bytes); err != nil {
return err
}
_, err = out.Write([]byte{'\n'})
return err
}
// ReadConfig writes the JSON data into the config structure
func ReadConfig(in io.Reader) (*Config, error) {
config := new(Config)
// Allow (and ignore) unknown fields for forwards compatibility.
u := jsonpb.Unmarshaler{
AllowUnknownFields: true,
bytes, err := io.ReadAll(in)
if err != nil {
return nil, err
}
return config, u.Unmarshal(in, config)
config := new(Config)
// Discard unknown fields for forwards compatibility.
u := protojson.UnmarshalOptions{
DiscardUnknown: true,
}
return config, u.Unmarshal(bytes, config)
}