events should not be plural
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
a8484013dc
commit
ade54fdeda
9
Makefile
9
Makefile
|
@ -5,7 +5,7 @@
|
|||
# go install
|
||||
|
||||
|
||||
all: droplet.pb.go hypervisor.pb.go cluster.pb.go events.pb.go experiments.pb.go
|
||||
all: droplet.pb.go hypervisor.pb.go cluster.pb.go event.pb.go experiments.pb.go
|
||||
make -C example
|
||||
|
||||
vet: lint
|
||||
|
@ -42,11 +42,11 @@ hypervisor.pb.go: hypervisor.proto
|
|||
--go_opt=Mhypervisor.proto=go.wit.com/lib/protobuf/virtbuf \
|
||||
hypervisor.proto
|
||||
|
||||
events.pb.go: events.proto
|
||||
event.pb.go: event.proto
|
||||
cd ~/go/src && protoc --go_out=. \
|
||||
--proto_path=go.wit.com/lib/protobuf/virtbuf \
|
||||
--go_opt=Mevents.proto=go.wit.com/lib/protobuf/virtbuf \
|
||||
events.proto
|
||||
--go_opt=Mevent.proto=go.wit.com/lib/protobuf/virtbuf \
|
||||
event.proto
|
||||
|
||||
experiments.pb.go: experiments.proto
|
||||
cd ~/go/src && protoc --go_out=. \
|
||||
|
@ -59,6 +59,7 @@ cluster.pb.go: cluster.proto
|
|||
--go_opt=Mdroplet.proto=go.wit.com/lib/protobuf/virtbuf \
|
||||
--go_opt=Mcluster.proto=go.wit.com/lib/protobuf/virtbuf \
|
||||
--go_opt=Mhypervisor.proto=go.wit.com/lib/protobuf/virtbuf \
|
||||
--go_opt=Mevent.proto=go.wit.com/lib/protobuf/virtbuf \
|
||||
cluster.proto
|
||||
|
||||
deps:
|
||||
|
|
|
@ -3,10 +3,12 @@ package virtbuf;
|
|||
|
||||
import "droplet.proto";
|
||||
import "hypervisor.proto";
|
||||
import "event.proto";
|
||||
|
||||
message Cluster {
|
||||
int64 id = 1;
|
||||
repeated Droplet droplets = 2;
|
||||
repeated Hypervisor hypervisors = 3;
|
||||
repeated string dirs = 4;
|
||||
repeated string dirs = 2;
|
||||
repeated Droplet droplets = 3;
|
||||
repeated Hypervisor hypervisors = 4;
|
||||
repeated Event events = 5;
|
||||
}
|
||||
|
|
36
config.go
36
config.go
|
@ -22,6 +22,34 @@ func (e *Events) ConfigSave() error {
|
|||
return ConfigWriteTEXT(e, "events.text")
|
||||
}
|
||||
|
||||
func (c *Cluster) ConfigSave() error {
|
||||
var d *Droplets
|
||||
d = new(Droplets)
|
||||
d.Droplets = c.Droplets
|
||||
if err := ConfigWriteJSON(d, "newdroplets.json"); err != nil {
|
||||
fmt.Println("droplets.json write failed")
|
||||
return err
|
||||
}
|
||||
|
||||
var h *Hypervisors
|
||||
h = new(Hypervisors)
|
||||
h.Hypervisors = c.Hypervisors
|
||||
if err := ConfigWriteJSON(h, "newhypervisors.json"); err != nil {
|
||||
fmt.Println("hypervisors.json write failed")
|
||||
return err
|
||||
}
|
||||
|
||||
var e *Events
|
||||
e = new(Events)
|
||||
e.Events = c.Events
|
||||
if err := ConfigWriteJSON(h, "newEvents.json"); err != nil {
|
||||
fmt.Println("newEvents.json write failed")
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// read in the events log file
|
||||
// reads in from the prototext file
|
||||
// prototext file formats are not garrenteed to be stable. todo: hammer that out
|
||||
|
@ -211,10 +239,18 @@ func (d *Droplets) FormatJSON() string {
|
|||
return protojson.Format(d)
|
||||
}
|
||||
|
||||
func (d *Droplet) FormatJSON() string {
|
||||
return protojson.Format(d)
|
||||
}
|
||||
|
||||
func (e *Events) FormatJSON() string {
|
||||
return protojson.Format(e)
|
||||
}
|
||||
|
||||
func (h *Hypervisors) FormatJSON() string {
|
||||
return protojson.Format(h)
|
||||
}
|
||||
|
||||
// apparently this isn't supposed to be used?
|
||||
// https://protobuf.dev/reference/go/faq/#unstable-text
|
||||
// this is a shame because this is much nicer output than JSON Format()
|
||||
|
|
28
helpers.go
28
helpers.go
|
@ -25,32 +25,14 @@ func (x *Hypervisor) GetMemoryPrintable() string {
|
|||
return fmt.Sprintf("%d GB", i)
|
||||
}
|
||||
|
||||
/*
|
||||
func (c *Cluster) MarshalJSON() ([]byte, error) {
|
||||
return protojson.Marshal(c)
|
||||
func (all *Droplets) FindDroplet(name string) *Droplet {
|
||||
for _, d := range all.Droplets {
|
||||
if d.Hostname == name {
|
||||
return d
|
||||
}
|
||||
|
||||
func (c *Cluster) FormatJSON() string {
|
||||
return protojson.Format(c)
|
||||
}
|
||||
|
||||
func (c *Cluster) UnmarshalJSON(data []byte) error {
|
||||
return protojson.Unmarshal(data, c)
|
||||
return nil
|
||||
}
|
||||
*/
|
||||
|
||||
// apparently this isn't supposed to be used?
|
||||
// https://protobuf.dev/reference/go/faq/#unstable-text
|
||||
// this is a shame because this is much nicer output than JSON Format()
|
||||
/*
|
||||
func (c *Cluster) FormatTEXT() string {
|
||||
return prototext.Format(c)
|
||||
}
|
||||
|
||||
func (d *Droplets) FormatTEXT() string {
|
||||
return prototext.Format(d)
|
||||
}
|
||||
*/
|
||||
|
||||
func (c *Cluster) FindDroplet(name string) *Droplet {
|
||||
for _, d := range c.Droplets {
|
||||
|
|
Loading…
Reference in New Issue