You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2018/03/14 15:11:53 UTC

[incubator-trafficcontrol] branch master updated (b377089 -> cc5332d)

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

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


    from b377089  moved the migration to change the migration date
     new 0bd12df  add rpm release to about
     new 3109e60  remove log message
     new d86dd4b  remove obsolete /version route
     new f3aab7d  remove unused import
     new cc5332d  remove unused import

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 traffic_ops/build/traffic_ops.spec                 |  2 +-
 traffic_ops/traffic_ops_golang/about/about.go      | 52 +++++++++++-----------
 traffic_ops/traffic_ops_golang/about/about_test.go | 15 ++++---
 traffic_ops/traffic_ops_golang/routes.go           |  2 +-
 .../traffic_ops_golang/traffic_ops_golang.go       |  4 +-
 traffic_ops/traffic_ops_golang/wrappers.go         |  2 +-
 6 files changed, 41 insertions(+), 36 deletions(-)

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

[incubator-trafficcontrol] 05/05: remove unused import

Posted by de...@apache.org.
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

commit cc5332dd675d44093c67ef0747c145269308dd4a
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Wed Mar 14 09:07:13 2018 -0600

    remove unused import
---
 traffic_ops/traffic_ops_golang/wrappers.go | 1 -
 1 file changed, 1 deletion(-)

diff --git a/traffic_ops/traffic_ops_golang/wrappers.go b/traffic_ops/traffic_ops_golang/wrappers.go
index 4824d58..93b92c7 100644
--- a/traffic_ops/traffic_ops_golang/wrappers.go
+++ b/traffic_ops/traffic_ops_golang/wrappers.go
@@ -38,7 +38,6 @@ import (
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/about"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/auth"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/tocookie"
-	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/utils"
 	"github.com/jmoiron/sqlx"
 )
 

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

[incubator-trafficcontrol] 04/05: remove unused import

Posted by de...@apache.org.
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

commit f3aab7db8e0a3e056643d3fd8f0743d0467011b3
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Wed Mar 14 09:04:42 2018 -0600

    remove unused import
---
 traffic_ops/traffic_ops_golang/routes.go | 1 -
 1 file changed, 1 deletion(-)

diff --git a/traffic_ops/traffic_ops_golang/routes.go b/traffic_ops/traffic_ops_golang/routes.go
index 9f026b6..6fdf289 100644
--- a/traffic_ops/traffic_ops_golang/routes.go
+++ b/traffic_ops/traffic_ops_golang/routes.go
@@ -46,7 +46,6 @@ import (
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/status"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/systeminfo"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/types"
-	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/utils"
 
 	"github.com/basho/riak-go-client"
 )

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

[incubator-trafficcontrol] 01/05: add rpm release to about

Posted by de...@apache.org.
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

commit 0bd12df3c5cc2420fb7b78ff2b4a769994652eb1
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Tue Mar 13 13:45:14 2018 -0600

    add rpm release to about
---
 traffic_ops/build/traffic_ops.spec                 |  2 +-
 traffic_ops/traffic_ops_golang/about/about.go      | 52 +++++++++++-----------
 traffic_ops/traffic_ops_golang/about/about_test.go | 14 +++---
 traffic_ops/traffic_ops_golang/routes.go           |  6 ++-
 .../traffic_ops_golang/traffic_ops_golang.go       |  4 +-
 traffic_ops/traffic_ops_golang/wrappers.go         |  3 +-
 6 files changed, 46 insertions(+), 35 deletions(-)

diff --git a/traffic_ops/build/traffic_ops.spec b/traffic_ops/build/traffic_ops.spec
index 326bcf6..ded298d 100644
--- a/traffic_ops/build/traffic_ops.spec
+++ b/traffic_ops/build/traffic_ops.spec
@@ -104,7 +104,7 @@ Built: %(date) by %{getenv: USER}
       #echo "go getting at $(pwd)" && \
       #go get -d -v && \
       echo "go building at $(pwd)" && \
-      go build -ldflags "-X main.version=%{version}-%{release} -B 0x`git rev-parse HEAD`" \
+      go build -ldflags "-X main.version=traffic_ops-%{version}-%{release} -B 0x`git rev-parse HEAD`" \
     ) || { echo "Could not build go program at $(pwd): $!"; exit 1; }
 
 %install
