mitchell852 closed pull request #2128: fixed nil panic on the ChangeLogMessage for the servers URL: https://github.com/apache/incubator-trafficcontrol/pull/2128
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/traffic_ops/traffic_ops_golang/server/servers.go b/traffic_ops/traffic_ops_golang/server/servers.go index 484994b96..60a46826d 100644 --- a/traffic_ops/traffic_ops_golang/server/servers.go +++ b/traffic_ops/traffic_ops_golang/server/servers.go @@ -151,10 +151,28 @@ 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 - message := action + ` ` + status + `server: { "hostName":"` + hostName + `", id:` + strconv.Itoa(*server.ID) + ` }` + var status string + if server.Status != nil { + status = *server.Status + } + + var hostName string + if server.HostName != nil { + hostName = *server.HostName + } + + var domainName string + if server.DomainName != nil { + domainName = *server.DomainName + } + + var serverID string + if server.ID != nil { + serverID = strconv.Itoa(*server.ID) + } + + message := action + ` ` + status + ` server: { "hostName":"` + hostName + `", "domainName":"` + domainName + `", id:` + serverID + ` }` return message, nil } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services