You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2018/07/04 02:39:34 UTC
[trafficcontrol] 09/15: run goimports on all files
This is an automated email from the ASF dual-hosted git repository.
dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit ec1e7f8570e830b31688294ef84afa84c84ab396
Author: Dylan Volz <Dy...@comcast.com>
AuthorDate: Tue Jun 26 23:49:01 2018 -0600
run goimports on all files
---
traffic_ops/traffic_ops_golang/api/change_log.go | 10 +-
.../traffic_ops_golang/api/shared_handlers.go | 7 +-
.../traffic_ops_golang/api/shared_handlers_test.go | 10 +-
traffic_ops/traffic_ops_golang/asn/asns.go | 7 +-
traffic_ops/traffic_ops_golang/asn/asns_test.go | 6 +-
.../traffic_ops_golang/cachegroup/cachegroups.go | 4 +-
.../cachegroup/cachegroups_test.go | 3 +-
traffic_ops/traffic_ops_golang/cdn/cdns.go | 6 +-
traffic_ops/traffic_ops_golang/cdn/cdns_test.go | 4 +-
.../traffic_ops_golang/coordinate/coordinates.go | 6 +-
.../coordinate/coordinates_test.go | 20 +--
.../traffic_ops_golang/crconfig/edgelocations.go | 1 -
.../deliveryservice/deliveryservicesv12.go | 191 ++++++++++-----------
.../deliveryservice/deliveryservicesv13.go | 16 +-
.../deliveryservice/request/comment/comments.go | 8 +-
.../request/comment/comments_test.go | 2 +-
.../deliveryservice/request/requests.go | 16 +-
.../deliveryservice/request/requests_test.go | 16 +-
.../deliveryservice/request/validate.go | 1 -
.../deliveryservice/servers/servers.go | 6 +-
.../deliveryservicesregexes.go | 2 +-
.../traffic_ops_golang/division/divisions.go | 6 +-
.../traffic_ops_golang/division/divisions_test.go | 2 +-
traffic_ops/traffic_ops_golang/origin/origins.go | 6 +-
.../traffic_ops_golang/origin/origins_test.go | 2 +-
.../traffic_ops_golang/parameter/parameters.go | 6 +-
.../parameter/parameters_test.go | 6 +-
.../physlocation/phys_locations.go | 6 +-
.../physlocation/phys_locations_test.go | 2 +-
.../traffic_ops_golang/profile/profiles_test.go | 2 +-
.../profileparameter/profile_parameters.go | 6 +-
.../profileparameter/profile_parameters_test.go | 3 +-
traffic_ops/traffic_ops_golang/region/regions.go | 6 +-
.../traffic_ops_golang/region/regions_test.go | 2 +-
traffic_ops/traffic_ops_golang/riaksvc/dsutil.go | 3 +-
traffic_ops/traffic_ops_golang/role/roles.go | 6 +-
traffic_ops/traffic_ops_golang/routes.go | 12 +-
traffic_ops/traffic_ops_golang/server/servers.go | 6 +-
.../staticdnsentry/staticdnsentry.go | 6 +-
traffic_ops/traffic_ops_golang/status/statuses.go | 6 +-
.../traffic_ops_golang/status/statuses_test.go | 2 +-
.../traffic_ops_golang/systeminfo/system_info.go | 9 +-
traffic_ops/traffic_ops_golang/tenant/tenancy.go | 19 +-
traffic_ops/traffic_ops_golang/types/types.go | 6 +-
traffic_ops/traffic_ops_golang/types/types_test.go | 3 +-
45 files changed, 233 insertions(+), 242 deletions(-)
diff --git a/traffic_ops/traffic_ops_golang/api/change_log.go b/traffic_ops/traffic_ops_golang/api/change_log.go
index b8117ec..b9761e4 100644
--- a/traffic_ops/traffic_ops_golang/api/change_log.go
+++ b/traffic_ops/traffic_ops_golang/api/change_log.go
@@ -21,6 +21,7 @@ package api
import (
"database/sql"
+ "errors"
"fmt"
"github.com/apache/trafficcontrol/lib/go-log"
@@ -28,7 +29,6 @@ import (
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/auth"
"github.com/jmoiron/sqlx"
- "errors"
)
type ChangeLog struct {
@@ -77,10 +77,10 @@ func CreateChangeLogBuildMsg(level string, action string, user *auth.CurrentUser
}
func CreateChangeLogRawErr(level string, msg string, user *auth.CurrentUser, tx *sql.Tx) error {
- if _, err := tx.Exec(`INSERT INTO log (level, message, tm_user) VALUES ($1, $2, $3)`, level, msg, user.ID); err != nil {
- return errors.New("Inserting change log level '" + level + "' message '" + msg + "' user '" + user.UserName + "': " + err.Error())
- }
- return nil
+ if _, err := tx.Exec(`INSERT INTO log (level, message, tm_user) VALUES ($1, $2, $3)`, level, msg, user.ID); err != nil {
+ return errors.New("Inserting change log level '" + level + "' message '" + msg + "' user '" + user.UserName + "': " + err.Error())
+ }
+ return nil
}
func CreateChangeLogRaw(level string, msg string, user *auth.CurrentUser, db *sql.DB) {
diff --git a/traffic_ops/traffic_ops_golang/api/shared_handlers.go b/traffic_ops/traffic_ops_golang/api/shared_handlers.go
index 4a10cdb..46f4b77 100644
--- a/traffic_ops/traffic_ops_golang/api/shared_handlers.go
+++ b/traffic_ops/traffic_ops_golang/api/shared_handlers.go
@@ -304,7 +304,7 @@ func UpdateHandler(typeFactory func(reqInfo *APIInfo) CRUDer) http.HandlerFunc {
//auditing here
err = CreateChangeLog(ApiChange, Updated, u, inf.User, inf.Tx)
if err != nil {
- HandleErr(w,r,http.StatusInternalServerError,tc.DBError,errors.New("inserting changelog: " + err.Error()))
+ HandleErr(w, r, http.StatusInternalServerError, tc.DBError, errors.New("inserting changelog: "+err.Error()))
return
}
*inf.CommitTx = true
@@ -343,7 +343,6 @@ func DeleteHandler(typeFactory func(reqInfo *APIInfo) CRUDer) http.HandlerFunc {
}
defer inf.Close()
-
d := typeFactory(inf)
params, err := GetCombinedParams(r)
@@ -395,7 +394,7 @@ func DeleteHandler(typeFactory func(reqInfo *APIInfo) CRUDer) http.HandlerFunc {
log.Debugf("changelog for delete on object")
err = CreateChangeLog(ApiChange, Deleted, d, inf.User, inf.Tx)
if err != nil {
- HandleErr(w,r,http.StatusInternalServerError,tc.DBError,errors.New("inserting changelog: " + err.Error()))
+ HandleErr(w, r, http.StatusInternalServerError, tc.DBError, errors.New("inserting changelog: "+err.Error()))
return
}
*inf.CommitTx = true
@@ -467,7 +466,7 @@ func CreateHandler(typeConstructor func(reqInfo *APIInfo) CRUDer) http.HandlerFu
err = CreateChangeLog(ApiChange, Created, i, inf.User, inf.Tx)
if err != nil {
- HandleErr(w,r,http.StatusInternalServerError,tc.DBError,errors.New("inserting changelog: " + err.Error()))
+ HandleErr(w, r, http.StatusInternalServerError, tc.DBError, errors.New("inserting changelog: "+err.Error()))
return
}
*inf.CommitTx = true
diff --git a/traffic_ops/traffic_ops_golang/api/shared_handlers_test.go b/traffic_ops/traffic_ops_golang/api/shared_handlers_test.go
index 56880d4..f234d8a 100644
--- a/traffic_ops/traffic_ops_golang/api/shared_handlers_test.go
+++ b/traffic_ops/traffic_ops_golang/api/shared_handlers_test.go
@@ -42,7 +42,7 @@ type tester struct {
errorType tc.ApiErrorType //only for testing
}
-func GetTypeSingleton() func(apiInfo *APIInfo) CRUDer{
+func GetTypeSingleton() func(apiInfo *APIInfo) CRUDer {
return func(apiInfo *APIInfo) CRUDer {
tester := tester{}
return &tester
@@ -129,12 +129,12 @@ func TestCreateHandler(t *testing.T) {
ctx = context.WithValue(ctx, DBContextKey, db)
ctx = context.WithValue(ctx, ConfigContextKey, &cfg)
ctx = context.WithValue(ctx, ReqIDContextKey, uint64(0))
- ctx = context.WithValue(ctx, PathParamsKey, map[string]string{"id":"1"})
+ ctx = context.WithValue(ctx, PathParamsKey, map[string]string{"id": "1"})
// Add our context to the request
r = r.WithContext(ctx)
- typeRef := tester{ID:1}
+ typeRef := tester{ID: 1}
createFunc := CreateHandler(GetTypeSingleton())
@@ -221,7 +221,7 @@ func TestUpdateHandler(t *testing.T) {
// Add our context to the request
r = r.WithContext(ctx)
- typeRef := tester{ID:1}
+ typeRef := tester{ID: 1}
updateFunc := UpdateHandler(GetTypeSingleton())
//verifies we get the right changelog insertion
@@ -265,7 +265,7 @@ func TestDeleteHandler(t *testing.T) {
// Add our context to the request
r = r.WithContext(ctx)
- typeRef := tester{ID:1}
+ typeRef := tester{ID: 1}
deleteFunc := DeleteHandler(GetTypeSingleton())
//verifies we get the right changelog insertion
diff --git a/traffic_ops/traffic_ops_golang/asn/asns.go b/traffic_ops/traffic_ops_golang/asn/asns.go
index 9306392..0886c6f 100644
--- a/traffic_ops/traffic_ops_golang/asn/asns.go
+++ b/traffic_ops/traffic_ops_golang/asn/asns.go
@@ -41,13 +41,13 @@ import (
const ASNsPrivLevel = 10
//we need a type alias to define functions on
-type TOASNV11 struct{
+type TOASNV11 struct {
ReqInfo *api.APIInfo `json:"-"`
tc.ASNNullable
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TOASNV11{reqInfo, tc.ASNNullable{}}
return &toReturn
}
@@ -157,7 +157,6 @@ func (asn *TOASNV11) Read(parameters map[string]string) ([]interface{}, []error,
return iasns, err, errType
}
-
// V11ReadAll implements the asns 1.1 route, which is different from the 1.1 route for a single ASN and from 1.2+ routes, in that it wraps the content in an additional "asns" object.
func V11ReadAll() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
diff --git a/traffic_ops/traffic_ops_golang/asn/asns_test.go b/traffic_ops/traffic_ops_golang/asn/asns_test.go
index 5ad859a..3c1c159 100644
--- a/traffic_ops/traffic_ops_golang/asn/asns_test.go
+++ b/traffic_ops/traffic_ops_golang/asn/asns_test.go
@@ -30,8 +30,8 @@ import (
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
"github.com/jmoiron/sqlx"
- sqlmock "gopkg.in/DATA-DOG/go-sqlmock.v1"
"github.com/apache/trafficcontrol/lib/go-util"
+ sqlmock "gopkg.in/DATA-DOG/go-sqlmock.v1"
)
func getTestASNs() []tc.ASNNullable {
@@ -80,7 +80,7 @@ func TestGetASNs(t *testing.T) {
mock.ExpectQuery("SELECT").WillReturnRows(rows)
mock.ExpectCommit()
v := map[string]string{"dsId": "1"}
- reqInfo := api.APIInfo{Tx:db.MustBegin(),CommitTx:util.BoolPtr(false)}
+ reqInfo := api.APIInfo{Tx: db.MustBegin(), CommitTx: util.BoolPtr(false)}
asns, errs, _ := GetTypeSingleton()(&reqInfo).Read(v)
if len(errs) > 0 {
@@ -116,7 +116,7 @@ func TestInterfaces(t *testing.T) {
func TestValidate(t *testing.T) {
i := -99
- asn := TOASNV11{nil,tc.ASNNullable{ASN: &i, CachegroupID: &i}}
+ asn := TOASNV11{nil, tc.ASNNullable{ASN: &i, CachegroupID: &i}}
errs := test.SortErrors(asn.Validate())
expected := []error{
diff --git a/traffic_ops/traffic_ops_golang/cachegroup/cachegroups.go b/traffic_ops/traffic_ops_golang/cachegroup/cachegroups.go
index 784e15f..505352b 100644
--- a/traffic_ops/traffic_ops_golang/cachegroup/cachegroups.go
+++ b/traffic_ops/traffic_ops_golang/cachegroup/cachegroups.go
@@ -37,10 +37,10 @@ import (
"github.com/lib/pq"
)
-type TOCacheGroup struct{
+type TOCacheGroup struct {
ReqInfo *api.APIInfo `json:"-"`
v13.CacheGroupNullable
- }
+}
func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
return func(reqInfo *api.APIInfo) api.CRUDer {
diff --git a/traffic_ops/traffic_ops_golang/cachegroup/cachegroups_test.go b/traffic_ops/traffic_ops_golang/cachegroup/cachegroups_test.go
index 1c4eaff..1dade56 100644
--- a/traffic_ops/traffic_ops_golang/cachegroup/cachegroups_test.go
+++ b/traffic_ops/traffic_ops_golang/cachegroup/cachegroups_test.go
@@ -79,7 +79,6 @@ func TestReadCacheGroups(t *testing.T) {
db := sqlx.NewDb(mockDB, "sqlmock")
defer db.Close()
-
testCGs := getTestCacheGroups()
cols := test.ColsFromStructByTag("db", v13.CacheGroup{})
rows := sqlmock.NewRows(cols)
@@ -103,7 +102,7 @@ func TestReadCacheGroups(t *testing.T) {
mock.ExpectCommit()
v := map[string]string{"id": "1"}
- reqInfo := api.APIInfo{Tx:db.MustBegin(),CommitTx:util.BoolPtr(false)}
+ reqInfo := api.APIInfo{Tx: db.MustBegin(), CommitTx: util.BoolPtr(false)}
cachegroups, errs, _ := GetTypeSingleton()(&reqInfo).Read(v)
if len(errs) > 0 {
t.Errorf("cdn.Read expected: no errors, actual: %v", errs)
diff --git a/traffic_ops/traffic_ops_golang/cdn/cdns.go b/traffic_ops/traffic_ops_golang/cdn/cdns.go
index 007468e..3412a4c 100644
--- a/traffic_ops/traffic_ops_golang/cdn/cdns.go
+++ b/traffic_ops/traffic_ops_golang/cdn/cdns.go
@@ -38,13 +38,13 @@ import (
)
//we need a type alias to define functions on
-type TOCDN struct{
+type TOCDN struct {
ReqInfo *api.APIInfo `json:"-"`
v13.CDNNullable
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TOCDN{reqInfo, v13.CDNNullable{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/cdn/cdns_test.go b/traffic_ops/traffic_ops_golang/cdn/cdns_test.go
index c09529e..2bc4288 100644
--- a/traffic_ops/traffic_ops_golang/cdn/cdns_test.go
+++ b/traffic_ops/traffic_ops_golang/cdn/cdns_test.go
@@ -27,8 +27,8 @@ import (
"time"
"github.com/apache/trafficcontrol/lib/go-tc"
- "github.com/apache/trafficcontrol/lib/go-util"
"github.com/apache/trafficcontrol/lib/go-tc/v13"
+ "github.com/apache/trafficcontrol/lib/go-util"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
"github.com/jmoiron/sqlx"
@@ -83,7 +83,7 @@ func TestReadCDNs(t *testing.T) {
mock.ExpectCommit()
v := map[string]string{"dsId": "1"}
- reqInfo := api.APIInfo{Tx:db.MustBegin(),CommitTx:util.BoolPtr(false)}
+ reqInfo := api.APIInfo{Tx: db.MustBegin(), CommitTx: util.BoolPtr(false)}
servers, errs, _ := GetTypeSingleton()(&reqInfo).Read(v)
if len(errs) > 0 {
t.Errorf("cdn.Read expected: no errors, actual: %v", errs)
diff --git a/traffic_ops/traffic_ops_golang/coordinate/coordinates.go b/traffic_ops/traffic_ops_golang/coordinate/coordinates.go
index 2707519..eaabede 100644
--- a/traffic_ops/traffic_ops_golang/coordinate/coordinates.go
+++ b/traffic_ops/traffic_ops_golang/coordinate/coordinates.go
@@ -38,13 +38,13 @@ import (
)
//we need a type alias to define functions on
-type TOCoordinate struct{
+type TOCoordinate struct {
ReqInfo *api.APIInfo `json:"-"`
v13.CoordinateNullable
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TOCoordinate{reqInfo, v13.CoordinateNullable{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/coordinate/coordinates_test.go b/traffic_ops/traffic_ops_golang/coordinate/coordinates_test.go
index 6d3275b..b8ba402 100644
--- a/traffic_ops/traffic_ops_golang/coordinate/coordinates_test.go
+++ b/traffic_ops/traffic_ops_golang/coordinate/coordinates_test.go
@@ -26,9 +26,9 @@ import (
"testing"
"time"
- "github.com/apache/trafficcontrol/lib/go-util"
"github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/lib/go-tc/v13"
+ "github.com/apache/trafficcontrol/lib/go-util"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
"github.com/jmoiron/sqlx"
@@ -87,7 +87,7 @@ func TestReadCoordinates(t *testing.T) {
mock.ExpectCommit()
v := map[string]string{"id": "1"}
- reqInfo := api.APIInfo{Tx:db.MustBegin(),CommitTx:util.BoolPtr(false)}
+ reqInfo := api.APIInfo{Tx: db.MustBegin(), CommitTx: util.BoolPtr(false)}
coordinates, errs, _ := GetTypeSingleton()(&reqInfo).Read(v)
if len(errs) > 0 {
t.Errorf("coordinate.Read expected: no errors, actual: %v", errs)
@@ -141,10 +141,10 @@ func TestValidate(t *testing.T) {
la := -190.0
lo := -190.0
lu := tc.TimeNoMod{Time: time.Now()}
- c := TOCoordinate{ CoordinateNullable: v13.CoordinateNullable{ID: &id,
- Name: &nm,
- Latitude: &la,
- Longitude: &lo,
+ c := TOCoordinate{CoordinateNullable: v13.CoordinateNullable{ID: &id,
+ Name: &nm,
+ Latitude: &la,
+ Longitude: &lo,
LastUpdated: &lu,
}}
errs := test.SortErrors(c.Validate())
@@ -163,10 +163,10 @@ func TestValidate(t *testing.T) {
nm = "This.is.2.a-Valid---Coordinate."
la = 90.0
lo = 90.0
- c = TOCoordinate{ CoordinateNullable: v13.CoordinateNullable{ID: &id,
- Name: &nm,
- Latitude: &la,
- Longitude: &lo,
+ c = TOCoordinate{CoordinateNullable: v13.CoordinateNullable{ID: &id,
+ Name: &nm,
+ Latitude: &la,
+ Longitude: &lo,
LastUpdated: &lu,
}}
expectedErrs = []error{}
diff --git a/traffic_ops/traffic_ops_golang/crconfig/edgelocations.go b/traffic_ops/traffic_ops_golang/crconfig/edgelocations.go
index 5020caf..924afb6 100644
--- a/traffic_ops/traffic_ops_golang/crconfig/edgelocations.go
+++ b/traffic_ops/traffic_ops_golang/crconfig/edgelocations.go
@@ -70,7 +70,6 @@ and cachegroup_fallbacks.primary_cg = $1 order by cachegroup_fallbacks.set_order
}
defer dbRows.Close()
-
if fallbackToClosest == nil {
fallbackToClosest = new(bool)
*fallbackToClosest = true
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv12.go b/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv12.go
index dd2d3cc..5c5d1d9 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv12.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv12.go
@@ -36,15 +36,13 @@ import (
"github.com/lib/pq"
)
-
type TODeliveryServiceV12 struct {
ReqInfo *api.APIInfo
tc.DeliveryServiceNullableV12
}
-
-func GetTypeV12Factory() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer{
+func GetTypeV12Factory() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TODeliveryServiceV12{reqInfo, tc.DeliveryServiceNullableV12{}}
return &toReturn
}
@@ -130,7 +128,6 @@ func (ds *TODeliveryServiceV12) IsTenantAuthorized(user *auth.CurrentUser) (bool
return isTenantAuthorized(user, ds.ReqInfo.Tx, &ds.DeliveryServiceNullableV12)
}
-
// getTenantID returns the tenant Id of the given delivery service. Note it may return a nil id and nil error, if the tenant ID in the database is nil.
func getTenantID(tx *sql.Tx, ds *tc.DeliveryServiceNullableV12) (*int, error) {
if ds.ID == nil && ds.XMLID == nil {
@@ -173,13 +170,12 @@ func isTenantAuthorized(user *auth.CurrentUser, tx *sqlx.Tx, ds *tc.DeliveryServ
return true, nil
}
-
func (ds *TODeliveryServiceV12) Validate() []error {
return ds.DeliveryServiceNullableV12.Validate(ds.ReqInfo.Tx.Tx)
}
// unimplemented, needed to satisfy CRUDer, since the framework doesn't allow a create to return an array of one
-func(ds *TODeliveryServiceV12) Create() (error, tc.ApiErrorType) {
+func (ds *TODeliveryServiceV12) Create() (error, tc.ApiErrorType) {
return errors.New("The Create method is not implemented"), http.StatusNotImplemented
}
@@ -214,122 +210,121 @@ func CreateV12() http.HandlerFunc {
}
}
- func(ds *TODeliveryServiceV12) Read(params map[string]string) ([]interface{}, []error, tc.ApiErrorType) {
+func (ds *TODeliveryServiceV12) Read(params map[string]string) ([]interface{}, []error, tc.ApiErrorType) {
returnable := []interface{}{}
dses, errs, errType := readGetDeliveryServices(params, ds.ReqInfo.Tx, ds.ReqInfo.User)
if len(errs) > 0 {
- for _, err := range errs {
- if err.Error() == `id cannot parse to integer` {
- return nil, []error{errors.New("Resource not found.")}, tc.DataMissingError //matches perl response
- }
- }
- return nil, errs, errType
+ for _, err := range errs {
+ if err.Error() == `id cannot parse to integer` {
+ return nil, []error{errors.New("Resource not found.")}, tc.DataMissingError //matches perl response
+ }
+ }
+ return nil, errs, errType
}
for _, ds := range dses {
- returnable = append(returnable, ds.DeliveryServiceNullableV12)
+ returnable = append(returnable, ds.DeliveryServiceNullableV12)
}
return returnable, nil, tc.NoError
- }
-
- //The DeliveryService implementation of the Deleter interface
- //all implementations of Deleter should use transactions and return the proper errorType
- func(ds *TODeliveryServiceV12) Delete() (error, tc.ApiErrorType){
- log.Debugln("TODeliveryServiceV12.Delete calling id '%v' xmlid '%v'\n", ds.ID, ds.XMLID)
- // return nil, tc.NoError // debug
+}
- if ds.ID == nil {
- log.Errorln("TODeliveryServiceV12.Delete called with nil ID")
- return tc.DBError, tc.DataMissingError
- }
- xmlID, ok, err := ds.GetXMLID(ds.ReqInfo.Tx)
- if err != nil {
- log.Errorln("TODeliveryServiceV12.Delete ID '" + string(*ds.ID) + "' loading XML ID: " + err.Error())
- return tc.DBError, tc.SystemError
- }
- if !ok {
- log.Errorln("TODeliveryServiceV12.Delete ID '" + string(*ds.ID) + "' had no delivery service!")
- return tc.DBError, tc.DataMissingError
- }
- ds.XMLID = &xmlID
+//The DeliveryService implementation of the Deleter interface
+//all implementations of Deleter should use transactions and return the proper errorType
+func (ds *TODeliveryServiceV12) Delete() (error, tc.ApiErrorType) {
+ log.Debugln("TODeliveryServiceV12.Delete calling id '%v' xmlid '%v'\n", ds.ID, ds.XMLID)
+ // return nil, tc.NoError // debug
- // Note ds regexes MUST be deleted before the ds, because there's a ON DELETE CASCADE on deliveryservice_regex (but not on regex).
- // Likewise, it MUST happen in a transaction with the later DS delete, so they aren't deleted if the DS delete fails.
- if _, err := ds.ReqInfo.Tx.Exec(`DELETE FROM regex WHERE id IN (SELECT regex FROM deliveryservice_regex WHERE deliveryservice=$1)`, *ds.ID); err != nil {
- log.Errorln("TODeliveryServiceV12.Delete deleting regexes for delivery service: " + err.Error())
- return tc.DBError, tc.SystemError
- }
+ if ds.ID == nil {
+ log.Errorln("TODeliveryServiceV12.Delete called with nil ID")
+ return tc.DBError, tc.DataMissingError
+ }
+ xmlID, ok, err := ds.GetXMLID(ds.ReqInfo.Tx)
+ if err != nil {
+ log.Errorln("TODeliveryServiceV12.Delete ID '" + string(*ds.ID) + "' loading XML ID: " + err.Error())
+ return tc.DBError, tc.SystemError
+ }
+ if !ok {
+ log.Errorln("TODeliveryServiceV12.Delete ID '" + string(*ds.ID) + "' had no delivery service!")
+ return tc.DBError, tc.DataMissingError
+ }
+ ds.XMLID = &xmlID
- if _, err := ds.ReqInfo.Tx.Exec(`DELETE FROM deliveryservice_regex WHERE deliveryservice=$1`, *ds.ID); err != nil {
- log.Errorln("TODeliveryServiceV12.Delete deleting delivery service regexes: " + err.Error())
- return tc.DBError, tc.SystemError
- }
+ // Note ds regexes MUST be deleted before the ds, because there's a ON DELETE CASCADE on deliveryservice_regex (but not on regex).
+ // Likewise, it MUST happen in a transaction with the later DS delete, so they aren't deleted if the DS delete fails.
+ if _, err := ds.ReqInfo.Tx.Exec(`DELETE FROM regex WHERE id IN (SELECT regex FROM deliveryservice_regex WHERE deliveryservice=$1)`, *ds.ID); err != nil {
+ log.Errorln("TODeliveryServiceV12.Delete deleting regexes for delivery service: " + err.Error())
+ return tc.DBError, tc.SystemError
+ }
- result, err := ds.ReqInfo.Tx.Exec(`DELETE FROM deliveryservice WHERE id=$1`, *ds.ID)
- if err != nil {
- log.Errorln("TODeliveryServiceV12.Delete deleting delivery service: " + err.Error())
- return tc.DBError, tc.SystemError
- }
- rowsAffected, err := result.RowsAffected()
- if err != nil {
- return tc.DBError, tc.SystemError
- }
- if rowsAffected != 1 {
- if rowsAffected < 1 {
- return errors.New("no delivery service with that id found"), tc.DataMissingError
- }
- return fmt.Errorf("this create affected too many rows: %d", rowsAffected), tc.SystemError
- }
+ if _, err := ds.ReqInfo.Tx.Exec(`DELETE FROM deliveryservice_regex WHERE deliveryservice=$1`, *ds.ID); err != nil {
+ log.Errorln("TODeliveryServiceV12.Delete deleting delivery service regexes: " + err.Error())
+ return tc.DBError, tc.SystemError
+ }
- paramConfigFilePrefixes := []string{"hdr_rw_", "hdr_rw_mid_", "regex_remap_", "cacheurl_"}
- configFiles := []string{}
- for _, prefix := range paramConfigFilePrefixes {
- configFiles = append(configFiles, prefix + *ds.XMLID+".config")
+ result, err := ds.ReqInfo.Tx.Exec(`DELETE FROM deliveryservice WHERE id=$1`, *ds.ID)
+ if err != nil {
+ log.Errorln("TODeliveryServiceV12.Delete deleting delivery service: " + err.Error())
+ return tc.DBError, tc.SystemError
+ }
+ rowsAffected, err := result.RowsAffected()
+ if err != nil {
+ return tc.DBError, tc.SystemError
+ }
+ if rowsAffected != 1 {
+ if rowsAffected < 1 {
+ return errors.New("no delivery service with that id found"), tc.DataMissingError
}
+ return fmt.Errorf("this create affected too many rows: %d", rowsAffected), tc.SystemError
+ }
- if _, err := ds.ReqInfo.Tx.Exec(`DELETE FROM parameter WHERE name = 'location' AND config_file = ANY($1)`, pq.Array(configFiles)); err != nil {
- log.Errorln("TODeliveryServiceV12.Delete deleting delivery service parameters: " + err.Error())
- return tc.DBError, tc.SystemError
- }
+ paramConfigFilePrefixes := []string{"hdr_rw_", "hdr_rw_mid_", "regex_remap_", "cacheurl_"}
+ configFiles := []string{}
+ for _, prefix := range paramConfigFilePrefixes {
+ configFiles = append(configFiles, prefix+*ds.XMLID+".config")
+ }
- return nil, tc.NoError
+ if _, err := ds.ReqInfo.Tx.Exec(`DELETE FROM parameter WHERE name = 'location' AND config_file = ANY($1)`, pq.Array(configFiles)); err != nil {
+ log.Errorln("TODeliveryServiceV12.Delete deleting delivery service parameters: " + err.Error())
+ return tc.DBError, tc.SystemError
}
+ return nil, tc.NoError
+}
// unimplemented, needed to satisfy CRUDer, since the framework doesn't allow an update to return an array of one
-func(ds *TODeliveryServiceV12) Update() (error, tc.ApiErrorType) {
+func (ds *TODeliveryServiceV12) Update() (error, tc.ApiErrorType) {
return errors.New("The Update method is not implemented"), http.StatusNotImplemented
}
func UpdateV12() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
- inf, userErr, sysErr, errCode := api.NewInfo(r, []string{"id"}, []string{"id"})
- if userErr != nil || sysErr != nil {
- api.HandleErr(w, r, errCode, userErr, sysErr)
- return
- }
- defer inf.Close()
+ inf, userErr, sysErr, errCode := api.NewInfo(r, []string{"id"}, []string{"id"})
+ if userErr != nil || sysErr != nil {
+ api.HandleErr(w, r, errCode, userErr, sysErr)
+ return
+ }
+ defer inf.Close()
- ds := tc.DeliveryServiceNullableV12{}
- ds.ID = util.IntPtr(inf.IntParams["id"])
- if err := api.Parse(r.Body, inf.Tx.Tx, &ds); err != nil {
- api.HandleErr(w, r, http.StatusBadRequest, errors.New("decoding: "+err.Error()), nil)
- return
- }
- dsv13 := tc.NewDeliveryServiceNullableV13FromV12(ds)
- if authorized, err := isTenantAuthorized(inf.User, inf.Tx, &ds); err != nil {
- api.HandleErr(w, r, http.StatusInternalServerError, nil, errors.New("checking tenant: "+err.Error()))
- return
- } else if !authorized {
- api.HandleErr(w, r, http.StatusForbidden, errors.New("not authorized on this tenant"), nil)
- return
- }
- dsv13, errCode, userErr, sysErr = update(inf.Tx.Tx, *inf.Config, inf.User, &dsv13)
- if userErr != nil || sysErr != nil {
- api.HandleErr(w, r, errCode, userErr, sysErr)
- return
+ ds := tc.DeliveryServiceNullableV12{}
+ ds.ID = util.IntPtr(inf.IntParams["id"])
+ if err := api.Parse(r.Body, inf.Tx.Tx, &ds); err != nil {
+ api.HandleErr(w, r, http.StatusBadRequest, errors.New("decoding: "+err.Error()), nil)
+ return
+ }
+ dsv13 := tc.NewDeliveryServiceNullableV13FromV12(ds)
+ if authorized, err := isTenantAuthorized(inf.User, inf.Tx, &ds); err != nil {
+ api.HandleErr(w, r, http.StatusInternalServerError, nil, errors.New("checking tenant: "+err.Error()))
+ return
+ } else if !authorized {
+ api.HandleErr(w, r, http.StatusForbidden, errors.New("not authorized on this tenant"), nil)
+ return
+ }
+ dsv13, errCode, userErr, sysErr = update(inf.Tx.Tx, *inf.Config, inf.User, &dsv13)
+ if userErr != nil || sysErr != nil {
+ api.HandleErr(w, r, errCode, userErr, sysErr)
+ return
+ }
+ *inf.CommitTx = true
+ api.WriteResp(w, r, []tc.DeliveryServiceNullableV12{dsv13.DeliveryServiceNullableV12})
}
- *inf.CommitTx = true
- api.WriteResp(w, r, []tc.DeliveryServiceNullableV12{dsv13.DeliveryServiceNullableV12})
}
-}
\ No newline at end of file
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv13.go b/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv13.go
index 3eab671..fbd996e 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv13.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv13.go
@@ -21,8 +21,8 @@ package deliveryservice
import (
"database/sql"
- "errors"
"encoding/json"
+ "errors"
"fmt"
"net/http"
"strconv"
@@ -50,7 +50,7 @@ type TODeliveryServiceV13 struct {
}
func (ds *TODeliveryServiceV13) V12() *TODeliveryServiceV12 {
- return &TODeliveryServiceV12{ReqInfo:ds.ReqInfo, DeliveryServiceNullableV12: ds.DeliveryServiceNullableV12}
+ return &TODeliveryServiceV12{ReqInfo: ds.ReqInfo, DeliveryServiceNullableV12: ds.DeliveryServiceNullableV12}
}
func (ds TODeliveryServiceV13) MarshalJSON() ([]byte, error) {
@@ -60,8 +60,8 @@ func (ds *TODeliveryServiceV13) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, ds.DeliveryServiceNullableV13)
}
-func GetTypeV13Factory() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer{
+func GetTypeV13Factory() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TODeliveryServiceV13{reqInfo, tc.DeliveryServiceNullableV13{}}
return &toReturn
}
@@ -94,7 +94,7 @@ func (ds *TODeliveryServiceV13) Validate() []error {
}
// unimplemented, needed to satisfy CRUDer, since the framework doesn't allow a create to return an array of one
-func(ds *TODeliveryServiceV13) Create() (error, tc.ApiErrorType) {
+func (ds *TODeliveryServiceV13) Create() (error, tc.ApiErrorType) {
return errors.New("The Create method is not implemented"), http.StatusNotImplemented
}
@@ -236,7 +236,7 @@ func create(tx *sql.Tx, cfg config.Config, user *auth.CurrentUser, ds tc.Deliver
}
ds.LastUpdated = &lastUpdated
- if err := api.CreateChangeLogRawErr(api.ApiChange, "Created ds: "+*ds.XMLID+" id: "+strconv.Itoa(*ds.ID), user, tx); err!= nil {
+ if err := api.CreateChangeLogRawErr(api.ApiChange, "Created ds: "+*ds.XMLID+" id: "+strconv.Itoa(*ds.ID), user, tx); err != nil {
return tc.DeliveryServiceNullableV13{}, http.StatusInternalServerError, nil, errors.New("error writing to audit log: " + err.Error())
}
return ds, http.StatusOK, nil, nil
@@ -378,7 +378,7 @@ func getTypeFromID(id int, tx *sql.Tx) (tc.DSType, error) {
}
// unimplemented, needed to satisfy CRUDer, since the framework doesn't allow an update to return an array of one
-func(ds *TODeliveryServiceV13) Update() (error, tc.ApiErrorType) {
+func (ds *TODeliveryServiceV13) Update() (error, tc.ApiErrorType) {
return errors.New("The Update method is not implemented"), http.StatusNotImplemented
}
@@ -536,7 +536,6 @@ func update(tx *sql.Tx, cfg config.Config, user *auth.CurrentUser, ds *tc.Delive
ds.MatchList = &ml
}
-
if newDSType.HasSSLKeys() && oldHostName != newHostName {
if err := updateSSLKeys(ds, newHostName, tx, cfg); err != nil {
return tc.DeliveryServiceNullableV13{}, http.StatusInternalServerError, nil, errors.New("updating delivery service " + *ds.XMLID + ": updating SSL keys: " + err.Error())
@@ -685,7 +684,6 @@ func readGetDeliveryServices(params map[string]string, tx *sqlx.Tx, user *auth.C
return dses, nil, tc.NoError
}
-
func updateSSLKeys(ds *tc.DeliveryServiceNullableV13, hostName string, tx *sql.Tx, cfg config.Config) error {
if ds.XMLID == nil {
return errors.New("delivery services has no XMLID!")
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/request/comment/comments.go b/traffic_ops/traffic_ops_golang/deliveryservice/request/comment/comments.go
index 50ca589..5887b8f 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/request/comment/comments.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/request/comment/comments.go
@@ -36,13 +36,13 @@ import (
)
//we need a type alias to define functions on
-type TODeliveryServiceRequestComment struct{
+type TODeliveryServiceRequestComment struct {
ReqInfo *api.APIInfo `json:"-"`
tc.DeliveryServiceRequestCommentNullable
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TODeliveryServiceRequestComment{reqInfo, tc.DeliveryServiceRequestCommentNullable{}}
return &toReturn
}
@@ -222,7 +222,7 @@ func (comment *TODeliveryServiceRequestComment) Update() (error, tc.ApiErrorType
func (comment *TODeliveryServiceRequestComment) Delete() (error, tc.ApiErrorType) {
var current TODeliveryServiceRequestComment
- err :=comment.ReqInfo.Tx.QueryRowx(selectQuery() + `WHERE dsrc.id=` + strconv.Itoa(*comment.ID)).StructScan(¤t)
+ err := comment.ReqInfo.Tx.QueryRowx(selectQuery() + `WHERE dsrc.id=` + strconv.Itoa(*comment.ID)).StructScan(¤t)
if err != nil {
log.Errorf("Error querying DeliveryServiceRequestComments: %v", err)
return err, tc.SystemError
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/request/comment/comments_test.go b/traffic_ops/traffic_ops_golang/deliveryservice/request/comment/comments_test.go
index 17b436c..fa1de48 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/request/comment/comments_test.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/request/comment/comments_test.go
@@ -25,9 +25,9 @@ import (
"strings"
"testing"
+ "github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
- "github.com/apache/trafficcontrol/lib/go-tc"
)
func TestFuncs(t *testing.T) {
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/request/requests.go b/traffic_ops/traffic_ops_golang/deliveryservice/request/requests.go
index 8ac9f2b..e2bd836 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/request/requests.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/request/requests.go
@@ -36,13 +36,13 @@ import (
)
//we need a type alias to define functions on
-type TODeliveryServiceRequest struct{
+type TODeliveryServiceRequest struct {
ReqInfo *api.APIInfo `json:"-"`
tc.DeliveryServiceRequestNullable
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TODeliveryServiceRequest{reqInfo, tc.DeliveryServiceRequestNullable{}}
return &toReturn
}
@@ -447,14 +447,13 @@ WHERE id=:id`
////////////////////////////////////////////////////////////////
// Assignment change
-func GetAssignmentTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetAssignmentTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := deliveryServiceRequestAssignment{TODeliveryServiceRequest{reqInfo, tc.DeliveryServiceRequestNullable{}}}
return &toReturn
}
}
-
type deliveryServiceRequestAssignment struct {
TODeliveryServiceRequest
}
@@ -538,12 +537,13 @@ type deliveryServiceRequestStatus struct {
TODeliveryServiceRequest
}
-func GetStatusTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetStatusTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := deliveryServiceRequestStatus{TODeliveryServiceRequest{reqInfo, tc.DeliveryServiceRequestNullable{}}}
return &toReturn
}
}
+
// Update status only
func (req *deliveryServiceRequestStatus) Update() (error, tc.ApiErrorType) {
// req represents the state the deliveryservice_request is to transition to
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/request/requests_test.go b/traffic_ops/traffic_ops_golang/deliveryservice/request/requests_test.go
index b69b9b9..d22033a 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/request/requests_test.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/request/requests_test.go
@@ -77,14 +77,14 @@ func TestGetDeliveryServiceRequest(t *testing.T) {
}}
expectedErrors := []string{
- /*
- `'regionalGeoBlocking' is required`,
- `'xmlId' cannot contain spaces`,
- `'dscp' is required`,
- `'displayName' cannot be blank`,
- `'geoProvider' is required`,
- `'typeId' is required`,
- */
+ /*
+ `'regionalGeoBlocking' is required`,
+ `'xmlId' cannot contain spaces`,
+ `'dscp' is required`,
+ `'displayName' cannot be blank`,
+ `'geoProvider' is required`,
+ `'typeId' is required`,
+ */
}
r.SetKeys(map[string]interface{}{"id": 10})
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/request/validate.go b/traffic_ops/traffic_ops_golang/deliveryservice/request/validate.go
index 977a996..2249a43 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/request/validate.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/request/validate.go
@@ -63,6 +63,5 @@ func (req *TODeliveryServiceRequest) Validate() []error {
errs = append(errs, e...)
-
return errs
}
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
index 48406af..177408c 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
@@ -713,13 +713,13 @@ func dssSelectQuery() string {
return selectStmt
}
-type TODSSDeliveryService struct{
+type TODSSDeliveryService struct {
ReqInfo *api.APIInfo `json:"-"`
tc.DSSDeliveryService
}
-func GetDSSDeliveryServiceReaderSingleton() func(reqInfo *api.APIInfo)api.Reader {
- return func(reqInfo *api.APIInfo)api.Reader {
+func GetDSSDeliveryServiceReaderSingleton() func(reqInfo *api.APIInfo) api.Reader {
+ return func(reqInfo *api.APIInfo) api.Reader {
toReturn := TODSSDeliveryService{reqInfo, tc.DSSDeliveryService{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/deliveryservicesregexes/deliveryservicesregexes.go b/traffic_ops/traffic_ops_golang/deliveryservicesregexes/deliveryservicesregexes.go
index b091ea9..7016943 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservicesregexes/deliveryservicesregexes.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservicesregexes/deliveryservicesregexes.go
@@ -557,7 +557,7 @@ func Delete(dbx *sqlx.DB) http.HandlerFunc {
}
log.Debugf("changelog for delete on object")
- api.CreateChangeLogRaw(api.ApiChange,fmt.Sprintf(`deleted deliveryservice_regex {"ds": %d, "regex": %d}`, dsID, regexID), user, dbx.DB)
+ api.CreateChangeLogRaw(api.ApiChange, fmt.Sprintf(`deleted deliveryservice_regex {"ds": %d, "regex": %d}`, dsID, regexID), user, dbx.DB)
resp := struct {
tc.Alerts
}{tc.CreateAlerts(tc.SuccessLevel, "deliveryservice_regex was deleted.")}
diff --git a/traffic_ops/traffic_ops_golang/division/divisions.go b/traffic_ops/traffic_ops_golang/division/divisions.go
index fa9d3a3..0e0e7e7 100644
--- a/traffic_ops/traffic_ops_golang/division/divisions.go
+++ b/traffic_ops/traffic_ops_golang/division/divisions.go
@@ -36,13 +36,13 @@ import (
)
//we need a type alias to define functions on
-type TODivision struct{
+type TODivision struct {
ReqInfo *api.APIInfo `json:"-"`
tc.DivisionNullable
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TODivision{reqInfo, tc.DivisionNullable{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/division/divisions_test.go b/traffic_ops/traffic_ops_golang/division/divisions_test.go
index eedcbba..a8d93a8 100644
--- a/traffic_ops/traffic_ops_golang/division/divisions_test.go
+++ b/traffic_ops/traffic_ops_golang/division/divisions_test.go
@@ -75,7 +75,7 @@ func TestGetDivisions(t *testing.T) {
mock.ExpectCommit()
v := map[string]string{"dsId": "1"}
- reqInfo := api.APIInfo{Tx:db.MustBegin(),CommitTx:util.BoolPtr(false)}
+ reqInfo := api.APIInfo{Tx: db.MustBegin(), CommitTx: util.BoolPtr(false)}
servers, errs, errType := GetTypeSingleton()(&reqInfo).Read(v)
if len(errs) > 0 {
t.Errorf("getDivisions expected: no errors, actual: %v with error type: %s", errs, errType.String())
diff --git a/traffic_ops/traffic_ops_golang/origin/origins.go b/traffic_ops/traffic_ops_golang/origin/origins.go
index 73f4a4a..e760660 100644
--- a/traffic_ops/traffic_ops_golang/origin/origins.go
+++ b/traffic_ops/traffic_ops_golang/origin/origins.go
@@ -41,13 +41,13 @@ import (
)
//we need a type alias to define functions on
-type TOOrigin struct{
+type TOOrigin struct {
ReqInfo *api.APIInfo `json:"-"`
v13.Origin
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TOOrigin{reqInfo, v13.Origin{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/origin/origins_test.go b/traffic_ops/traffic_ops_golang/origin/origins_test.go
index ed5db33..56d1b87 100644
--- a/traffic_ops/traffic_ops_golang/origin/origins_test.go
+++ b/traffic_ops/traffic_ops_golang/origin/origins_test.go
@@ -204,7 +204,7 @@ func TestValidate(t *testing.T) {
port := 65535
pro := "http"
lu := tc.TimeNoMod{Time: time.Now()}
- c = TOOrigin{Origin:v13.Origin{ID: &id,
+ c = TOOrigin{Origin: v13.Origin{ID: &id,
Name: &nm,
DeliveryServiceID: &id,
FQDN: &fqdn,
diff --git a/traffic_ops/traffic_ops_golang/parameter/parameters.go b/traffic_ops/traffic_ops_golang/parameter/parameters.go
index a948c01..c0363f9 100644
--- a/traffic_ops/traffic_ops_golang/parameter/parameters.go
+++ b/traffic_ops/traffic_ops_golang/parameter/parameters.go
@@ -49,13 +49,13 @@ var (
)
//we need a type alias to define functions on
-type TOParameter struct{
+type TOParameter struct {
ReqInfo *api.APIInfo `json:"-"`
tc.ParameterNullable
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TOParameter{reqInfo, tc.ParameterNullable{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/parameter/parameters_test.go b/traffic_ops/traffic_ops_golang/parameter/parameters_test.go
index 9b465f9..090e70b 100644
--- a/traffic_ops/traffic_ops_golang/parameter/parameters_test.go
+++ b/traffic_ops/traffic_ops_golang/parameter/parameters_test.go
@@ -31,8 +31,8 @@ import (
"encoding/json"
- sqlmock "gopkg.in/DATA-DOG/go-sqlmock.v1"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/auth"
+ sqlmock "gopkg.in/DATA-DOG/go-sqlmock.v1"
)
func getTestParameters() []tc.ParameterNullable {
@@ -95,9 +95,9 @@ func TestGetParameters(t *testing.T) {
mock.ExpectQuery("SELECT").WillReturnRows(rows)
mock.ExpectCommit()
v := map[string]string{"name": "1"}
- user := auth.CurrentUser{PrivLevel:30}
+ user := auth.CurrentUser{PrivLevel: 30}
- reqInfo := api.APIInfo{Tx:db.MustBegin(),CommitTx:util.BoolPtr(false),User:&user}
+ reqInfo := api.APIInfo{Tx: db.MustBegin(), CommitTx: util.BoolPtr(false), User: &user}
pps, errs, _ := GetTypeSingleton()(&reqInfo).Read(v)
if len(errs) > 0 {
t.Errorf("parameter.Read expected: no errors, actual: %v", errs)
diff --git a/traffic_ops/traffic_ops_golang/physlocation/phys_locations.go b/traffic_ops/traffic_ops_golang/physlocation/phys_locations.go
index b579a99..8528341 100644
--- a/traffic_ops/traffic_ops_golang/physlocation/phys_locations.go
+++ b/traffic_ops/traffic_ops_golang/physlocation/phys_locations.go
@@ -36,13 +36,13 @@ import (
)
//we need a type alias to define functions on
-type TOPhysLocation struct{
+type TOPhysLocation struct {
ReqInfo *api.APIInfo `json:"-"`
tc.PhysLocationNullable
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TOPhysLocation{reqInfo, tc.PhysLocationNullable{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/physlocation/phys_locations_test.go b/traffic_ops/traffic_ops_golang/physlocation/phys_locations_test.go
index 3cad4ec..bb459c8 100644
--- a/traffic_ops/traffic_ops_golang/physlocation/phys_locations_test.go
+++ b/traffic_ops/traffic_ops_golang/physlocation/phys_locations_test.go
@@ -97,7 +97,7 @@ func TestGetPhysLocations(t *testing.T) {
mock.ExpectCommit()
v := map[string]string{"dsId": "1"}
- reqInfo := api.APIInfo{Tx:db.MustBegin(),CommitTx:util.BoolPtr(false)}
+ reqInfo := api.APIInfo{Tx: db.MustBegin(), CommitTx: util.BoolPtr(false)}
physLocations, errs, _ := GetTypeSingleton()(&reqInfo).Read(v)
if len(errs) > 0 {
diff --git a/traffic_ops/traffic_ops_golang/profile/profiles_test.go b/traffic_ops/traffic_ops_golang/profile/profiles_test.go
index b00ea6c..5ad1b95 100644
--- a/traffic_ops/traffic_ops_golang/profile/profiles_test.go
+++ b/traffic_ops/traffic_ops_golang/profile/profiles_test.go
@@ -98,7 +98,7 @@ func TestGetProfiles(t *testing.T) {
mock.ExpectCommit()
v := map[string]string{"name": "1"}
- reqInfo := api.APIInfo{Tx:db.MustBegin(),CommitTx:util.BoolPtr(false)}
+ reqInfo := api.APIInfo{Tx: db.MustBegin(), CommitTx: util.BoolPtr(false)}
profiles, errs, _ := GetTypeSingleton()(&reqInfo).Read(v)
if len(errs) > 0 {
diff --git a/traffic_ops/traffic_ops_golang/profileparameter/profile_parameters.go b/traffic_ops/traffic_ops_golang/profileparameter/profile_parameters.go
index 703d40c..e6e3366 100644
--- a/traffic_ops/traffic_ops_golang/profileparameter/profile_parameters.go
+++ b/traffic_ops/traffic_ops_golang/profileparameter/profile_parameters.go
@@ -42,13 +42,13 @@ const (
)
//we need a type alias to define functions on
-type TOProfileParameter struct{
+type TOProfileParameter struct {
ReqInfo *api.APIInfo `json:"-"`
v13.ProfileParameterNullable
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TOProfileParameter{reqInfo, v13.ProfileParameterNullable{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/profileparameter/profile_parameters_test.go b/traffic_ops/traffic_ops_golang/profileparameter/profile_parameters_test.go
index 013ce3a..fea3c7d 100644
--- a/traffic_ops/traffic_ops_golang/profileparameter/profile_parameters_test.go
+++ b/traffic_ops/traffic_ops_golang/profileparameter/profile_parameters_test.go
@@ -83,8 +83,7 @@ func TestGetProfileParameters(t *testing.T) {
mock.ExpectCommit()
v := map[string]string{"profile": "1"}
- reqInfo := api.APIInfo{Tx:db.MustBegin(),CommitTx:util.BoolPtr(false)}
-
+ reqInfo := api.APIInfo{Tx: db.MustBegin(), CommitTx: util.BoolPtr(false)}
pps, errs, _ := GetTypeSingleton()(&reqInfo).Read(v)
if len(errs) > 0 {
diff --git a/traffic_ops/traffic_ops_golang/region/regions.go b/traffic_ops/traffic_ops_golang/region/regions.go
index b54598c..f963923 100644
--- a/traffic_ops/traffic_ops_golang/region/regions.go
+++ b/traffic_ops/traffic_ops_golang/region/regions.go
@@ -32,13 +32,13 @@ import (
)
//we need a type alias to define functions on
-type TORegion struct{
+type TORegion struct {
ReqInfo *api.APIInfo `json:"-"`
tc.Region
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TORegion{reqInfo, tc.Region{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/region/regions_test.go b/traffic_ops/traffic_ops_golang/region/regions_test.go
index ad7cb6c..50d26de 100644
--- a/traffic_ops/traffic_ops_golang/region/regions_test.go
+++ b/traffic_ops/traffic_ops_golang/region/regions_test.go
@@ -76,7 +76,7 @@ func TestReadRegions(t *testing.T) {
mock.ExpectCommit()
v := map[string]string{"id": "1"}
- reqInfo := api.APIInfo{Tx:db.MustBegin(),CommitTx:util.BoolPtr(false)}
+ reqInfo := api.APIInfo{Tx: db.MustBegin(), CommitTx: util.BoolPtr(false)}
regions, errs, _ := GetTypeSingleton()(&reqInfo).Read(v)
if len(errs) > 0 {
diff --git a/traffic_ops/traffic_ops_golang/riaksvc/dsutil.go b/traffic_ops/traffic_ops_golang/riaksvc/dsutil.go
index 8140292..9a62735 100644
--- a/traffic_ops/traffic_ops_golang/riaksvc/dsutil.go
+++ b/traffic_ops/traffic_ops_golang/riaksvc/dsutil.go
@@ -63,7 +63,6 @@ func GetDeliveryServiceSSLKeysObj(xmlID string, version string, tx *sql.Tx, auth
return key, found, nil
}
-
func GetDeliveryServiceSSLKeysObjTx(xmlID string, version string, tx *sql.Tx, authOpts *riak.AuthOptions) (tc.DeliveryServiceSSLKeys, bool, error) {
key := tc.DeliveryServiceSSLKeys{}
if version == "" {
@@ -94,7 +93,7 @@ func GetDeliveryServiceSSLKeysObjTx(xmlID string, version string, tx *sql.Tx, au
return key, found, nil
}
- func PutDeliveryServiceSSLKeysObj(key tc.DeliveryServiceSSLKeys, tx *sql.Tx, authOpts *riak.AuthOptions) error {
+func PutDeliveryServiceSSLKeysObj(key tc.DeliveryServiceSSLKeys, tx *sql.Tx, authOpts *riak.AuthOptions) error {
keyJSON, err := json.Marshal(&key)
if err != nil {
return errors.New("marshalling key: " + err.Error())
diff --git a/traffic_ops/traffic_ops_golang/role/roles.go b/traffic_ops/traffic_ops_golang/role/roles.go
index 2cc8a37..763ab62 100644
--- a/traffic_ops/traffic_ops_golang/role/roles.go
+++ b/traffic_ops/traffic_ops_golang/role/roles.go
@@ -37,13 +37,13 @@ import (
)
//we need a type alias to define functions on
-type TORole struct{
+type TORole struct {
ReqInfo *api.APIInfo `json:"-"`
v13.Role
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TORole{reqInfo, v13.Role{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/routes.go b/traffic_ops/traffic_ops_golang/routes.go
index c270424..6b3b215 100644
--- a/traffic_ops/traffic_ops_golang/routes.go
+++ b/traffic_ops/traffic_ops_golang/routes.go
@@ -175,12 +175,12 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
// get all edge servers associated with a delivery service (from deliveryservice_server table)
- {1.1, http.MethodGet, `deliveryserviceserver$`, dsserver.ReadDSSHandler(d.DB),auth.PrivLevelReadOnly, Authenticated, nil},
- {1.1, http.MethodPost,`deliveryserviceserver$`, dsserver.GetReplaceHandler(d.DB),auth.PrivLevelOperations, Authenticated, nil},
- {1.1, http.MethodPost,`deliveryservices/{xml_id}/servers$`, dsserver.GetCreateHandler( d.DB ) ,auth.PrivLevelOperations, Authenticated, nil},
- {1.1, http.MethodGet, `servers/{id}/deliveryservices$`, api.ReadOnlyHandler(dsserver.GetDSSDeliveryServiceReaderSingleton()),auth.PrivLevelReadOnly, Authenticated, nil},
- {1.1, http.MethodGet, `deliveryservices/{id}/servers$`, dsserver.GetReadHandler(d.DB, tc.Assigned),auth.PrivLevelReadOnly, Authenticated, nil},
- {1.1, http.MethodGet, `deliveryservices/{id}/unassigned_servers$`, dsserver.GetReadHandler(d.DB, tc.Unassigned),auth.PrivLevelReadOnly, Authenticated, nil},
+ {1.1, http.MethodGet, `deliveryserviceserver$`, dsserver.ReadDSSHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil},
+ {1.1, http.MethodPost, `deliveryserviceserver$`, dsserver.GetReplaceHandler(d.DB), auth.PrivLevelOperations, Authenticated, nil},
+ {1.1, http.MethodPost, `deliveryservices/{xml_id}/servers$`, dsserver.GetCreateHandler(d.DB), auth.PrivLevelOperations, Authenticated, nil},
+ {1.1, http.MethodGet, `servers/{id}/deliveryservices$`, api.ReadOnlyHandler(dsserver.GetDSSDeliveryServiceReaderSingleton()), auth.PrivLevelReadOnly, Authenticated, nil},
+ {1.1, http.MethodGet, `deliveryservices/{id}/servers$`, dsserver.GetReadHandler(d.DB, tc.Assigned), auth.PrivLevelReadOnly, Authenticated, nil},
+ {1.1, http.MethodGet, `deliveryservices/{id}/unassigned_servers$`, dsserver.GetReadHandler(d.DB, tc.Unassigned), auth.PrivLevelReadOnly, Authenticated, nil},
//{1.1, http.MethodGet, `deliveryservices/{id}/servers/eligible$`, dsserver.GetReadHandler(d.Tx, tc.Eligible),auth.PrivLevelReadOnly, Authenticated, nil},
//Server
diff --git a/traffic_ops/traffic_ops_golang/server/servers.go b/traffic_ops/traffic_ops_golang/server/servers.go
index 1ad8eea..7e51ab3 100644
--- a/traffic_ops/traffic_ops_golang/server/servers.go
+++ b/traffic_ops/traffic_ops_golang/server/servers.go
@@ -39,13 +39,13 @@ import (
)
//we need a type alias to define functions on
-type TOServer struct{
+type TOServer struct {
ReqInfo *api.APIInfo `json:"-"`
v13.ServerNullable
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TOServer{reqInfo, v13.ServerNullable{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
index 2c06d35..7ebc076 100644
--- a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
+++ b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
@@ -26,13 +26,13 @@ import (
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/dbhelpers"
)
-type TOStaticDNSEntry struct{
+type TOStaticDNSEntry struct {
ReqInfo *api.APIInfo `json:"-"`
tc.StaticDNSEntry
}
-func GetReaderSingleton() func(reqInfo *api.APIInfo)api.Reader {
- return func(reqInfo *api.APIInfo)api.Reader {
+func GetReaderSingleton() func(reqInfo *api.APIInfo) api.Reader {
+ return func(reqInfo *api.APIInfo) api.Reader {
toReturn := TOStaticDNSEntry{reqInfo, tc.StaticDNSEntry{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/status/statuses.go b/traffic_ops/traffic_ops_golang/status/statuses.go
index d00aed9..5821a35 100644
--- a/traffic_ops/traffic_ops_golang/status/statuses.go
+++ b/traffic_ops/traffic_ops_golang/status/statuses.go
@@ -36,13 +36,13 @@ import (
)
//we need a type alias to define functions on
-type TOStatus struct{
+type TOStatus struct {
ReqInfo *api.APIInfo `json:"-"`
tc.StatusNullable
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TOStatus{reqInfo, tc.StatusNullable{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/status/statuses_test.go b/traffic_ops/traffic_ops_golang/status/statuses_test.go
index 7a684f1..d455787 100644
--- a/traffic_ops/traffic_ops_golang/status/statuses_test.go
+++ b/traffic_ops/traffic_ops_golang/status/statuses_test.go
@@ -77,7 +77,7 @@ func TestReadStatuses(t *testing.T) {
mock.ExpectCommit()
v := map[string]string{"dsId": "1"}
- reqInfo := api.APIInfo{Tx:db.MustBegin(),CommitTx:util.BoolPtr(false)}
+ reqInfo := api.APIInfo{Tx: db.MustBegin(), CommitTx: util.BoolPtr(false)}
statuses, errs, _ := GetTypeSingleton()(&reqInfo).Read(v)
if len(errs) > 0 {
diff --git a/traffic_ops/traffic_ops_golang/systeminfo/system_info.go b/traffic_ops/traffic_ops_golang/systeminfo/system_info.go
index 40da18a..22972ab 100644
--- a/traffic_ops/traffic_ops_golang/systeminfo/system_info.go
+++ b/traffic_ops/traffic_ops_golang/systeminfo/system_info.go
@@ -20,16 +20,17 @@ package systeminfo
*/
import (
+ "context"
"encoding/json"
"fmt"
"net/http"
- "context"
tc "github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/auth"
- "github.com/jmoiron/sqlx"
"time"
+
+ "github.com/jmoiron/sqlx"
)
func Handler(db *sqlx.DB) http.HandlerFunc {
@@ -80,9 +81,9 @@ p.last_updated,
p.value
FROM parameter p
WHERE p.config_file='global'`
- ctx, cancel := context.WithTimeout(context.Background(), time.Second * 10)
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
- rows, err := db.QueryxContext(ctx,query)
+ rows, err := db.QueryxContext(ctx, query)
if err != nil {
return nil, fmt.Errorf("querying: %v", err)
diff --git a/traffic_ops/traffic_ops_golang/tenant/tenancy.go b/traffic_ops/traffic_ops_golang/tenant/tenancy.go
index ea6d5ce..cd8edd3 100644
--- a/traffic_ops/traffic_ops_golang/tenant/tenancy.go
+++ b/traffic_ops/traffic_ops_golang/tenant/tenancy.go
@@ -38,9 +38,6 @@ import (
"github.com/lib/pq"
)
-// TOTenant provides a local type against which to define methods
-type TOTenant tc.TenantNullable
-
// DeliveryServiceTenantInfo provides only deliveryservice info needed here
type DeliveryServiceTenantInfo tc.DeliveryServiceNullable
@@ -295,10 +292,18 @@ func IsResourceAuthorizedToUserTx(resourceTenantID int, user *auth.CurrentUser,
}
}
-// GetRefType allows shared handlers to decode JSON to the tenant type
-// Part of the Identifier interface
-func GetRefType() *TOTenant {
- return &TOTenant{}
+
+// TOTenant provides a local type against which to define methods
+type TOTenant struct {
+ ReqInfo *api.APIInfo `json:"-"`
+ tc.TenantNullable
+}
+
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
+ toReturn := TOTenant{reqInfo, tc.TenantNullable{}}
+ return &toReturn
+ }
}
// GetID wraps the ID member with null checking
diff --git a/traffic_ops/traffic_ops_golang/types/types.go b/traffic_ops/traffic_ops_golang/types/types.go
index f160f8b..ab95214 100644
--- a/traffic_ops/traffic_ops_golang/types/types.go
+++ b/traffic_ops/traffic_ops_golang/types/types.go
@@ -36,13 +36,13 @@ import (
)
//we need a type alias to define functions on
-type TOType struct{
+type TOType struct {
ReqInfo *api.APIInfo `json:"-"`
tc.TypeNullable
}
-func GetTypeSingleton() func(reqInfo *api.APIInfo)api.CRUDer {
- return func(reqInfo *api.APIInfo)api.CRUDer {
+func GetTypeSingleton() func(reqInfo *api.APIInfo) api.CRUDer {
+ return func(reqInfo *api.APIInfo) api.CRUDer {
toReturn := TOType{reqInfo, tc.TypeNullable{}}
return &toReturn
}
diff --git a/traffic_ops/traffic_ops_golang/types/types_test.go b/traffic_ops/traffic_ops_golang/types/types_test.go
index 252bed2..780f893 100644
--- a/traffic_ops/traffic_ops_golang/types/types_test.go
+++ b/traffic_ops/traffic_ops_golang/types/types_test.go
@@ -86,8 +86,7 @@ func TestGetType(t *testing.T) {
mock.ExpectCommit()
v := map[string]string{"dsId": "1"}
- reqInfo := api.APIInfo{Tx:db.MustBegin(),CommitTx:util.BoolPtr(false)}
-
+ reqInfo := api.APIInfo{Tx: db.MustBegin(), CommitTx: util.BoolPtr(false)}
types, errs, _ := GetTypeSingleton()(&reqInfo).Read(v)
if len(errs) > 0 {