diff --git a/traffic_ops/traffic_ops_golang/about/about.go b/traffic_ops/traffic_ops_golang/about/about.go
index 3670365..8a4e674 100644
--- a/traffic_ops/traffic_ops_golang/about/about.go
+++ b/traffic_ops/traffic_ops_golang/about/about.go
@@ -28,52 +28,54 @@ import (
 
 // about allows access to the version info identified at build time
 type about struct {
-	CommitHash           string `json:"commitHash,omitempty"`
-	Commits              string `json:"commits,omitempty"`
-	GoVersion            string `json:"goVersion,omitempty"`
-	TrafficOpsName       string `json:"name,omitempty"`
-	TrafficOpsRPMVersion string `json:"trafficOpsRPMVersion,omitempty"`
-	TrafficOpsVersion    string `json:"trafficOpsVersion,omitempty"`
+	CommitHash string `json:"commitHash,omitempty"`
+	Commits    string `json:"commits,omitempty"`
+	GoVersion  string `json:"goVersion,omitempty"`
+	Release    string `json:"release"`
+	Name       string `json:"name,omitempty"`
+	RPMVersion string `json:"RPMVersion,omitempty"`
+	Version    string `json:"Version,omitempty"`
 }
 
 // About contains version info to be exposed by `api/.../about.json` endpoint
 var About about
 
-func splitRPMVersion(v string) (string, string, string, string) {
+func splitRPMVersion(v string) (string, string, string, string, string) {
 
 	if v == "" {
-		return "UnknownVersion", "", "", ""
+		return "UnknownVersion", "", "", "", ""
 	}
-	// RPM version is something like traffic_ops-2.3.0-8765.a0b1c3d4
-	//  -- if not of that form, Name, Version, Commits, CommitHash may be missing
+	// RPM version is something like traffic_ops-2.3.0-8765.a0b1c3d4.el7
+	//  -- if not of that form, Name, Version, Commits, CommitHash, Release may be missing
 	s := strings.SplitN(v, "-", 3)
 	if len(s) >= 3 {
 		// 3rd field is commits.hash
-		t := strings.SplitN(s[2], ".", 2)
+		t := strings.SplitN(s[2], ".", 3)
 		s = append(s[0:2], t...)
 	}
-	for cap(s) < 4 {
+	for len(s) < 5 {
 		s = append(s, "")
 	}
-	return s[0], s[1], s[2], s[3]
+	return s[0], s[1], s[2], s[3], s[4]
 }
 
-func init() {
-	// name, version, commits, hash -- parts of rpm version string
-	n, v, c, h := splitRPMVersion(About.TrafficOpsRPMVersion)
+// SetAbout is called by main.main to store the static info for the .../about endpoint
+func SetAbout(s string) {
+	// name, version, commits, hash, Release -- parts of rpm version string
+	n, v, c, h, r := splitRPMVersion(s)
 	About = about{
-		GoVersion:            runtime.Version(),
-		TrafficOpsRPMVersion: About.TrafficOpsRPMVersion,
-		TrafficOpsName:       n,
-		TrafficOpsVersion:    v,
-		Commits:              c,
-		CommitHash:           h,
+		CommitHash: h,
+		Commits:    c,
+		GoVersion:  runtime.Version(),
+		Release:    r,
+		Name:       n,
+		RPMVersion: s,
+		Version:    v,
 	}
-
 }
 
-// AboutHandler returns info about running Traffic Ops
-func AboutHandler() http.HandlerFunc {
+// Handler returns info about running Traffic Ops
+func Handler() http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		w.Header().Set("Content-Type", "application/json")
 
diff --git a/traffic_ops/traffic_ops_golang/about/about_test.go b/traffic_ops/traffic_ops_golang/about/about_test.go
index 19f5a0c..1701982 100644
--- a/traffic_ops/traffic_ops_golang/about/about_test.go
+++ b/traffic_ops/traffic_ops_golang/about/about_test.go
@@ -23,16 +23,17 @@ import (
 	"testing"
 )
 
-var testSet = map[string][]string{
-	"test0-0.1.0-1234.01ab23cd": []string{"test0", "0.1.0", "1234", "01ab23cd"},
-	"test1-0.2.0":               []string{"test1", "0.2.0", "", ""},
-	"test2":                     []string{"test2", "", "", ""},
+var testSet = map[string][5]string{
+	"traffic_ops-2.3.0-8095.fd4fc11a.el7": [5]string{"traffic_ops", "2.3.0", "8095", "fd4fc11a", "el7"},
+	"test0-0.1.0-1234.01ab23cd.el7":       [5]string{"test0", "0.1.0", "1234", "01ab23cd", "el7"},
+	"test1-0.2.0":                         [5]string{"test1", "0.2.0", "", ""},
+	"test2":                               [5]string{"test2", "", "", ""},
 }
 
 func TestSplitRPMVersion(t *testing.T) {
 	for s, e := range testSet {
 		t.Logf("Testing %s %v", s, e)
-		n, v, c, h := splitRPMVersion(s)
+		n, v, c, h, a := splitRPMVersion(s)
 
 		if n != e[0] {
 			t.Errorf("expected name '%s', got '%s'", n, e[0])
@@ -46,5 +47,8 @@ func TestSplitRPMVersion(t *testing.T) {
 		if h != e[3] {
 			t.Errorf("expected commitHash '%s', got '%s'", h, e[3])
 		}
+		if a != e[4] {
+			t.Errorf("expected commitHash '%s', got '%s'", h, e[4])
+		}
 	}
 }
diff --git a/traffic_ops/traffic_ops_golang/routes.go b/traffic_ops/traffic_ops_golang/routes.go
index 2ecef92..d8c2b31 100644
--- a/traffic_ops/traffic_ops_golang/routes.go
+++ b/traffic_ops/traffic_ops_golang/routes.go
@@ -46,6 +46,7 @@ import (
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/status"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/systeminfo"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/types"
+	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/utils"
 
 	"github.com/basho/riak-go-client"
 )
@@ -68,7 +69,7 @@ func Routes(d ServerData) ([]Route, http.Handler, error) {
 
 	routes := []Route{
 		//About
-		{1.3, http.MethodGet, `about/?(\.json)?$`, about.AboutHandler(), auth.PrivLevelReadOnly, Authenticated, nil},
+		{1.3, http.MethodGet, `about/?(\.json)?$`, about.Handler(), auth.PrivLevelReadOnly, Authenticated, nil},
 
 		// Proxied routes
 		//CDNs
@@ -190,6 +191,9 @@ func Routes(d ServerData) ([]Route, http.Handler, error) {
 
 		//System
 		{1.2, http.MethodGet, `system/info/?(\.json)?$`, systeminfo.Handler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil},
+
+		//Version
+		{1.3, http.MethodGet, `version$`, utils.VersionHandler(), auth.PrivLevelReadOnly, Authenticated, nil},
 	}
 	return routes, proxyHandler, nil
 }
diff --git a/traffic_ops/traffic_ops_golang/traffic_ops_golang.go b/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
index cc95281..a361e14 100644
--- a/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
+++ b/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
@@ -40,7 +40,7 @@ import (
 var version = "development"
 
 func init() {
-	about.About.TrafficOpsRPMVersion = version
+	about.SetAbout(version)
 }
 
 func main() {
@@ -51,7 +51,7 @@ func main() {
 	flag.Parse()
 
 	if *showVersion {
-		fmt.Println(about.About.TrafficOpsRPMVersion)
+		fmt.Println(about.About.RPMVersion)
 		os.Exit(0)
 	}
 	if len(os.Args) < 2 {
diff --git a/traffic_ops/traffic_ops_golang/wrappers.go b/traffic_ops/traffic_ops_golang/wrappers.go
index 6f5cb04..4824d58 100644
--- a/traffic_ops/traffic_ops_golang/wrappers.go
+++ b/traffic_ops/traffic_ops_golang/wrappers.go
@@ -38,11 +38,12 @@ import (
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/about"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/auth"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/tocookie"
+	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/utils"
 	"github.com/jmoiron/sqlx"
 )
 
 // ServerName - the server identifier
-var ServerName = "traffic_ops_golang" + "/" + about.About.TrafficOpsVersion
+var ServerName = "traffic_ops_golang" + "/" + about.About.Version
 
 // AuthBase ...
 type AuthBase struct {

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

[incubator-trafficcontrol] 03/05: remove obsolete /version route

Posted by de...@apache.org.
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

commit d86dd4b3b095c454e701eaaa022f229bca7d68f4
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Wed Mar 14 09:01:43 2018 -0600

    remove obsolete /version route
---
 traffic_ops/traffic_ops_golang/routes.go | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/routes.go b/traffic_ops/traffic_ops_golang/routes.go
index d8c2b31..9f026b6 100644
--- a/traffic_ops/traffic_ops_golang/routes.go
+++ b/traffic_ops/traffic_ops_golang/routes.go
@@ -191,9 +191,6 @@ func Routes(d ServerData) ([]Route, http.Handler, error) {
 
 		//System
 		{1.2, http.MethodGet, `system/info/?(\.json)?$`, systeminfo.Handler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil},
-
-		//Version
-		{1.3, http.MethodGet, `version$`, utils.VersionHandler(), auth.PrivLevelReadOnly, Authenticated, nil},
 	}
 	return routes, proxyHandler, nil
 }

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

[incubator-trafficcontrol] 02/05: remove log message

Posted by de...@apache.org.
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

commit 3109e60d506d00d48f7f93767124f6054c40ff3f
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Wed Mar 14 08:55:27 2018 -0600

    remove log message
---
 traffic_ops/traffic_ops_golang/about/about_test.go | 1 -
 1 file changed, 1 deletion(-)

diff --git a/traffic_ops/traffic_ops_golang/about/about_test.go b/traffic_ops/traffic_ops_golang/about/about_test.go
index 1701982..5aefacd 100644
--- a/traffic_ops/traffic_ops_golang/about/about_test.go
+++ b/traffic_ops/traffic_ops_golang/about/about_test.go
@@ -32,7 +32,6 @@ var testSet = map[string][5]string{
 
 func TestSplitRPMVersion(t *testing.T) {
 	for s, e := range testSet {
-		t.Logf("Testing %s %v", s, e)
 		n, v, c, h, a := splitRPMVersion(s)
 
 		if n != e[0] {

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