trafficcontrol-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dewr...@apache.org
Subject [incubator-trafficcontrol] branch master updated: move config.go into its own package
Date Wed, 28 Feb 2018 16:13:17 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 29fd0bf  move config.go into its own package
29fd0bf is described below

commit 29fd0bf4dfbf0713f99b86a30cd76d3d3d8a5772
Author: Dan Kirkwood <dangogh@apache.org>
AuthorDate: Mon Feb 26 10:02:04 2018 -0700

    move config.go into its own package
---
 traffic_ops/traffic_ops_golang/{ => config}/config.go   |  2 +-
 traffic_ops/traffic_ops_golang/deliveryservices_keys.go | 15 ++++++++-------
 traffic_ops/traffic_ops_golang/riak.go                  |  3 ++-
 traffic_ops/traffic_ops_golang/routing.go               |  3 ++-
 traffic_ops/traffic_ops_golang/traffic_ops_golang.go    |  5 +++--
 5 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/config.go b/traffic_ops/traffic_ops_golang/config/config.go
similarity index 99%
rename from traffic_ops/traffic_ops_golang/config.go
rename to traffic_ops/traffic_ops_golang/config/config.go
index 8b47610..46d7142 100644
--- a/traffic_ops/traffic_ops_golang/config.go
+++ b/traffic_ops/traffic_ops_golang/config/config.go
@@ -1,4 +1,4 @@
-package main
+package config
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
diff --git a/traffic_ops/traffic_ops_golang/deliveryservices_keys.go b/traffic_ops/traffic_ops_golang/deliveryservices_keys.go
index ee2b870..49e61f4 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservices_keys.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservices_keys.go
@@ -35,6 +35,7 @@ import (
 	"github.com/apache/incubator-trafficcontrol/lib/go-tc"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/api"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/auth"
+	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/config"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/tenant"
 	"github.com/basho/riak-go-client"
 	"github.com/jmoiron/sqlx"
@@ -95,7 +96,7 @@ func getXMLID(cdnID sql.NullInt64, hostRegex string, db *sqlx.DB) (sql.NullStrin
 	return xmlID, nil
 }
 
-func getDeliveryServiceSSLKeysByXMLID(xmlID string, version string, db *sqlx.DB, cfg Config)
([]byte, error) {
+func getDeliveryServiceSSLKeysByXMLID(xmlID string, version string, db *sqlx.DB, cfg config.Config)
([]byte, error) {
 	var respBytes []byte
 	// create and start a cluster
 	cluster, err := getRiakCluster(db, cfg)
@@ -237,7 +238,7 @@ func verifyAndEncodeCertificate(certificate string, rootCA string) (string,
erro
 	return base64EncodedStr, nil
 }
 
-func addDeliveryServiceSSLKeysHandler(db *sqlx.DB, cfg Config) http.HandlerFunc {
+func addDeliveryServiceSSLKeysHandler(db *sqlx.DB, cfg config.Config) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		handleErr := tc.GetHandleErrorsFunc(w, r)
 		var keysObj tc.DeliveryServiceSSLKeys
@@ -334,7 +335,7 @@ func addDeliveryServiceSSLKeysHandler(db *sqlx.DB, cfg Config) http.HandlerFunc
 }
 
 // fetch the ssl keys for a deliveryservice specified by the fully qualified hostname
-func getDeliveryServiceSSLKeysByHostNameHandler(db *sqlx.DB, cfg Config) http.HandlerFunc
{
+func getDeliveryServiceSSLKeysByHostNameHandler(db *sqlx.DB, cfg config.Config) http.HandlerFunc
{
 	return func(w http.ResponseWriter, r *http.Request) {
 		handleErr := tc.GetHandleErrorsFunc(w, r)
 		var respBytes []byte
@@ -438,7 +439,7 @@ func getDeliveryServiceSSLKeysByHostNameHandler(db *sqlx.DB, cfg Config)
http.Ha
 }
 
 // fetch the deliveryservice ssl keys by the specified xmlID.
-func getDeliveryServiceSSLKeysByXMLIDHandler(db *sqlx.DB, cfg Config) http.HandlerFunc {
+func getDeliveryServiceSSLKeysByXMLIDHandler(db *sqlx.DB, cfg config.Config) http.HandlerFunc
{
 	return func(w http.ResponseWriter, r *http.Request) {
 		handleErr := tc.GetHandleErrorsFunc(w, r)
 		var respBytes []byte
@@ -494,7 +495,7 @@ func getDeliveryServiceSSLKeysByXMLIDHandler(db *sqlx.DB, cfg Config)
http.Handl
 // Delivery Services: URI Sign Keys.
 
 // Http POST or PUT handler used to store urisigning keys to a delivery service.
-func saveDeliveryServiceURIKeysHandler(db *sqlx.DB, cfg Config) http.HandlerFunc {
+func saveDeliveryServiceURIKeysHandler(db *sqlx.DB, cfg config.Config) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		handleErr := tc.GetHandleErrorsFunc(w, r)
 
@@ -570,7 +571,7 @@ func saveDeliveryServiceURIKeysHandler(db *sqlx.DB, cfg Config) http.HandlerFunc
 }
 
 // endpoint handler for fetching uri signing keys from riak
-func getURIsignkeysHandler(db *sqlx.DB, cfg Config) http.HandlerFunc {
+func getURIsignkeysHandler(db *sqlx.DB, cfg config.Config) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		handleErr := tc.GetHandleErrorsFunc(w, r)
 
@@ -630,7 +631,7 @@ func getURIsignkeysHandler(db *sqlx.DB, cfg Config) http.HandlerFunc {
 }
 
 // Http DELETE handler used to remove urisigning keys assigned to a delivery service.
-func removeDeliveryServiceURIKeysHandler(db *sqlx.DB, cfg Config) http.HandlerFunc {
+func removeDeliveryServiceURIKeysHandler(db *sqlx.DB, cfg config.Config) http.HandlerFunc
{
 	return func(w http.ResponseWriter, r *http.Request) {
 		handleErr := tc.GetHandleErrorsFunc(w, r)
 
diff --git a/traffic_ops/traffic_ops_golang/riak.go b/traffic_ops/traffic_ops_golang/riak.go
index cfd33f3..c241a74 100644
--- a/traffic_ops/traffic_ops_golang/riak.go
+++ b/traffic_ops/traffic_ops_golang/riak.go
@@ -26,6 +26,7 @@ import (
 	"time"
 
 	"github.com/apache/incubator-trafficcontrol/lib/go-tc"
+	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/config"
 	"github.com/basho/riak-go-client"
 	"github.com/jmoiron/sqlx"
 	"github.com/lestrrat/go-jwx/jwk"
@@ -157,7 +158,7 @@ func saveObject(obj *riak.Object, bucket string, cluster StorageCluster)
error {
 }
 
 // returns a riak cluster of online riak nodes.
-func getRiakCluster(db *sqlx.DB, cfg Config) (StorageCluster, error) {
+func getRiakCluster(db *sqlx.DB, cfg config.Config) (StorageCluster, error) {
 	riakServerQuery := `
 		SELECT s.host_name, s.domain_name FROM server s 
 		INNER JOIN type t on s.type = t.id 
diff --git a/traffic_ops/traffic_ops_golang/routing.go b/traffic_ops/traffic_ops_golang/routing.go
index a940d5d..2fce1bb 100644
--- a/traffic_ops/traffic_ops_golang/routing.go
+++ b/traffic_ops/traffic_ops_golang/routing.go
@@ -32,6 +32,7 @@ import (
 	"fmt"
 
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/api"
+	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/config"
 	"github.com/jmoiron/sqlx"
 )
 
@@ -59,7 +60,7 @@ func getDefaultMiddleware() []Middleware {
 
 // ServerData ...
 type ServerData struct {
-	Config
+	config.Config
 	DB *sqlx.DB
 }
 
diff --git a/traffic_ops/traffic_ops_golang/traffic_ops_golang.go b/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
index af61ae8..d7c99ed 100644
--- a/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
+++ b/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
@@ -29,6 +29,7 @@ import (
 	"time"
 
 	"github.com/apache/incubator-trafficcontrol/lib/go-log"
+	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/config"
 
 	"github.com/jmoiron/sqlx"
 	_ "github.com/lib/pq"
@@ -48,10 +49,10 @@ func main() {
 		os.Exit(1)
 	}
 
-	var cfg Config
+	var cfg config.Config
 	var err error
 	var errorToLog error
-	if cfg, err = LoadConfig(*configFileName, *dbConfigFileName, *riakConfigFileName); err !=
nil {
+	if cfg, err = config.LoadConfig(*configFileName, *dbConfigFileName, *riakConfigFileName);
err != nil {
 		if !strings.Contains(err.Error(), "riak conf") {
 			fmt.Println("Error loading config: " + err.Error())
 			return

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

Mime
View raw message