topo: fix proto path

master
q3k 2018-10-25 05:36:18 -07:00
parent fad1a80fba
commit 477ffe775b
6 changed files with 10 additions and 8 deletions

View File

@ -1,5 +1,7 @@
syntax = "proto3"; syntax = "proto3";
package proto;
message Config { message Config {
repeated Switch switch = 1; repeated Switch switch = 1;
repeated Machine machine = 2; repeated Machine machine = 2;

View File

@ -10,7 +10,7 @@ import (
"github.com/digitalocean/go-netbox/netbox/models" "github.com/digitalocean/go-netbox/netbox/models"
"github.com/golang/glog" "github.com/golang/glog"
confpb "code.hackerspace.pl/hscloud/go/svc/topo/proto/config" pb "code.hackerspace.pl/hscloud/go/svc/topo/proto"
) )
type MachinePort struct { type MachinePort struct {
@ -60,7 +60,7 @@ func (g *Graph) RemoveSwitch(name string) {
glog.Infof("Removed switch %q", name) glog.Infof("Removed switch %q", name)
} }
func (g *Graph) LoadConfig(conf *confpb.Config) error { func (g *Graph) LoadConfig(conf *pb.Config) error {
loadedMachines := make(map[string]bool) loadedMachines := make(map[string]bool)
loadedSwitches := make(map[string]bool) loadedSwitches := make(map[string]bool)

View File

@ -13,7 +13,7 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
confpb "code.hackerspace.pl/hscloud/go/svc/topo/proto/config" pb "code.hackerspace.pl/hscloud/go/svc/topo/proto"
"code.hackerspace.pl/hscloud/go/svc/topo/graph" "code.hackerspace.pl/hscloud/go/svc/topo/graph"
"code.hackerspace.pl/hscloud/go/svc/topo/state" "code.hackerspace.pl/hscloud/go/svc/topo/state"
@ -47,7 +47,7 @@ func main() {
glog.Exitf("Could not read config: %v", err) glog.Exitf("Could not read config: %v", err)
} }
config := confpb.Config{} config := pb.Config{}
proto.UnmarshalText(string(data), &config) proto.UnmarshalText(string(data), &config)
stm := state.NewManager() stm := state.NewManager()

View File

@ -1 +1 @@
config config.pb.go

View File

@ -1,3 +1,3 @@
//go:generate protoc -I.. ../config.proto --go_out=plugins=grpc:config //go:generate protoc -I.. ../config.proto --go_out=plugins=grpc:.
package proto package proto

View File

@ -8,7 +8,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
ipb "code.hackerspace.pl/hscloud/go/proto/infra" ipb "code.hackerspace.pl/hscloud/go/proto/infra"
confpb "code.hackerspace.pl/hscloud/go/svc/topo/proto/config" pb "code.hackerspace.pl/hscloud/go/svc/topo/proto"
"code.hackerspace.pl/hscloud/go/pki" "code.hackerspace.pl/hscloud/go/pki"
) )
@ -49,7 +49,7 @@ func NewManager() *StateManager {
} }
} }
func (s *StateManager) FetchState(ctx context.Context, conf *confpb.Config) error { func (s *StateManager) FetchState(ctx context.Context, conf *pb.Config) error {
s.Mu.Lock() s.Mu.Lock()
defer s.Mu.Unlock() defer s.Mu.Unlock()
for _, sw := range conf.Switch { for _, sw := range conf.Switch {