You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ro...@apache.org on 2019/02/22 20:02:49 UTC

[trafficcontrol] branch master updated: moved 'main' packages that didn't need to be in 'main' into their own packages

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 270aaf3  moved 'main' packages that didn't need to be in 'main' into their own packages
270aaf3 is described below

commit 270aaf36404dbe6a60091a63b4cea454ce6dfa54
Author: ocket8888 <oc...@gmail.com>
AuthorDate: Wed Nov 14 11:11:16 2018 -0700

    moved 'main' packages that didn't need to be in 'main' into their own packages
---
 traffic_ops/traffic_ops_golang/{ => routing}/routes.go    | 15 ++++++++-------
 traffic_ops/traffic_ops_golang/{ => routing}/routing.go   |  2 +-
 .../traffic_ops_golang/{ => routing}/routing_test.go      |  2 +-
 traffic_ops/traffic_ops_golang/{ => routing}/wrappers.go  |  2 +-
 .../traffic_ops_golang/{ => routing}/wrappers_test.go     |  2 +-
 traffic_ops/traffic_ops_golang/traffic_ops_golang.go      |  7 ++++---
 .../traffic_ops_golang/{ => urisigning}/urisigning.go     |  8 ++++----
 .../{ => urisigning}/urisigning_test.go                   |  2 +-
 8 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/routes.go b/traffic_ops/traffic_ops_golang/routing/routes.go
similarity index 98%
rename from traffic_ops/traffic_ops_golang/routes.go
rename to traffic_ops/traffic_ops_golang/routing/routes.go
index 4e72de7..394ed7d 100644
--- a/traffic_ops/traffic_ops_golang/routes.go
+++ b/traffic_ops/traffic_ops_golang/routing/routes.go
@@ -1,4 +1,4 @@
-package main
+package routing
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -69,6 +69,7 @@ import (
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/steeringtargets"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/systeminfo"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/types"
+	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/urisigning"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/user"
 
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/origin"
@@ -304,10 +305,10 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
 		{1.3, http.MethodDelete, `deliveryservice_request_comments/?$`, api.DeleteHandler(&comment.TODeliveryServiceRequestComment{}), auth.PrivLevelPortal, Authenticated, nil},
 
 		//Delivery service uri signing keys: CRUD
-		{1.3, http.MethodGet, `deliveryservices/{xmlID}/urisignkeys$`, getURIsignkeysHandler, auth.PrivLevelAdmin, Authenticated, nil},
-		{1.3, http.MethodPost, `deliveryservices/{xmlID}/urisignkeys$`, saveDeliveryServiceURIKeysHandler, auth.PrivLevelAdmin, Authenticated, nil},
-		{1.3, http.MethodPut, `deliveryservices/{xmlID}/urisignkeys$`, saveDeliveryServiceURIKeysHandler, auth.PrivLevelAdmin, Authenticated, nil},
-		{1.3, http.MethodDelete, `deliveryservices/{xmlID}/urisignkeys$`, removeDeliveryServiceURIKeysHandler, auth.PrivLevelAdmin, Authenticated, nil},
+		{1.3, http.MethodGet, `deliveryservices/{xmlID}/urisignkeys$`, urisigning.GetURIsignkeysHandler, auth.PrivLevelAdmin, Authenticated, nil},
+		{1.3, http.MethodPost, `deliveryservices/{xmlID}/urisignkeys$`, urisigning.SaveDeliveryServiceURIKeysHandler, auth.PrivLevelAdmin, Authenticated, nil},
+		{1.3, http.MethodPut, `deliveryservices/{xmlID}/urisignkeys$`, urisigning.SaveDeliveryServiceURIKeysHandler, auth.PrivLevelAdmin, Authenticated, nil},
+		{1.3, http.MethodDelete, `deliveryservices/{xmlID}/urisignkeys$`, urisigning.RemoveDeliveryServiceURIKeysHandler, auth.PrivLevelAdmin, Authenticated, nil},
 
 		// Federations by CDN (the actual table for federation)
 		{1.1, http.MethodGet, `cdns/{name}/federations/?(\.json)?$`, api.ReadHandler(&cdnfederation.TOCDNFederation{}), auth.PrivLevelReadOnly, Authenticated, nil},
@@ -427,7 +428,7 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
 	return routes, rawRoutes, proxyHandler, nil
 }
 
-func memoryStatsHandler() http.HandlerFunc {
+func MemoryStatsHandler() http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		handleErrs := tc.GetHandleErrorsFunc(w, r)
 		stats := runtime.MemStats{}
@@ -444,7 +445,7 @@ func memoryStatsHandler() http.HandlerFunc {
 	}
 }
 
