From 361fdfba0465b0a7a287bc3bc85ff02b014405ed Mon Sep 17 00:00:00 2001
From: Asim Aslam <asim@aslam.me>
Date: Tue, 24 Dec 2019 17:42:22 +0000
Subject: [PATCH] move around k8s api

---
 util/kubernetes/{client => }/api/api_test.go | 0
 util/kubernetes/{client => }/api/request.go  | 8 --------
 util/kubernetes/{client => }/api/response.go | 9 +++------
 util/kubernetes/client/client.go             | 2 +-
 4 files changed, 4 insertions(+), 15 deletions(-)
 rename util/kubernetes/{client => }/api/api_test.go (100%)
 rename util/kubernetes/{client => }/api/request.go (96%)
 rename util/kubernetes/{client => }/api/response.go (89%)

diff --git a/util/kubernetes/client/api/api_test.go b/util/kubernetes/api/api_test.go
similarity index 100%
rename from util/kubernetes/client/api/api_test.go
rename to util/kubernetes/api/api_test.go
diff --git a/util/kubernetes/client/api/request.go b/util/kubernetes/api/request.go
similarity index 96%
rename from util/kubernetes/client/api/request.go
rename to util/kubernetes/api/request.go
index de314dca..b0f12ef7 100644
--- a/util/kubernetes/client/api/request.go
+++ b/util/kubernetes/api/request.go
@@ -8,8 +8,6 @@ import (
 	"io"
 	"net/http"
 	"net/url"
-
-	"github.com/micro/go-micro/util/log"
 )
 
 // Request is used to construct a http request for the k8s API.
@@ -103,7 +101,6 @@ func (r *Request) Body(in interface{}) *Request {
 			r.err = err
 			return r
 		}
-		log.Debugf("Request body: %v", b)
 		r.body = b
 		return r
 	}
@@ -120,7 +117,6 @@ func (r *Request) Body(in interface{}) *Request {
 		return r
 	}
 
-	log.Debugf("Request body: %v", b)
 	r.body = b
 	return r
 }
@@ -202,8 +198,6 @@ func (r *Request) Do() *Response {
 		}
 	}
 
-	log.Debugf("kubernetes api request: %v", req)
-
 	res, err := r.client.Do(req)
 	if err != nil {
 		return &Response{
@@ -211,8 +205,6 @@ func (r *Request) Do() *Response {
 		}
 	}
 
-	log.Debugf("kubernetes api response: %v", res)
-
 	// return res, err
 	return newResponse(res, err)
 }
diff --git a/util/kubernetes/client/api/response.go b/util/kubernetes/api/response.go
similarity index 89%
rename from util/kubernetes/client/api/response.go
rename to util/kubernetes/api/response.go
index ceed48db..4f74e41d 100644
--- a/util/kubernetes/client/api/response.go
+++ b/util/kubernetes/api/response.go
@@ -5,8 +5,6 @@ import (
 	"errors"
 	"io/ioutil"
 	"net/http"
-
-	"github.com/micro/go-micro/util/log"
 )
 
 // Errors ...
@@ -82,13 +80,12 @@ func newResponse(res *http.Response, err error) *Response {
 		return r
 	}
 
-	log.Logf("kubernetes: request failed with code %v", r.res.StatusCode)
-
 	b, err := ioutil.ReadAll(r.res.Body)
 	if err == nil {
-		log.Log("kubernetes: request failed with body:")
-		log.Log(string(b))
+		r.err = errors.New(string(b))
+		return r
 	}
+
 	r.err = ErrUnknown
 
 	return r
diff --git a/util/kubernetes/client/client.go b/util/kubernetes/client/client.go
index 2ae295e3..1c8b91b3 100644
--- a/util/kubernetes/client/client.go
+++ b/util/kubernetes/client/client.go
@@ -11,7 +11,7 @@ import (
 	"path"
 	"strconv"
 
-	"github.com/micro/go-micro/util/kubernetes/client/api"
+	"github.com/micro/go-micro/util/kubernetes/api"
 	"github.com/micro/go-micro/util/log"
 )