From 28c60ef59a9e0d53dc33660c55bc053bfd414642 Mon Sep 17 00:00:00 2001 From: Divyansh Manchanda Date: Mon, 5 Aug 2019 14:14:07 +0530 Subject: [PATCH] [v2.15] redis CRUD --- k8s-poolprovider/values.yaml | 2 +- kubernetes.yaml | 2 +- main.go | 23 +++++------------------ redis.go | 1 + 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/k8s-poolprovider/values.yaml b/k8s-poolprovider/values.yaml index e2368d5..8f10f8c 100644 --- a/k8s-poolprovider/values.yaml +++ b/k8s-poolprovider/values.yaml @@ -14,7 +14,7 @@ rbac: image: repository: divyanshm/k8s-poolprovider - tag: v2.14 + tag: v2.15 pullPolicy: IfNotPresent vsts: diff --git a/kubernetes.yaml b/kubernetes.yaml index 86d1fec..f5902f1 100644 --- a/kubernetes.yaml +++ b/kubernetes.yaml @@ -68,7 +68,7 @@ spec: spec: serviceAccountName: pipelineprovider containers: - - image: divyanshm/k8s-poolprovider:v2.14 + - image: divyanshm/k8s-poolprovider:v2.15 name: k8s-poolprovider command: ["/app/main"] ports: diff --git a/main.go b/main.go index 69795c6..c761f9d 100644 --- a/main.go +++ b/main.go @@ -73,25 +73,12 @@ func StorageGetHandler(s Storage) http.HandlerFunc { func StorageSetHandler(s Storage) http.HandlerFunc { return func(resp http.ResponseWriter, req *http.Request) { - key := req.URL.Query()["key"] - value := req.URL.Query()["value"] - fmt.Fprintf(resp, "key is %s, value is %s", key[0], value[0]); - if key == nil || key[0] == "" { - key[0] = "fu" - } + key := "some sample key" + value := "some sample value" - if value == nil || value[0] == "" { - value[0] = "bar" - } - - err := s.Set(key[0], value[0]) - if err != nil { - resp.WriteHeader(http.StatusInternalServerError) - fmt.Fprintf(resp, "Error" + err.Error()) - return - } - resp.WriteHeader(http.StatusOK) - fmt.Fprintf(resp, "Value set") + s.Set(key, value) + retrievedValue, _ := s.Get(key) + fmt.Fprintf(resp, "All good. Retrieved %s", retrievedValue) } } diff --git a/redis.go b/redis.go index 770cbc0..c6d7da7 100644 --- a/redis.go +++ b/redis.go @@ -61,6 +61,7 @@ func (r *RedisStorage) Init() string { if err != nil { fmt.Println("worst_car_ever not found", err) } + return worst_car_ever }