From 8f505815d5e272e9afab6f90d839f38a1c9cc4da Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Thu, 23 Mar 2017 19:08:15 -0400 Subject: [PATCH 1/3] Updating wording. Removed vendoring section and some superfluous info. --- README.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index cd6af0f..ccc3c18 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ # gorealis [![GoDoc](https://godoc.org/github.com/rdelval/gorealis?status.svg)](https://godoc.org/github.com/rdelval/gorealis) -Go library for communicating with [Apache Aurora](https://github.com/apache/aurora). -Named after the northern lights (Aurora Borealis). +Go library for interacting with [Apache Aurora](https://github.com/apache/aurora). ### Aurora version compatibility Please see [.auroraversion](./.auroraversion) to see the latest Aurora version against which this -library has been tested. Vendoring a working version of this library is highly recommended. +library has been tested. ## Usage @@ -17,9 +16,5 @@ library has been tested. Vendoring a working version of this library is highly r * Create or import a custom transport that uses https://github.com/jmcvetta/napping to improve efficiency * End to end testing with Vagrant setup -## Importing -* We suggest using a vendoring tool such as [govendor](https://github.com/kardianos/govendor) and -fetching by version, for example: `govendor fetch github.com/rdelval/gorealis@v1` - ## Contributions -Contributions are very much welcome. Please raise an issue so that the contribution may be discussed before it's made. \ No newline at end of file +Contributions are always welcome. Please raise an issue so that the contribution may be discussed before it's made. \ No newline at end of file From cb6100e6909eac53e61151513b5654a0b5955f86 Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Thu, 23 Mar 2017 19:18:23 -0400 Subject: [PATCH 2/3] Reverted change made to vendored thrift library which caused some issues when vendoring gorealis itself. Added a workaround to overcome the default httpPostClient in the thrift library defaulting to headers for the thrift JSON protocol --- realis.go | 7 ++++++- .../git.apache.org/thrift.git/lib/go/thrift/http_client.go | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/realis.go b/realis.go index 339f07e..87b904c 100644 --- a/realis.go +++ b/realis.go @@ -31,6 +31,8 @@ import ( "github.com/rdelval/gorealis/response" ) +const VERSION = "1.0.4" + type Realis interface { AbortJobUpdate(updateKey aurora.JobUpdateKey, message string) (*aurora.Response, error) AddInstances(instKey aurora.InstanceKey, count int32) (*aurora.Response, error) @@ -225,6 +227,7 @@ func newTJSONConfig(url string, timeoutms int) (*RealisConfig, error) { httpTrans := (trans).(*thrift.THttpClient) httpTrans.SetHeader("Content-Type", "application/x-thrift") + httpTrans.SetHeader("User-Agent", "GoRealis v"+VERSION) return &RealisConfig{transport: trans, protoFactory: thrift.NewTJSONProtocolFactory()}, nil } @@ -237,9 +240,11 @@ func newTBinaryConfig(url string, timeoutms int) (*RealisConfig, error) { } httpTrans := (trans).(*thrift.THttpClient) + httpTrans.DelHeader("Content-Type") // Workaround for using thrift HttpPostClient + httpTrans.SetHeader("Accept", "application/vnd.apache.thrift.binary") httpTrans.SetHeader("Content-Type", "application/vnd.apache.thrift.binary") - httpTrans.SetHeader("User-Agent", "GoRealis v1.0.4") + httpTrans.SetHeader("User-Agent", "GoRealis v"+VERSION) return &RealisConfig{transport: trans, protoFactory: thrift.NewTBinaryProtocolFactoryDefault()}, nil diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client.go index f47b3cf..88eb2c1 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client.go +++ b/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client.go @@ -103,7 +103,7 @@ func NewTHttpClientWithOptions(urlstr string, options THttpClientOptions) (TTran if client == nil { client = DefaultHttpClient } - httpHeader := map[string][]string{} + httpHeader := map[string][]string{"Content-Type": []string{"application/x-thrift"}} return &THttpClient{client: client, response: response, url: parsedURL, header: httpHeader}, nil } @@ -121,7 +121,7 @@ func NewTHttpPostClientWithOptions(urlstr string, options THttpClientOptions) (T if client == nil { client = DefaultHttpClient } - httpHeader := map[string][]string{} + httpHeader := map[string][]string{"Content-Type": []string{"application/x-thrift"}} return &THttpClient{client: client, url: parsedURL, requestBuffer: bytes.NewBuffer(buf), header: httpHeader}, nil } From d27d8a47062e9678ca405be9c36244e786fdde69 Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Thu, 23 Mar 2017 20:44:45 -0400 Subject: [PATCH 3/3] Updated end to end test on vagrant images to reflect new client creation. --- realis_e2e_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/realis_e2e_test.go b/realis_e2e_test.go index bbcda61..465e085 100644 --- a/realis_e2e_test.go +++ b/realis_e2e_test.go @@ -28,8 +28,10 @@ var r Realis var thermosPayload []byte func TestMain(m *testing.M) { + var err error + // New configuration to connect to Vagrant image - config, err := NewDefaultConfig("http://192.168.33.7:8081",10000) + r, err = NewDefaultClientUsingUrl("http://192.168.33.7:8081","aurora", "secret") if err != nil { fmt.Println("Please run vagrant box before running test suite") os.Exit(1) @@ -41,10 +43,6 @@ func TestMain(m *testing.M) { os.Exit(1) } - // Configured for vagrant - AddBasicAuth(&config, "aurora", "secret") - r = NewClient(config) - os.Exit(m.Run()) }