Skip to content

Commit

Permalink
Improve output readability
Browse files Browse the repository at this point in the history
  • Loading branch information
adriacidre committed Mar 16, 2017
1 parent fcfa0ec commit 2f6cc99
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 22 deletions.
8 changes: 6 additions & 2 deletions c_ebs_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ func (n *EBSVolume) getSingleDetail(c component, prefix string) (lines []Message
name = prefix + " " + name
}
status, _ := c["_state"].(string)
lines = append(lines, Message{Body: " - " + name, Level: ""})
level := "INFO"
if status == "errored" {
level = "ERROR"
}
lines = append(lines, Message{Body: " " + name, Level: level})
id, _ := c["volume_aws_id"].(string)
if id != "" {
lines = append(lines, Message{Body: " AWS ID : " + id, Level: ""})
}
lines = append(lines, Message{Body: " Status : " + status, Level: ""})
if status == "errored" {
err, _ := c["error"].(string)
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"})
lines = append(lines, Message{Body: " Error : " + err, Level: ""})
}
return lines
}
8 changes: 6 additions & 2 deletions c_elb.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ func (n *ELB) getSingleDetail(c component, prefix string) (lines []Message) {
name = prefix + " " + name
}
status, _ := c["_state"].(string)
lines = append(lines, Message{Body: " - " + name, Level: ""})
level := "INFO"
if status == "errored" {
level = "ERROR"
}
lines = append(lines, Message{Body: " " + name, Level: level})
lines = append(lines, Message{Body: " Status : " + status, Level: ""})
if c["dns_name"] != nil {
dnsName, _ := c["dns_name"].(string)
Expand All @@ -45,7 +49,7 @@ func (n *ELB) getSingleDetail(c component, prefix string) (lines []Message) {
lines = append(lines)
if status == "errored" {
err, _ := c["error"].(string)
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"})
lines = append(lines, Message{Body: " Error : " + err, Level: ""})
}

return lines
Expand Down
8 changes: 6 additions & 2 deletions c_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ func (n *Firewall) getSingleDetail(c component, prefix string) (lines []Message)
name = prefix + " " + name
}
status, _ := c["_state"].(string)
lines = append(lines, Message{Body: " - " + name, Level: ""})
level := "INFO"
if status == "errored" {
level = "ERROR"
}
lines = append(lines, Message{Body: " " + name, Level: level})
lines = append(lines, Message{Body: " Status : " + status, Level: ""})
if status == "errored" {
err, _ := c["error"].(string)
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"})
lines = append(lines, Message{Body: " Error : " + err, Level: ""})
}
return lines
}
8 changes: 6 additions & 2 deletions c_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ func (n *Instance) getSingleDetail(c component, prefix string) (lines []Message)
name = prefix + " " + name
}
status, _ := c["_state"].(string)
lines = append(lines, Message{Body: " - " + name, Level: ""})
level := "INFO"
if status == "errored" {
level = "ERROR"
}
lines = append(lines, Message{Body: " " + name, Level: level})
lines = append(lines, Message{Body: " IP : " + ip, Level: ""})
publicIP, _ := c["public_ip"].(string)
if publicIP != "" {
Expand All @@ -47,7 +51,7 @@ func (n *Instance) getSingleDetail(c component, prefix string) (lines []Message)
lines = append(lines, Message{Body: " Status : " + status, Level: ""})
if status == "errored" {
err, _ := c["error"].(string)
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"})
lines = append(lines, Message{Body: " Error : " + err, Level: ""})
}
return lines
}
8 changes: 6 additions & 2 deletions c_nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ func (n *Nat) getSingleDetail(c component, prefix string) (lines []Message) {
name = prefix + " " + name
}
status, _ := c["_state"].(string)
lines = append(lines, Message{Body: " - " + name, Level: ""})
level := "INFO"
if status == "errored" {
level = "ERROR"
}
lines = append(lines, Message{Body: " " + name, Level: level})
lines = append(lines, Message{Body: " Status : " + status, Level: ""})
if status == "errored" {
err, _ := c["error"].(string)
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"})
lines = append(lines, Message{Body: " Error : " + err, Level: ""})
}
return lines
}
8 changes: 6 additions & 2 deletions c_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ func (n *Network) getSingleDetail(c component, prefix string) (lines []Message)
name = prefix + " " + name
}
status, _ := c["_state"].(string)
lines = append(lines, Message{Body: " - " + name, Level: ""})
level := "INFO"
if status == "errored" {
level = "ERROR"
}
lines = append(lines, Message{Body: " " + name, Level: level})
lines = append(lines, Message{Body: " IP : " + ip, Level: ""})
id, _ := c["network_aws_id"].(string)
if id != "" {
Expand All @@ -41,7 +45,7 @@ func (n *Network) getSingleDetail(c component, prefix string) (lines []Message)
lines = append(lines, Message{Body: " Status : " + status, Level: ""})
if status == "errored" {
err, _ := c["error"].(string)
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"})
lines = append(lines, Message{Body: " Error : " + err, Level: ""})
}
return lines
}
8 changes: 6 additions & 2 deletions c_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ func (n *RDSCluster) getSingleDetail(c component, prefix string) (lines []Messag
engine, _ := c["engine"].(string)
endpoint, _ := c["endpoint"].(string)
status, _ := c["_state"].(string)
lines = append(lines, Message{Body: " - " + name, Level: ""})
level := "INFO"
if status == "errored" {
level = "ERROR"
}
lines = append(lines, Message{Body: " " + name, Level: level})
lines = append(lines, Message{Body: " Engine : " + engine, Level: ""})
lines = append(lines, Message{Body: " Endpoint : " + endpoint, Level: ""})
if status == "errored" {
err, _ := c["error"].(string)
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"})
lines = append(lines, Message{Body: " Error : " + err, Level: ""})
}
return lines
}
8 changes: 6 additions & 2 deletions c_rds_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ func (n *RDSInstance) getSingleDetail(c component, prefix string) (lines []Messa
cluster, _ := c["cluster"].(string)
endpoint, _ := c["endpoint"].(string)
status, _ := c["_state"].(string)
lines = append(lines, Message{Body: " - " + name, Level: ""})
level := "INFO"
if status == "errored" {
level = "ERROR"
}
lines = append(lines, Message{Body: " " + name, Level: level})
lines = append(lines, Message{Body: " Engine : " + engine, Level: ""})
lines = append(lines, Message{Body: " Cluster : " + cluster, Level: ""})
lines = append(lines, Message{Body: " Endpoint : " + endpoint, Level: ""})
if status == "errored" {
err, _ := c["error"].(string)
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"})
lines = append(lines, Message{Body: " Error : " + err, Level: ""})
}

return lines
Expand Down
8 changes: 6 additions & 2 deletions c_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ func (n *Router) getSingleDetail(c component, prefix string) (lines []Message) {
name = prefix + " " + name
}
status, _ := c["_state"].(string)
level := "INFO"
if status == "errored" {
level = "ERROR"
}
ip, _ := c["ip"].(string)
lines = append(lines, Message{Body: " - " + name, Level: ""})
lines = append(lines, Message{Body: " " + name, Level: level})
lines = append(lines, Message{Body: " IP : " + ip, Level: ""})
lines = append(lines, Message{Body: " Status : " + status, Level: ""})
if status == "errored" {
err, _ := c["error"].(string)
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"})
lines = append(lines, Message{Body: " Error : " + err, Level: ""})
}

return lines
Expand Down
8 changes: 6 additions & 2 deletions c_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ func (n *S3Bucket) getSingleDetail(c component, prefix string) (lines []Message)
acl = "by grantees"
}
status, _ := c["_state"].(string)
lines = append(lines, Message{Body: " - " + name, Level: ""})
level := "INFO"
if status == "errored" {
level = "ERROR"
}
lines = append(lines, Message{Body: " " + name, Level: level})
lines = append(lines, Message{Body: " ACL : " + acl, Level: ""})
lines = append(lines, Message{Body: " Status : " + status, Level: ""})
if status == "errored" {
err, _ := c["error"].(string)
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"})
lines = append(lines, Message{Body: " Error : " + err, Level: ""})
}
return lines
}
8 changes: 6 additions & 2 deletions c_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ func (n *Vpc) getSingleDetail(c component, prefix string) (lines []Message) {
}
subnet, _ := c["subnet"].(string)
status, _ := c["_state"].(string)
lines = append(lines, Message{Body: " - " + id, Level: ""})
level := "INFO"
if status == "errored" {
level = "ERROR"
}
lines = append(lines, Message{Body: " " + id, Level: level})
lines = append(lines, Message{Body: " Subnet : " + subnet, Level: ""})
lines = append(lines, Message{Body: " Status : " + status, Level: ""})
if status == "errored" {
err, _ := c["error"].(string)
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"})
lines = append(lines, Message{Body: " Error : " + err, Level: ""})
}
return lines
}

0 comments on commit 2f6cc99

Please sign in to comment.