Skip to content

Commit

Permalink
update auth to use api keys (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Clivern authored Jun 19, 2020
1 parent fe639c2 commit b1a6f72
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 64 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.14.4

ARG BEETLE_VERSION=0.1.1
ARG BEETLE_VERSION=0.2.0

ENV GO111MODULE=on

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<p align="center">
<img src="https://raw.githubusercontent.com/clivern/Beetle/master/assets/img/gopher.png?v=0.1.1" width="180" />
<img src="https://raw.githubusercontent.com/clivern/Beetle/master/assets/img/gopher.png?v=0.2.0" width="180" />
<h3 align="center">Beetle</h3>
<p align="center">Kubernetes multi-cluster deployment service</p>
<p align="center">
<a href="https://travis-ci.com/Clivern/Beetle"><img src="https://travis-ci.com/Clivern/Beetle.svg?branch=master"></a>
<a href="https://github.com/Clivern/Beetle/releases"><img src="https://img.shields.io/badge/Version-v0.1.1-red.svg"></a>
<a href="https://goreportcard.com/report/github.com/Clivern/Beetle"><img src="https://goreportcard.com/badge/github.com/clivern/Beetle?v=0.1.1"></a>
<a href="https://github.com/Clivern/Beetle/releases"><img src="https://img.shields.io/badge/Version-v0.2.0-red.svg"></a>
<a href="https://goreportcard.com/report/github.com/Clivern/Beetle"><img src="https://goreportcard.com/badge/github.com/clivern/Beetle?v=0.2.0"></a>
<a href="https://hub.docker.com/r/clivern/beetle"><img src="https://img.shields.io/badge/Docker-Latest-orange"></a>
<a href="https://github.com/Clivern/Beetle/blob/master/LICENSE"><img src="https://img.shields.io/badge/LICENSE-MIT-orange.svg"></a>
</p>
</p>
<br/>
<p align="center">
<img src="https://raw.githubusercontent.com/Clivern/Beetle/master/assets/img/chart.png?v=0.1.1" width="100%" />
<img src="https://raw.githubusercontent.com/Clivern/Beetle/master/assets/img/chart.png?v=0.2.0" width="100%" />
</p>
<br/>

Expand Down Expand Up @@ -79,7 +79,7 @@ app:

# API Configs
api:
token: ${BEETLE_API_TOKEN:- }
key: ${BEETLE_API_KEY:- }

# Runtime, Requests/Response and Beetle Metrics
metrics:
Expand Down Expand Up @@ -119,7 +119,7 @@ app:
webhook:
url: ${BEETLE_WEBHOOK_URL:- }
retry: ${BEETLE_WEBHOOK_RETRY:-3}
token: ${BEETLE_WEBHOOK_TOKEN:- }
apiKey: ${BEETLE_WEBHOOK_API_KEY:- }

# Log configs
log:
Expand Down
4 changes: 2 additions & 2 deletions config.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ app:

# API Configs
api:
token: ${BEETLE_API_TOKEN:- }
key: ${BEETLE_API_KEY:- }

# Runtime, Requests/Response and Beetle Metrics
metrics:
Expand Down Expand Up @@ -65,7 +65,7 @@ app:
webhook:
url: ${BEETLE_WEBHOOK_URL:- }
retry: ${BEETLE_WEBHOOK_RETRY:-3}
token: ${BEETLE_WEBHOOK_TOKEN:- }
apiKey: ${BEETLE_WEBHOOK_API_KEY:- }

# Log configs
log:
Expand Down
4 changes: 2 additions & 2 deletions config.testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ app:

# API Configs
api:
token: ${BEETLE_API_TOKEN:- }
key: ${BEETLE_API_KEY:- }

# Runtime, Requests/Response and Beetle Metrics
metrics:
Expand Down Expand Up @@ -65,7 +65,7 @@ app:
webhook:
url: ${BEETLE_WEBHOOK_URL:- }
retry: ${BEETLE_WEBHOOK_RETRY:-3}
token: ${BEETLE_WEBHOOK_TOKEN:- }
apiKey: ${BEETLE_WEBHOOK_API_KEY:- }

# Log configs
log:
Expand Down
16 changes: 0 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jinzhu/gorm v1.9.13 h1:fcdacwmUcoyon8XHkQrdPJZ7pnHAYclHZ6iLYER5nX4=
github.com/jinzhu/gorm v1.9.13/go.mod h1:C0zfmO9z9J61PGrs46nfRkfsq0/8ErGTKBxyudR2KvI=
github.com/jinzhu/gorm v1.9.14 h1:Kg3ShyTPcM6nzVo148fRrcMO6MNKuqtOUwnzqMgVniM=
github.com/jinzhu/gorm v1.9.14/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
Expand Down Expand Up @@ -227,8 +225,6 @@ github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHX
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
Expand Down Expand Up @@ -270,8 +266,6 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.6.0 h1:YVPodQOcK15POxhgARIvnDRVpLcuK8mglnMrWfyrw6A=
github.com/prometheus/client_golang v1.6.0/go.mod h1:ZLOG9ck3JLRdB5MgO8f+lLTe83AXG6ro35rLTxvnIl4=
github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U=
github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
Expand All @@ -281,15 +275,11 @@ github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6T
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U=
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.11 h1:DhHlBtkHWPYi8O2y31JkK0TF+DGM+51OopZjH/Ia5qI=
github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
Expand Down Expand Up @@ -432,8 +422,6 @@ golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f h1:gWF768j/LaZugp8dyS4UwsslYCYz9XgFxvlgsn0n9H8=
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down Expand Up @@ -526,13 +514,9 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
k8s.io/api v0.18.2/go.mod h1:SJCWI7OLzhZSvbY7U8zwNl9UA4o1fizoug34OV/2r78=
k8s.io/api v0.18.3 h1:2AJaUQdgUZLoDZHrun21PW2Nx9+ll6cUzvn3IKhSIn0=
k8s.io/api v0.18.3/go.mod h1:UOaMwERbqJMfeeeHc8XJKawj4P9TgDRnViIqqBeH2QA=
k8s.io/api v0.18.4 h1:8x49nBRxuXGUlDlwlWd3RMY1SayZrzFfxea3UZSkFw4=
k8s.io/api v0.18.4/go.mod h1:lOIQAKYgai1+vz9J7YcDZwC26Z0zQewYOGWdyIPUUQ4=
k8s.io/apimachinery v0.18.2/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA=
k8s.io/apimachinery v0.18.3 h1:pOGcbVAhxADgUYnjS08EFXs9QMl8qaH5U4fr5LGUrSk=
k8s.io/apimachinery v0.18.3/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko=
k8s.io/apimachinery v0.18.4 h1:ST2beySjhqwJoIFk6p7Hp5v5O0hYY6Gngq/gUYXTPIA=
k8s.io/apimachinery v0.18.4/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko=
k8s.io/client-go v0.18.2 h1:aLB0iaD4nmwh7arT2wIn+lMnAq7OswjaejkQ8p9bBYE=
Expand Down
2 changes: 1 addition & 1 deletion internal/app/controller/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func Daemon() {
map[string]string{},
map[string]string{
"Content-Type": "application/json",
"X-AUTH-TOKEN": viper.GetString("app.webhook.token"),
"X-API-KEY": viper.GetString("app.webhook.apiKey"),
"X-NOTIFICATION-ID": job.UUID,
"X-ACTION-NAME": job.Type,
"X-DEPLOYMENT-ID": parentJob.UUID,
Expand Down
6 changes: 3 additions & 3 deletions internal/app/middleware/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ func Auth() gin.HandlerFunc {
method := c.Request.Method

if strings.Contains(path, "/api/") {
authToken := c.GetHeader("X-AUTH-TOKEN")
if viper.GetString("app.api.token") != "" && authToken != viper.GetString("app.api.token") {
apiKey := c.GetHeader("X-API-KEY")
if viper.GetString("app.api.key") != "" && apiKey != viper.GetString("app.api.key") {
log.WithFields(log.Fields{
"correlation_id": c.Request.Header.Get("X-Correlation-ID"),
"http_method": method,
"http_path": path,
"auth_token": authToken,
"api_key": apiKey,
}).Info(`Unauthorized access`)

c.AbortWithStatus(http.StatusUnauthorized)
Expand Down
24 changes: 12 additions & 12 deletions internal/app/module/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestHttpGet(t *testing.T) {
context.TODO(),
"https://httpbin.org/get",
map[string]string{"arg1": "value1"},
map[string]string{"X-Auth": "hipp-123"},
map[string]string{"X-Api-Key": "hipp-123"},
)

pkg.Expect(t, http.StatusOK, httpClient.GetStatusCode(response))
Expand All @@ -32,7 +32,7 @@ func TestHttpGet(t *testing.T) {
pkg.Expect(t, true, strings.Contains(body, "value1"))
pkg.Expect(t, true, strings.Contains(body, "arg1"))
pkg.Expect(t, true, strings.Contains(body, "arg1=value1"))
pkg.Expect(t, true, strings.Contains(body, "X-Auth"))
pkg.Expect(t, true, strings.Contains(body, "X-Api-Key"))
pkg.Expect(t, true, strings.Contains(body, "hipp-123"))
pkg.Expect(t, nil, error)
})
Expand All @@ -46,7 +46,7 @@ func TestHttpDelete(t *testing.T) {
context.TODO(),
"https://httpbin.org/delete",
map[string]string{"arg1": "value1"},
map[string]string{"X-Auth": "hipp-123"},
map[string]string{"X-Api-Key": "hipp-123"},
)

pkg.Expect(t, http.StatusOK, httpClient.GetStatusCode(response))
Expand All @@ -57,7 +57,7 @@ func TestHttpDelete(t *testing.T) {
pkg.Expect(t, true, strings.Contains(body, "value1"))
pkg.Expect(t, true, strings.Contains(body, "arg1"))
pkg.Expect(t, true, strings.Contains(body, "arg1=value1"))
pkg.Expect(t, true, strings.Contains(body, "X-Auth"))
pkg.Expect(t, true, strings.Contains(body, "X-Api-Key"))
pkg.Expect(t, true, strings.Contains(body, "hipp-123"))
pkg.Expect(t, nil, error)
})
Expand All @@ -72,7 +72,7 @@ func TestHttpPost(t *testing.T) {
"https://httpbin.org/post",
`{"Username":"admin", "Password":"12345"}`,
map[string]string{"arg1": "value1"},
map[string]string{"X-Auth": "hipp-123"},
map[string]string{"X-Api-Key": "hipp-123"},
)

pkg.Expect(t, http.StatusOK, httpClient.GetStatusCode(response))
Expand All @@ -87,7 +87,7 @@ func TestHttpPost(t *testing.T) {
pkg.Expect(t, true, strings.Contains(body, "value1"))
pkg.Expect(t, true, strings.Contains(body, "arg1"))
pkg.Expect(t, true, strings.Contains(body, "arg1=value1"))
pkg.Expect(t, true, strings.Contains(body, "X-Auth"))
pkg.Expect(t, true, strings.Contains(body, "X-Api-Key"))
pkg.Expect(t, true, strings.Contains(body, "hipp-123"))
pkg.Expect(t, nil, error)
})
Expand All @@ -102,7 +102,7 @@ func TestHttpPut(t *testing.T) {
"https://httpbin.org/put",
`{"Username":"admin", "Password":"12345"}`,
map[string]string{"arg1": "value1"},
map[string]string{"X-Auth": "hipp-123"},
map[string]string{"X-Api-Key": "hipp-123"},
)

pkg.Expect(t, http.StatusOK, httpClient.GetStatusCode(response))
Expand All @@ -117,7 +117,7 @@ func TestHttpPut(t *testing.T) {
pkg.Expect(t, true, strings.Contains(body, "value1"))
pkg.Expect(t, true, strings.Contains(body, "arg1"))
pkg.Expect(t, true, strings.Contains(body, "arg1=value1"))
pkg.Expect(t, true, strings.Contains(body, "X-Auth"))
pkg.Expect(t, true, strings.Contains(body, "X-Api-Key"))
pkg.Expect(t, true, strings.Contains(body, "hipp-123"))
pkg.Expect(t, nil, error)
})
Expand All @@ -131,7 +131,7 @@ func TestHttpGetStatusCode1(t *testing.T) {
context.TODO(),
"https://httpbin.org/status/200",
map[string]string{"arg1": "value1"},
map[string]string{"X-Auth": "hipp-123"},
map[string]string{"X-Api-Key": "hipp-123"},
)

pkg.Expect(t, http.StatusOK, httpClient.GetStatusCode(response))
Expand All @@ -152,7 +152,7 @@ func TestHttpGetStatusCode2(t *testing.T) {
context.TODO(),
"https://httpbin.org/status/500",
map[string]string{"arg1": "value1"},
map[string]string{"X-Auth": "hipp-123"},
map[string]string{"X-Api-Key": "hipp-123"},
)

pkg.Expect(t, http.StatusInternalServerError, httpClient.GetStatusCode(response))
Expand All @@ -173,7 +173,7 @@ func TestHttpGetStatusCode3(t *testing.T) {
context.TODO(),
"https://httpbin.org/status/404",
map[string]string{"arg1": "value1"},
map[string]string{"X-Auth": "hipp-123"},
map[string]string{"X-Api-Key": "hipp-123"},
)

pkg.Expect(t, http.StatusNotFound, httpClient.GetStatusCode(response))
Expand All @@ -194,7 +194,7 @@ func TestHttpGetStatusCode4(t *testing.T) {
context.TODO(),
"https://httpbin.org/status/201",
map[string]string{"arg1": "value1"},
map[string]string{"X-Auth": "hipp-123"},
map[string]string{"X-Api-Key": "hipp-123"},
)

pkg.Expect(t, http.StatusCreated, httpClient.GetStatusCode(response))
Expand Down
8 changes: 4 additions & 4 deletions sdk/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
)

// GetApplications Get Applications List
func GetApplications(ctx context.Context, httpClient *module.HTTPClient, serverURL, cluster, namespace, token string) (model.Applications, error) {
func GetApplications(ctx context.Context, httpClient *module.HTTPClient, serverURL, cluster, namespace, apiKey string) (model.Applications, error) {
var result model.Applications

response, err := httpClient.Get(
ctx,
fmt.Sprintf("%s/api/v1/cluster/%s/namespace/%s/app", serverURL, cluster, namespace),
map[string]string{},
map[string]string{"X-AUTH-TOKEN": token},
map[string]string{"X-API-KEY": apiKey},
)

if err != nil {
Expand Down Expand Up @@ -54,14 +54,14 @@ func GetApplications(ctx context.Context, httpClient *module.HTTPClient, serverU
}

// GetApplication Get Application
func GetApplication(ctx context.Context, httpClient *module.HTTPClient, serverURL, cluster, namespace, application, token string) (model.Application, error) {
func GetApplication(ctx context.Context, httpClient *module.HTTPClient, serverURL, cluster, namespace, application, apiKey string) (model.Application, error) {
var result model.Application

response, err := httpClient.Get(
ctx,
fmt.Sprintf("%s/api/v1/cluster/%s/namespace/%s/app/%s", serverURL, cluster, namespace, application),
map[string]string{},
map[string]string{"X-AUTH-TOKEN": token},
map[string]string{"X-API-KEY": apiKey},
)

if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions sdk/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
)

// GetClusters Get Clusters List
func GetClusters(ctx context.Context, httpClient *module.HTTPClient, serverURL, token string) (model.Clusters, error) {
func GetClusters(ctx context.Context, httpClient *module.HTTPClient, serverURL, apiKey string) (model.Clusters, error) {
var result model.Clusters

response, err := httpClient.Get(
ctx,
fmt.Sprintf("%s/api/v1/cluster", serverURL),
map[string]string{},
map[string]string{"X-AUTH-TOKEN": token},
map[string]string{"X-API-KEY": apiKey},
)

if err != nil {
Expand Down Expand Up @@ -54,14 +54,14 @@ func GetClusters(ctx context.Context, httpClient *module.HTTPClient, serverURL,
}

// GetCluster Get Cluster
func GetCluster(ctx context.Context, httpClient *module.HTTPClient, serverURL, cluster, token string) (model.Cluster, error) {
func GetCluster(ctx context.Context, httpClient *module.HTTPClient, serverURL, cluster, apiKey string) (model.Cluster, error) {
var result model.Cluster

response, err := httpClient.Get(
ctx,
fmt.Sprintf("%s/api/v1/cluster/%s", serverURL, cluster),
map[string]string{},
map[string]string{"X-AUTH-TOKEN": token},
map[string]string{"X-API-KEY": apiKey},
)

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions sdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// CreateDeployment Get Application
func CreateDeployment(ctx context.Context, httpClient *module.HTTPClient, serverURL string, request model.DeploymentRequest, token string) (model.Job, error) {
func CreateDeployment(ctx context.Context, httpClient *module.HTTPClient, serverURL string, request model.DeploymentRequest, apiKey string) (model.Job, error) {
var result model.Job

requestBody, err := request.ConvertToJSON()
Expand All @@ -28,7 +28,7 @@ func CreateDeployment(ctx context.Context, httpClient *module.HTTPClient, server
fmt.Sprintf("%s/api/v1/cluster/%s/namespace/%s/app/%s", serverURL, request.Cluster, request.Namespace, request.Application),
requestBody,
map[string]string{},
map[string]string{"X-AUTH-TOKEN": token},
map[string]string{"X-API-KEY": apiKey},
)

if err != nil {
Expand Down
Loading

0 comments on commit b1a6f72

Please sign in to comment.