You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by el...@apache.org on 2018/06/14 17:10:21 UTC

[trafficcontrol] 06/08: Rawlin's comments 1. Adding cache group id for audit logs for DELETE. 2. GoLang naming conventions

This is an automated email from the ASF dual-hosted git repository.

elsloo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit a35918c64a31d2b12910e1f7b11a7df0a60431d5
Author: Vijayanand Subramanian <vi...@gmail.com>
AuthorDate: Tue May 29 13:24:57 2018 -0400

    Rawlin's comments 1. Adding cache group id for audit logs for DELETE. 2. GoLang naming conventions
---
 lib/go-tc/cachegroupfallback.go                    | 24 +++++++++++-----------
 traffic_ops/app/lib/API/CachegroupFallback.pm      | 12 ++++++++---
 .../traffic_ops_golang/crconfig/edgelocations.go   |  2 +-
 3 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/lib/go-tc/cachegroupfallback.go b/lib/go-tc/cachegroupfallback.go
index e7ffc18..ecd1d8c 100644
--- a/lib/go-tc/cachegroupfallback.go
+++ b/lib/go-tc/cachegroupfallback.go
@@ -20,24 +20,24 @@ package tc
  * under the License.
  */
 
-// A List of cachegroupFallbacks Response
-// swagger:response cachegroupFallbacksResponse
+// A List of CacheGroupFallbacks Response
+// swagger:response CacheGroupFallbacksResponse
 // in: body
-type cachegroupFallbacksResponse struct {
+type CacheGroupFallbacksResponse struct {
 	// in: body
-	Response []cachegroupFallback `json:"response"`
+	Response []CacheGroupFallback `json:"response"`
 }
 
-// A Single cachegroupFallback Response for Update and Create to depict what changed
-// swagger:response cachegroupFallbackResponse
+// A Single CacheGroupFallback Response for Update and Create to depict what changed
+// swagger:response CacheGroupFallbackResponse
 // in: body
-type cachegroupFallbackResponse struct {
+type CacheGroupFallbackResponse struct {
 	// in: body
-	Response cachegroupFallback `json:"response"`
+	Response CacheGroupFallback `json:"response"`
 }
 
-// cachegroupFallback ...
-type cachegroupFallback struct {
+// CacheGroupFallback ...
+type CacheGroupFallback struct {
 
 	PrimaryCgId int `json:"primaryId" db:"primary_cg"`
 	BackupCgId  int `json:"backupId" db:"backup_cg"`
@@ -45,8 +45,8 @@ type cachegroupFallback struct {
 
 }
 
-// cachegroupFallbackNullable ...
-type cachegroupFallbackNullable struct {
+// CacheGroupFallbackNullable ...
+type CacheGroupFallbackNullable struct {
 
 	PrimaryCgId *int `json:"primaryId" db:"primary_cg"`
 	BackupCgId  *int `json:"backupId" db:"backup_cg"`
diff --git a/traffic_ops/app/lib/API/CachegroupFallback.pm b/traffic_ops/app/lib/API/CachegroupFallback.pm
index 888fd0e..a9114da 100644
--- a/traffic_ops/app/lib/API/CachegroupFallback.pm
+++ b/traffic_ops/app/lib/API/CachegroupFallback.pm
@@ -33,6 +33,7 @@ sub delete {
 	my $fallback_id = $self->param('fallbackId');
 	my $params = $self->req->json;
 	my $rs_backups = undef; 
+	my $result = ""; 
 
 	if ( !&is_oper($self) ) {
 		return $self->forbidden();
@@ -40,22 +41,27 @@ sub delete {
 
 	if ( defined ($cache_id) && defined($fallback_id) ) {
 		$rs_backups = $self->db->resultset('CachegroupFallback')->search( { primary_cg => $cache_id , backup_cg => $fallback_id} );
+		$result = "Backup Cachegroup $fallback_id  DELETED from cachegroup $cache_id fallback list";
 	} elsif (defined ($cache_id)) {
 		$rs_backups = $self->db->resultset('CachegroupFallback')->search( { primary_cg => $cache_id} );
+		$result = "Fallback list for Cachegroup $cache_id DELETED";
 	} elsif (defined ($fallback_id)) {
+		$result = "Cachegroup $fallback_id DELETED from all the configured fallback lists";
 		$rs_backups = $self->db->resultset('CachegroupFallback')->search( { backup_cg => $fallback_id} );
+	} else {
+		return $self->alert("Invalid input");
 	}
 
 	if ( ($rs_backups->count > 0) ) {
 		my $del_records = $rs_backups->delete();
 		if ($del_records) {
-			&log( $self, "Backup configuration DELETED", "APICHANGE");
-			return $self->success_message("Backup configuration DELETED");
+			&log( $self, $result, "APICHANGE");
+			return $self->success( $result );
 		} else {
 			return $self->alert( "Backup configuration DELETE Failed!." );
 		}
 	} else {
-		$self->app->log->error("No backup Cachegroups found");
+		$self->app->log->error( "No backup Cachegroups found" );
 		return $self->not_found();
 	}
 }
diff --git a/traffic_ops/traffic_ops_golang/crconfig/edgelocations.go b/traffic_ops/traffic_ops_golang/crconfig/edgelocations.go
index b981aa5..61f43ba 100644
--- a/traffic_ops/traffic_ops_golang/crconfig/edgelocations.go
+++ b/traffic_ops/traffic_ops_golang/crconfig/edgelocations.go
@@ -49,7 +49,7 @@ and (st.name = 'REPORTED' or st.name = 'ONLINE' or st.name = 'ADMIN_DOWN')
 
 	for rows.Next() {
 		cachegroup := ""
-		primaryCacheID := ""
+		primaryCacheID := 0
 		ttype := ""
 		latlon := tc.CRConfigLatitudeLongitude{}
 		if err := rows.Scan(&cachegroup, &primaryCacheID, &ttype, &latlon.Lat, &latlon.Lon); err != nil {

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.