From b1a6f72f4af21c85d4eea85c5a5d2b2e41ea495c Mon Sep 17 00:00:00 2001
From: Ahmed
Date: Fri, 19 Jun 2020 17:07:19 +0200
Subject: [PATCH] update auth to use api keys (#121)
---
Dockerfile | 2 +-
README.md | 12 ++++++------
config.dist.yml | 4 ++--
config.testing.yml | 4 ++--
go.sum | 16 ----------------
internal/app/controller/daemon.go | 2 +-
internal/app/middleware/auth.go | 6 +++---
internal/app/module/http_test.go | 24 ++++++++++++------------
sdk/application.go | 8 ++++----
sdk/cluster.go | 8 ++++----
sdk/deployment.go | 4 ++--
sdk/job.go | 12 ++++++------
sdk/namespace.go | 8 ++++----
swagger.yaml | 28 +++++++++++++++++++++++++++-
14 files changed, 74 insertions(+), 64 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index b13b9bfb..60944c95 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,6 @@
FROM golang:1.14.4
-ARG BEETLE_VERSION=0.1.1
+ARG BEETLE_VERSION=0.2.0
ENV GO111MODULE=on
diff --git a/README.md b/README.md
index 9f116aba..ff907e5b 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,18 @@
-
+
Beetle
Kubernetes multi-cluster deployment service
-
-
+
+
-
+
@@ -79,7 +79,7 @@ app:
# API Configs
api:
- token: ${BEETLE_API_TOKEN:- }
+ key: ${BEETLE_API_KEY:- }
# Runtime, Requests/Response and Beetle Metrics
metrics:
@@ -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:
diff --git a/config.dist.yml b/config.dist.yml
index 74d0bc13..5628df14 100644
--- a/config.dist.yml
+++ b/config.dist.yml
@@ -25,7 +25,7 @@ app:
# API Configs
api:
- token: ${BEETLE_API_TOKEN:- }
+ key: ${BEETLE_API_KEY:- }
# Runtime, Requests/Response and Beetle Metrics
metrics:
@@ -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:
diff --git a/config.testing.yml b/config.testing.yml
index 410e0bc3..2454d956 100644
--- a/config.testing.yml
+++ b/config.testing.yml
@@ -25,7 +25,7 @@ app:
# API Configs
api:
- token: ${BEETLE_API_TOKEN:- }
+ key: ${BEETLE_API_KEY:- }
# Runtime, Requests/Response and Beetle Metrics
metrics:
@@ -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:
diff --git a/go.sum b/go.sum
index d75f18e7..93b683d7 100644
--- a/go.sum
+++ b/go.sum
@@ -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=
@@ -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=
@@ -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=
@@ -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=
@@ -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=
@@ -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=
diff --git a/internal/app/controller/daemon.go b/internal/app/controller/daemon.go
index 29f11283..bcc8bdb7 100644
--- a/internal/app/controller/daemon.go
+++ b/internal/app/controller/daemon.go
@@ -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,
diff --git a/internal/app/middleware/auth.go b/internal/app/middleware/auth.go
index 5426702c..25a46b21 100644
--- a/internal/app/middleware/auth.go
+++ b/internal/app/middleware/auth.go
@@ -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)
diff --git a/internal/app/module/http_test.go b/internal/app/module/http_test.go
index edc431e1..d66c45c2 100644
--- a/internal/app/module/http_test.go
+++ b/internal/app/module/http_test.go
@@ -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))
@@ -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)
})
@@ -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))
@@ -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)
})
@@ -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))
@@ -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)
})
@@ -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))
@@ -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)
})
@@ -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))
@@ -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))
@@ -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))
@@ -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))
diff --git a/sdk/application.go b/sdk/application.go
index b96bb7df..c0f35ea6 100644
--- a/sdk/application.go
+++ b/sdk/application.go
@@ -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 {
@@ -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 {
diff --git a/sdk/cluster.go b/sdk/cluster.go
index a52e0f31..c31c9fe7 100644
--- a/sdk/cluster.go
+++ b/sdk/cluster.go
@@ -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 {
@@ -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 {
diff --git a/sdk/deployment.go b/sdk/deployment.go
index baf68ede..2b514b73 100644
--- a/sdk/deployment.go
+++ b/sdk/deployment.go
@@ -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()
@@ -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 {
diff --git a/sdk/job.go b/sdk/job.go
index f3d04c96..ef9048c1 100644
--- a/sdk/job.go
+++ b/sdk/job.go
@@ -14,14 +14,14 @@ import (
)
// GetJobs Get Jobs List
-func GetJobs(ctx context.Context, httpClient *module.HTTPClient, serverURL, token string) (model.Jobs, error) {
+func GetJobs(ctx context.Context, httpClient *module.HTTPClient, serverURL, apiKey string) (model.Jobs, error) {
var result model.Jobs
response, err := httpClient.Get(
ctx,
fmt.Sprintf("%s/api/v1/job", serverURL),
map[string]string{},
- map[string]string{"X-AUTH-TOKEN": token},
+ map[string]string{"X-API-KEY": apiKey},
)
if err != nil {
@@ -54,14 +54,14 @@ func GetJobs(ctx context.Context, httpClient *module.HTTPClient, serverURL, toke
}
// GetJob Get Job
-func GetJob(ctx context.Context, httpClient *module.HTTPClient, serverURL, uuid, token string) (model.Job, error) {
+func GetJob(ctx context.Context, httpClient *module.HTTPClient, serverURL, uuid, apiKey string) (model.Job, error) {
var result model.Job
response, err := httpClient.Get(
ctx,
fmt.Sprintf("%s/api/v1/job/%s", serverURL, uuid),
map[string]string{},
- map[string]string{"X-AUTH-TOKEN": token},
+ map[string]string{"X-API-KEY": apiKey},
)
if err != nil {
@@ -94,12 +94,12 @@ func GetJob(ctx context.Context, httpClient *module.HTTPClient, serverURL, uuid,
}
// DeleteJob Delete Job
-func DeleteJob(ctx context.Context, httpClient *module.HTTPClient, serverURL, uuid, token string) (bool, error) {
+func DeleteJob(ctx context.Context, httpClient *module.HTTPClient, serverURL, uuid, apiKey string) (bool, error) {
response, err := httpClient.Delete(
ctx,
fmt.Sprintf("%s/api/v1/job/%s", serverURL, uuid),
map[string]string{},
- map[string]string{"X-AUTH-TOKEN": token},
+ map[string]string{"X-API-KEY": apiKey},
)
if err != nil {
diff --git a/sdk/namespace.go b/sdk/namespace.go
index ad56cd73..1dc47453 100644
--- a/sdk/namespace.go
+++ b/sdk/namespace.go
@@ -14,14 +14,14 @@ import (
)
// GetNamespaces Get Namespaces List
-func GetNamespaces(ctx context.Context, httpClient *module.HTTPClient, serverURL, cluster, token string) (model.Namespaces, error) {
+func GetNamespaces(ctx context.Context, httpClient *module.HTTPClient, serverURL, cluster, apiKey string) (model.Namespaces, error) {
var result model.Namespaces
response, err := httpClient.Get(
ctx,
fmt.Sprintf("%s/api/v1/cluster/%s/namespace", serverURL, cluster),
map[string]string{},
- map[string]string{"X-AUTH-TOKEN": token},
+ map[string]string{"X-API-KEY": apiKey},
)
if err != nil {
@@ -54,14 +54,14 @@ func GetNamespaces(ctx context.Context, httpClient *module.HTTPClient, serverURL
}
// GetNamespace Get Namespace
-func GetNamespace(ctx context.Context, httpClient *module.HTTPClient, serverURL, cluster, namespace, token string) (model.Namespace, error) {
+func GetNamespace(ctx context.Context, httpClient *module.HTTPClient, serverURL, cluster, namespace, apiKey string) (model.Namespace, error) {
var result model.Namespace
response, err := httpClient.Get(
ctx,
fmt.Sprintf("%s/api/v1/cluster/%s/namespace/%s", serverURL, cluster, namespace),
map[string]string{},
- map[string]string{"X-AUTH-TOKEN": token},
+ map[string]string{"X-API-KEY": apiKey},
)
if err != nil {
diff --git a/swagger.yaml b/swagger.yaml
index 48df50c1..303add53 100644
--- a/swagger.yaml
+++ b/swagger.yaml
@@ -85,6 +85,8 @@ paths:
description: "Resource not found"
500:
description: "Internal server error"
+ security:
+ - api_key: []
/api/v1/cluster/{cn}:
get:
@@ -112,6 +114,8 @@ paths:
description: "Resource not found"
500:
description: "Internal server error"
+ security:
+ - api_key: []
/api/v1/cluster/{cn}/namespace:
get:
@@ -139,6 +143,8 @@ paths:
description: "Resource not found"
500:
description: "Internal server error"
+ security:
+ - api_key: []
/api/v1/cluster/{cn}/namespace/{ns}:
get:
@@ -171,6 +177,8 @@ paths:
description: "Resource not found"
500:
description: "Internal server error"
+ security:
+ - api_key: []
/api/v1/cluster/{cn}/namespace/{ns}/app:
get:
@@ -203,6 +211,8 @@ paths:
description: "Resource not found"
500:
description: "Internal server error"
+ security:
+ - api_key: []
/api/v1/cluster/{cn}/namespace/{ns}/app/{id}:
get:
@@ -240,6 +250,8 @@ paths:
description: "Resource not found"
500:
description: "Internal server error"
+ security:
+ - api_key: []
post:
tags:
@@ -271,7 +283,6 @@ paths:
required: true
schema:
$ref: '#/definitions/DeploymentRequest'
-
responses:
202:
description: "successful operation"
@@ -283,6 +294,8 @@ paths:
description: "Resource not found"
500:
description: "Internal server error"
+ security:
+ - api_key: []
/api/v1/job:
get:
@@ -302,6 +315,8 @@ paths:
description: "Invalid request"
500:
description: "Internal server error"
+ security:
+ - api_key: []
/api/v1/job/{uuid}:
get:
@@ -329,6 +344,9 @@ paths:
description: "Job not found"
500:
description: "Internal server error"
+ security:
+ - api_key: []
+
delete:
tags:
- "Job"
@@ -352,6 +370,14 @@ paths:
description: "Job not found"
500:
description: "Internal server error"
+ security:
+ - api_key: []
+
+securityDefinitions:
+ api_key:
+ type: apiKey
+ name: X-API-KEY
+ in: header
definitions:
healthResponse: