protobuf: remove gogoproto

Removes gogo/protobuf from buildx and updates to a version of
moby/buildkit where gogo is removed.

This also changes how the proto files are generated. This is because
newer versions of protobuf are more strict about name conflicts. If two
files have the same name (even if they are relative paths) and are used
in different protoc commands, they'll conflict in the registry.

Since protobuf file generation doesn't work very well with
`paths=source_relative`, this removes the `go:generate` expression and
just relies on the dockerfile to perform the generation.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
Jonathan A. Sternberg
2024-10-02 15:51:59 -05:00
parent 8e47387d02
commit b35a0f4718
592 changed files with 46288 additions and 110420 deletions

View File

@ -107,11 +107,11 @@ func doubleWalkDiff(ctx context.Context, changeFn ChangeFunc, a, b walkerFn, fil
var f *types.Stat
var f2copy *currentPath
if f2 != nil {
statCopy := *f2.stat
statCopy := f2.stat.Clone()
if filter != nil {
filter(f2.path, &statCopy)
filter(f2.path, statCopy)
}
f2copy = &currentPath{path: f2.path, stat: &statCopy}
f2copy = &currentPath{path: f2.path, stat: statCopy}
}
k, p := pathChange(f1, f2copy)
switch k {
@ -189,7 +189,7 @@ func sameFile(f1, f2 *currentPath, differ DiffType) (same bool, retErr error) {
}
// If not a directory also check size, modtime, and content
if !f1.stat.IsDir() {
if f1.stat.Size_ != f2.stat.Size_ {
if f1.stat.Size != f2.stat.Size {
return false, nil
}

View File

@ -126,10 +126,10 @@ func (dw *DiskWriter) HandleChange(kind ChangeKind, p string, fi os.FileInfo, er
return errors.WithStack(&os.PathError{Path: p, Err: syscall.EBADMSG, Op: "change without stat info"})
}
statCopy := *stat
statCopy := stat.Clone()
if dw.filter != nil {
if ok := dw.filter(p, &statCopy); !ok {
if ok := dw.filter(p, statCopy); !ok {
return nil
}
}
@ -148,7 +148,7 @@ func (dw *DiskWriter) HandleChange(kind ChangeKind, p string, fi os.FileInfo, er
}
if oldFi != nil && fi.IsDir() && oldFi.IsDir() {
if err := rewriteMetadata(destPath, &statCopy); err != nil {
if err := rewriteMetadata(destPath, statCopy); err != nil {
return errors.Wrapf(err, "error setting dir metadata for %s", destPath)
}
return nil
@ -172,7 +172,7 @@ func (dw *DiskWriter) HandleChange(kind ChangeKind, p string, fi os.FileInfo, er
}
dw.dirModTimes[destPath] = statCopy.ModTime
case fi.Mode()&os.ModeDevice != 0 || fi.Mode()&os.ModeNamedPipe != 0:
if err := handleTarTypeBlockCharFifo(newPath, &statCopy); err != nil {
if err := handleTarTypeBlockCharFifo(newPath, statCopy); err != nil {
return errors.Wrapf(err, "failed to create device %s", newPath)
}
case fi.Mode()&os.ModeSymlink != 0:
@ -200,7 +200,7 @@ func (dw *DiskWriter) HandleChange(kind ChangeKind, p string, fi os.FileInfo, er
}
}
if err := rewriteMetadata(newPath, &statCopy); err != nil {
if err := rewriteMetadata(newPath, statCopy); err != nil {
return errors.Wrapf(err, "error setting metadata for %s", newPath)
}
@ -218,7 +218,7 @@ func (dw *DiskWriter) HandleChange(kind ChangeKind, p string, fi os.FileInfo, er
if isRegularFile {
if dw.opt.AsyncDataCb != nil {
dw.requestAsyncFileData(p, destPath, fi, &statCopy)
dw.requestAsyncFileData(p, destPath, fi, statCopy)
}
} else {
return dw.processChange(dw.ctx, kind, p, fi, nil)
@ -351,8 +351,10 @@ func (lfw *lazyFileWriter) Close() error {
// We generate random temporary file names so that there's a good
// chance the file doesn't exist yet - keeps the number of tries in
// TempFile to a minimum.
var rand uint32
var randmu sync.Mutex
var (
rand uint32
randmu sync.Mutex
)
func reseed() uint32 {
return uint32(time.Now().UnixNano() + int64(os.Getpid()))

View File

@ -34,13 +34,30 @@ target "test-noroot" {
target "lint" {
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
output = ["type=cacheonly"]
args = {
GO_VERSION = "${GO_VERSION}"
}
}
target "validate-generated-files" {
dockerfile = "./hack/dockerfiles/generated-files.Dockerfile"
output = ["type=cacheonly"]
target = "validate"
args = {
GO_VERSION = "${GO_VERSION}"
}
}
target "generated-files" {
inherits = ["validate-generated-files"]
output = ["."]
target = "update"
}
target "validate-gomod" {
dockerfile = "./hack/dockerfiles/gomod.Dockerfile"
output = ["type=cacheonly"]
target = "validate"
args = {
# go mod may produce different results between go versions,
@ -58,6 +75,7 @@ target "gomod" {
target "validate-shfmt" {
dockerfile = "./hack/dockerfiles/shfmt.Dockerfile"
output = ["type=cacheonly"]
target = "validate"
}

View File

@ -91,7 +91,7 @@ func (fs *fs) Open(p string) (io.ReadCloser, error) {
}
type Dir struct {
Stat types.Stat
Stat *types.Stat
FS FS
}
@ -125,12 +125,12 @@ func (fs *subDirFS) Walk(ctx context.Context, target string, fn gofs.WalkDirFunc
continue
}
fi := &StatInfo{&d.Stat}
fi := &StatInfo{d.Stat.Clone()}
if !fi.IsDir() {
return errors.WithStack(&os.PathError{Path: d.Stat.Path, Err: syscall.ENOTDIR, Op: "walk subdir"})
}
dStat := d.Stat
if err := fn(d.Stat.Path, &DirEntryInfo{Stat: &dStat}, nil); err != nil {
dStat := d.Stat.Clone()
if err := fn(d.Stat.Path, &DirEntryInfo{Stat: dStat}, nil); err != nil {
return err
}
if err := d.FS.Walk(ctx, rest, func(p string, entry gofs.DirEntry, err error) error {
@ -176,8 +176,7 @@ func (fs *subDirFS) Open(p string) (io.ReadCloser, error) {
return d.FS.Open(parts[1])
}
type emptyReader struct {
}
type emptyReader struct{}
func (*emptyReader) Read([]byte) (int, error) {
return 0, io.EOF
@ -190,18 +189,23 @@ type StatInfo struct {
func (s *StatInfo) Name() string {
return filepath.Base(s.Stat.Path)
}
func (s *StatInfo) Size() int64 {
return s.Stat.Size_
return s.Stat.Size
}
func (s *StatInfo) Mode() os.FileMode {
return os.FileMode(s.Stat.Mode)
}
func (s *StatInfo) ModTime() time.Time {
return time.Unix(s.Stat.ModTime/1e9, s.Stat.ModTime%1e9)
}
func (s *StatInfo) IsDir() bool {
return s.Mode().IsDir()
}
func (s *StatInfo) Sys() interface{} {
return s.Stat
}
@ -221,18 +225,21 @@ func (s *DirEntryInfo) Name() string {
}
return s.entry.Name()
}
func (s *DirEntryInfo) IsDir() bool {
if s.Stat != nil {
return s.Stat.IsDir()
}
return s.entry.IsDir()
}
func (s *DirEntryInfo) Type() gofs.FileMode {
if s.Stat != nil {
return gofs.FileMode(s.Stat.Mode)
}
return s.entry.Type()
}
func (s *DirEntryInfo) Info() (gofs.FileInfo, error) {
if s.Stat == nil {
fi, err := s.entry.Info()
@ -246,6 +253,6 @@ func (s *DirEntryInfo) Info() (gofs.FileInfo, error) {
s.Stat = stat
}
st := *s.Stat
return &StatInfo{&st}, nil
st := s.Stat.Clone()
return &StatInfo{st}, nil
}

View File

@ -27,7 +27,7 @@ func mkstat(path, relpath string, fi os.FileInfo, inodemap map[uint64]string) (*
setUnixOpt(fi, stat, relpath, inodemap)
if !fi.IsDir() {
stat.Size_ = fi.Size()
stat.Size = fi.Size()
if fi.Mode()&os.ModeSymlink != 0 {
link, err := os.Readlink(path)
if err != nil {

View File

@ -52,7 +52,7 @@ func setUnixOpt(fi os.FileInfo, stat *types.Stat, path string, seenFiles map[uin
if s.Nlink > 1 {
if oldpath, ok := seenFiles[ino]; ok {
stat.Linkname = oldpath
stat.Size_ = 0
stat.Size = 0
linked = true
}
}

View File

@ -1,3 +0,0 @@
package types
//go:generate protoc --gogoslick_out=. stat.proto wire.proto

View File

@ -1,7 +1,40 @@
package types
import "os"
import (
"os"
func (s Stat) IsDir() bool {
"google.golang.org/protobuf/proto"
)
func (s *Stat) IsDir() bool {
return os.FileMode(s.Mode).IsDir()
}
func (s *Stat) Marshal() ([]byte, error) {
return proto.MarshalOptions{Deterministic: true}.Marshal(s)
}
func (s *Stat) Unmarshal(dAtA []byte) error {
return proto.UnmarshalOptions{Merge: true}.Unmarshal(dAtA, s)
}
func (s *Stat) Clone() *Stat {
clone := &Stat{
Path: s.Path,
Mode: s.Mode,
Uid: s.Uid,
Gid: s.Gid,
Size: s.Size,
ModTime: s.ModTime,
Linkname: s.Linkname,
Devmajor: s.Devmajor,
Devminor: s.Devminor,
}
if s.Xattrs != nil {
s.Xattrs = make(map[string][]byte, len(s.Xattrs))
for k, v := range s.Xattrs {
clone.Xattrs[k] = v
}
}
return clone
}

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@ syntax = "proto3";
package fsutil.types;
option go_package = "types";
option go_package = "github.com/tonistiigi/fsutil/types";
message Stat {
string path = 1;
@ -16,4 +16,4 @@ message Stat {
int64 devmajor = 8;
int64 devminor = 9;
map<string, bytes> xattrs = 10;
}
}

23
vendor/github.com/tonistiigi/fsutil/types/wire.go generated vendored Normal file
View File

@ -0,0 +1,23 @@
package types
import "google.golang.org/protobuf/proto"
const (
PACKET_STAT = Packet_PACKET_STAT
PACKET_REQ = Packet_PACKET_REQ
PACKET_DATA = Packet_PACKET_DATA
PACKET_FIN = Packet_PACKET_FIN
PACKET_ERR = Packet_PACKET_ERR
)
func (p *Packet) Marshal() ([]byte, error) {
return proto.MarshalOptions{Deterministic: true}.Marshal(p)
}
func (p *Packet) Unmarshal(dAtA []byte) error {
return proto.UnmarshalOptions{Merge: true}.Unmarshal(dAtA, p)
}
func (p *Packet) Size() int {
return proto.Size(p)
}

View File

@ -1,575 +1,247 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: wire.proto
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc v3.11.4
// source: github.com/tonistiigi/fsutil/types/wire.proto
package types
import (
bytes "bytes"
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
strconv "strconv"
strings "strings"
sync "sync"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Packet_PacketType int32
const (
PACKET_STAT Packet_PacketType = 0
PACKET_REQ Packet_PacketType = 1
PACKET_DATA Packet_PacketType = 2
PACKET_FIN Packet_PacketType = 3
PACKET_ERR Packet_PacketType = 4
Packet_PACKET_STAT Packet_PacketType = 0
Packet_PACKET_REQ Packet_PacketType = 1
Packet_PACKET_DATA Packet_PacketType = 2
Packet_PACKET_FIN Packet_PacketType = 3
Packet_PACKET_ERR Packet_PacketType = 4
)
var Packet_PacketType_name = map[int32]string{
0: "PACKET_STAT",
1: "PACKET_REQ",
2: "PACKET_DATA",
3: "PACKET_FIN",
4: "PACKET_ERR",
// Enum value maps for Packet_PacketType.
var (
Packet_PacketType_name = map[int32]string{
0: "PACKET_STAT",
1: "PACKET_REQ",
2: "PACKET_DATA",
3: "PACKET_FIN",
4: "PACKET_ERR",
}
Packet_PacketType_value = map[string]int32{
"PACKET_STAT": 0,
"PACKET_REQ": 1,
"PACKET_DATA": 2,
"PACKET_FIN": 3,
"PACKET_ERR": 4,
}
)
func (x Packet_PacketType) Enum() *Packet_PacketType {
p := new(Packet_PacketType)
*p = x
return p
}
var Packet_PacketType_value = map[string]int32{
"PACKET_STAT": 0,
"PACKET_REQ": 1,
"PACKET_DATA": 2,
"PACKET_FIN": 3,
"PACKET_ERR": 4,
func (x Packet_PacketType) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Packet_PacketType) Descriptor() protoreflect.EnumDescriptor {
return file_github_com_tonistiigi_fsutil_types_wire_proto_enumTypes[0].Descriptor()
}
func (Packet_PacketType) Type() protoreflect.EnumType {
return &file_github_com_tonistiigi_fsutil_types_wire_proto_enumTypes[0]
}
func (x Packet_PacketType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Packet_PacketType.Descriptor instead.
func (Packet_PacketType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_f2dcdddcdf68d8e0, []int{0, 0}
return file_github_com_tonistiigi_fsutil_types_wire_proto_rawDescGZIP(), []int{0, 0}
}
type Packet struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Type Packet_PacketType `protobuf:"varint,1,opt,name=type,proto3,enum=fsutil.types.Packet_PacketType" json:"type,omitempty"`
Stat *Stat `protobuf:"bytes,2,opt,name=stat,proto3" json:"stat,omitempty"`
ID uint32 `protobuf:"varint,3,opt,name=ID,proto3" json:"ID,omitempty"`
Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
}
func (m *Packet) Reset() { *m = Packet{} }
func (x *Packet) Reset() {
*x = Packet{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_tonistiigi_fsutil_types_wire_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Packet) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Packet) ProtoMessage() {}
func (*Packet) Descriptor() ([]byte, []int) {
return fileDescriptor_f2dcdddcdf68d8e0, []int{0}
}
func (m *Packet) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Packet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Packet.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
func (x *Packet) ProtoReflect() protoreflect.Message {
mi := &file_github_com_tonistiigi_fsutil_types_wire_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return b[:n], nil
return ms
}
}
func (m *Packet) XXX_Merge(src proto.Message) {
xxx_messageInfo_Packet.Merge(m, src)
}
func (m *Packet) XXX_Size() int {
return m.Size()
}
func (m *Packet) XXX_DiscardUnknown() {
xxx_messageInfo_Packet.DiscardUnknown(m)
return mi.MessageOf(x)
}
var xxx_messageInfo_Packet proto.InternalMessageInfo
// Deprecated: Use Packet.ProtoReflect.Descriptor instead.
func (*Packet) Descriptor() ([]byte, []int) {
return file_github_com_tonistiigi_fsutil_types_wire_proto_rawDescGZIP(), []int{0}
}
func (m *Packet) GetType() Packet_PacketType {
if m != nil {
return m.Type
func (x *Packet) GetType() Packet_PacketType {
if x != nil {
return x.Type
}
return PACKET_STAT
return Packet_PACKET_STAT
}
func (m *Packet) GetStat() *Stat {
if m != nil {
return m.Stat
func (x *Packet) GetStat() *Stat {
if x != nil {
return x.Stat
}
return nil
}
func (m *Packet) GetID() uint32 {
if m != nil {
return m.ID
func (x *Packet) GetID() uint32 {
if x != nil {
return x.ID
}
return 0
}
func (m *Packet) GetData() []byte {
if m != nil {
return m.Data
func (x *Packet) GetData() []byte {
if x != nil {
return x.Data
}
return nil
}
func init() {
proto.RegisterEnum("fsutil.types.Packet_PacketType", Packet_PacketType_name, Packet_PacketType_value)
proto.RegisterType((*Packet)(nil), "fsutil.types.Packet")
}
var File_github_com_tonistiigi_fsutil_types_wire_proto protoreflect.FileDescriptor
func init() { proto.RegisterFile("wire.proto", fileDescriptor_f2dcdddcdf68d8e0) }
var fileDescriptor_f2dcdddcdf68d8e0 = []byte{
// 276 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2a, 0xcf, 0x2c, 0x4a,
0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x49, 0x2b, 0x2e, 0x2d, 0xc9, 0xcc, 0xd1, 0x2b,
0xa9, 0x2c, 0x48, 0x2d, 0x96, 0xe2, 0x2a, 0x2e, 0x49, 0x2c, 0x81, 0xc8, 0x28, 0xbd, 0x64, 0xe4,
0x62, 0x0b, 0x48, 0x4c, 0xce, 0x4e, 0x2d, 0x11, 0x32, 0xe6, 0x62, 0x01, 0xc9, 0x4b, 0x30, 0x2a,
0x30, 0x6a, 0xf0, 0x19, 0xc9, 0xeb, 0x21, 0xeb, 0xd1, 0x83, 0xa8, 0x81, 0x52, 0x21, 0x95, 0x05,
0xa9, 0x41, 0x60, 0xc5, 0x42, 0x6a, 0x5c, 0x2c, 0x20, 0xd3, 0x24, 0x98, 0x14, 0x18, 0x35, 0xb8,
0x8d, 0x84, 0x50, 0x35, 0x05, 0x97, 0x24, 0x96, 0x04, 0x81, 0xe5, 0x85, 0xf8, 0xb8, 0x98, 0x3c,
0x5d, 0x24, 0x98, 0x15, 0x18, 0x35, 0x78, 0x83, 0x98, 0x3c, 0x5d, 0x84, 0x84, 0xb8, 0x58, 0x52,
0x12, 0x4b, 0x12, 0x25, 0x58, 0x14, 0x18, 0x35, 0x78, 0x82, 0xc0, 0x6c, 0xa5, 0x38, 0x2e, 0x2e,
0x84, 0xf9, 0x42, 0xfc, 0x5c, 0xdc, 0x01, 0x8e, 0xce, 0xde, 0xae, 0x21, 0xf1, 0xc1, 0x21, 0x8e,
0x21, 0x02, 0x0c, 0x42, 0x7c, 0x5c, 0x5c, 0x50, 0x81, 0x20, 0xd7, 0x40, 0x01, 0x46, 0x24, 0x05,
0x2e, 0x8e, 0x21, 0x8e, 0x02, 0x4c, 0x48, 0x0a, 0xdc, 0x3c, 0xfd, 0x04, 0x98, 0x91, 0xf8, 0xae,
0x41, 0x41, 0x02, 0x2c, 0x4e, 0xd6, 0x17, 0x1e, 0xca, 0x31, 0xdc, 0x78, 0x28, 0xc7, 0xf0, 0xe1,
0xa1, 0x1c, 0x63, 0xc3, 0x23, 0x39, 0xc6, 0x15, 0x8f, 0xe4, 0x18, 0x4f, 0x3c, 0x92, 0x63, 0xbc,
0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x17, 0x8f, 0xe4, 0x18, 0x3e, 0x3c, 0x92, 0x63,
0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x58, 0xc1,
0x7e, 0x49, 0x62, 0x03, 0x87, 0x97, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x9d, 0xe3, 0x51,
0x57, 0x01, 0x00, 0x00,
}
func (x Packet_PacketType) String() string {
s, ok := Packet_PacketType_name[int32(x)]
if ok {
return s
}
return strconv.Itoa(int(x))
}
func (this *Packet) Equal(that interface{}) bool {
if that == nil {
return this == nil
}
that1, ok := that.(*Packet)
if !ok {
that2, ok := that.(Packet)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
return this == nil
} else if this == nil {
return false
}
if this.Type != that1.Type {
return false
}
if !this.Stat.Equal(that1.Stat) {
return false
}
if this.ID != that1.ID {
return false
}
if !bytes.Equal(this.Data, that1.Data) {
return false
}
return true
}
func (this *Packet) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 8)
s = append(s, "&types.Packet{")
s = append(s, "Type: "+fmt.Sprintf("%#v", this.Type)+",\n")
if this.Stat != nil {
s = append(s, "Stat: "+fmt.Sprintf("%#v", this.Stat)+",\n")
}
s = append(s, "ID: "+fmt.Sprintf("%#v", this.ID)+",\n")
s = append(s, "Data: "+fmt.Sprintf("%#v", this.Data)+",\n")
s = append(s, "}")
return strings.Join(s, "")
}
func valueToGoStringWire(v interface{}, typ string) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
}
func (m *Packet) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *Packet) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Data) > 0 {
i -= len(m.Data)
copy(dAtA[i:], m.Data)
i = encodeVarintWire(dAtA, i, uint64(len(m.Data)))
i--
dAtA[i] = 0x22
}
if m.ID != 0 {
i = encodeVarintWire(dAtA, i, uint64(m.ID))
i--
dAtA[i] = 0x18
}
if m.Stat != nil {
{
size, err := m.Stat.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintWire(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
if m.Type != 0 {
i = encodeVarintWire(dAtA, i, uint64(m.Type))
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
func encodeVarintWire(dAtA []byte, offset int, v uint64) int {
offset -= sovWire(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *Packet) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Type != 0 {
n += 1 + sovWire(uint64(m.Type))
}
if m.Stat != nil {
l = m.Stat.Size()
n += 1 + l + sovWire(uint64(l))
}
if m.ID != 0 {
n += 1 + sovWire(uint64(m.ID))
}
l = len(m.Data)
if l > 0 {
n += 1 + l + sovWire(uint64(l))
}
return n
}
func sovWire(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozWire(x uint64) (n int) {
return sovWire(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (this *Packet) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&Packet{`,
`Type:` + fmt.Sprintf("%v", this.Type) + `,`,
`Stat:` + strings.Replace(fmt.Sprintf("%v", this.Stat), "Stat", "Stat", 1) + `,`,
`ID:` + fmt.Sprintf("%v", this.ID) + `,`,
`Data:` + fmt.Sprintf("%v", this.Data) + `,`,
`}`,
}, "")
return s
}
func valueToStringWire(v interface{}) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("*%v", pv)
}
func (m *Packet) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowWire
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Packet: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Packet: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
}
m.Type = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowWire
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Type |= Packet_PacketType(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Stat", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowWire
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthWire
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthWire
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Stat == nil {
m.Stat = &Stat{}
}
if err := m.Stat.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
}
m.ID = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowWire
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.ID |= uint32(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowWire
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthWire
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthWire
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
if m.Data == nil {
m.Data = []byte{}
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipWire(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthWire
}
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthWire
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipWire(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowWire
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowWire
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
case 1:
iNdEx += 8
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowWire
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if length < 0 {
return 0, ErrInvalidLengthWire
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupWire
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthWire
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
var file_github_com_tonistiigi_fsutil_types_wire_proto_rawDesc = []byte{
0x0a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6f, 0x6e,
0x69, 0x73, 0x74, 0x69, 0x69, 0x67, 0x69, 0x2f, 0x66, 0x73, 0x75, 0x74, 0x69, 0x6c, 0x2f, 0x74,
0x79, 0x70, 0x65, 0x73, 0x2f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
0x0c, 0x66, 0x73, 0x75, 0x74, 0x69, 0x6c, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x1a, 0x2d, 0x67,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6f, 0x6e, 0x69, 0x73, 0x74,
0x69, 0x69, 0x67, 0x69, 0x2f, 0x66, 0x73, 0x75, 0x74, 0x69, 0x6c, 0x2f, 0x74, 0x79, 0x70, 0x65,
0x73, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe9, 0x01, 0x0a,
0x06, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x33, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x66, 0x73, 0x75, 0x74, 0x69, 0x6c, 0x2e, 0x74,
0x79, 0x70, 0x65, 0x73, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x50, 0x61, 0x63, 0x6b,
0x65, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x26, 0x0a, 0x04,
0x73, 0x74, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x66, 0x73, 0x75,
0x74, 0x69, 0x6c, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x52, 0x04,
0x73, 0x74, 0x61, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d,
0x52, 0x02, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01,
0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x5e, 0x0a, 0x0a, 0x50, 0x61, 0x63, 0x6b,
0x65, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54,
0x5f, 0x53, 0x54, 0x41, 0x54, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x41, 0x43, 0x4b, 0x45,
0x54, 0x5f, 0x52, 0x45, 0x51, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x41, 0x43, 0x4b, 0x45,
0x54, 0x5f, 0x44, 0x41, 0x54, 0x41, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x41, 0x43, 0x4b,
0x45, 0x54, 0x5f, 0x46, 0x49, 0x4e, 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x41, 0x43, 0x4b,
0x45, 0x54, 0x5f, 0x45, 0x52, 0x52, 0x10, 0x04, 0x42, 0x24, 0x5a, 0x22, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6f, 0x6e, 0x69, 0x73, 0x74, 0x69, 0x69, 0x67,
0x69, 0x2f, 0x66, 0x73, 0x75, 0x74, 0x69, 0x6c, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
ErrInvalidLengthWire = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowWire = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupWire = fmt.Errorf("proto: unexpected end of group")
file_github_com_tonistiigi_fsutil_types_wire_proto_rawDescOnce sync.Once
file_github_com_tonistiigi_fsutil_types_wire_proto_rawDescData = file_github_com_tonistiigi_fsutil_types_wire_proto_rawDesc
)
func file_github_com_tonistiigi_fsutil_types_wire_proto_rawDescGZIP() []byte {
file_github_com_tonistiigi_fsutil_types_wire_proto_rawDescOnce.Do(func() {
file_github_com_tonistiigi_fsutil_types_wire_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_tonistiigi_fsutil_types_wire_proto_rawDescData)
})
return file_github_com_tonistiigi_fsutil_types_wire_proto_rawDescData
}
var file_github_com_tonistiigi_fsutil_types_wire_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_github_com_tonistiigi_fsutil_types_wire_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_github_com_tonistiigi_fsutil_types_wire_proto_goTypes = []interface{}{
(Packet_PacketType)(0), // 0: fsutil.types.Packet.PacketType
(*Packet)(nil), // 1: fsutil.types.Packet
(*Stat)(nil), // 2: fsutil.types.Stat
}
var file_github_com_tonistiigi_fsutil_types_wire_proto_depIdxs = []int32{
0, // 0: fsutil.types.Packet.type:type_name -> fsutil.types.Packet.PacketType
2, // 1: fsutil.types.Packet.stat:type_name -> fsutil.types.Stat
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_github_com_tonistiigi_fsutil_types_wire_proto_init() }
func file_github_com_tonistiigi_fsutil_types_wire_proto_init() {
if File_github_com_tonistiigi_fsutil_types_wire_proto != nil {
return
}
file_github_com_tonistiigi_fsutil_types_stat_proto_init()
if !protoimpl.UnsafeEnabled {
file_github_com_tonistiigi_fsutil_types_wire_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Packet); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_github_com_tonistiigi_fsutil_types_wire_proto_rawDesc,
NumEnums: 1,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_github_com_tonistiigi_fsutil_types_wire_proto_goTypes,
DependencyIndexes: file_github_com_tonistiigi_fsutil_types_wire_proto_depIdxs,
EnumInfos: file_github_com_tonistiigi_fsutil_types_wire_proto_enumTypes,
MessageInfos: file_github_com_tonistiigi_fsutil_types_wire_proto_msgTypes,
}.Build()
File_github_com_tonistiigi_fsutil_types_wire_proto = out.File
file_github_com_tonistiigi_fsutil_types_wire_proto_rawDesc = nil
file_github_com_tonistiigi_fsutil_types_wire_proto_goTypes = nil
file_github_com_tonistiigi_fsutil_types_wire_proto_depIdxs = nil
}

View File

@ -2,9 +2,9 @@ syntax = "proto3";
package fsutil.types;
option go_package = "types";
option go_package = "github.com/tonistiigi/fsutil/types";
import "stat.proto";
import "github.com/tonistiigi/fsutil/types/stat.proto";
message Packet {
enum PacketType {