-func dbStatsHandler(db *sqlx.DB) http.HandlerFunc {
+func DBStatsHandler(db *sqlx.DB) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		handleErrs := tc.GetHandleErrorsFunc(w, r)
 		stats := db.DB.Stats()
diff --git a/traffic_ops/traffic_ops_golang/routing.go b/traffic_ops/traffic_ops_golang/routing/routing.go
similarity index 99%
rename from traffic_ops/traffic_ops_golang/routing.go
rename to traffic_ops/traffic_ops_golang/routing/routing.go
index 7460138..297fc4d 100644
--- a/traffic_ops/traffic_ops_golang/routing.go
+++ b/traffic_ops/traffic_ops_golang/routing/routing.go
@@ -1,4 +1,4 @@
-package main
+package routing
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
diff --git a/traffic_ops/traffic_ops_golang/routing_test.go b/traffic_ops/traffic_ops_golang/routing/routing_test.go
similarity index 99%
rename from traffic_ops/traffic_ops_golang/routing_test.go
rename to traffic_ops/traffic_ops_golang/routing/routing_test.go
index b081bff..e5f1298 100644
--- a/traffic_ops/traffic_ops_golang/routing_test.go
+++ b/traffic_ops/traffic_ops_golang/routing/routing_test.go
@@ -1,4 +1,4 @@
-package main
+package routing
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
diff --git a/traffic_ops/traffic_ops_golang/wrappers.go b/traffic_ops/traffic_ops_golang/routing/wrappers.go
similarity index 99%
rename from traffic_ops/traffic_ops_golang/wrappers.go
rename to traffic_ops/traffic_ops_golang/routing/wrappers.go
index 980ccfb..cf74bc3 100644
--- a/traffic_ops/traffic_ops_golang/wrappers.go
+++ b/traffic_ops/traffic_ops_golang/routing/wrappers.go
@@ -1,4 +1,4 @@
-package main
+package routing
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
diff --git a/traffic_ops/traffic_ops_golang/wrappers_test.go b/traffic_ops/traffic_ops_golang/routing/wrappers_test.go
similarity index 99%
rename from traffic_ops/traffic_ops_golang/wrappers_test.go
rename to traffic_ops/traffic_ops_golang/routing/wrappers_test.go
index d0f7cef..387aadd 100644
--- a/traffic_ops/traffic_ops_golang/wrappers_test.go
+++ b/traffic_ops/traffic_ops_golang/routing/wrappers_test.go
@@ -1,4 +1,4 @@
-package main
+package routing
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
diff --git a/traffic_ops/traffic_ops_golang/traffic_ops_golang.go b/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
index b3f6ef3..504941d 100644
--- a/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
+++ b/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
@@ -38,6 +38,7 @@ import (
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/auth"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/config"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/plugin"
+	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/routing"
 
 	"github.com/jmoiron/sqlx"
 	_ "github.com/lib/pq"
@@ -122,8 +123,8 @@ func main() {
 	pprofMux := http.DefaultServeMux
 	http.DefaultServeMux = http.NewServeMux() // this is so we don't serve pprof over 443.
 
-	pprofMux.Handle("/db-stats", dbStatsHandler(db))
-	pprofMux.Handle("/memory-stats", memoryStatsHandler())
+	pprofMux.Handle("/db-stats", routing.DBStatsHandler(db))
+	pprofMux.Handle("/memory-stats", routing.MemoryStatsHandler())
 	go func() {
 		debugServer := http.Server{
 			Addr:    "localhost:6060",
@@ -132,7 +133,7 @@ func main() {
 		log.Errorln(debugServer.ListenAndServe())
 	}()
 
-	if err := RegisterRoutes(ServerData{DB: db, Config: cfg, Profiling: &profiling, Plugins: plugins}); err != nil {
+	if err := routing.RegisterRoutes(routing.ServerData{DB: db, Config: cfg, Profiling: &profiling, Plugins: plugins}); err != nil {
 		log.Errorf("registering routes: %v\n", err)
 		return
 	}
diff --git a/traffic_ops/traffic_ops_golang/urisigning.go b/traffic_ops/traffic_ops_golang/urisigning/urisigning.go
similarity index 97%
rename from traffic_ops/traffic_ops_golang/urisigning.go
rename to traffic_ops/traffic_ops_golang/urisigning/urisigning.go
index 9f8b004..cbe8781 100644
--- a/traffic_ops/traffic_ops_golang/urisigning.go
+++ b/traffic_ops/traffic_ops_golang/urisigning/urisigning.go
@@ -1,4 +1,4 @@
-package main
+package urisigning
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -45,7 +45,7 @@ type URISignerKeyset struct {
 }
 
 // endpoint handler for fetching uri signing keys from riak
-func getURIsignkeysHandler(w http.ResponseWriter, r *http.Request) {
+func GetURIsignkeysHandler(w http.ResponseWriter, r *http.Request) {
 	inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
 	if userErr != nil || sysErr != nil {
 		api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
@@ -85,7 +85,7 @@ func getURIsignkeysHandler(w http.ResponseWriter, r *http.Request) {
 }
 
 // removeDeliveryServiceURIKeysHandler is the HTTP DELETE handler used to remove urisigning keys assigned to a delivery service.
-func removeDeliveryServiceURIKeysHandler(w http.ResponseWriter, r *http.Request) {
+func RemoveDeliveryServiceURIKeysHandler(w http.ResponseWriter, r *http.Request) {
 	inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
 	if userErr != nil || sysErr != nil {
 		api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
@@ -129,7 +129,7 @@ func removeDeliveryServiceURIKeysHandler(w http.ResponseWriter, r *http.Request)
 }
 
 // saveDeliveryServiceURIKeysHandler is the HTTP POST or PUT handler used to store urisigning keys to a delivery service.
-func saveDeliveryServiceURIKeysHandler(w http.ResponseWriter, r *http.Request) {
+func SaveDeliveryServiceURIKeysHandler(w http.ResponseWriter, r *http.Request) {
 	inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
 	if userErr != nil || sysErr != nil {
 		api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
diff --git a/traffic_ops/traffic_ops_golang/urisigning_test.go b/traffic_ops/traffic_ops_golang/urisigning/urisigning_test.go
similarity index 99%
rename from traffic_ops/traffic_ops_golang/urisigning_test.go
rename to traffic_ops/traffic_ops_golang/urisigning/urisigning_test.go
index 98dcfef..983b591 100644
--- a/traffic_ops/traffic_ops_golang/urisigning_test.go
+++ b/traffic_ops/traffic_ops_golang/urisigning/urisigning_test.go
@@ -1,4 +1,4 @@
-package main
+package urisigning
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one