From 610bce868d14430f1e0cc30577ed78e9fa9450c3 Mon Sep 17 00:00:00 2001 From: Tom Bevan Date: Wed, 29 Mar 2017 19:03:39 +0100 Subject: [PATCH] removing status line from output if empty --- c_ebs_volume.go | 4 +++- c_elb.go | 4 +++- c_firewall.go | 4 +++- c_instance.go | 4 +++- c_nat.go | 4 +++- c_network.go | 4 +++- c_router.go | 4 +++- c_s3.go | 4 +++- c_vpc.go | 4 +++- 9 files changed, 27 insertions(+), 9 deletions(-) diff --git a/c_ebs_volume.go b/c_ebs_volume.go index b6b7cc4..48a9e37 100644 --- a/c_ebs_volume.go +++ b/c_ebs_volume.go @@ -45,7 +45,9 @@ func (n *EBSVolume) getSingleDetail(c component, prefix string) (lines []Message if id != "" { lines = append(lines, Message{Body: " AWS ID : " + id, Level: ""}) } - lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + if status != "" { + lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + } if status == "errored" { err, _ := c["error"].(string) lines = append(lines, Message{Body: " Error : " + err, Level: ""}) diff --git a/c_elb.go b/c_elb.go index abf9fa9..95e6d24 100644 --- a/c_elb.go +++ b/c_elb.go @@ -43,7 +43,9 @@ func (n *ELB) getSingleDetail(c component, prefix string) (lines []Message) { return lines } lines = append(lines, Message{Body: " " + name, Level: level}) - lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + if status != "" { + lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + } if c["dns_name"] != nil { dnsName, _ := c["dns_name"].(string) if dnsName != "" { diff --git a/c_firewall.go b/c_firewall.go index de6455a..56a1518 100644 --- a/c_firewall.go +++ b/c_firewall.go @@ -43,7 +43,9 @@ func (n *Firewall) getSingleDetail(c component, prefix string) (lines []Message) return lines } lines = append(lines, Message{Body: " " + name, Level: level}) - lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + if status != "" { + lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + } if status == "errored" { err, _ := c["error"].(string) lines = append(lines, Message{Body: " Error : " + err, Level: ""}) diff --git a/c_instance.go b/c_instance.go index 8fe2fd0..eb855e3 100644 --- a/c_instance.go +++ b/c_instance.go @@ -53,7 +53,9 @@ func (n *Instance) getSingleDetail(c component, prefix string) (lines []Message) if id != "" { lines = append(lines, Message{Body: " AWS ID : " + id, Level: ""}) } - lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + if status != "" { + lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + } if status == "errored" { err, _ := c["error"].(string) lines = append(lines, Message{Body: " Error : " + err, Level: ""}) diff --git a/c_nat.go b/c_nat.go index 15a8a2f..5568d2b 100644 --- a/c_nat.go +++ b/c_nat.go @@ -43,7 +43,9 @@ func (n *Nat) getSingleDetail(c component, prefix string) (lines []Message) { return lines } lines = append(lines, Message{Body: " " + name, Level: level}) - lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + if status != "" { + lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + } if status == "errored" { err, _ := c["error"].(string) lines = append(lines, Message{Body: " Error : " + err, Level: ""}) diff --git a/c_network.go b/c_network.go index bf8e281..ab43f0f 100644 --- a/c_network.go +++ b/c_network.go @@ -47,7 +47,9 @@ func (n *Network) getSingleDetail(c component, prefix string) (lines []Message) if id != "" { lines = append(lines, Message{Body: " AWS ID : " + id, Level: ""}) } - lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + if status != "" { + lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + } if status == "errored" { err, _ := c["error"].(string) lines = append(lines, Message{Body: " Error : " + err, Level: ""}) diff --git a/c_router.go b/c_router.go index bfd64fc..e359f96 100644 --- a/c_router.go +++ b/c_router.go @@ -36,7 +36,9 @@ func (n *Router) getSingleDetail(c component, prefix string) (lines []Message) { return lines } lines = append(lines, Message{Body: " " + name, Level: level}) - lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + if status != "" { + lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + } if status == "errored" { err, _ := c["error"].(string) lines = append(lines, Message{Body: " Error : " + err, Level: ""}) diff --git a/c_s3.go b/c_s3.go index 587b565..4f1f6d7 100644 --- a/c_s3.go +++ b/c_s3.go @@ -48,7 +48,9 @@ func (n *S3Bucket) getSingleDetail(c component, prefix string) (lines []Message) } 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 != "" { + lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + } if status == "errored" { err, _ := c["error"].(string) lines = append(lines, Message{Body: " Error : " + err, Level: ""}) diff --git a/c_vpc.go b/c_vpc.go index 983312c..c8ccd41 100644 --- a/c_vpc.go +++ b/c_vpc.go @@ -45,7 +45,9 @@ func (n *Vpc) getSingleDetail(c component, prefix string) (lines []Message) { } 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 != "" { + lines = append(lines, Message{Body: " Status : " + status, Level: ""}) + } if status == "errored" { err, _ := c["error"].(string) lines = append(lines, Message{Body: " Error : " + err, Level: ""})