diff --git a/Makefile b/Makefile index 287ab9b..7a9a3aa 100644 --- a/Makefile +++ b/Makefile @@ -11,12 +11,18 @@ all: # # Then: make events.pb.go + make config.pb.go events.pb.go: events.proto # protoc --version 3.6++ does not mean that protoc will generate version3 .go files protoc --version protoc --go_out=. events.proto +config.pb.go: config.proto + # protoc --version 3.6++ does not mean that protoc will generate version3 .go files + protoc --version + protoc --go_out=. config.proto + compile: protoc --go_out=. *.proto diff --git a/config.pb.go b/config.pb.go new file mode 100644 index 0000000..970144d --- /dev/null +++ b/config.pb.go @@ -0,0 +1,224 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: config.proto + +package witProtobuf + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type Config struct { + USER string `protobuf:"bytes,1,opt,name=USER,proto3" json:"USER,omitempty"` + Width int32 `protobuf:"varint,2,opt,name=width,proto3" json:"width,omitempty"` + Height int32 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + Hostname string `protobuf:"bytes,4,opt,name=hostname,proto3" json:"hostname,omitempty"` + Debugging bool `protobuf:"varint,5,opt,name=debugging,proto3" json:"debugging,omitempty"` + Debugtable bool `protobuf:"varint,6,opt,name=debugtable,proto3" json:"debugtable,omitempty"` + Accounts []*Config_Account `protobuf:"bytes,7,rep,name=accounts,proto3" json:"accounts,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Config) Reset() { *m = Config{} } +func (m *Config) String() string { return proto.CompactTextString(m) } +func (*Config) ProtoMessage() {} +func (*Config) Descriptor() ([]byte, []int) { + return fileDescriptor_3eaf2c85e69e9ea4, []int{0} +} + +func (m *Config) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Config.Unmarshal(m, b) +} +func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Config.Marshal(b, m, deterministic) +} +func (m *Config) XXX_Merge(src proto.Message) { + xxx_messageInfo_Config.Merge(m, src) +} +func (m *Config) XXX_Size() int { + return xxx_messageInfo_Config.Size(m) +} +func (m *Config) XXX_DiscardUnknown() { + xxx_messageInfo_Config.DiscardUnknown(m) +} + +var xxx_messageInfo_Config proto.InternalMessageInfo + +func (m *Config) GetUSER() string { + if m != nil { + return m.USER + } + return "" +} + +func (m *Config) GetWidth() int32 { + if m != nil { + return m.Width + } + return 0 +} + +func (m *Config) GetHeight() int32 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *Config) GetHostname() string { + if m != nil { + return m.Hostname + } + return "" +} + +func (m *Config) GetDebugging() bool { + if m != nil { + return m.Debugging + } + return false +} + +func (m *Config) GetDebugtable() bool { + if m != nil { + return m.Debugtable + } + return false +} + +func (m *Config) GetAccounts() []*Config_Account { + if m != nil { + return m.Accounts + } + return nil +} + +type Config_Account struct { + Nick string `protobuf:"bytes,1,opt,name=nick,proto3" json:"nick,omitempty"` + Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` + Token string `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"` + Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"` + Hostname string `protobuf:"bytes,5,opt,name=hostname,proto3" json:"hostname,omitempty"` + Domainname string `protobuf:"bytes,6,opt,name=domainname,proto3" json:"domainname,omitempty"` + Port int32 `protobuf:"varint,7,opt,name=port,proto3" json:"port,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Config_Account) Reset() { *m = Config_Account{} } +func (m *Config_Account) String() string { return proto.CompactTextString(m) } +func (*Config_Account) ProtoMessage() {} +func (*Config_Account) Descriptor() ([]byte, []int) { + return fileDescriptor_3eaf2c85e69e9ea4, []int{0, 0} +} + +func (m *Config_Account) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Config_Account.Unmarshal(m, b) +} +func (m *Config_Account) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Config_Account.Marshal(b, m, deterministic) +} +func (m *Config_Account) XXX_Merge(src proto.Message) { + xxx_messageInfo_Config_Account.Merge(m, src) +} +func (m *Config_Account) XXX_Size() int { + return xxx_messageInfo_Config_Account.Size(m) +} +func (m *Config_Account) XXX_DiscardUnknown() { + xxx_messageInfo_Config_Account.DiscardUnknown(m) +} + +var xxx_messageInfo_Config_Account proto.InternalMessageInfo + +func (m *Config_Account) GetNick() string { + if m != nil { + return m.Nick + } + return "" +} + +func (m *Config_Account) GetUsername() string { + if m != nil { + return m.Username + } + return "" +} + +func (m *Config_Account) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *Config_Account) GetPassword() string { + if m != nil { + return m.Password + } + return "" +} + +func (m *Config_Account) GetHostname() string { + if m != nil { + return m.Hostname + } + return "" +} + +func (m *Config_Account) GetDomainname() string { + if m != nil { + return m.Domainname + } + return "" +} + +func (m *Config_Account) GetPort() int32 { + if m != nil { + return m.Port + } + return 0 +} + +func init() { + proto.RegisterType((*Config)(nil), "witProtobuf.Config") + proto.RegisterType((*Config_Account)(nil), "witProtobuf.Config.Account") +} + +func init() { proto.RegisterFile("config.proto", fileDescriptor_3eaf2c85e69e9ea4) } + +var fileDescriptor_3eaf2c85e69e9ea4 = []byte{ + // 279 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xcf, 0x4e, 0xb4, 0x30, + 0x14, 0xc5, 0xc3, 0x30, 0xfc, 0xbb, 0xf3, 0xad, 0x9a, 0x2f, 0xa6, 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x62, 0xc4, 0xca, 0x9b, 0x50, 0x79, 0xd1, 0x1e, 0xde, 0x99, 0xa3, 0xd0, 0x48, 0x59, 0xb0, + 0x20, 0xfc, 0x17, 0x03, 0xb7, 0x76, 0x36, 0x63, 0xb7, 0x40, 0x2e, 0xfa, 0xd7, 0x01, 0x92, 0x3f, + 0x07, 0xf0, 0x88, 0xe6, 0xc4, 0x95, 0xc6, 0x34, 0xc5, 0x74, 0xe5, 0xf8, 0x76, 0x83, 0x19, 0x1d, + 0xcd, 0xf0, 0xa4, 0x38, 0x37, 0x29, 0xbe, 0xd8, 0xc3, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x57, + 0x19, 0xe1, 0xc9, 0xc1, 0x01, 0x00, 0x00, +} diff --git a/config.proto b/config.proto new file mode 100644 index 0000000..4ae6130 --- /dev/null +++ b/config.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package witProtobuf; + +message Config { + string USER = 1; + int32 width = 2; + int32 height = 3; + string hostname = 4; + bool debugging = 5; + bool debugtable = 6; + + repeated Account accounts = 7; + + message Account { + string nick = 1; + string username = 2; + string token = 3; + string password = 4; + string hostname = 5; + string domainname = 6; + int32 port = 7; + } +} diff --git a/sampleData.go b/sampleData.go index ebdcc13..2e49dcd 100644 --- a/sampleData.go +++ b/sampleData.go @@ -140,3 +140,37 @@ func MakeAddVmEvent() *Event { } return e } + +func MakeDefaultConfig() *Config { + log.Println("MakeDefaultConfig() makes a default config") + + c := &Config{ + USER: "jcarr", + Width: 700, + Height: 500, + Accounts: []*Config_Account{ + { + Nick: "jcarr", + Username: "jcarr@wit.com", + Token: "eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9.eyJ4IjozLCJyIjoiIiwiY3NyZiI6InRBY1p2eXVJbk1YdWUxV0RSbDFIeDI5YSIsImV4cCI6MTU1OTI3MDQwMCwiaXNzIjoid2l0Iiwic3ViIjoiamNhcnJAd2l0LmNvbSJ9.bqXX_6yrUHQGYh3SEmW8ydSa9Xfqx-HIKutTN_GirwhC_VrVX1xJBcgYfjdKGegvwY7Td1vO3rs40Iz7ifcptrtdzJnDX62d_1JJPKBHUQUfnTLr2qoTgaljElFM0Q_e", + Domainname: "test.wit.com", + Hostname: "hosttest.wit.com", + }, + { + Nick: "jcarr2", + Username: "jcarr@wit.com", + Token: "brokenToken", + Domainname: "test.wit.com", + Hostname: "hosttest.wit.com", + }, + { + Nick: "bmath", + Username: "jcarr@wit.com", + Token: "eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9.eyJ4IjoyLCJyIjoiIiwiY3NyZiI6Ik9rR0JWenphV2cxQjVlN0R5YjRXSzIyWCIsImV4cCI6MTU1OTE4NTc1MiwiaXNzIjoid2l0Iiwic3ViIjoiYm1hdGhAd2l0LmNvbSJ9.vdOAXyt3VIovqEIbivgt6upqR8glZv2UdzFcyudzCmGV-msdZWi_9TZaATyQMxEaVD3K6gRunakyOWK0jw4xxeDUbQym86IKMU2UOjp0tN0z72OmH822NmQ8_AgWiKNI", + Domainname: "test.wit.com", + Hostname: "hosttest.wit.com", + }, + }, + } + return c +}