github.com/nicocha30/gvisor-ligolo@v0.0.0-20230726075806-989fa2c0a413/pkg/shim/runtimeoptions/runtimeoptions_cri.go (about)

     1  // Copyright 2018 The containerd Authors.
     2  // Copyright 2018 The gVisor Authors.
     3  //
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  //     https://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  // Unless required by applicable law or agreed to in writing, software
    11  // distributed under the License is distributed on an "AS IS" BASIS,
    12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  
    16  //go:build go1.1
    17  // +build go1.1
    18  
    19  package runtimeoptions
    20  
    21  import (
    22  	"fmt"
    23  	"io"
    24  	math_bits "math/bits"
    25  	"reflect"
    26  	"strings"
    27  
    28  	"github.com/gogo/protobuf/proto"
    29  )
    30  
    31  // This is a compile-time assertion to ensure that this generated file
    32  // is compatible with the proto package it is being compiled against.
    33  // A compilation error at this line likely means your copy of the
    34  // proto package needs to be updated.
    35  const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
    36  
    37  type Options struct {
    38  	// TypeUrl specifies the type of the content inside the config file.
    39  	TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"`
    40  	// ConfigPath specifies the filesystem location of the config file
    41  	// used by the runtime.
    42  	ConfigPath           string   `protobuf:"bytes,2,opt,name=config_path,json=configPath,proto3" json:"config_path,omitempty"`
    43  	XXX_NoUnkeyedLiteral struct{} `json:"-"`
    44  	XXX_sizecache        int32    `json:"-"`
    45  }
    46  
    47  func (m *Options) Reset()      { *m = Options{} }
    48  func (*Options) ProtoMessage() {}
    49  func (*Options) Descriptor() ([]byte, []int) {
    50  	return fileDescriptor_7700dd27e3487aa6, []int{0}
    51  }
    52  func (m *Options) XXX_Unmarshal(b []byte) error {
    53  	return m.Unmarshal(b)
    54  }
    55  func (m *Options) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
    56  	if deterministic {
    57  		return xxx_messageInfo_Options.Marshal(b, m, deterministic)
    58  	} else {
    59  		b = b[:cap(b)]
    60  		n, err := m.MarshalToSizedBuffer(b)
    61  		if err != nil {
    62  			return nil, err
    63  		}
    64  		return b[:n], nil
    65  	}
    66  }
    67  func (m *Options) XXX_Merge(src proto.Message) {
    68  	xxx_messageInfo_Options.Merge(m, src)
    69  }
    70  func (m *Options) XXX_Size() int {
    71  	return m.Size()
    72  }
    73  func (m *Options) XXX_DiscardUnknown() {
    74  	xxx_messageInfo_Options.DiscardUnknown(m)
    75  }
    76  
    77  var xxx_messageInfo_Options proto.InternalMessageInfo
    78  
    79  func (m *Options) GetTypeUrl() string {
    80  	if m != nil {
    81  		return m.TypeUrl
    82  	}
    83  	return ""
    84  }
    85  
    86  func (m *Options) GetConfigPath() string {
    87  	if m != nil {
    88  		return m.ConfigPath
    89  	}
    90  	return ""
    91  }
    92  
    93  func init() {
    94  	proto.RegisterType((*Options)(nil), "runtimeoptions.v1.Options")
    95  }
    96  
    97  func init() {
    98  	proto.RegisterFile("github.com/containerd/containerd/pkg/runtimeoptions/v1/api.proto", fileDescriptor_7700dd27e3487aa6)
    99  }
   100  
   101  var fileDescriptor_7700dd27e3487aa6 = []byte{
   102  	// 214 bytes of a gzipped FileDescriptorProto
   103  	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x48, 0xcf, 0x2c, 0xc9,
   104  	0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
   105  	0x4a, 0x41, 0x66, 0x16, 0x64, 0xa7, 0xeb, 0x17, 0x95, 0xe6, 0x95, 0x64, 0xe6, 0xa6, 0xe6, 0x17,
   106  	0x94, 0x64, 0xe6, 0xe7, 0x15, 0xeb, 0x97, 0x19, 0xea, 0x27, 0x16, 0x64, 0xea, 0x15, 0x14, 0xe5,
   107  	0x97, 0xe4, 0x0b, 0x09, 0xa2, 0x4a, 0xea, 0x95, 0x19, 0x4a, 0xe9, 0x22, 0x19, 0x9a, 0x9e, 0x9f,
   108  	0x9e, 0xaf, 0x0f, 0x56, 0x99, 0x54, 0x9a, 0x06, 0xe6, 0x81, 0x39, 0x60, 0x16, 0xc4, 0x04, 0x25,
   109  	0x57, 0x2e, 0x76, 0x7f, 0x88, 0x66, 0x21, 0x49, 0x2e, 0x8e, 0x92, 0xca, 0x82, 0xd4, 0xf8, 0xd2,
   110  	0xa2, 0x1c, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x76, 0x10, 0x3f, 0xb4, 0x28, 0x47, 0x48,
   111  	0x9e, 0x8b, 0x3b, 0x39, 0x3f, 0x2f, 0x2d, 0x33, 0x3d, 0xbe, 0x20, 0xb1, 0x24, 0x43, 0x82, 0x09,
   112  	0x2c, 0xcb, 0x05, 0x11, 0x0a, 0x48, 0x2c, 0xc9, 0x70, 0x4a, 0x3b, 0xf1, 0x50, 0x8e, 0xf1, 0xc6,
   113  	0x43, 0x39, 0x86, 0x86, 0x47, 0x72, 0x8c, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8,
   114  	0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x51, 0x1e, 0xe4, 0x79, 0xd4, 0x1a, 0x55, 0x24,
   115  	0xbe, 0xcc, 0x30, 0x89, 0x0d, 0xec, 0x6a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x91, 0x3c,
   116  	0x3e, 0x79, 0x3b, 0x01, 0x00, 0x00,
   117  }
   118  
   119  func (m *Options) Marshal() (dAtA []byte, err error) {
   120  	size := m.Size()
   121  	dAtA = make([]byte, size)
   122  	n, err := m.MarshalToSizedBuffer(dAtA[:size])
   123  	if err != nil {
   124  		return nil, err
   125  	}
   126  	return dAtA[:n], nil
   127  }
   128  
   129  func (m *Options) MarshalTo(dAtA []byte) (int, error) {
   130  	size := m.Size()
   131  	return m.MarshalToSizedBuffer(dAtA[:size])
   132  }
   133  
   134  func (m *Options) MarshalToSizedBuffer(dAtA []byte) (int, error) {
   135  	i := len(dAtA)
   136  	_ = i
   137  	var l int
   138  	_ = l
   139  	if len(m.ConfigPath) > 0 {
   140  		i -= len(m.ConfigPath)
   141  		copy(dAtA[i:], m.ConfigPath)
   142  		i = encodeVarintApi(dAtA, i, uint64(len(m.ConfigPath)))
   143  		i--
   144  		dAtA[i] = 0x12
   145  	}
   146  	if len(m.TypeUrl) > 0 {
   147  		i -= len(m.TypeUrl)
   148  		copy(dAtA[i:], m.TypeUrl)
   149  		i = encodeVarintApi(dAtA, i, uint64(len(m.TypeUrl)))
   150  		i--
   151  		dAtA[i] = 0xa
   152  	}
   153  	return len(dAtA) - i, nil
   154  }
   155  
   156  func encodeVarintApi(dAtA []byte, offset int, v uint64) int {
   157  	offset -= sovApi(v)
   158  	base := offset
   159  	for v >= 1<<7 {
   160  		dAtA[offset] = uint8(v&0x7f | 0x80)
   161  		v >>= 7
   162  		offset++
   163  	}
   164  	dAtA[offset] = uint8(v)
   165  	return base
   166  }
   167  func (m *Options) Size() (n int) {
   168  	if m == nil {
   169  		return 0
   170  	}
   171  	var l int
   172  	_ = l
   173  	l = len(m.TypeUrl)
   174  	if l > 0 {
   175  		n += 1 + l + sovApi(uint64(l))
   176  	}
   177  	l = len(m.ConfigPath)
   178  	if l > 0 {
   179  		n += 1 + l + sovApi(uint64(l))
   180  	}
   181  	return n
   182  }
   183  
   184  func sovApi(x uint64) (n int) {
   185  	return (math_bits.Len64(x|1) + 6) / 7
   186  }
   187  func sozApi(x uint64) (n int) {
   188  	return sovApi(uint64((x << 1) ^ uint64((int64(x) >> 63))))
   189  }
   190  func (this *Options) String() string {
   191  	if this == nil {
   192  		return "nil"
   193  	}
   194  	s := strings.Join([]string{`&Options{`,
   195  		`TypeUrl:` + fmt.Sprintf("%v", this.TypeUrl) + `,`,
   196  		`ConfigPath:` + fmt.Sprintf("%v", this.ConfigPath) + `,`,
   197  		`}`,
   198  	}, "")
   199  	return s
   200  }
   201  func valueToStringApi(v interface{}) string {
   202  	rv := reflect.ValueOf(v)
   203  	if rv.IsNil() {
   204  		return "nil"
   205  	}
   206  	pv := reflect.Indirect(rv).Interface()
   207  	return fmt.Sprintf("*%v", pv)
   208  }
   209  func (m *Options) Unmarshal(dAtA []byte) error {
   210  	l := len(dAtA)
   211  	iNdEx := 0
   212  	for iNdEx < l {
   213  		preIndex := iNdEx
   214  		var wire uint64
   215  		for shift := uint(0); ; shift += 7 {
   216  			if shift >= 64 {
   217  				return ErrIntOverflowApi
   218  			}
   219  			if iNdEx >= l {
   220  				return io.ErrUnexpectedEOF
   221  			}
   222  			b := dAtA[iNdEx]
   223  			iNdEx++
   224  			wire |= uint64(b&0x7F) << shift
   225  			if b < 0x80 {
   226  				break
   227  			}
   228  		}
   229  		fieldNum := int32(wire >> 3)
   230  		wireType := int(wire & 0x7)
   231  		if wireType == 4 {
   232  			return fmt.Errorf("proto: Options: wiretype end group for non-group")
   233  		}
   234  		if fieldNum <= 0 {
   235  			return fmt.Errorf("proto: Options: illegal tag %d (wire type %d)", fieldNum, wire)
   236  		}
   237  		switch fieldNum {
   238  		case 1:
   239  			if wireType != 2 {
   240  				return fmt.Errorf("proto: wrong wireType = %d for field TypeUrl", wireType)
   241  			}
   242  			var stringLen uint64
   243  			for shift := uint(0); ; shift += 7 {
   244  				if shift >= 64 {
   245  					return ErrIntOverflowApi
   246  				}
   247  				if iNdEx >= l {
   248  					return io.ErrUnexpectedEOF
   249  				}
   250  				b := dAtA[iNdEx]
   251  				iNdEx++
   252  				stringLen |= uint64(b&0x7F) << shift
   253  				if b < 0x80 {
   254  					break
   255  				}
   256  			}
   257  			intStringLen := int(stringLen)
   258  			if intStringLen < 0 {
   259  				return ErrInvalidLengthApi
   260  			}
   261  			postIndex := iNdEx + intStringLen
   262  			if postIndex < 0 {
   263  				return ErrInvalidLengthApi
   264  			}
   265  			if postIndex > l {
   266  				return io.ErrUnexpectedEOF
   267  			}
   268  			m.TypeUrl = string(dAtA[iNdEx:postIndex])
   269  			iNdEx = postIndex
   270  		case 2:
   271  			if wireType != 2 {
   272  				return fmt.Errorf("proto: wrong wireType = %d for field ConfigPath", wireType)
   273  			}
   274  			var stringLen uint64
   275  			for shift := uint(0); ; shift += 7 {
   276  				if shift >= 64 {
   277  					return ErrIntOverflowApi
   278  				}
   279  				if iNdEx >= l {
   280  					return io.ErrUnexpectedEOF
   281  				}
   282  				b := dAtA[iNdEx]
   283  				iNdEx++
   284  				stringLen |= uint64(b&0x7F) << shift
   285  				if b < 0x80 {
   286  					break
   287  				}
   288  			}
   289  			intStringLen := int(stringLen)
   290  			if intStringLen < 0 {
   291  				return ErrInvalidLengthApi
   292  			}
   293  			postIndex := iNdEx + intStringLen
   294  			if postIndex < 0 {
   295  				return ErrInvalidLengthApi
   296  			}
   297  			if postIndex > l {
   298  				return io.ErrUnexpectedEOF
   299  			}
   300  			m.ConfigPath = string(dAtA[iNdEx:postIndex])
   301  			iNdEx = postIndex
   302  		default:
   303  			iNdEx = preIndex
   304  			skippy, err := skipApi(dAtA[iNdEx:])
   305  			if err != nil {
   306  				return err
   307  			}
   308  			if (skippy < 0) || (iNdEx+skippy) < 0 {
   309  				return ErrInvalidLengthApi
   310  			}
   311  			if (iNdEx + skippy) > l {
   312  				return io.ErrUnexpectedEOF
   313  			}
   314  			iNdEx += skippy
   315  		}
   316  	}
   317  
   318  	if iNdEx > l {
   319  		return io.ErrUnexpectedEOF
   320  	}
   321  	return nil
   322  }
   323  func skipApi(dAtA []byte) (n int, err error) {
   324  	l := len(dAtA)
   325  	iNdEx := 0
   326  	depth := 0
   327  	for iNdEx < l {
   328  		var wire uint64
   329  		for shift := uint(0); ; shift += 7 {
   330  			if shift >= 64 {
   331  				return 0, ErrIntOverflowApi
   332  			}
   333  			if iNdEx >= l {
   334  				return 0, io.ErrUnexpectedEOF
   335  			}
   336  			b := dAtA[iNdEx]
   337  			iNdEx++
   338  			wire |= (uint64(b) & 0x7F) << shift
   339  			if b < 0x80 {
   340  				break
   341  			}
   342  		}
   343  		wireType := int(wire & 0x7)
   344  		switch wireType {
   345  		case 0:
   346  			for shift := uint(0); ; shift += 7 {
   347  				if shift >= 64 {
   348  					return 0, ErrIntOverflowApi
   349  				}
   350  				if iNdEx >= l {
   351  					return 0, io.ErrUnexpectedEOF
   352  				}
   353  				iNdEx++
   354  				if dAtA[iNdEx-1] < 0x80 {
   355  					break
   356  				}
   357  			}
   358  		case 1:
   359  			iNdEx += 8
   360  		case 2:
   361  			var length int
   362  			for shift := uint(0); ; shift += 7 {
   363  				if shift >= 64 {
   364  					return 0, ErrIntOverflowApi
   365  				}
   366  				if iNdEx >= l {
   367  					return 0, io.ErrUnexpectedEOF
   368  				}
   369  				b := dAtA[iNdEx]
   370  				iNdEx++
   371  				length |= (int(b) & 0x7F) << shift
   372  				if b < 0x80 {
   373  					break
   374  				}
   375  			}
   376  			if length < 0 {
   377  				return 0, ErrInvalidLengthApi
   378  			}
   379  			iNdEx += length
   380  		case 3:
   381  			depth++
   382  		case 4:
   383  			if depth == 0 {
   384  				return 0, ErrUnexpectedEndOfGroupApi
   385  			}
   386  			depth--
   387  		case 5:
   388  			iNdEx += 4
   389  		default:
   390  			return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
   391  		}
   392  		if iNdEx < 0 {
   393  			return 0, ErrInvalidLengthApi
   394  		}
   395  		if depth == 0 {
   396  			return iNdEx, nil
   397  		}
   398  	}
   399  	return 0, io.ErrUnexpectedEOF
   400  }
   401  
   402  var (
   403  	ErrInvalidLengthApi        = fmt.Errorf("proto: negative length found during unmarshaling")
   404  	ErrIntOverflowApi          = fmt.Errorf("proto: integer overflow")
   405  	ErrUnexpectedEndOfGroupApi = fmt.Errorf("proto: unexpected end of group")
   406  )