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
|
# 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
|
make -C example
|
||||||
|
|
||||||
vet: lint
|
vet: lint
|
||||||
|
@ -42,11 +42,11 @@ hypervisor.pb.go: hypervisor.proto
|
||||||
--go_opt=Mhypervisor.proto=go.wit.com/lib/protobuf/virtbuf \
|
--go_opt=Mhypervisor.proto=go.wit.com/lib/protobuf/virtbuf \
|
||||||
hypervisor.proto
|
hypervisor.proto
|
||||||
|
|
||||||
events.pb.go: events.proto
|
event.pb.go: event.proto
|
||||||
cd ~/go/src && protoc --go_out=. \
|
cd ~/go/src && protoc --go_out=. \
|
||||||
--proto_path=go.wit.com/lib/protobuf/virtbuf \
|
--proto_path=go.wit.com/lib/protobuf/virtbuf \
|
||||||
--go_opt=Mevents.proto=go.wit.com/lib/protobuf/virtbuf \
|
--go_opt=Mevent.proto=go.wit.com/lib/protobuf/virtbuf \
|
||||||
events.proto
|
event.proto
|
||||||
|
|
||||||
experiments.pb.go: experiments.proto
|
experiments.pb.go: experiments.proto
|
||||||
cd ~/go/src && protoc --go_out=. \
|
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=Mdroplet.proto=go.wit.com/lib/protobuf/virtbuf \
|
||||||
--go_opt=Mcluster.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=Mhypervisor.proto=go.wit.com/lib/protobuf/virtbuf \
|
||||||
|
--go_opt=Mevent.proto=go.wit.com/lib/protobuf/virtbuf \
|
||||||
cluster.proto
|
cluster.proto
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
|
|
|
@ -3,10 +3,12 @@ package virtbuf;
|
||||||
|
|
||||||
import "droplet.proto";
|
import "droplet.proto";
|
||||||
import "hypervisor.proto";
|
import "hypervisor.proto";
|
||||||
|
import "event.proto";
|
||||||
|
|
||||||
message Cluster {
|
message Cluster {
|
||||||
int64 id = 1;
|
int64 id = 1;
|
||||||
repeated Droplet droplets = 2;
|
repeated string dirs = 2;
|
||||||
repeated Hypervisor hypervisors = 3;
|
repeated Droplet droplets = 3;
|
||||||
repeated string dirs = 4;
|
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")
|
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
|
// read in the events log file
|
||||||
// reads in from the prototext file
|
// reads in from the prototext file
|
||||||
// prototext file formats are not garrenteed to be stable. todo: hammer that out
|
// 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)
|
return protojson.Format(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Droplet) FormatJSON() string {
|
||||||
|
return protojson.Format(d)
|
||||||
|
}
|
||||||
|
|
||||||
func (e *Events) FormatJSON() string {
|
func (e *Events) FormatJSON() string {
|
||||||
return protojson.Format(e)
|
return protojson.Format(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *Hypervisors) FormatJSON() string {
|
||||||
|
return protojson.Format(h)
|
||||||
|
}
|
||||||
|
|
||||||
// apparently this isn't supposed to be used?
|
// apparently this isn't supposed to be used?
|
||||||
// https://protobuf.dev/reference/go/faq/#unstable-text
|
// https://protobuf.dev/reference/go/faq/#unstable-text
|
||||||
// this is a shame because this is much nicer output than JSON Format()
|
// 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)
|
return fmt.Sprintf("%d GB", i)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
func (all *Droplets) FindDroplet(name string) *Droplet {
|
||||||
func (c *Cluster) MarshalJSON() ([]byte, error) {
|
for _, d := range all.Droplets {
|
||||||
return protojson.Marshal(c)
|
if d.Hostname == name {
|
||||||
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) FormatJSON() string {
|
|
||||||
return protojson.Format(c)
|
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
func (c *Cluster) UnmarshalJSON(data []byte) error {
|
|
||||||
return protojson.Unmarshal(data, c)
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// 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 {
|
func (c *Cluster) FindDroplet(name string) *Droplet {
|
||||||
for _, d := range c.Droplets {
|
for _, d := range c.Droplets {
|
||||||
|
|
Loading…
Reference in New Issue