github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/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  package runtimeoptions
    17  
    18  import (
    19  	"fmt"
    20  	"io"
    21  	"reflect"
    22  	"strings"
    23  
    24  	proto "github.com/gogo/protobuf/proto"
    25  )
    26  
    27  // This is a compile-time assertion to ensure that this generated file
    28  // is compatible with the proto package it is being compiled against.
    29  // A compilation error at this line likely means your copy of the
    30  // proto package needs to be updated.
    31  const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
    32  
    33  type Options struct {
    34  	// TypeUrl specifies the type of the content inside the config file.
    35  	TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"`
    36  	// ConfigPath specifies the filesystem location of the config file
    37  	// used by the runtime.
    38  	ConfigPath string `protobuf:"bytes,2,opt,name=config_path,json=configPath,proto3" json:"config_path,omitempty"`
    39  }
    40  
    41  func (m *Options) Reset()                    { *m = Options{} }
    42  func (*Options) ProtoMessage()               {}
    43  func (*Options) Descriptor() ([]byte, []int) { return fileDescriptorApi, []int{0} }
    44  
    45  func (m *Options) GetTypeUrl() string {
    46  	if m != nil {
    47  		return m.TypeUrl
    48  	}
    49  	return ""
    50  }
    51  
    52  func (m *Options) GetConfigPath() string {
    53  	if m != nil {
    54  		return m.ConfigPath
    55  	}
    56  	return ""
    57  }
    58  
    59  func init() {
    60  	proto.RegisterType((*Options)(nil), "cri.runtimeoptions.v1.Options")
    61  }
    62  
    63  func (m *Options) Marshal() (dAtA []byte, err error) {
    64  	size := m.Size()
    65  	dAtA = make([]byte, size)
    66  	n, err := m.MarshalTo(dAtA)
    67  	if err != nil {
    68  		return nil, err
    69  	}
    70  	return dAtA[:n], nil
    71  }
    72  
    73  func (m *Options) MarshalTo(dAtA []byte) (int, error) {
    74  	var i int
    75  	_ = i
    76  	var l int
    77  	_ = l
    78  	if len(m.TypeUrl) > 0 {
    79  		dAtA[i] = 0xa
    80  		i++
    81  		i = encodeVarintApi(dAtA, i, uint64(len(m.TypeUrl)))
    82  		i += copy(dAtA[i:], m.TypeUrl)
    83  	}
    84  	if len(m.ConfigPath) > 0 {
    85  		dAtA[i] = 0x12
    86  		i++
    87  		i = encodeVarintApi(dAtA, i, uint64(len(m.ConfigPath)))
    88  		i += copy(dAtA[i:], m.ConfigPath)
    89  	}
    90  	return i, nil
    91  }
    92  
    93  func encodeVarintApi(dAtA []byte, offset int, v uint64) int {
    94  	for v >= 1<<7 {
    95  		dAtA[offset] = uint8(v&0x7f | 0x80)
    96  		v >>= 7
    97  		offset++
    98  	}
    99  	dAtA[offset] = uint8(v)
   100  	return offset + 1
   101  }
   102  
   103  func (m *Options) Size() (n int) {
   104  	var l int
   105  	_ = l
   106  	l = len(m.TypeUrl)
   107  	if l > 0 {
   108  		n += 1 + l + sovApi(uint64(l))
   109  	}
   110  	l = len(m.ConfigPath)
   111  	if l > 0 {
   112  		n += 1 + l + sovApi(uint64(l))
   113  	}
   114  	return n
   115  }
   116  
   117  func sovApi(x uint64) (n int) {
   118  	for {
   119  		n++
   120  		x >>= 7
   121  		if x == 0 {
   122  			break
   123  		}
   124  	}
   125  	return n
   126  }
   127  
   128  func sozApi(x uint64) (n int) {
   129  	return sovApi(uint64((x << 1) ^ uint64((int64(x) >> 63))))
   130  }
   131  
   132  func (this *Options) String() string {
   133  	if this == nil {
   134  		return "nil"
   135  	}
   136  	s := strings.Join([]string{`&Options{`,
   137  		`TypeUrl:` + fmt.Sprintf("%v", this.TypeUrl) + `,`,
   138  		`ConfigPath:` + fmt.Sprintf("%v", this.ConfigPath) + `,`,
   139  		`}`,
   140  	}, "")
   141  	return s
   142  }
   143  
   144  func valueToStringApi(v interface{}) string {
   145  	rv := reflect.ValueOf(v)
   146  	if rv.IsNil() {
   147  		return "nil"
   148  	}
   149  	pv := reflect.Indirect(rv).Interface()
   150  	return fmt.Sprintf("*%v", pv)
   151  }
   152  
   153  func (m *Options) Unmarshal(dAtA []byte) error {
   154  	l := len(dAtA)
   155  	iNdEx := 0
   156  	for iNdEx < l {
   157  		preIndex := iNdEx
   158  		var wire uint64
   159  		for shift := uint(0); ; shift += 7 {
   160  			if shift >= 64 {
   161  				return ErrIntOverflowApi
   162  			}
   163  			if iNdEx >= l {
   164  				return io.ErrUnexpectedEOF
   165  			}
   166  			b := dAtA[iNdEx]
   167  			iNdEx++
   168  			wire |= (uint64(b) & 0x7F) << shift
   169  			if b < 0x80 {
   170  				break
   171  			}
   172  		}
   173  		fieldNum := int32(wire >> 3)
   174  		wireType := int(wire & 0x7)
   175  		if wireType == 4 {
   176  			return fmt.Errorf("proto: Options: wiretype end group for non-group")
   177  		}
   178  		if fieldNum <= 0 {
   179  			return fmt.Errorf("proto: Options: illegal tag %d (wire type %d)", fieldNum, wire)
   180  		}
   181  		switch fieldNum {
   182  		case 1:
   183  			if wireType != 2 {
   184  				return fmt.Errorf("proto: wrong wireType = %d for field TypeUrl", wireType)
   185  			}
   186  			var stringLen uint64
   187  			for shift := uint(0); ; shift += 7 {
   188  				if shift >= 64 {
   189  					return ErrIntOverflowApi
   190  				}
   191  				if iNdEx >= l {
   192  					return io.ErrUnexpectedEOF
   193  				}
   194  				b := dAtA[iNdEx]
   195  				iNdEx++
   196  				stringLen |= (uint64(b) & 0x7F) << shift
   197  				if b < 0x80 {
   198  					break
   199  				}
   200  			}
   201  			intStringLen := int(stringLen)
   202  			if intStringLen < 0 {
   203  				return ErrInvalidLengthApi
   204  			}
   205  			postIndex := iNdEx + intStringLen
   206  			if postIndex > l {
   207  				return io.ErrUnexpectedEOF
   208  			}
   209  			m.TypeUrl = string(dAtA[iNdEx:postIndex])
   210  			iNdEx = postIndex
   211  		case 2:
   212  			if wireType != 2 {
   213  				return fmt.Errorf("proto: wrong wireType = %d for field ConfigPath", wireType)
   214  			}
   215  			var stringLen uint64
   216  			for shift := uint(0); ; shift += 7 {
   217  				if shift >= 64 {
   218  					return ErrIntOverflowApi
   219  				}
   220  				if iNdEx >= l {
   221  					return io.ErrUnexpectedEOF
   222  				}
   223  				b := dAtA[iNdEx]
   224  				iNdEx++
   225  				stringLen |= (uint64(b) & 0x7F) << shift
   226  				if b < 0x80 {
   227  					break
   228  				}
   229  			}
   230  			intStringLen := int(stringLen)
   231  			if intStringLen < 0 {
   232  				return ErrInvalidLengthApi
   233  			}
   234  			postIndex := iNdEx + intStringLen
   235  			if postIndex > l {
   236  				return io.ErrUnexpectedEOF
   237  			}
   238  			m.ConfigPath = string(dAtA[iNdEx:postIndex])
   239  			iNdEx = postIndex
   240  		default:
   241  			iNdEx = preIndex
   242  			skippy, err := skipApi(dAtA[iNdEx:])
   243  			if err != nil {
   244  				return err
   245  			}
   246  			if skippy < 0 {
   247  				return ErrInvalidLengthApi
   248  			}
   249  			if (iNdEx + skippy) > l {
   250  				return io.ErrUnexpectedEOF
   251  			}
   252  			iNdEx += skippy
   253  		}
   254  	}
   255  
   256  	if iNdEx > l {
   257  		return io.ErrUnexpectedEOF
   258  	}
   259  	return nil
   260  }
   261  
   262  func skipApi(dAtA []byte) (n int, err error) {
   263  	l := len(dAtA)
   264  	iNdEx := 0
   265  	for iNdEx < l {
   266  		var wire uint64
   267  		for shift := uint(0); ; shift += 7 {
   268  			if shift >= 64 {
   269  				return 0, ErrIntOverflowApi
   270  			}
   271  			if iNdEx >= l {
   272  				return 0, io.ErrUnexpectedEOF
   273  			}
   274  			b := dAtA[iNdEx]
   275  			iNdEx++
   276  			wire |= (uint64(b) & 0x7F) << shift
   277  			if b < 0x80 {
   278  				break
   279  			}
   280  		}
   281  		wireType := int(wire & 0x7)
   282  		switch wireType {
   283  		case 0:
   284  			for shift := uint(0); ; shift += 7 {
   285  				if shift >= 64 {
   286  					return 0, ErrIntOverflowApi
   287  				}
   288  				if iNdEx >= l {
   289  					return 0, io.ErrUnexpectedEOF
   290  				}
   291  				iNdEx++
   292  				if dAtA[iNdEx-1] < 0x80 {
   293  					break
   294  				}
   295  			}
   296  			return iNdEx, nil
   297  		case 1:
   298  			iNdEx += 8
   299  			return iNdEx, nil
   300  		case 2:
   301  			var length int
   302  			for shift := uint(0); ; shift += 7 {
   303  				if shift >= 64 {
   304  					return 0, ErrIntOverflowApi
   305  				}
   306  				if iNdEx >= l {
   307  					return 0, io.ErrUnexpectedEOF
   308  				}
   309  				b := dAtA[iNdEx]
   310  				iNdEx++
   311  				length |= (int(b) & 0x7F) << shift
   312  				if b < 0x80 {
   313  					break
   314  				}
   315  			}
   316  			iNdEx += length
   317  			if length < 0 {
   318  				return 0, ErrInvalidLengthApi
   319  			}
   320  			return iNdEx, nil
   321  		case 3:
   322  			for {
   323  				var innerWire uint64
   324  				var start int = iNdEx
   325  				for shift := uint(0); ; shift += 7 {
   326  					if shift >= 64 {
   327  						return 0, ErrIntOverflowApi
   328  					}
   329  					if iNdEx >= l {
   330  						return 0, io.ErrUnexpectedEOF
   331  					}
   332  					b := dAtA[iNdEx]
   333  					iNdEx++
   334  					innerWire |= (uint64(b) & 0x7F) << shift
   335  					if b < 0x80 {
   336  						break
   337  					}
   338  				}
   339  				innerWireType := int(innerWire & 0x7)
   340  				if innerWireType == 4 {
   341  					break
   342  				}
   343  				next, err := skipApi(dAtA[start:])
   344  				if err != nil {
   345  					return 0, err
   346  				}
   347  				iNdEx = start + next
   348  			}
   349  			return iNdEx, nil
   350  		case 4:
   351  			return iNdEx, nil
   352  		case 5:
   353  			iNdEx += 4
   354  			return iNdEx, nil
   355  		default:
   356  			return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
   357  		}
   358  	}
   359  	panic("unreachable")
   360  }
   361  
   362  var (
   363  	ErrInvalidLengthApi = fmt.Errorf("proto: negative length found during unmarshaling")
   364  	ErrIntOverflowApi   = fmt.Errorf("proto: integer overflow")
   365  )
   366  
   367  func init() { proto.RegisterFile("api.proto", fileDescriptorApi) }
   368  
   369  var fileDescriptorApi = []byte{
   370  	// 183 bytes of a gzipped FileDescriptorProto
   371  	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4c, 0x2c, 0xc8, 0xd4,
   372  	0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x4d, 0x2e, 0xca, 0xd4, 0x2b, 0x2a, 0xcd, 0x2b, 0xc9,
   373  	0xcc, 0x4d, 0xcd, 0x2f, 0x28, 0xc9, 0xcc, 0xcf, 0x2b, 0xd6, 0x2b, 0x33, 0x94, 0xd2, 0x4d, 0xcf,
   374  	0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0x4f, 0xcf, 0xd7, 0x07, 0xab,
   375  	0x4e, 0x2a, 0x4d, 0x03, 0xf3, 0xc0, 0x1c, 0x30, 0x0b, 0x62, 0x8a, 0x92, 0x2b, 0x17, 0xbb, 0x3f,
   376  	0x44, 0xb3, 0x90, 0x24, 0x17, 0x47, 0x49, 0x65, 0x41, 0x6a, 0x7c, 0x69, 0x51, 0x8e, 0x04, 0xa3,
   377  	0x02, 0xa3, 0x06, 0x67, 0x10, 0x3b, 0x88, 0x1f, 0x5a, 0x94, 0x23, 0x24, 0xcf, 0xc5, 0x9d, 0x9c,
   378  	0x9f, 0x97, 0x96, 0x99, 0x1e, 0x5f, 0x90, 0x58, 0x92, 0x21, 0xc1, 0x04, 0x96, 0xe5, 0x82, 0x08,
   379  	0x05, 0x24, 0x96, 0x64, 0x38, 0xc9, 0x9c, 0x78, 0x28, 0xc7, 0x78, 0xe3, 0xa1, 0x1c, 0x43, 0xc3,
   380  	0x23, 0x39, 0xc6, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71,
   381  	0xc2, 0x63, 0x39, 0x86, 0x24, 0x36, 0xb0, 0x5d, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07,
   382  	0x00, 0xf2, 0x18, 0xbe, 0x00, 0x00, 0x00,
   383  }