From b761b4248948d631212df123c313fa33aa48fbdc Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 20 Mar 2018 10:45:40 +0100 Subject: [PATCH] Feature/admin auth (#13) * add admin auth config variables * update readme * code format * rename basic auth variables and envs * update readme * update gokong with govendor * just rebuild * merge * update newest commit * can be null * fix name * lowercase for variables --- README.md | 9 ++++++++ kong/provider.go | 22 +++++++++++++++++++ kong/provider_test.go | 8 +++++++ .../github.com/kevholditch/gokong/README.md | 13 +++++++++++ vendor/github.com/kevholditch/gokong/apis.go | 13 +++++------ .../kevholditch/gokong/certificates.go | 11 +++++----- .../github.com/kevholditch/gokong/client.go | 12 ++++++++++ .../kevholditch/gokong/consumers.go | 17 +++++++------- .../github.com/kevholditch/gokong/plugins.go | 11 +++++----- .../github.com/kevholditch/gokong/request.go | 13 +++++++++++ vendor/github.com/kevholditch/gokong/snis.go | 11 +++++----- .../github.com/kevholditch/gokong/status.go | 3 +-- .../kevholditch/gokong/upstreams.go | 11 +++++----- vendor/vendor.json | 6 ++--- 14 files changed, 114 insertions(+), 46 deletions(-) create mode 100644 vendor/github.com/kevholditch/gokong/request.go diff --git a/README.md b/README.md index 79205c76..e6e91c5f 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,15 @@ provider "kong" { } ``` +Optionaly you can configure Username and Password for BasicAuth: +```hcl +provider "kong" { + kong_admin_uri = "http://myKong:8001" + kong_admin_username = "youruser" + kong_admin_password = "yourpass" +} +``` + By convention the provider will first check the env variable `KONG_ADMIN_ADDR` if that variable is not set then it will default to `http://localhost:8001` if you do not provide a provider block as above. diff --git a/kong/provider.go b/kong/provider.go index dc8bc922..122340b9 100644 --- a/kong/provider.go +++ b/kong/provider.go @@ -16,6 +16,18 @@ func Provider() terraform.ResourceProvider { DefaultFunc: envDefaultFuncWithDefault("KONG_ADMIN_ADDR", "http://localhost:8001"), Description: "The address of the kong admin url e.g. http://localhost:8001", }, + "kong_admin_usermame": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + DefaultFunc: envDefaultFuncWithDefault("KONG_ADMIN_USERNAME", ""), + Description: "An basic auth user for kong admin", + }, + "kong_admin_password": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + DefaultFunc: envDefaultFuncWithDefault("KONG_ADMIN_PASSWORD", ""), + Description: "An basic auth password for kong admin", + }, }, ResourcesMap: map[string]*schema.Resource{ @@ -54,8 +66,18 @@ func envDefaultFuncWithDefault(key string, defaultValue string) schema.SchemaDef } func providerConfigure(d *schema.ResourceData) (interface{}, error) { + username := "" + if d.Get("kong_admin_username") != nil { + username = d.Get("kong_admin_username").(string) + } + password := "" + if d.Get("kong_admin_password") != nil { + password = d.Get("kong_admin_password").(string) + } config := &gokong.Config{ HostAddress: d.Get("kong_admin_uri").(string), + Username: username, + Password: password, } return gokong.NewClient(config), nil diff --git a/kong/provider_test.go b/kong/provider_test.go index 883fc80e..af5d36d6 100644 --- a/kong/provider_test.go +++ b/kong/provider_test.go @@ -40,6 +40,14 @@ func TestMain(m *testing.M) { if err != nil { log.Fatalf("Could not set kong host address env variable: %v", err) } + err = os.Setenv(gokong.EnvKongAdminPassword, "AnUsername") + if err != nil { + log.Fatalf("Could not set kong admin username env variable: %v", err) + } + err = os.Setenv(gokong.EnvKongAdminPassword, "AnyPassword") + if err != nil { + log.Fatalf("Could not set kong admin password env variable: %v", err) + } code := m.Run() diff --git a/vendor/github.com/kevholditch/gokong/README.md b/vendor/github.com/kevholditch/gokong/README.md index da5e5353..42c58954 100644 --- a/vendor/github.com/kevholditch/gokong/README.md +++ b/vendor/github.com/kevholditch/gokong/README.md @@ -7,6 +7,14 @@ A kong go client fully tested with no mocks!! ## GoKong GoKong is a easy to use api client for [kong](https://getkong.org/). The difference with the gokong library is all of its tests are written against a real running kong running inside a docker container, yep that's right you won't see a horrible mock anywhere!! +## Supported Kong Versions +As per [travis build](https://travis-ci.org/kevholditch/gokong): +``` +KONG_VERSION=0.11 +KONG_VERSION=0.11.1 +KONG_VERSION=0.11.2 +``` + ## Importing To add gokong via `go get`: @@ -41,6 +49,11 @@ You can of course create your own config with the address set to whatever you wa config := gokong.Config{HostAddress:"http://localhost:1234"} ``` +Also you can apply Username and Password for admin-api Basic Auth: +```go +config := gokong.Config{HostAddress:"http://localhost:1234",Username:"adminuser",Password:"yoursecret"} +``` + Getting the status of the kong server: ```go diff --git a/vendor/github.com/kevholditch/gokong/apis.go b/vendor/github.com/kevholditch/gokong/apis.go index 10998bed..b56464c4 100644 --- a/vendor/github.com/kevholditch/gokong/apis.go +++ b/vendor/github.com/kevholditch/gokong/apis.go @@ -3,8 +3,6 @@ package gokong import ( "encoding/json" "fmt" - - "github.com/parnurzeal/gorequest" ) type ApiClient struct { @@ -68,8 +66,7 @@ func (apiClient *ApiClient) GetByName(name string) (*Api, error) { } func (apiClient *ApiClient) GetById(id string) (*Api, error) { - - _, body, errs := gorequest.New().Get(apiClient.config.HostAddress + ApisPath + id).End() + _, body, errs := NewRequest(apiClient.config).Get(apiClient.config.HostAddress+ApisPath+id).Set("If-None-Match", `W/"wyzzy"`).End() if errs != nil { return nil, fmt.Errorf("could not get api, error: %v", errs) } @@ -99,7 +96,7 @@ func (apiClient *ApiClient) ListFiltered(filter *ApiFilter) (*Apis, error) { return nil, fmt.Errorf("could not build query string for apis filter, error: %v", err) } - _, body, errs := gorequest.New().Get(address).End() + _, body, errs := NewRequest(apiClient.config).Get(address).End() if errs != nil { return nil, fmt.Errorf("could not get apis, error: %v", errs) } @@ -115,7 +112,7 @@ func (apiClient *ApiClient) ListFiltered(filter *ApiFilter) (*Apis, error) { func (apiClient *ApiClient) Create(newApi *ApiRequest) (*Api, error) { - _, body, errs := gorequest.New().Post(apiClient.config.HostAddress + ApisPath).Send(newApi).End() + _, body, errs := NewRequest(apiClient.config).Post(apiClient.config.HostAddress + ApisPath).Send(newApi).End() if errs != nil { return nil, fmt.Errorf("could not create new api, error: %v", errs) } @@ -139,7 +136,7 @@ func (apiClient *ApiClient) DeleteByName(name string) error { func (apiClient *ApiClient) DeleteById(id string) error { - res, _, errs := gorequest.New().Delete(apiClient.config.HostAddress + ApisPath + id).End() + res, _, errs := NewRequest(apiClient.config).Delete(apiClient.config.HostAddress + ApisPath + id).End() if errs != nil { return fmt.Errorf("could not delete api, result: %v error: %v", res, errs) } @@ -153,7 +150,7 @@ func (apiClient *ApiClient) UpdateByName(name string, apiRequest *ApiRequest) (* func (apiClient *ApiClient) UpdateById(id string, apiRequest *ApiRequest) (*Api, error) { - _, body, errs := gorequest.New().Patch(apiClient.config.HostAddress + ApisPath + id).Send(apiRequest).End() + _, body, errs := NewRequest(apiClient.config).Patch(apiClient.config.HostAddress + ApisPath + id).Send(apiRequest).End() if errs != nil { return nil, fmt.Errorf("could not update api, error: %v", errs) } diff --git a/vendor/github.com/kevholditch/gokong/certificates.go b/vendor/github.com/kevholditch/gokong/certificates.go index 616f8fe3..bbb15b82 100644 --- a/vendor/github.com/kevholditch/gokong/certificates.go +++ b/vendor/github.com/kevholditch/gokong/certificates.go @@ -3,7 +3,6 @@ package gokong import ( "encoding/json" "fmt" - "github.com/parnurzeal/gorequest" ) type CertificateClient struct { @@ -30,7 +29,7 @@ const CertificatesPath = "/certificates/" func (certificateClient *CertificateClient) GetById(id string) (*Certificate, error) { - _, body, errs := gorequest.New().Get(certificateClient.config.HostAddress + CertificatesPath + id).End() + _, body, errs := NewRequest(certificateClient.config).Get(certificateClient.config.HostAddress + CertificatesPath + id).End() if errs != nil { return nil, fmt.Errorf("could not get certificate, error: %v", errs) } @@ -50,7 +49,7 @@ func (certificateClient *CertificateClient) GetById(id string) (*Certificate, er func (certificateClient *CertificateClient) Create(certificateRequest *CertificateRequest) (*Certificate, error) { - _, body, errs := gorequest.New().Post(certificateClient.config.HostAddress + CertificatesPath).Send(certificateRequest).End() + _, body, errs := NewRequest(certificateClient.config).Post(certificateClient.config.HostAddress + CertificatesPath).Send(certificateRequest).End() if errs != nil { return nil, fmt.Errorf("could not create new certificate, error: %v", errs) } @@ -70,7 +69,7 @@ func (certificateClient *CertificateClient) Create(certificateRequest *Certifica func (certificateClient *CertificateClient) DeleteById(id string) error { - res, _, errs := gorequest.New().Delete(certificateClient.config.HostAddress + CertificatesPath + id).End() + res, _, errs := NewRequest(certificateClient.config).Delete(certificateClient.config.HostAddress + CertificatesPath + id).End() if errs != nil { return fmt.Errorf("could not delete certificate, result: %v error: %v", res, errs) } @@ -80,7 +79,7 @@ func (certificateClient *CertificateClient) DeleteById(id string) error { func (certificateClient *CertificateClient) List() (*Certificates, error) { - _, body, errs := gorequest.New().Get(certificateClient.config.HostAddress + CertificatesPath).End() + _, body, errs := NewRequest(certificateClient.config).Get(certificateClient.config.HostAddress + CertificatesPath).End() if errs != nil { return nil, fmt.Errorf("could not get certificates, error: %v", errs) } @@ -96,7 +95,7 @@ func (certificateClient *CertificateClient) List() (*Certificates, error) { func (certificateClient *CertificateClient) UpdateById(id string, certificateRequest *CertificateRequest) (*Certificate, error) { - _, body, errs := gorequest.New().Patch(certificateClient.config.HostAddress + CertificatesPath + id).Send(certificateRequest).End() + _, body, errs := NewRequest(certificateClient.config).Patch(certificateClient.config.HostAddress + CertificatesPath + id).Send(certificateRequest).End() if errs != nil { return nil, fmt.Errorf("could not update certificate, error: %v", errs) } diff --git a/vendor/github.com/kevholditch/gokong/client.go b/vendor/github.com/kevholditch/gokong/client.go index 9ff4db5e..f66e3d12 100644 --- a/vendor/github.com/kevholditch/gokong/client.go +++ b/vendor/github.com/kevholditch/gokong/client.go @@ -9,6 +9,8 @@ import ( ) const EnvKongAdminHostAddress = "KONG_ADMIN_ADDR" +const EnvKongAdminUsername = "KONG_ADMIN_USERNAME" +const EnvKongAdminPassword = "KONG_ADMIN_PASSWORD" type KongAdminClient struct { config *Config @@ -16,6 +18,8 @@ type KongAdminClient struct { type Config struct { HostAddress string + Username string + Password string } func addQueryString(currentUrl string, filter interface{}) (string, error) { @@ -41,11 +45,19 @@ func addQueryString(currentUrl string, filter interface{}) (string, error) { func NewDefaultConfig() *Config { config := &Config{ HostAddress: "http://localhost:8001", + Username: "", + Password: "", } if os.Getenv(EnvKongAdminHostAddress) != "" { config.HostAddress = strings.TrimRight(os.Getenv(EnvKongAdminHostAddress), "/") } + if os.Getenv(EnvKongAdminHostAddress) != "" { + config.Username = os.Getenv(EnvKongAdminUsername) + } + if os.Getenv(EnvKongAdminPassword) != "" { + config.Password = os.Getenv(EnvKongAdminPassword) + } return config } diff --git a/vendor/github.com/kevholditch/gokong/consumers.go b/vendor/github.com/kevholditch/gokong/consumers.go index d9f0c81a..71b33407 100644 --- a/vendor/github.com/kevholditch/gokong/consumers.go +++ b/vendor/github.com/kevholditch/gokong/consumers.go @@ -3,7 +3,6 @@ package gokong import ( "encoding/json" "fmt" - "github.com/parnurzeal/gorequest" ) type ConsumerClient struct { @@ -48,7 +47,7 @@ func (consumerClient *ConsumerClient) GetByUsername(username string) (*Consumer, func (consumerClient *ConsumerClient) GetById(id string) (*Consumer, error) { - _, body, errs := gorequest.New().Get(consumerClient.config.HostAddress + ConsumersPath + id).End() + _, body, errs := NewRequest(consumerClient.config).Get(consumerClient.config.HostAddress + ConsumersPath + id).End() if errs != nil { return nil, fmt.Errorf("could not get consumer, error: %v", errs) } @@ -68,7 +67,7 @@ func (consumerClient *ConsumerClient) GetById(id string) (*Consumer, error) { func (consumerClient *ConsumerClient) Create(consumerRequest *ConsumerRequest) (*Consumer, error) { - _, body, errs := gorequest.New().Post(consumerClient.config.HostAddress + ConsumersPath).Send(consumerRequest).End() + _, body, errs := NewRequest(consumerClient.config).Post(consumerClient.config.HostAddress + ConsumersPath).Send(consumerRequest).End() if errs != nil { return nil, fmt.Errorf("could not create new consumer, error: %v", errs) } @@ -98,7 +97,7 @@ func (consumerClient *ConsumerClient) ListFiltered(filter *ConsumerFilter) (*Con return nil, fmt.Errorf("could not build query string for consumer filter, error: %v", err) } - _, body, errs := gorequest.New().Get(address).End() + _, body, errs := NewRequest(consumerClient.config).Get(address).End() if errs != nil { return nil, fmt.Errorf("could not get consumers, error: %v", errs) } @@ -118,7 +117,7 @@ func (consumerClient *ConsumerClient) DeleteByUsername(username string) error { func (consumerClient *ConsumerClient) DeleteById(id string) error { - res, _, errs := gorequest.New().Delete(consumerClient.config.HostAddress + ConsumersPath + id).End() + res, _, errs := NewRequest(consumerClient.config).Delete(consumerClient.config.HostAddress + ConsumersPath + id).End() if errs != nil { return fmt.Errorf("could not delete consumer, result: %v error: %v", res, errs) } @@ -132,7 +131,7 @@ func (consumerClient *ConsumerClient) UpdateByUsername(username string, consumer func (consumerClient *ConsumerClient) UpdateById(id string, consumerRequest *ConsumerRequest) (*Consumer, error) { - _, body, errs := gorequest.New().Patch(consumerClient.config.HostAddress + ConsumersPath + id).Send(consumerRequest).End() + _, body, errs := NewRequest(consumerClient.config).Patch(consumerClient.config.HostAddress + ConsumersPath + id).Send(consumerRequest).End() if errs != nil { return nil, fmt.Errorf("could not update consumer, error: %v", errs) } @@ -152,7 +151,7 @@ func (consumerClient *ConsumerClient) UpdateById(id string, consumerRequest *Con func (consumerClient *ConsumerClient) CreatePluginConfig(consumerId string, pluginName string, pluginConfig string) (*ConsumerPluginConfig, error) { - _, body, errs := gorequest.New().Post(consumerClient.config.HostAddress + ConsumersPath + consumerId + "/" + pluginName).Send(pluginConfig).End() + _, body, errs := NewRequest(consumerClient.config).Post(consumerClient.config.HostAddress + ConsumersPath + consumerId + "/" + pluginName).Send(pluginConfig).End() if errs != nil { return nil, fmt.Errorf("could not configure plugin for consumer, error: %v", errs) } @@ -174,7 +173,7 @@ func (consumerClient *ConsumerClient) CreatePluginConfig(consumerId string, plug func (consumerClient *ConsumerClient) GetPluginConfig(consumerId string, pluginName string, id string) (*ConsumerPluginConfig, error) { - _, body, errs := gorequest.New().Get(consumerClient.config.HostAddress + ConsumersPath + consumerId + "/" + pluginName + "/" + id).End() + _, body, errs := NewRequest(consumerClient.config).Get(consumerClient.config.HostAddress + ConsumersPath + consumerId + "/" + pluginName + "/" + id).End() if errs != nil { return nil, fmt.Errorf("could not get plugin config for consumer, error: %v", errs) } @@ -196,7 +195,7 @@ func (consumerClient *ConsumerClient) GetPluginConfig(consumerId string, pluginN func (consumerClient *ConsumerClient) DeletePluginConfig(consumerId string, pluginName string, id string) error { - _, _, errs := gorequest.New().Delete(consumerClient.config.HostAddress + ConsumersPath + consumerId + "/" + pluginName + "/" + id).End() + _, _, errs := NewRequest(consumerClient.config).Delete(consumerClient.config.HostAddress + ConsumersPath + consumerId + "/" + pluginName + "/" + id).End() if errs != nil { return fmt.Errorf("could not delete plugin config for consumer, error: %v", errs) } diff --git a/vendor/github.com/kevholditch/gokong/plugins.go b/vendor/github.com/kevholditch/gokong/plugins.go index 5f667c9b..190d54e5 100644 --- a/vendor/github.com/kevholditch/gokong/plugins.go +++ b/vendor/github.com/kevholditch/gokong/plugins.go @@ -3,7 +3,6 @@ package gokong import ( "encoding/json" "fmt" - "github.com/parnurzeal/gorequest" ) type PluginClient struct { @@ -45,7 +44,7 @@ const PluginsPath = "/plugins/" func (pluginClient *PluginClient) GetById(id string) (*Plugin, error) { - _, body, errs := gorequest.New().Get(pluginClient.config.HostAddress + PluginsPath + id).End() + _, body, errs := NewRequest(pluginClient.config).Get(pluginClient.config.HostAddress + PluginsPath + id).End() if errs != nil { return nil, fmt.Errorf("could not get plugin, error: %v", errs) } @@ -75,7 +74,7 @@ func (pluginClient *PluginClient) ListFiltered(filter *PluginFilter) (*Plugins, return nil, fmt.Errorf("could not build query string for plugins filter, error: %v", err) } - _, body, errs := gorequest.New().Get(address).End() + _, body, errs := NewRequest(pluginClient.config).Get(address).End() if errs != nil { return nil, fmt.Errorf("could not get plugins, error: %v", errs) } @@ -91,7 +90,7 @@ func (pluginClient *PluginClient) ListFiltered(filter *PluginFilter) (*Plugins, func (pluginClient *PluginClient) Create(pluginRequest *PluginRequest) (*Plugin, error) { - _, body, errs := gorequest.New().Post(pluginClient.config.HostAddress + PluginsPath).Send(pluginRequest).End() + _, body, errs := NewRequest(pluginClient.config).Post(pluginClient.config.HostAddress + PluginsPath).Send(pluginRequest).End() if errs != nil { return nil, fmt.Errorf("could not create new plugin, error: %v", errs) } @@ -111,7 +110,7 @@ func (pluginClient *PluginClient) Create(pluginRequest *PluginRequest) (*Plugin, func (pluginClient *PluginClient) UpdateById(id string, pluginRequest *PluginRequest) (*Plugin, error) { - _, body, errs := gorequest.New().Patch(pluginClient.config.HostAddress + PluginsPath + id).Send(pluginRequest).End() + _, body, errs := NewRequest(pluginClient.config).Patch(pluginClient.config.HostAddress + PluginsPath + id).Send(pluginRequest).End() if errs != nil { return nil, fmt.Errorf("could not update plugin, error: %v", errs) } @@ -131,7 +130,7 @@ func (pluginClient *PluginClient) UpdateById(id string, pluginRequest *PluginReq func (pluginClient *PluginClient) DeleteById(id string) error { - res, _, errs := gorequest.New().Delete(pluginClient.config.HostAddress + PluginsPath + id).End() + res, _, errs := NewRequest(pluginClient.config).Delete(pluginClient.config.HostAddress + PluginsPath + id).End() if errs != nil { return fmt.Errorf("could not delete plugin, result: %v error: %v", res, errs) } diff --git a/vendor/github.com/kevholditch/gokong/request.go b/vendor/github.com/kevholditch/gokong/request.go new file mode 100644 index 00000000..8b482913 --- /dev/null +++ b/vendor/github.com/kevholditch/gokong/request.go @@ -0,0 +1,13 @@ +package gokong + +import ( + "github.com/parnurzeal/gorequest" +) + +func NewRequest(adminConfig *Config) *gorequest.SuperAgent { + request := gorequest.New() + if adminConfig.Username != "" || adminConfig.Password != "" { + request.SetBasicAuth(adminConfig.Username, adminConfig.Password) + } + return request +} diff --git a/vendor/github.com/kevholditch/gokong/snis.go b/vendor/github.com/kevholditch/gokong/snis.go index a9bb9171..74ed7b5a 100644 --- a/vendor/github.com/kevholditch/gokong/snis.go +++ b/vendor/github.com/kevholditch/gokong/snis.go @@ -3,7 +3,6 @@ package gokong import ( "encoding/json" "fmt" - "github.com/parnurzeal/gorequest" ) type SnisClient struct { @@ -29,7 +28,7 @@ const SnisPath = "/snis/" func (snisClient *SnisClient) Create(snisRequest *SnisRequest) (*Sni, error) { - _, body, errs := gorequest.New().Post(snisClient.config.HostAddress + SnisPath).Send(snisRequest).End() + _, body, errs := NewRequest(snisClient.config).Post(snisClient.config.HostAddress + SnisPath).Send(snisRequest).End() if errs != nil { return nil, fmt.Errorf("could not create new sni, error: %v", errs) } @@ -49,7 +48,7 @@ func (snisClient *SnisClient) Create(snisRequest *SnisRequest) (*Sni, error) { func (snisClient *SnisClient) GetByName(name string) (*Sni, error) { - _, body, errs := gorequest.New().Get(snisClient.config.HostAddress + SnisPath + name).End() + _, body, errs := NewRequest(snisClient.config).Get(snisClient.config.HostAddress + SnisPath + name).End() if errs != nil { return nil, fmt.Errorf("could not get sni, error: %v", errs) } @@ -69,7 +68,7 @@ func (snisClient *SnisClient) GetByName(name string) (*Sni, error) { func (snisClient *SnisClient) List() (*Snis, error) { - _, body, errs := gorequest.New().Get(snisClient.config.HostAddress + SnisPath).End() + _, body, errs := NewRequest(snisClient.config).Get(snisClient.config.HostAddress + SnisPath).End() if errs != nil { return nil, fmt.Errorf("could not get snis, error: %v", errs) } @@ -85,7 +84,7 @@ func (snisClient *SnisClient) List() (*Snis, error) { func (snisClient *SnisClient) DeleteByName(name string) error { - res, _, errs := gorequest.New().Delete(snisClient.config.HostAddress + SnisPath + name).End() + res, _, errs := NewRequest(snisClient.config).Delete(snisClient.config.HostAddress + SnisPath + name).End() if errs != nil { return fmt.Errorf("could not delete sni, result: %v error: %v", res, errs) } @@ -95,7 +94,7 @@ func (snisClient *SnisClient) DeleteByName(name string) error { func (snisClient *SnisClient) UpdateByName(name string, snisRequest *SnisRequest) (*Sni, error) { - _, body, errs := gorequest.New().Patch(snisClient.config.HostAddress + SnisPath + name).Send(snisRequest).End() + _, body, errs := NewRequest(snisClient.config).Patch(snisClient.config.HostAddress + SnisPath + name).Send(snisRequest).End() if errs != nil { return nil, fmt.Errorf("could not update sni, error: %v", errs) } diff --git a/vendor/github.com/kevholditch/gokong/status.go b/vendor/github.com/kevholditch/gokong/status.go index e3439652..ad8f1205 100644 --- a/vendor/github.com/kevholditch/gokong/status.go +++ b/vendor/github.com/kevholditch/gokong/status.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/parnurzeal/gorequest" ) type StatusClient struct { @@ -32,7 +31,7 @@ type databaseStatus struct { func (statusClient *StatusClient) Get() (*Status, error) { - _, body, errs := gorequest.New().Get(statusClient.config.HostAddress + "/status").End() + _, body, errs := NewRequest(statusClient.config).Get(statusClient.config.HostAddress + "/status").End() if errs != nil { return nil, errors.New(fmt.Sprintf("Could not call get status, error: %v", errs)) } diff --git a/vendor/github.com/kevholditch/gokong/upstreams.go b/vendor/github.com/kevholditch/gokong/upstreams.go index cb12baac..aeae6a0c 100644 --- a/vendor/github.com/kevholditch/gokong/upstreams.go +++ b/vendor/github.com/kevholditch/gokong/upstreams.go @@ -3,7 +3,6 @@ package gokong import ( "encoding/json" "fmt" - "github.com/parnurzeal/gorequest" ) type UpstreamClient struct { @@ -46,7 +45,7 @@ func (upstreamClient *UpstreamClient) GetByName(name string) (*Upstream, error) func (upstreamClient *UpstreamClient) GetById(id string) (*Upstream, error) { - _, body, errs := gorequest.New().Get(upstreamClient.config.HostAddress + UpstreamsPath + id).End() + _, body, errs := NewRequest(upstreamClient.config).Get(upstreamClient.config.HostAddress + UpstreamsPath + id).End() if errs != nil { return nil, fmt.Errorf("could not get upstream, error: %v", errs) } @@ -66,7 +65,7 @@ func (upstreamClient *UpstreamClient) GetById(id string) (*Upstream, error) { func (upstreamClient *UpstreamClient) Create(upstreamRequest *UpstreamRequest) (*Upstream, error) { - _, body, errs := gorequest.New().Post(upstreamClient.config.HostAddress + UpstreamsPath).Send(upstreamRequest).End() + _, body, errs := NewRequest(upstreamClient.config).Post(upstreamClient.config.HostAddress + UpstreamsPath).Send(upstreamRequest).End() if errs != nil { return nil, fmt.Errorf("could not create new upstream, error: %v", errs) } @@ -90,7 +89,7 @@ func (upstreamClient *UpstreamClient) DeleteByName(name string) error { func (upstreamClient *UpstreamClient) DeleteById(id string) error { - res, _, errs := gorequest.New().Delete(upstreamClient.config.HostAddress + UpstreamsPath + id).End() + res, _, errs := NewRequest(upstreamClient.config).Delete(upstreamClient.config.HostAddress + UpstreamsPath + id).End() if errs != nil { return fmt.Errorf("could not delete upstream, result: %v error: %v", res, errs) } @@ -110,7 +109,7 @@ func (upstreamClient *UpstreamClient) ListFiltered(filter *UpstreamFilter) (*Ups return nil, fmt.Errorf("could not build query string for upstreams filter, error: %v", err) } - _, body, errs := gorequest.New().Get(address).End() + _, body, errs := NewRequest(upstreamClient.config).Get(address).End() if errs != nil { return nil, fmt.Errorf("could not get upstreams, error: %v", errs) } @@ -130,7 +129,7 @@ func (upstreamClient *UpstreamClient) UpdateByName(name string, upstreamRequest func (upstreamClient *UpstreamClient) UpdateById(id string, upstreamRequest *UpstreamRequest) (*Upstream, error) { - _, body, errs := gorequest.New().Patch(upstreamClient.config.HostAddress + UpstreamsPath + id).Send(upstreamRequest).End() + _, body, errs := NewRequest(upstreamClient.config).Patch(upstreamClient.config.HostAddress + UpstreamsPath + id).Send(upstreamRequest).End() if errs != nil { return nil, fmt.Errorf("could not update upstream, error: %v", errs) } diff --git a/vendor/vendor.json b/vendor/vendor.json index 7135114a..5d9df8f9 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -535,10 +535,10 @@ "revisionTime": "2016-08-03T19:07:31Z" }, { - "checksumSHA1": "KchqvXPTF/OH0NlSn2NyZuck1s8=", + "checksumSHA1": "/oeab4Mqw33quPzpJ4iwe+X1VnM=", "path": "github.com/kevholditch/gokong", - "revision": "06e14c51d0044af2eb1189ba33a8d060594ee7c3", - "revisionTime": "2018-02-02T08:12:00Z" + "revision": "8bf13af68af45ba016db742b8803c90a92f0923a", + "revisionTime": "2018-03-19T13:48:11Z" }, { "path": "github.com/kevholditch/gokong...",