dewrich closed pull request #1926: move config.go into its own package
URL: https://github.com/apache/incubator-trafficcontrol/pull/1926
 
 
   

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/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 8b47610f64..46d7142fbc 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 ee2b870fa0..49e61f4f88 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 cfd33f3869..c241a748f1 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 070ac750b6..c1e8e57488 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 af61ae8d66..d7c99ed3a1 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


 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to