You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/04/12 16:36:59 UTC
[incubator-trafficcontrol] 01/02: fixed nil panic on the
ChangeLogMessage for the servers
This is an automated email from the ASF dual-hosted git repository.
mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git
commit 2412eaed0646d63df5e665ea68b6602b07692538
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Thu Apr 12 10:14:33 2018 -0600
fixed nil panic on the ChangeLogMessage for the servers
added a space to fix readability
---
traffic_ops/traffic_ops_golang/server/servers.go | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/traffic_ops/traffic_ops_golang/server/servers.go b/traffic_ops/traffic_ops_golang/server/servers.go
index 484994b..9cd354e 100644
--- a/traffic_ops/traffic_ops_golang/server/servers.go
+++ b/traffic_ops/traffic_ops_golang/server/servers.go
@@ -151,10 +151,20 @@ func (server *TOServer) Validate(db *sqlx.DB) []error {
// ChangeLogMessage implements the api.ChangeLogger interface for a custom log message
func (server TOServer) ChangeLogMessage(action string) (string, error) {
- status := *server.Status
- hostName := *server.HostName
+ var serverID string
+ var status string
+ var hostName string
+ if server.Status != nil {
+ status = *server.Status
+ }
+ if server.HostName != nil {
+ hostName = *server.HostName
+ }
+ if server.ID != nil {
+ serverID = strconv.Itoa(*server.ID)
+ }
- message := action + ` ` + status + `server: { "hostName":"` + hostName + `", id:` + strconv.Itoa(*server.ID) + ` }`
+ message := action + ` ` + status + ` server: { "hostName":"` + hostName + `", id:` + serverID + ` }`
return message, nil
}
--
To stop receiving notification emails like this one, please contact
mitchell852@apache.org.