duh. TRUNCATE on new files
This commit is contained in:
parent
0888e51c91
commit
9160268326
Notes:
Jeff Carr
2025-01-20 08:21:38 -06:00
// `autogen:go.mod` module go.wit.com/lib/protobuf/virtbuf go 1.21 toolchain go1.23.4 require ( github.com/google/uuid v1.6.0 go.wit.com/log v0.22.10 google.golang.org/protobuf v1.36.3 ) // `autogen:go.sum` github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= go.wit.com/log v0.22.10 h1:rlSgaYjvxbpcmi9UBQO3ESmbd/jiyFdRQFoGOvpCEUc= go.wit.com/log v0.22.10/go.mod h1:4uNPFBqhsAh8zNF+zxVEmC3c/9AZ8JeTfUUvRpddvLQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU= google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= // `autogen:droplet.marshal.pb.go` package virtbuf // This file was autogenerated with autogenpb. // go install go.wit.com/apps/autogenpb@latest // // You can use it on simple protobuf files // The .proto file must have a singular and plural form of a message // (for those of you that know ruby on rails, it's like that) // // You can mark which repos you want to auto generate sort.pb.go and marshal.pb.go files for // // For an example, // go-clone go.wit.com/lib/protobuf/gitpb // import ( "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" ) // human readable JSON func (v *Droplets) FormatJSON() string { return protojson.Format(v) } // marshal json func (v *Droplets) MarshalJSON() ([]byte, error) { return protojson.Marshal(v) } // unmarshal json func (v *Droplets) UnmarshalJSON(data []byte) error { return protojson.Unmarshal(data, v) } // apparently this isn't stable, but it's awesomely better // https://protobuf.dev/reference/go/faq/#unstable-text // it's so great for config files, I'm using it by default to try to fix the problems with it func (v *Droplets) FormatTEXT() string { return prototext.Format(v) } // unmarshalTEXT. This reads the .text config file back in after the user edits it func (v *Droplets) UnmarshalTEXT(data []byte) error { return prototext.Unmarshal(data, v) } // marshal to wire. This is called winning. func (v *Droplets) Marshal() ([]byte, error) { return proto.Marshal(v) } // unmarshal from wire. You have won. func (v *Droplets) Unmarshal(data []byte) error { return proto.Unmarshal(data, v) } // human readable JSON func (v *Droplet) FormatJSON() string { return protojson.Format(v) } // marshal json func (v *Droplet) MarshalJSON() ([]byte, error) { return protojson.Marshal(v) } // unmarshal json func (v *Droplet) UnmarshalJSON(data []byte) error { return protojson.Unmarshal(data, v) } // apparently this isn't stable, but it's awesomely better // https://protobuf.dev/reference/go/faq/#unstable-text // it's so great for config files, I'm using it by default to try to fix the problems with it func (v *Droplet) FormatTEXT() string { return prototext.Format(v) } // unmarshalTEXT. This reads the .text config file back in after the user edits it func (v *Droplet) UnmarshalTEXT(data []byte) error { return prototext.Unmarshal(data, v) } // marshal to wire. This is called winning. func (v *Droplet) Marshal() ([]byte, error) { return proto.Marshal(v) } // unmarshal from wire. You have won. func (v *Droplet) Unmarshal(data []byte) error { return proto.Unmarshal(data, v) } // `autogen:droplet.pb.go` // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.2-devel // protoc v3.21.12 // source: droplet.proto package virtbuf import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) 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) ) // virtual machine state type DropletState int32 const ( DropletState_ON DropletState = 0 DropletState_OFF DropletState = 1 DropletState_UNKNOWN DropletState = 2 // qemu says 'Shutdown' DropletState_PAUSED DropletState = 3 DropletState_CRASHED DropletState = 4 DropletState_INMIGRATE DropletState = 5 ) // Enum value maps for DropletState. var ( DropletState_name = map[int32]string{ 0: "ON", 1: "OFF", 2: "UNKNOWN", 3: "PAUSED", 4: "CRASHED", 5: "INMIGRATE", } DropletState_value = map[string]int32{ "ON": 0, "OFF": 1, "UNKNOWN": 2, "PAUSED": 3, "CRASHED": 4, "INMIGRATE": 5, } ) func (x DropletState) Enum() *DropletState { p := new(DropletState) *p = x return p } func (x DropletState) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (DropletState) Descriptor() protoreflect.EnumDescriptor { return file_droplet_proto_enumTypes[0].Descriptor() } func (DropletState) Type() protoreflect.EnumType { return &file_droplet_proto_enumTypes[0] } func (x DropletState) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use DropletState.Descriptor instead. func (DropletState) EnumDescriptor() ([]byte, []int) { return file_droplet_proto_rawDescGZIP(), []int{0} } type DropletArchive int32 const ( DropletArchive_DUP DropletArchive = 0 DropletArchive_USER DropletArchive = 1 ) // Enum value maps for DropletArchive. var ( DropletArchive_name = map[int32]string{ 0: "DUP", 1: "USER", } DropletArchive_value = map[string]int32{ "DUP": 0, "USER": 1, } ) func (x DropletArchive) Enum() *DropletArchive { p := new(DropletArchive) *p = x return p } func (x DropletArchive) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (DropletArchive) Descriptor() protoreflect.EnumDescriptor { return file_droplet_proto_enumTypes[1].Descriptor() } func (DropletArchive) Type() protoreflect.EnumType { return &file_droplet_proto_enumTypes[1] } func (x DropletArchive) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use DropletArchive.Descriptor instead. func (DropletArchive) EnumDescriptor() ([]byte, []int) { return file_droplet_proto_rawDescGZIP(), []int{1} } type Droplets struct { Lock sync.RWMutex // auto-added by go.wit.com/apps/autogenpb state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` // I guess why not just have this on each file Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // maybe can be used for protobuf schema change violations Droplets []*Droplet `protobuf:"bytes,3,rep,name=droplets,proto3" json:"droplets,omitempty"` } func (x *Droplets) Reset() { *x = Droplets{} mi := &file_droplet_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Droplets) String() string { return protoimpl.X.MessageStringOf(x) } func (*Droplets) ProtoMessage() {} func (x *Droplets) ProtoReflect() protoreflect.Message { mi := &file_droplet_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Droplets.ProtoReflect.Descriptor instead. func (*Droplets) Descriptor() ([]byte, []int) { return file_droplet_proto_rawDescGZIP(), []int{0} } func (x *Droplets) GetUuid() string { if x != nil { return x.Uuid } return "" } func (x *Droplets) GetVersion() string { if x != nil { return x.Version } return "" } func (x *Droplets) GetDroplets() []*Droplet { if x != nil { return x.Droplets } return nil } type Droplet struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` // `autogenpb:unique` // should be unique across the cluster Hostname string `protobuf:"bytes,2,opt,name=hostname,proto3" json:"hostname,omitempty"` // `autogenpb:unique` // should be unique and work in DNS Cpus int64 `protobuf:"varint,3,opt,name=cpus,proto3" json:"cpus,omitempty"` // what's the point of int64 vs int32 Memory int64 `protobuf:"varint,4,opt,name=memory,proto3" json:"memory,omitempty"` // in bytes Current *Current `protobuf:"bytes,5,opt,name=current,proto3" json:"current,omitempty"` // what the state and values of the droplet is StartState DropletState `protobuf:"varint,6,opt,name=start_state,json=startState,proto3,enum=virtbuf.DropletState" json:"start_state,omitempty"` // what the state of the droplet is SUPPOSED TO BE ('on' or 'off') QemuMachine string `protobuf:"bytes,7,opt,name=qemu_machine,json=qemuMachine,proto3" json:"qemu_machine,omitempty"` // the qemu machine type to use "pc-q35-9.0" SpicePort int64 `protobuf:"varint,8,opt,name=spice_port,json=spicePort,proto3" json:"spice_port,omitempty"` // preferred port to use for spice PreferredHypervisor string `protobuf:"bytes,9,opt,name=preferred_hypervisor,json=preferredHypervisor,proto3" json:"preferred_hypervisor,omitempty"` // the hypervisor to prefer to run the droplet on ForceHypervisor string `protobuf:"bytes,10,opt,name=force_hypervisor,json=forceHypervisor,proto3" json:"force_hypervisor,omitempty"` // use this hypervisor and this hypervisor only PreferredArch string `protobuf:"bytes,11,opt,name=preferred_arch,json=preferredArch,proto3" json:"preferred_arch,omitempty"` // the cpu arch to use "x86_64" (should really get this from the disk?) Networks []*Network `protobuf:"bytes,12,rep,name=networks,proto3" json:"networks,omitempty"` // really just mac addresses. should be unique across cluster Disks []*Disk `protobuf:"bytes,13,rep,name=disks,proto3" json:"disks,omitempty"` // disks to attach LocalOnly string `protobuf:"bytes,14,opt,name=local_only,json=localOnly,proto3" json:"local_only,omitempty"` // this is only defined locally on the hypervisor CustomXml string `protobuf:"bytes,15,opt,name=custom_xml,json=customXml,proto3" json:"custom_xml,omitempty"` // if needed, Archive *Archive `protobuf:"bytes,16,opt,name=archive,proto3" json:"archive,omitempty"` // what the state of the droplet is SUPPOSED TO BE ('on' or 'off') Unstable *timestamppb.Timestamp `protobuf:"bytes,39,opt,name=unstable,proto3" json:"unstable,omitempty"` // the last time we heard anything from this droplet UnstableTimeout *durationpb.Duration `protobuf:"bytes,40,opt,name=unstable_timeout,json=unstableTimeout,proto3" json:"unstable_timeout,omitempty"` // the last time we heard anything from this droplet } func (x *Droplet) Reset() { *x = Droplet{} mi := &file_droplet_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Droplet) String() string { return protoimpl.X.MessageStringOf(x) } func (*Droplet) ProtoMessage() {} func (x *Droplet) ProtoReflect() protoreflect.Message { mi := &file_droplet_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Droplet.ProtoReflect.Descriptor instead. func (*Droplet) Descriptor() ([]byte, []int) { return file_droplet_proto_rawDescGZIP(), []int{1} } func (x *Droplet) GetUuid() string { if x != nil { return x.Uuid } return "" } func (x *Droplet) GetHostname() string { if x != nil { return x.Hostname } return "" } func (x *Droplet) GetCpus() int64 { if x != nil { return x.Cpus } return 0 } func (x *Droplet) GetMemory() int64 { if x != nil { return x.Memory } return 0 } func (x *Droplet) GetCurrent() *Current { if x != nil { return x.Current } return nil } func (x *Droplet) GetStartState() DropletState { if x != nil { return x.StartState } return DropletState_ON } func (x *Droplet) GetQemuMachine() string { if x != nil { return x.QemuMachine } return "" } func (x *Droplet) GetSpicePort() int64 { if x != nil { return x.SpicePort } return 0 } func (x *Droplet) GetPreferredHypervisor() string { if x != nil { return x.PreferredHypervisor } return "" } func (x *Droplet) GetForceHypervisor() string { if x != nil { return x.ForceHypervisor } return "" } func (x *Droplet) GetPreferredArch() string { if x != nil { return x.PreferredArch } return "" } func (x *Droplet) GetNetworks() []*Network { if x != nil { return x.Networks } return nil } func (x *Droplet) GetDisks() []*Disk { if x != nil { return x.Disks } return nil } func (x *Droplet) GetLocalOnly() string { if x != nil { return x.LocalOnly } return "" } func (x *Droplet) GetCustomXml() string { if x != nil { return x.CustomXml } return "" } func (x *Droplet) GetArchive() *Archive { if x != nil { return x.Archive } return nil } func (x *Droplet) GetUnstable() *timestamppb.Timestamp { if x != nil { return x.Unstable } return nil } func (x *Droplet) GetUnstableTimeout() *durationpb.Duration { if x != nil { return x.UnstableTimeout } return nil } // volatile data. the current settings and values of things. // These are passed around while the cluster to monitor and control the systems // but they are not saved to the config file type Current struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields State DropletState `protobuf:"varint,1,opt,name=state,proto3,enum=virtbuf.DropletState" json:"state,omitempty"` // used to track the current state before taking any action Hypervisor string `protobuf:"bytes,2,opt,name=hypervisor,proto3" json:"hypervisor,omitempty"` // the current hypervisor the droplet is running on StartAttempts int64 `protobuf:"varint,3,opt,name=start_attempts,json=startAttempts,proto3" json:"start_attempts,omitempty"` // how many times a start has been attempted FullXml string `protobuf:"bytes,4,opt,name=full_xml,json=fullXml,proto3" json:"full_xml,omitempty"` // the full libvirt xml to import LastPoll *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=last_poll,json=lastPoll,proto3" json:"last_poll,omitempty"` // the last time we heard anything from this droplet ImageUrl string `protobuf:"bytes,6,opt,name=image_url,json=imageUrl,proto3" json:"image_url,omitempty"` // url to the image OffSince *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=off_since,json=offSince,proto3" json:"off_since,omitempty"` // when the droplet was turned off OnSince *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=on_since,json=onSince,proto3" json:"on_since,omitempty"` // when the droplet was turned on } func (x *Current) Reset() { *x = Current{} mi := &file_droplet_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Current) String() string { return protoimpl.X.MessageStringOf(x) } func (*Current) ProtoMessage() {} func (x *Current) ProtoReflect() protoreflect.Message { mi := &file_droplet_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Current.ProtoReflect.Descriptor instead. func (*Current) Descriptor() ([]byte, []int) { return file_droplet_proto_rawDescGZIP(), []int{2} } func (x *Current) GetState() DropletState { if x != nil { return x.State } return DropletState_ON } func (x *Current) GetHypervisor() string { if x != nil { return x.Hypervisor } return "" } func (x *Current) GetStartAttempts() int64 { if x != nil { return x.StartAttempts } return 0 } func (x *Current) GetFullXml() string { if x != nil { return x.FullXml } return "" } func (x *Current) GetLastPoll() *timestamppb.Timestamp { if x != nil { return x.LastPoll } return nil } func (x *Current) GetImageUrl() string { if x != nil { return x.ImageUrl } return "" } func (x *Current) GetOffSince() *timestamppb.Timestamp { if x != nil { return x.OffSince } return nil } func (x *Current) GetOnSince() *timestamppb.Timestamp { if x != nil { return x.OnSince } return nil } type Archive struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Reason DropletArchive `protobuf:"varint,1,opt,name=reason,proto3,enum=virtbuf.DropletArchive" json:"reason,omitempty"` // why the droplet was archived When *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=when,proto3" json:"when,omitempty"` // when it was archived } func (x *Archive) Reset() { *x = Archive{} mi := &file_droplet_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Archive) String() string { return protoimpl.X.MessageStringOf(x) } func (*Archive) ProtoMessage() {} func (x *Archive) ProtoReflect() protoreflect.Message { mi := &file_droplet_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Archive.ProtoReflect.Descriptor instead. func (*Archive) Descriptor() ([]byte, []int) { return file_droplet_proto_rawDescGZIP(), []int{3} } func (x *Archive) GetReason() DropletArchive { if x != nil { return x.Reason } return DropletArchive_DUP } func (x *Archive) GetWhen() *timestamppb.Timestamp { if x != nil { return x.When } return nil } type Network struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Mac string `protobuf:"bytes,1,opt,name=mac,proto3" json:"mac,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` } func (x *Network) Reset() { *x = Network{} mi := &file_droplet_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Network) String() string { return protoimpl.X.MessageStringOf(x) } func (*Network) ProtoMessage() {} func (x *Network) ProtoReflect() protoreflect.Message { mi := &file_droplet_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Network.ProtoReflect.Descriptor instead. func (*Network) Descriptor() ([]byte, []int) { return file_droplet_proto_rawDescGZIP(), []int{4} } func (x *Network) GetMac() string { if x != nil { return x.Mac } return "" } func (x *Network) GetName() string { if x != nil { return x.Name } return "" } type Disk struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"` Filepath string `protobuf:"bytes,2,opt,name=filepath,proto3" json:"filepath,omitempty"` Size int64 `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"` QemuArch string `protobuf:"bytes,4,opt,name=qemu_arch,json=qemuArch,proto3" json:"qemu_arch,omitempty"` // what arch. example: "x86_64" or "riscv64" } func (x *Disk) Reset() { *x = Disk{} mi := &file_droplet_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Disk) String() string { return protoimpl.X.MessageStringOf(x) } func (*Disk) ProtoMessage() {} func (x *Disk) ProtoReflect() protoreflect.Message { mi := &file_droplet_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Disk.ProtoReflect.Descriptor instead. func (*Disk) Descriptor() ([]byte, []int) { return file_droplet_proto_rawDescGZIP(), []int{5} } func (x *Disk) GetFilename() string { if x != nil { return x.Filename } return "" } func (x *Disk) GetFilepath() string { if x != nil { return x.Filepath } return "" } func (x *Disk) GetSize() int64 { if x != nil { return x.Size } return 0 } func (x *Disk) GetQemuArch() string { if x != nil { return x.QemuArch } return "" } var File_droplet_proto protoreflect.FileDescriptor var file_droplet_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x64, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x66, 0x0a, 0x08, 0x44, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x08, 0x64, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x52, 0x08, 0x64, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x73, 0x22, 0xcb, 0x05, 0x0a, 0x07, 0x44, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x70, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x70, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x2a, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x36, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x71, 0x65, 0x6d, 0x75, 0x5f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x71, 0x65, 0x6d, 0x75, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x70, 0x69, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x73, 0x70, 0x69, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x31, 0x0a, 0x14, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x64, 0x5f, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x64, 0x48, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x12, 0x29, 0x0a, 0x10, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x5f, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x48, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x64, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x64, 0x41, 0x72, 0x63, 0x68, 0x12, 0x2c, 0x0a, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x12, 0x23, 0x0a, 0x05, 0x64, 0x69, 0x73, 0x6b, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x69, 0x73, 0x6b, 0x52, 0x05, 0x64, 0x69, 0x73, 0x6b, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x78, 0x6d, 0x6c, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x58, 0x6d, 0x6c, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x07, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x12, 0x36, 0x0a, 0x08, 0x75, 0x6e, 0x73, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x27, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x75, 0x6e, 0x73, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x44, 0x0a, 0x10, 0x75, 0x6e, 0x73, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x28, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x75, 0x6e, 0x73, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x22, 0xde, 0x02, 0x0a, 0x07, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x61, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x73, 0x74, 0x61, 0x72, 0x74, 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x75, 0x6c, 0x6c, 0x5f, 0x78, 0x6d, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x75, 0x6c, 0x6c, 0x58, 0x6d, 0x6c, 0x12, 0x37, 0x0a, 0x09, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x70, 0x6f, 0x6c, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x50, 0x6f, 0x6c, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x37, 0x0a, 0x09, 0x6f, 0x66, 0x66, 0x5f, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x6f, 0x66, 0x66, 0x53, 0x69, 0x6e, 0x63, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x6f, 0x6e, 0x5f, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07, 0x6f, 0x6e, 0x53, 0x69, 0x6e, 0x63, 0x65, 0x22, 0x6a, 0x0a, 0x07, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x12, 0x2f, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x2e, 0x0a, 0x04, 0x77, 0x68, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x77, 0x68, 0x65, 0x6e, 0x22, 0x2f, 0x0a, 0x07, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x61, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x61, 0x63, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x6f, 0x0a, 0x04, 0x44, 0x69, 0x73, 0x6b, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x70, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x71, 0x65, 0x6d, 0x75, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x71, 0x65, 0x6d, 0x75, 0x41, 0x72, 0x63, 0x68, 0x2a, 0x54, 0x0a, 0x0c, 0x44, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x4f, 0x4e, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x46, 0x46, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x50, 0x41, 0x55, 0x53, 0x45, 0x44, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x52, 0x41, 0x53, 0x48, 0x45, 0x44, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x49, 0x4e, 0x4d, 0x49, 0x47, 0x52, 0x41, 0x54, 0x45, 0x10, 0x05, 0x2a, 0x23, 0x0a, 0x0e, 0x44, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x55, 0x50, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x55, 0x53, 0x45, 0x52, 0x10, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_droplet_proto_rawDescOnce sync.Once file_droplet_proto_rawDescData = file_droplet_proto_rawDesc ) func file_droplet_proto_rawDescGZIP() []byte { file_droplet_proto_rawDescOnce.Do(func() { file_droplet_proto_rawDescData = protoimpl.X.CompressGZIP(file_droplet_proto_rawDescData) }) return file_droplet_proto_rawDescData } var file_droplet_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_droplet_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_droplet_proto_goTypes = []any{ (DropletState)(0), // 0: virtbuf.DropletState (DropletArchive)(0), // 1: virtbuf.DropletArchive (*Droplets)(nil), // 2: virtbuf.Droplets (*Droplet)(nil), // 3: virtbuf.Droplet (*Current)(nil), // 4: virtbuf.Current (*Archive)(nil), // 5: virtbuf.Archive (*Network)(nil), // 6: virtbuf.Network (*Disk)(nil), // 7: virtbuf.Disk (*timestamppb.Timestamp)(nil), // 8: google.protobuf.Timestamp (*durationpb.Duration)(nil), // 9: google.protobuf.Duration } var file_droplet_proto_depIdxs = []int32{ 3, // 0: virtbuf.Droplets.droplets:type_name -> virtbuf.Droplet 4, // 1: virtbuf.Droplet.current:type_name -> virtbuf.Current 0, // 2: virtbuf.Droplet.start_state:type_name -> virtbuf.DropletState 6, // 3: virtbuf.Droplet.networks:type_name -> virtbuf.Network 7, // 4: virtbuf.Droplet.disks:type_name -> virtbuf.Disk 5, // 5: virtbuf.Droplet.archive:type_name -> virtbuf.Archive 8, // 6: virtbuf.Droplet.unstable:type_name -> google.protobuf.Timestamp 9, // 7: virtbuf.Droplet.unstable_timeout:type_name -> google.protobuf.Duration 0, // 8: virtbuf.Current.state:type_name -> virtbuf.DropletState 8, // 9: virtbuf.Current.last_poll:type_name -> google.protobuf.Timestamp 8, // 10: virtbuf.Current.off_since:type_name -> google.protobuf.Timestamp 8, // 11: virtbuf.Current.on_since:type_name -> google.protobuf.Timestamp 1, // 12: virtbuf.Archive.reason:type_name -> virtbuf.DropletArchive 8, // 13: virtbuf.Archive.when:type_name -> google.protobuf.Timestamp 14, // [14:14] is the sub-list for method output_type 14, // [14:14] is the sub-list for method input_type 14, // [14:14] is the sub-list for extension type_name 14, // [14:14] is the sub-list for extension extendee 0, // [0:14] is the sub-list for field type_name } func init() { file_droplet_proto_init() } func file_droplet_proto_init() { if File_droplet_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_droplet_proto_rawDesc, NumEnums: 2, NumMessages: 6, NumExtensions: 0, NumServices: 0, }, GoTypes: file_droplet_proto_goTypes, DependencyIndexes: file_droplet_proto_depIdxs, EnumInfos: file_droplet_proto_enumTypes, MessageInfos: file_droplet_proto_msgTypes, }.Build() File_droplet_proto = out.File file_droplet_proto_rawDesc = nil file_droplet_proto_goTypes = nil file_droplet_proto_depIdxs = nil } // `autogen:droplet.sort.pb.go` package virtbuf // This file was autogenerated with autogenpb. // go install go.wit.com/apps/autogenpb@latest // // You can use it on simple protobuf files // The .proto file must have a singular and plural form of a message // (for those of you that know ruby on rails, it's like that) // // You can mark which repos you want to auto generate sort.pb.go and marshal.pb.go files for // // For an example, // go-clone go.wit.com/lib/protobuf/gitpb // import ( "fmt" "os" "sort" "sync" ) type DropletIterator struct { sync.RWMutex packs []*Droplet index int } // NewDropletIterator initializes a new iterator. func NewDropletIterator(packs []*Droplet) *DropletIterator { return &DropletIterator{packs: packs} } // Scan moves to the next element and returns false if there are no more packs. // Use Scan() in a loop, similar to a while loop // // for iterator.Scan() // d := iterator.Next( // fmt.Println("found UUID:", d.Uuid // } func (it *DropletIterator) Scan() bool { if it.index >= len(it.packs) { return false } it.index++ return true } // Next() returns the next thing in the array func (it *DropletIterator) Next() *Droplet { if it.packs[it.index-1] == nil { for i, d := range it.packs { fmt.Println("i =", i, d) } fmt.Println("protobuf autogenpb sort error len =", len(it.packs)) fmt.Println("protobuf autogenpb sort error next == nil", it.index, it.index-1) os.Exit(-1) } return it.packs[it.index-1] } // does not enforce any unique fields func (all *Droplets) Append(newP *Droplet) bool { all.Lock.RLock() defer all.Lock.RUnlock() all.Droplets = append(all.Droplets, newP) return true } func (all *Droplets) All() *DropletIterator { dropletPointers := all.selectAllDroplet() iterator := NewDropletIterator(dropletPointers) return iterator } func (all *Droplets) Len() int { all.Lock.RLock() defer all.Lock.RUnlock() return len(all.Droplets) } func (all *Droplets) SortByUuid() *DropletIterator { packs := all.selectAllDroplet() sort.Sort(DropletUuid(packs)) iterator := NewDropletIterator(packs) return iterator } type DropletUuid []*Droplet func (a DropletUuid) Len() int { return len(a) } func (a DropletUuid) Less(i, j int) bool { return a[i].Uuid < a[j].Uuid } func (a DropletUuid) Swap(i, j int) { a[i], a[j] = a[j], a[i] } // enforces Uuid is unique func (all *Droplets) AppendUniqueUuid(newP *Droplet) bool { all.Lock.RLock() defer all.Lock.RUnlock() for _, p := range all.Droplets { if p.Uuid == newP.Uuid { return false } } all.Droplets = append(all.Droplets, newP) return true } func (all *Droplets) DeleteByUuid(s string) bool { all.Lock.RLock() defer all.Lock.RUnlock() for i, _ := range all.Droplets { if all.Droplets[i].Uuid == s { all.Droplets[i] = all.Droplets[len(all.Droplets)-1] all.Droplets = all.Droplets[:len(all.Droplets)-1] return true } } return false } // enforces Uuid is unique func (all *Droplets) ReplaceUuid(newP *Droplet) bool { // todo: make unique name here all.Lock.RLock() defer all.Lock.RUnlock() for _, p := range all.Droplets { if p.Uuid == newP.Uuid { return false } } all.Droplets = append(all.Droplets, newP) return true } // find a dependancy by the go path func (all *Droplets) FindByUuid(s string) *Droplet { if all == nil { return nil } all.Lock.RLock() defer all.Lock.RUnlock() for i, _ := range all.Droplets { if all.Droplets[i].Uuid == s { return all.Droplets[i] } } return nil } func (all *Droplets) SortByHostname() *DropletIterator { packs := all.selectAllDroplet() sort.Sort(DropletHostname(packs)) iterator := NewDropletIterator(packs) return iterator } type DropletHostname []*Droplet func (a DropletHostname) Len() int { return len(a) } func (a DropletHostname) Less(i, j int) bool { return a[i].Hostname < a[j].Hostname } func (a DropletHostname) Swap(i, j int) { a[i], a[j] = a[j], a[i] } // enforces Hostname is unique func (all *Droplets) AppendUniqueHostname(newP *Droplet) bool { all.Lock.RLock() defer all.Lock.RUnlock() for _, p := range all.Droplets { if p.Hostname == newP.Hostname { return false } } all.Droplets = append(all.Droplets, newP) return true } func (all *Droplets) DeleteByHostname(s string) bool { all.Lock.RLock() defer all.Lock.RUnlock() for i, _ := range all.Droplets { if all.Droplets[i].Hostname == s { all.Droplets[i] = all.Droplets[len(all.Droplets)-1] all.Droplets = all.Droplets[:len(all.Droplets)-1] return true } } return false } // enforces Hostname is unique func (all *Droplets) ReplaceHostname(newP *Droplet) bool { // todo: make unique name here all.Lock.RLock() defer all.Lock.RUnlock() for _, p := range all.Droplets { if p.Hostname == newP.Hostname { return false } } all.Droplets = append(all.Droplets, newP) return true } // find a dependancy by the go path func (all *Droplets) FindByHostname(s string) *Droplet { if all == nil { return nil } all.Lock.RLock() defer all.Lock.RUnlock() for i, _ := range all.Droplets { if all.Droplets[i].Hostname == s { return all.Droplets[i] } } return nil } // safely returns a slice of pointers to the Droplet protobufs func (all *Droplets) selectAllDroplet() []*Droplet { all.Lock.RLock() defer all.Lock.RUnlock() // Create a new slice to hold pointers to each Droplet var aStuff []*Droplet aStuff = make([]*Droplet, len(all.Droplets)) for i, p := range all.Droplets { aStuff[i] = p // Copy pointers for safe iteration } return aStuff } // `autogen:event.marshal.pb.go` package virtbuf // This file was autogenerated with autogenpb. // go install go.wit.com/apps/autogenpb@latest // // You can use it on simple protobuf files // The .proto file must have a singular and plural form of a message // (for those of you that know ruby on rails, it's like that) // // You can mark which repos you want to auto generate sort.pb.go and marshal.pb.go files for // // For an example, // go-clone go.wit.com/lib/protobuf/gitpb // import ( "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" ) // human readable JSON func (v *Events) FormatJSON() string { return protojson.Format(v) } // marshal json func (v *Events) MarshalJSON() ([]byte, error) { return protojson.Marshal(v) } // unmarshal json func (v *Events) UnmarshalJSON(data []byte) error { return protojson.Unmarshal(data, v) } // apparently this isn't stable, but it's awesomely better // https://protobuf.dev/reference/go/faq/#unstable-text // it's so great for config files, I'm using it by default to try to fix the problems with it func (v *Events) FormatTEXT() string { return prototext.Format(v) } // unmarshalTEXT. This reads the .text config file back in after the user edits it func (v *Events) UnmarshalTEXT(data []byte) error { return prototext.Unmarshal(data, v) } // marshal to wire. This is called winning. func (v *Events) Marshal() ([]byte, error) { return proto.Marshal(v) } // unmarshal from wire. You have won. func (v *Events) Unmarshal(data []byte) error { return proto.Unmarshal(data, v) } // `autogen:event.pb.go` // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.2-devel // protoc v3.21.12 // source: event.proto package virtbuf import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) 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 EventType int32 const ( EventType_ADD EventType = 0 EventType_DELETE EventType = 1 EventType_POWERON EventType = 2 EventType_POWEROFF EventType = 3 // should indicate a "normal" shutdown EventType_HIBERNATE EventType = 4 EventType_MIGRATE EventType = 5 EventType_DEMO EventType = 6 EventType_GET EventType = 7 // request something EventType_LOGIN EventType = 8 // attempt to login EventType_OK EventType = 9 // everything is ok EventType_FAIL EventType = 10 // everything failed EventType_CRASH EventType = 11 // droplet hard crashed EventType_CHANGE EventType = 12 // droplet or hypervisor config change ) // Enum value maps for EventType. var ( EventType_name = map[int32]string{ 0: "ADD", 1: "DELETE", 2: "POWERON", 3: "POWEROFF", 4: "HIBERNATE", 5: "MIGRATE", 6: "DEMO", 7: "GET", 8: "LOGIN", 9: "OK", 10: "FAIL", 11: "CRASH", 12: "CHANGE", } EventType_value = map[string]int32{ "ADD": 0, "DELETE": 1, "POWERON": 2, "POWEROFF": 3, "HIBERNATE": 4, "MIGRATE": 5, "DEMO": 6, "GET": 7, "LOGIN": 8, "OK": 9, "FAIL": 10, "CRASH": 11, "CHANGE": 12, } ) func (x EventType) Enum() *EventType { p := new(EventType) *p = x return p } func (x EventType) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (EventType) Descriptor() protoreflect.EnumDescriptor { return file_event_proto_enumTypes[0].Descriptor() } func (EventType) Type() protoreflect.EnumType { return &file_event_proto_enumTypes[0] } func (x EventType) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use EventType.Descriptor instead. func (EventType) EnumDescriptor() ([]byte, []int) { return file_event_proto_rawDescGZIP(), []int{0} } type Events struct { Lock sync.RWMutex // auto-added by go.wit.com/apps/autogenpb state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` // I guess why not just have this on each file Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // maybe can be used for protobuf schema change violations EventSize int64 `protobuf:"varint,3,opt,name=event_size,json=eventSize,proto3" json:"event_size,omitempty"` // max events to store in a single Events []*Event `protobuf:"bytes,4,rep,name=events,proto3" json:"events,omitempty"` // all the events } func (x *Events) Reset() { *x = Events{} mi := &file_event_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Events) String() string { return protoimpl.X.MessageStringOf(x) } func (*Events) ProtoMessage() {} func (x *Events) ProtoReflect() protoreflect.Message { mi := &file_event_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Events.ProtoReflect.Descriptor instead. func (*Events) Descriptor() ([]byte, []int) { return file_event_proto_rawDescGZIP(), []int{0} } func (x *Events) GetUuid() string { if x != nil { return x.Uuid } return "" } func (x *Events) GetVersion() string { if x != nil { return x.Version } return "" } func (x *Events) GetEventSize() int64 { if x != nil { return x.EventSize } return 0 } func (x *Events) GetEvents() []*Event { if x != nil { return x.Events } return nil } // this information leans towards being human readable not programatic // in other words, it's better to just have the droplet name here rather than the uuid // at least for now in the early days. but maybe forever. // homelab clouds normally don't have many events. // we are talking less than 1 a minute. even 1 an hour is often a lot type Event struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // `autogenpb:unique` // should be unique across the cluster Etype EventType `protobuf:"varint,2,opt,name=etype,proto3,enum=virtbuf.EventType" json:"etype,omitempty"` Droplet string `protobuf:"bytes,3,opt,name=droplet,proto3" json:"droplet,omitempty"` // name of the droplet DropletUuid string `protobuf:"bytes,4,opt,name=droplet_uuid,json=dropletUuid,proto3" json:"droplet_uuid,omitempty"` // uuid of the droplet Hypervisor string `protobuf:"bytes,5,opt,name=hypervisor,proto3" json:"hypervisor,omitempty"` // name of the hypervisor HypervisorUuid string `protobuf:"bytes,6,opt,name=hypervisor_uuid,json=hypervisorUuid,proto3" json:"hypervisor_uuid,omitempty"` // uuid of the hypervisor Start *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=start,proto3" json:"start,omitempty"` // start time End *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=end,proto3" json:"end,omitempty"` // end time FieldName string `protobuf:"bytes,9,opt,name=field_name,json=fieldName,proto3" json:"field_name,omitempty"` // the field name that changed OrigVal string `protobuf:"bytes,10,opt,name=orig_val,json=origVal,proto3" json:"orig_val,omitempty"` // original value NewVal string `protobuf:"bytes,11,opt,name=new_val,json=newVal,proto3" json:"new_val,omitempty"` // new value OrigAny *anypb.Any `protobuf:"bytes,12,opt,name=orig_any,json=origAny,proto3" json:"orig_any,omitempty"` // anypb format. probably overkill NewAny *anypb.Any `protobuf:"bytes,13,opt,name=new_any,json=newAny,proto3" json:"new_any,omitempty"` // anypb format } func (x *Event) Reset() { *x = Event{} mi := &file_event_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Event) String() string { return protoimpl.X.MessageStringOf(x) } func (*Event) ProtoMessage() {} func (x *Event) ProtoReflect() protoreflect.Message { mi := &file_event_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Event.ProtoReflect.Descriptor instead. func (*Event) Descriptor() ([]byte, []int) { return file_event_proto_rawDescGZIP(), []int{1} } func (x *Event) GetId() int32 { if x != nil { return x.Id } return 0 } func (x *Event) GetEtype() EventType { if x != nil { return x.Etype } return EventType_ADD } func (x *Event) GetDroplet() string { if x != nil { return x.Droplet } return "" } func (x *Event) GetDropletUuid() string { if x != nil { return x.DropletUuid } return "" } func (x *Event) GetHypervisor() string { if x != nil { return x.Hypervisor } return "" } func (x *Event) GetHypervisorUuid() string { if x != nil { return x.HypervisorUuid } return "" } func (x *Event) GetStart() *timestamppb.Timestamp { if x != nil { return x.Start } return nil } func (x *Event) GetEnd() *timestamppb.Timestamp { if x != nil { return x.End } return nil } func (x *Event) GetFieldName() string { if x != nil { return x.FieldName } return "" } func (x *Event) GetOrigVal() string { if x != nil { return x.OrigVal } return "" } func (x *Event) GetNewVal() string { if x != nil { return x.NewVal } return "" } func (x *Event) GetOrigAny() *anypb.Any { if x != nil { return x.OrigAny } return nil } func (x *Event) GetNewAny() *anypb.Any { if x != nil { return x.NewAny } return nil } var File_event_proto protoreflect.FileDescriptor var file_event_proto_rawDesc = []byte{ 0x0a, 0x0b, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x7d, 0x0a, 0x06, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xda, 0x03, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x05, 0x65, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x65, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x72, 0x6f, 0x70, 0x6c, 0x65, 0x74, 0x55, 0x75, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x55, 0x75, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x2c, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, 0x69, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x65, 0x77, 0x5f, 0x76, 0x61, 0x6c, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x65, 0x77, 0x56, 0x61, 0x6c, 0x12, 0x2f, 0x0a, 0x08, 0x6f, 0x72, 0x69, 0x67, 0x5f, 0x61, 0x6e, 0x79, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x6f, 0x72, 0x69, 0x67, 0x41, 0x6e, 0x79, 0x12, 0x2d, 0x0a, 0x07, 0x6e, 0x65, 0x77, 0x5f, 0x61, 0x6e, 0x79, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x06, 0x6e, 0x65, 0x77, 0x41, 0x6e, 0x79, 0x2a, 0x9e, 0x01, 0x0a, 0x09, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x44, 0x44, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x4f, 0x57, 0x45, 0x52, 0x4f, 0x4e, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x4f, 0x57, 0x45, 0x52, 0x4f, 0x46, 0x46, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x48, 0x49, 0x42, 0x45, 0x52, 0x4e, 0x41, 0x54, 0x45, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x4d, 0x49, 0x47, 0x52, 0x41, 0x54, 0x45, 0x10, 0x05, 0x12, 0x08, 0x0a, 0x04, 0x44, 0x45, 0x4d, 0x4f, 0x10, 0x06, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x45, 0x54, 0x10, 0x07, 0x12, 0x09, 0x0a, 0x05, 0x4c, 0x4f, 0x47, 0x49, 0x4e, 0x10, 0x08, 0x12, 0x06, 0x0a, 0x02, 0x4f, 0x4b, 0x10, 0x09, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x41, 0x49, 0x4c, 0x10, 0x0a, 0x12, 0x09, 0x0a, 0x05, 0x43, 0x52, 0x41, 0x53, 0x48, 0x10, 0x0b, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x10, 0x0c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_event_proto_rawDescOnce sync.Once file_event_proto_rawDescData = file_event_proto_rawDesc ) func file_event_proto_rawDescGZIP() []byte { file_event_proto_rawDescOnce.Do(func() { file_event_proto_rawDescData = protoimpl.X.CompressGZIP(file_event_proto_rawDescData) }) return file_event_proto_rawDescData } var file_event_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_event_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_event_proto_goTypes = []any{ (EventType)(0), // 0: virtbuf.EventType (*Events)(nil), // 1: virtbuf.Events (*Event)(nil), // 2: virtbuf.Event (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp (*anypb.Any)(nil), // 4: google.protobuf.Any } var file_event_proto_depIdxs = []int32{ 2, // 0: virtbuf.Events.events:type_name -> virtbuf.Event 0, // 1: virtbuf.Event.etype:type_name -> virtbuf.EventType 3, // 2: virtbuf.Event.start:type_name -> google.protobuf.Timestamp 3, // 3: virtbuf.Event.end:type_name -> google.protobuf.Timestamp 4, // 4: virtbuf.Event.orig_any:type_name -> google.protobuf.Any 4, // 5: virtbuf.Event.new_any:type_name -> google.protobuf.Any 6, // [6:6] is the sub-list for method output_type 6, // [6:6] is the sub-list for method input_type 6, // [6:6] is the sub-list for extension type_name 6, // [6:6] is the sub-list for extension extendee 0, // [0:6] is the sub-list for field type_name } func init() { file_event_proto_init() } func file_event_proto_init() { if File_event_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_event_proto_rawDesc, NumEnums: 1, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, GoTypes: file_event_proto_goTypes, DependencyIndexes: file_event_proto_depIdxs, EnumInfos: file_event_proto_enumTypes, MessageInfos: file_event_proto_msgTypes, }.Build() File_event_proto = out.File file_event_proto_rawDesc = nil file_event_proto_goTypes = nil file_event_proto_depIdxs = nil } // `autogen:experiments.pb.go` // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.2-devel // protoc v3.21.12 // source: experiments.proto package virtbuf import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) 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 WhatsThis struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // is it possible to have custom formatting in JSON and TEXT marshal/unmarshal ? Humantest *WhatInfo `protobuf:"bytes,1,opt,name=humantest,proto3" json:"humantest,omitempty"` End *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=end,proto3" json:"end,omitempty"` // end time OrigVal *anypb.Any `protobuf:"bytes,3,opt,name=orig_val,json=origVal,proto3" json:"orig_val,omitempty"` // original value NewVal *anypb.Any `protobuf:"bytes,4,opt,name=new_val,json=newVal,proto3" json:"new_val,omitempty"` // new value } func (x *WhatsThis) Reset() { *x = WhatsThis{} mi := &file_experiments_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *WhatsThis) String() string { return protoimpl.X.MessageStringOf(x) } func (*WhatsThis) ProtoMessage() {} func (x *WhatsThis) ProtoReflect() protoreflect.Message { mi := &file_experiments_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use WhatsThis.ProtoReflect.Descriptor instead. func (*WhatsThis) Descriptor() ([]byte, []int) { return file_experiments_proto_rawDescGZIP(), []int{0} } func (x *WhatsThis) GetHumantest() *WhatInfo { if x != nil { return x.Humantest } return nil } func (x *WhatsThis) GetEnd() *timestamppb.Timestamp { if x != nil { return x.End } return nil } func (x *WhatsThis) GetOrigVal() *anypb.Any { if x != nil { return x.OrigVal } return nil } func (x *WhatsThis) GetNewVal() *anypb.Any { if x != nil { return x.NewVal } return nil } // this is for exerimenting type WhatInfo struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Capacity int64 `protobuf:"varint,1,opt,name=capacity,proto3" json:"capacity,omitempty"` // Stores the storage capacity in bytes. } func (x *WhatInfo) Reset() { *x = WhatInfo{} mi := &file_experiments_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *WhatInfo) String() string { return protoimpl.X.MessageStringOf(x) } func (*WhatInfo) ProtoMessage() {} func (x *WhatInfo) ProtoReflect() protoreflect.Message { mi := &file_experiments_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use WhatInfo.ProtoReflect.Descriptor instead. func (*WhatInfo) Descriptor() ([]byte, []int) { return file_experiments_proto_rawDescGZIP(), []int{1} } func (x *WhatInfo) GetCapacity() int64 { if x != nil { return x.Capacity } return 0 } var File_experiments_proto protoreflect.FileDescriptor var file_experiments_proto_rawDesc = []byte{ 0x0a, 0x11, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xca, 0x01, 0x0a, 0x09, 0x57, 0x68, 0x61, 0x74, 0x73, 0x54, 0x68, 0x69, 0x73, 0x12, 0x2f, 0x0a, 0x09, 0x68, 0x75, 0x6d, 0x61, 0x6e, 0x74, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x68, 0x61, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x68, 0x75, 0x6d, 0x61, 0x6e, 0x74, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x12, 0x2f, 0x0a, 0x08, 0x6f, 0x72, 0x69, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x6f, 0x72, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x12, 0x2d, 0x0a, 0x07, 0x6e, 0x65, 0x77, 0x5f, 0x76, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x06, 0x6e, 0x65, 0x77, 0x56, 0x61, 0x6c, 0x22, 0x26, 0x0a, 0x08, 0x57, 0x68, 0x61, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_experiments_proto_rawDescOnce sync.Once file_experiments_proto_rawDescData = file_experiments_proto_rawDesc ) func file_experiments_proto_rawDescGZIP() []byte { file_experiments_proto_rawDescOnce.Do(func() { file_experiments_proto_rawDescData = protoimpl.X.CompressGZIP(file_experiments_proto_rawDescData) }) return file_experiments_proto_rawDescData } var file_experiments_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_experiments_proto_goTypes = []any{ (*WhatsThis)(nil), // 0: virtbuf.WhatsThis (*WhatInfo)(nil), // 1: virtbuf.WhatInfo (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp (*anypb.Any)(nil), // 3: google.protobuf.Any } var file_experiments_proto_depIdxs = []int32{ 1, // 0: virtbuf.WhatsThis.humantest:type_name -> virtbuf.WhatInfo 2, // 1: virtbuf.WhatsThis.end:type_name -> google.protobuf.Timestamp 3, // 2: virtbuf.WhatsThis.orig_val:type_name -> google.protobuf.Any 3, // 3: virtbuf.WhatsThis.new_val:type_name -> google.protobuf.Any 4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name 4, // [4:4] is the sub-list for extension extendee 0, // [0:4] is the sub-list for field type_name } func init() { file_experiments_proto_init() } func file_experiments_proto_init() { if File_experiments_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_experiments_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, GoTypes: file_experiments_proto_goTypes, DependencyIndexes: file_experiments_proto_depIdxs, MessageInfos: file_experiments_proto_msgTypes, }.Build() File_experiments_proto = out.File file_experiments_proto_rawDesc = nil file_experiments_proto_goTypes = nil file_experiments_proto_depIdxs = nil } // `autogen:hypervisor.marshal.pb.go` package virtbuf // This file was autogenerated with autogenpb. // go install go.wit.com/apps/autogenpb@latest // // You can use it on simple protobuf files // The .proto file must have a singular and plural form of a message // (for those of you that know ruby on rails, it's like that) // // You can mark which repos you want to auto generate sort.pb.go and marshal.pb.go files for // // For an example, // go-clone go.wit.com/lib/protobuf/gitpb // import ( "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" ) // human readable JSON func (v *Hypervisors) FormatJSON() string { return protojson.Format(v) } // marshal json func (v *Hypervisors) MarshalJSON() ([]byte, error) { return protojson.Marshal(v) } // unmarshal json func (v *Hypervisors) UnmarshalJSON(data []byte) error { return protojson.Unmarshal(data, v) } // apparently this isn't stable, but it's awesomely better // https://protobuf.dev/reference/go/faq/#unstable-text // it's so great for config files, I'm using it by default to try to fix the problems with it func (v *Hypervisors) FormatTEXT() string { return prototext.Format(v) } // unmarshalTEXT. This reads the .text config file back in after the user edits it func (v *Hypervisors) UnmarshalTEXT(data []byte) error { return prototext.Unmarshal(data, v) } // marshal to wire. This is called winning. func (v *Hypervisors) Marshal() ([]byte, error) { return proto.Marshal(v) } // unmarshal from wire. You have won. func (v *Hypervisors) Unmarshal(data []byte) error { return proto.Unmarshal(data, v) } // `autogen:hypervisor.pb.go` // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.2-devel // protoc v3.21.12 // source: hypervisor.proto package virtbuf import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) 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) ) // think about this more type HypervisorArch int32 const ( HypervisorArch_RISCV64 HypervisorArch = 0 HypervisorArch_X86_64 HypervisorArch = 1 HypervisorArch_ARM64 HypervisorArch = 2 ) // Enum value maps for HypervisorArch. var ( HypervisorArch_name = map[int32]string{ 0: "RISCV64", 1: "X86_64", 2: "ARM64", } HypervisorArch_value = map[string]int32{ "RISCV64": 0, "X86_64": 1, "ARM64": 2, } ) func (x HypervisorArch) Enum() *HypervisorArch { p := new(HypervisorArch) *p = x return p } func (x HypervisorArch) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (HypervisorArch) Descriptor() protoreflect.EnumDescriptor { return file_hypervisor_proto_enumTypes[0].Descriptor() } func (HypervisorArch) Type() protoreflect.EnumType { return &file_hypervisor_proto_enumTypes[0] } func (x HypervisorArch) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use HypervisorArch.Descriptor instead. func (HypervisorArch) EnumDescriptor() ([]byte, []int) { return file_hypervisor_proto_rawDescGZIP(), []int{0} } type Hypervisors struct { Lock sync.RWMutex // auto-added by go.wit.com/apps/autogenpb state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` // I guess why not just have this on each file Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // maybe can be used for protobuf schema change violations Hypervisors []*Hypervisor `protobuf:"bytes,3,rep,name=hypervisors,proto3" json:"hypervisors,omitempty"` } func (x *Hypervisors) Reset() { *x = Hypervisors{} mi := &file_hypervisor_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Hypervisors) String() string { return protoimpl.X.MessageStringOf(x) } func (*Hypervisors) ProtoMessage() {} func (x *Hypervisors) ProtoReflect() protoreflect.Message { mi := &file_hypervisor_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Hypervisors.ProtoReflect.Descriptor instead. func (*Hypervisors) Descriptor() ([]byte, []int) { return file_hypervisor_proto_rawDescGZIP(), []int{0} } func (x *Hypervisors) GetUuid() string { if x != nil { return x.Uuid } return "" } func (x *Hypervisors) GetVersion() string { if x != nil { return x.Version } return "" } func (x *Hypervisors) GetHypervisors() []*Hypervisor { if x != nil { return x.Hypervisors } return nil } type Hypervisor struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` // `autogenpb:unique` Hostname string `protobuf:"bytes,2,opt,name=hostname,proto3" json:"hostname,omitempty"` // `autogenpb:unique` Active bool `protobuf:"varint,3,opt,name=active,proto3" json:"active,omitempty"` // is allowed to start new droplets Cpus int64 `protobuf:"varint,4,opt,name=cpus,proto3" json:"cpus,omitempty"` Memory int64 `protobuf:"varint,5,opt,name=memory,proto3" json:"memory,omitempty"` // in bytes Comment string `protobuf:"bytes,6,opt,name=comment,proto3" json:"comment,omitempty"` Autoscan bool `protobuf:"varint,7,opt,name=autoscan,proto3" json:"autoscan,omitempty"` // to scan or not to scan by virtigo Arch HypervisorArch `protobuf:"varint,8,opt,name=arch,proto3,enum=virtbuf.HypervisorArch" json:"arch,omitempty"` } func (x *Hypervisor) Reset() { *x = Hypervisor{} mi := &file_hypervisor_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Hypervisor) String() string { return protoimpl.X.MessageStringOf(x) } func (*Hypervisor) ProtoMessage() {} func (x *Hypervisor) ProtoReflect() protoreflect.Message { mi := &file_hypervisor_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Hypervisor.ProtoReflect.Descriptor instead. func (*Hypervisor) Descriptor() ([]byte, []int) { return file_hypervisor_proto_rawDescGZIP(), []int{1} } func (x *Hypervisor) GetUuid() string { if x != nil { return x.Uuid } return "" } func (x *Hypervisor) GetHostname() string { if x != nil { return x.Hostname } return "" } func (x *Hypervisor) GetActive() bool { if x != nil { return x.Active } return false } func (x *Hypervisor) GetCpus() int64 { if x != nil { return x.Cpus } return 0 } func (x *Hypervisor) GetMemory() int64 { if x != nil { return x.Memory } return 0 } func (x *Hypervisor) GetComment() string { if x != nil { return x.Comment } return "" } func (x *Hypervisor) GetAutoscan() bool { if x != nil { return x.Autoscan } return false } func (x *Hypervisor) GetArch() HypervisorArch { if x != nil { return x.Arch } return HypervisorArch_RISCV64 } var File_hypervisor_proto protoreflect.FileDescriptor var file_hypervisor_proto_rawDesc = []byte{ 0x0a, 0x10, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x22, 0x72, 0x0a, 0x0b, 0x48, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x35, 0x0a, 0x0b, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x48, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x52, 0x0b, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x73, 0x22, 0xe3, 0x01, 0x0a, 0x0a, 0x48, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x70, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x70, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x75, 0x74, 0x6f, 0x73, 0x63, 0x61, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x61, 0x75, 0x74, 0x6f, 0x73, 0x63, 0x61, 0x6e, 0x12, 0x2b, 0x0a, 0x04, 0x61, 0x72, 0x63, 0x68, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x76, 0x69, 0x72, 0x74, 0x62, 0x75, 0x66, 0x2e, 0x48, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x41, 0x72, 0x63, 0x68, 0x52, 0x04, 0x61, 0x72, 0x63, 0x68, 0x2a, 0x34, 0x0a, 0x0e, 0x48, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x41, 0x72, 0x63, 0x68, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x49, 0x53, 0x43, 0x56, 0x36, 0x34, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x58, 0x38, 0x36, 0x5f, 0x36, 0x34, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x52, 0x4d, 0x36, 0x34, 0x10, 0x02, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_hypervisor_proto_rawDescOnce sync.Once file_hypervisor_proto_rawDescData = file_hypervisor_proto_rawDesc ) func file_hypervisor_proto_rawDescGZIP() []byte { file_hypervisor_proto_rawDescOnce.Do(func() { file_hypervisor_proto_rawDescData = protoimpl.X.CompressGZIP(file_hypervisor_proto_rawDescData) }) return file_hypervisor_proto_rawDescData } var file_hypervisor_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_hypervisor_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_hypervisor_proto_goTypes = []any{ (HypervisorArch)(0), // 0: virtbuf.HypervisorArch (*Hypervisors)(nil), // 1: virtbuf.Hypervisors (*Hypervisor)(nil), // 2: virtbuf.Hypervisor } var file_hypervisor_proto_depIdxs = []int32{ 2, // 0: virtbuf.Hypervisors.hypervisors:type_name -> virtbuf.Hypervisor 0, // 1: virtbuf.Hypervisor.arch:type_name -> virtbuf.HypervisorArch 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_hypervisor_proto_init() } func file_hypervisor_proto_init() { if File_hypervisor_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_hypervisor_proto_rawDesc, NumEnums: 1, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, GoTypes: file_hypervisor_proto_goTypes, DependencyIndexes: file_hypervisor_proto_depIdxs, EnumInfos: file_hypervisor_proto_enumTypes, MessageInfos: file_hypervisor_proto_msgTypes, }.Build() File_hypervisor_proto = out.File file_hypervisor_proto_rawDesc = nil file_hypervisor_proto_goTypes = nil file_hypervisor_proto_depIdxs = nil } // `autogen:hypervisor.sort.pb.go` package virtbuf // This file was autogenerated with autogenpb. // go install go.wit.com/apps/autogenpb@latest // // You can use it on simple protobuf files // The .proto file must have a singular and plural form of a message // (for those of you that know ruby on rails, it's like that) // // You can mark which repos you want to auto generate sort.pb.go and marshal.pb.go files for // // For an example, // go-clone go.wit.com/lib/protobuf/gitpb // import ( "fmt" "os" "sort" "sync" ) type HypervisorIterator struct { sync.RWMutex packs []*Hypervisor index int } // NewHypervisorIterator initializes a new iterator. func NewHypervisorIterator(packs []*Hypervisor) *HypervisorIterator { return &HypervisorIterator{packs: packs} } // Scan moves to the next element and returns false if there are no more packs. // Use Scan() in a loop, similar to a while loop // // for iterator.Scan() // d := iterator.Next( // fmt.Println("found UUID:", d.Uuid // } func (it *HypervisorIterator) Scan() bool { if it.index >= len(it.packs) { return false } it.index++ return true } // Next() returns the next thing in the array func (it *HypervisorIterator) Next() *Hypervisor { if it.packs[it.index-1] == nil { for i, d := range it.packs { fmt.Println("i =", i, d) } fmt.Println("protobuf autogenpb sort error len =", len(it.packs)) fmt.Println("protobuf autogenpb sort error next == nil", it.index, it.index-1) os.Exit(-1) } return it.packs[it.index-1] } // does not enforce any unique fields func (all *Hypervisors) Append(newP *Hypervisor) bool { all.Lock.RLock() defer all.Lock.RUnlock() all.Hypervisors = append(all.Hypervisors, newP) return true } func (all *Hypervisors) All() *HypervisorIterator { hypervisorPointers := all.selectAllHypervisor() iterator := NewHypervisorIterator(hypervisorPointers) return iterator } func (all *Hypervisors) Len() int { all.Lock.RLock() defer all.Lock.RUnlock() return len(all.Hypervisors) } func (all *Hypervisors) SortByUuid() *HypervisorIterator { packs := all.selectAllHypervisor() sort.Sort(HypervisorUuid(packs)) iterator := NewHypervisorIterator(packs) return iterator } type HypervisorUuid []*Hypervisor func (a HypervisorUuid) Len() int { return len(a) } func (a HypervisorUuid) Less(i, j int) bool { return a[i].Uuid < a[j].Uuid } func (a HypervisorUuid) Swap(i, j int) { a[i], a[j] = a[j], a[i] } // enforces Uuid is unique func (all *Hypervisors) AppendUniqueUuid(newP *Hypervisor) bool { all.Lock.RLock() defer all.Lock.RUnlock() for _, p := range all.Hypervisors { if p.Uuid == newP.Uuid { return false } } all.Hypervisors = append(all.Hypervisors, newP) return true } func (all *Hypervisors) DeleteByUuid(s string) bool { all.Lock.RLock() defer all.Lock.RUnlock() for i, _ := range all.Hypervisors { if all.Hypervisors[i].Uuid == s { all.Hypervisors[i] = all.Hypervisors[len(all.Hypervisors)-1] all.Hypervisors = all.Hypervisors[:len(all.Hypervisors)-1] return true } } return false } // enforces Uuid is unique func (all *Hypervisors) ReplaceUuid(newP *Hypervisor) bool { // todo: make unique name here all.Lock.RLock() defer all.Lock.RUnlock() for _, p := range all.Hypervisors { if p.Uuid == newP.Uuid { return false } } all.Hypervisors = append(all.Hypervisors, newP) return true } // find a dependancy by the go path func (all *Hypervisors) FindByUuid(s string) *Hypervisor { if all == nil { return nil } all.Lock.RLock() defer all.Lock.RUnlock() for i, _ := range all.Hypervisors { if all.Hypervisors[i].Uuid == s { return all.Hypervisors[i] } } return nil } func (all *Hypervisors) SortByHostname() *HypervisorIterator { packs := all.selectAllHypervisor() sort.Sort(HypervisorHostname(packs)) iterator := NewHypervisorIterator(packs) return iterator } type HypervisorHostname []*Hypervisor func (a HypervisorHostname) Len() int { return len(a) } func (a HypervisorHostname) Less(i, j int) bool { return a[i].Hostname < a[j].Hostname } func (a HypervisorHostname) Swap(i, j int) { a[i], a[j] = a[j], a[i] } // enforces Hostname is unique func (all *Hypervisors) AppendUniqueHostname(newP *Hypervisor) bool { all.Lock.RLock() defer all.Lock.RUnlock() for _, p := range all.Hypervisors { if p.Hostname == newP.Hostname { return false } } all.Hypervisors = append(all.Hypervisors, newP) return true } func (all *Hypervisors) DeleteByHostname(s string) bool { all.Lock.RLock() defer all.Lock.RUnlock() for i, _ := range all.Hypervisors { if all.Hypervisors[i].Hostname == s { all.Hypervisors[i] = all.Hypervisors[len(all.Hypervisors)-1] all.Hypervisors = all.Hypervisors[:len(all.Hypervisors)-1] return true } } return false } // enforces Hostname is unique func (all *Hypervisors) ReplaceHostname(newP *Hypervisor) bool { // todo: make unique name here all.Lock.RLock() defer all.Lock.RUnlock() for _, p := range all.Hypervisors { if p.Hostname == newP.Hostname { return false } } all.Hypervisors = append(all.Hypervisors, newP) return true } // find a dependancy by the go path func (all *Hypervisors) FindByHostname(s string) *Hypervisor { if all == nil { return nil } all.Lock.RLock() defer all.Lock.RUnlock() for i, _ := range all.Hypervisors { if all.Hypervisors[i].Hostname == s { return all.Hypervisors[i] } } return nil } // safely returns a slice of pointers to the Hypervisor protobufs func (all *Hypervisors) selectAllHypervisor() []*Hypervisor { all.Lock.RLock() defer all.Lock.RUnlock() // Create a new slice to hold pointers to each Hypervisor var aStuff []*Hypervisor aStuff = make([]*Hypervisor, len(all.Hypervisors)) for i, p := range all.Hypervisors { aStuff[i] = p // Copy pointers for safe iteration } return aStuff } // `autogen:`
|
@ -142,7 +142,7 @@ func loadFile(filename string) ([]byte, error) {
|
|||
|
||||
func ConfigWriteJSON(a any, filename string) error {
|
||||
fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), filename)
|
||||
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE, 0666)
|
||||
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
defer cfgfile.Close()
|
||||
if err != nil {
|
||||
fmt.Println("open config file :", err)
|
||||
|
@ -159,7 +159,7 @@ func ConfigWriteJSON(a any, filename string) error {
|
|||
|
||||
func ConfigWriteTEXT(a any, filename string) error {
|
||||
fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), filename)
|
||||
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE, 0666)
|
||||
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
defer cfgfile.Close()
|
||||
if err != nil {
|
||||
fmt.Println("open config file :", err)
|
||||
|
@ -176,7 +176,7 @@ func ConfigWriteTEXT(a any, filename string) error {
|
|||
|
||||
func (c *Cluster) configWriteDroplets() error {
|
||||
fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), "droplets.new.text")
|
||||
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE, 0666)
|
||||
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
defer cfgfile.Close()
|
||||
if err != nil {
|
||||
fmt.Println("open config file :", err)
|
||||
|
|
Loading…
Reference in New Issue