Skip to content

Commit

Permalink
standarised output, fixed import output
Browse files Browse the repository at this point in the history
  • Loading branch information
purehyperbole committed Mar 29, 2017
1 parent 7e099cf commit 6451609
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 35 deletions.
4 changes: 3 additions & 1 deletion c_ebs_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ func (n *EBSVolume) Handle(subject string, c component, lines []Message) []Messa
case "ebs_volume.delete":
lines = n.getSingleDetail(c, "Deleted EBS volume ")
case "ebs_volumes.find":
lines = n.getSingleDetail(c, "Found EBS volume ")
for _, cx := range c.getFoundComponents() {
lines = append(lines, n.getSingleDetail(cx, "Found EBS volumes")...)
}
}
return lines
}
Expand Down
5 changes: 3 additions & 2 deletions c_elb.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ func (n *ELB) Handle(subject string, c component, lines []Message) []Message {
case "elb.delete":
lines = n.getSingleDetail(c, "Deleted ELB")
case "elbs.find":
lines = n.getSingleDetail(c, "Found ELB")

for _, cx := range c.getFoundComponents() {
lines = append(lines, n.getSingleDetail(cx, "Found ELBs")...)
}
}
return lines
}
Expand Down
10 changes: 6 additions & 4 deletions c_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ func (n *Firewall) Handle(subject string, c component, lines []Message) []Messag
subject = parts[0] + "." + parts[1]
switch subject {
case "firewall.create":
lines = n.getSingleDetail(c, "Firewall created")
lines = n.getSingleDetail(c, "Created Firewall")
case "firewall.update":
lines = n.getSingleDetail(c, "Firewall updated")
lines = n.getSingleDetail(c, "Updated Firewall")
case "firewall.delete":
lines = n.getSingleDetail(c, "Firewall deleted")
lines = n.getSingleDetail(c, "Deleted Firewall")
case "firewalls.find":
lines = n.getSingleDetail(c, "Firewall found")
for _, cx := range c.getFoundComponents() {
lines = append(lines, n.getSingleDetail(cx, "Found Firewalls")...)
}
}
return lines
}
Expand Down
10 changes: 6 additions & 4 deletions c_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ func (n *Instance) Handle(subject string, c component, lines []Message) []Messag
subject = parts[0] + "." + parts[1]
switch subject {
case "instance.create":
lines = n.getSingleDetail(c, "Instance created")
lines = n.getSingleDetail(c, "Created Instance")
case "instance.update":
lines = n.getSingleDetail(c, "Instance udpated")
lines = n.getSingleDetail(c, "Updated Instance")
case "instance.delete":
lines = n.getSingleDetail(c, "Instance delete")
lines = n.getSingleDetail(c, "Deleted Instance")
case "instances.find":
lines = n.getSingleDetail(c, "Instance find")
for _, cx := range c.getFoundComponents() {
lines = append(lines, n.getSingleDetail(cx, "Found Instances")...)
}
}
return lines
}
Expand Down
10 changes: 6 additions & 4 deletions c_nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ func (n *Nat) Handle(subject string, c component, lines []Message) []Message {
subject = parts[0] + "." + parts[1]
switch subject {
case "nat.create":
lines = n.getSingleDetail(c, "Nat created")
lines = n.getSingleDetail(c, "Created Nat")
case "nat.update":
lines = n.getSingleDetail(c, "Nat updated")
lines = n.getSingleDetail(c, "Updated Nat")
case "nat.delete":
lines = n.getSingleDetail(c, "Nat deleted")
lines = n.getSingleDetail(c, "Deleted Nat")
case "nats.find":
lines = n.getSingleDetail(c, "Nat created")
for _, cx := range c.getFoundComponents() {
lines = append(lines, n.getSingleDetail(cx, "Found Nats")...)
}
}
return lines
}
Expand Down
8 changes: 5 additions & 3 deletions c_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ func (n *Network) Handle(subject string, c component, lines []Message) []Message
subject = parts[0] + "." + parts[1]
switch subject {
case "network.create":
lines = n.getSingleDetail(c, "Network created")
lines = n.getSingleDetail(c, "Created Network")
case "network.delete":
lines = n.getSingleDetail(c, "Network deleted")
lines = n.getSingleDetail(c, "Deleted Network")
case "networks.find":
lines = n.getSingleDetail(c, "Network found")
for _, cx := range c.getFoundComponents() {
lines = append(lines, n.getSingleDetail(cx, "Found Networks")...)
}
}
return lines
}
Expand Down
10 changes: 6 additions & 4 deletions c_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ func (n *RDSCluster) Handle(subject string, c component, lines []Message) []Mess
subject = parts[0] + "." + parts[1]
switch subject {
case "rds_cluster.create":
lines = n.getSingleDetail(c, "RDS cluster created")
lines = n.getSingleDetail(c, "Created RDS Cluster")
case "rds_cluster.update":
lines = n.getSingleDetail(c, "RDS cluster updated")
lines = n.getSingleDetail(c, "Updated RDS Cluster")
case "rds_cluster.delete":
lines = n.getSingleDetail(c, "RDS cluster deleted")
lines = n.getSingleDetail(c, "Deleted RDS Cluster")
case "rds_clusters.find":
lines = n.getSingleDetail(c, "RDS cluster found")
for _, cx := range c.getFoundComponents() {
lines = append(lines, n.getSingleDetail(cx, "Found RDS Clusters")...)
}
}
return lines
}
Expand Down
10 changes: 6 additions & 4 deletions c_rds_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ func (n *RDSInstance) Handle(subject string, c component, lines []Message) []Mes
subject = parts[0] + "." + parts[1]
switch subject {
case "rds_instance.create":
lines = n.getSingleDetail(c, "RDS instance created")
lines = n.getSingleDetail(c, "Created RDS Instance")
case "rds_instance.udpate":
lines = n.getSingleDetail(c, "RDS instance updated")
lines = n.getSingleDetail(c, "Updated RDS Instance")
case "rds_instance.delete":
lines = n.getSingleDetail(c, "RDS instance deleted")
lines = n.getSingleDetail(c, "Deleted RDS Instance")
case "rds_instances.find":
lines = n.getSingleDetail(c, "RDS instance found")
for _, cx := range c.getFoundComponents() {
lines = append(lines, n.getSingleDetail(cx, "Found RDS Instances")...)
}
}
return lines
}
Expand Down
2 changes: 1 addition & 1 deletion c_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (n *Router) Handle(subject string, c component, lines []Message) []Message
switch subject {

case "router.create", "router.update":
lines = n.getSingleDetail(c, "Configured router")
lines = n.getSingleDetail(c, "Configured Router")
}
return lines
}
Expand Down
10 changes: 6 additions & 4 deletions c_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ func (n *S3Bucket) Handle(subject string, c component, lines []Message) []Messag
subject = parts[0] + "." + parts[1]
switch subject {
case "s3.create":
lines = n.getSingleDetail(c, "S3 bucket created")
lines = n.getSingleDetail(c, "Created S3 Bucket")
case "s3.update":
lines = n.getSingleDetail(c, "S3 bucket updated")
lines = n.getSingleDetail(c, "Updated S3 Bucket")
case "s3.delete":
lines = n.getSingleDetail(c, "S3 bucket deleted")
lines = n.getSingleDetail(c, "Deleted S3 Bucket")
case "s3s.find":
lines = n.getSingleDetail(c, "S3 bucket imported")
for _, cx := range c.getFoundComponents() {
lines = append(lines, n.getSingleDetail(cx, "Found S3 Buckets")...)
}
}
return lines
}
Expand Down
10 changes: 6 additions & 4 deletions c_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ func (n *Vpc) Handle(subject string, c component, lines []Message) []Message {
subject = parts[0] + "." + parts[1]
switch subject {
case "vpc.create":
lines = n.getSingleDetail(c, "VPC created")
lines = n.getSingleDetail(c, "Created VPC")
case "vpc.update":
lines = n.getSingleDetail(c, "VPC udpated")
lines = n.getSingleDetail(c, "Updated VPC")
case "vpc.delete":
lines = n.getSingleDetail(c, "VPC deleted")
lines = n.getSingleDetail(c, "Deleted VPC")
case "vpcs.find":
lines = n.getSingleDetail(c, "VPC Found")
for _, cx := range c.getFoundComponents() {
lines = append(lines, n.getSingleDetail(cx, "Found VPCs")...)
}
}
return lines
}
Expand Down
13 changes: 13 additions & 0 deletions generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ func (m *component) getServicePart() string {
return pieces[len(pieces)-1]
}

func (m *component) getFoundComponents() []component {
var c []component

components, ok := (*m)["components"].([]interface{})
if ok {
for _, x := range components {
c = append(c, x.(component))
}
}

return c
}

func genericHandler(msg *nats.Msg) {
var msgLines []Message
var c component
Expand Down

0 comments on commit 6451609

Please sign in to comment.