mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
changed exported types
This commit is contained in:
parent
dc2352cab7
commit
86bfb014b3
8 changed files with 56 additions and 16 deletions
|
@ -27,4 +27,4 @@
|
|||
"messageType":"eventReturnAck"
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
21
example-inmessage/orig.toml
Normal file
21
example-inmessage/orig.toml
Normal file
|
@ -0,0 +1,21 @@
|
|||
[[jsonFromFile]]
|
||||
[jsonFromFile.subject]
|
||||
node = "ship1"
|
||||
messageType = "command"
|
||||
method = "shellcommand"
|
||||
domain = "shell"
|
||||
|
||||
[jsonFromFile.message]
|
||||
data = [ "bash", "-c", "uname -a" ]
|
||||
messageType = "eventReturnAck"
|
||||
|
||||
[[jsonFromFile]]
|
||||
[jsonFromFile.subject]
|
||||
node = "ship2"
|
||||
messageType = "command"
|
||||
method = "shellcommand"
|
||||
domain = "shell"
|
||||
|
||||
[jsonFromFile.message]
|
||||
data = [ "bash", "-c", "uname -a" ]
|
||||
messageType = "eventReturnAck"
|
12
example-inmessage/orig2.yml
Normal file
12
example-inmessage/orig2.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
- subject:
|
||||
node: ship1
|
||||
messageType: command
|
||||
method: shellcommand
|
||||
domain: shell
|
||||
message:
|
||||
data:
|
||||
- bash
|
||||
- '-c'
|
||||
- uname -a
|
||||
messageType: eventReturnAck
|
|
@ -41,17 +41,20 @@ func getMessagesFromFile(directoryToCheck string, fileName string, fileContentCh
|
|||
}
|
||||
|
||||
type jsonFromFile struct {
|
||||
Subject `json:"subject"`
|
||||
Message `json:"message"`
|
||||
Subject `json:"subject" yaml:"subject"`
|
||||
Message `json:"message" yaml:"message"`
|
||||
}
|
||||
|
||||
func jsonFromFileData(b []byte) ([]jsonFromFile, error) {
|
||||
JS := []jsonFromFile{}
|
||||
|
||||
//err := yaml.Unmarshal(b, &JS)
|
||||
err := json.Unmarshal(b, &JS)
|
||||
// TODO: Look into also marshaling from yaml and toml later
|
||||
//err := yaml.Unmarshal(b, &JS)
|
||||
//err := toml.Unmarshal(b, &JS)
|
||||
//fmt.Printf("%#v\n", JS)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error: json unmarshal of file failed: %v", err)
|
||||
return nil, fmt.Errorf("error: unmarshal of file failed: %#v", err)
|
||||
}
|
||||
|
||||
return JS, nil
|
||||
|
|
5
go.mod
5
go.mod
|
@ -3,11 +3,12 @@ module github.com/RaaLabs/steward
|
|||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/fsnotify/fsnotify v1.4.9
|
||||
github.com/ghodss/yaml v1.0.0
|
||||
github.com/golang/protobuf v1.4.3 // indirect
|
||||
github.com/nats-io/nats-server/v2 v2.1.9 // indirect
|
||||
github.com/nats-io/nats.go v1.10.0
|
||||
github.com/pelletier/go-toml v1.8.1
|
||||
google.golang.org/protobuf v1.25.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
)
|
||||
|
|
7
go.sum
7
go.sum
|
@ -1,13 +1,13 @@
|
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
|
@ -39,6 +39,8 @@ github.com/nats-io/nkeys v0.1.4 h1:aEsHIssIk6ETN5m2/MD8Y4B2X7FfXrBAUdkyRvbVYzA=
|
|||
github.com/nats-io/nkeys v0.1.4/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1tqEu/s=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM=
|
||||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
|
@ -89,6 +91,7 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
|
|||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
|
|
14
publisher.go
14
publisher.go
|
@ -37,13 +37,13 @@ const (
|
|||
|
||||
type Message struct {
|
||||
// The Unique ID of the message
|
||||
ID int `json:"id"`
|
||||
ID int `json:"id" yaml:"id"`
|
||||
// The actual data in the message
|
||||
// TODO: Change this to a slice instead...or maybe use an
|
||||
// interface type here to handle several data types ?
|
||||
Data []string `json:"data"`
|
||||
Data []string `json:"data" yaml:"data"`
|
||||
// The type of the message being sent
|
||||
MessageType MessageType `json:"messageType"`
|
||||
MessageType MessageType `json:"messageType" yaml:"messageType"`
|
||||
}
|
||||
|
||||
// server is the structure that will hold the state about spawned
|
||||
|
@ -171,16 +171,16 @@ type node string
|
|||
// specific process
|
||||
type Subject struct {
|
||||
// node, the name of the node
|
||||
Node string `json:"node"`
|
||||
Node string `json:"node" yaml:"node"`
|
||||
// messageType, command/event
|
||||
MessageType string `json:"messageType"`
|
||||
MessageType string `json:"messageType" yaml:"messageType"`
|
||||
// method, what is this message doing, etc. shellcommand, syslog, etc.
|
||||
Method string `json:"method"`
|
||||
Method string `json:"method" yaml:"method"`
|
||||
// domain is used to differentiate services. Like there can be more
|
||||
// logging services, but rarely more logging services for the same
|
||||
// thing. Domain is here used to differentiate the the services and
|
||||
// tell with one word what it is for.
|
||||
Domain string `json:"domain"`
|
||||
Domain string `json:"domain" yaml:"domain"`
|
||||
// messageCh is the channel for receiving new content to be sent
|
||||
messageCh chan Message
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue