Skip to content

Commit

Permalink
[#3589] Remove the cache from the controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ljupcovangelski committed Sep 23, 2022
1 parent c8676b6 commit f1585ee
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 97 deletions.
12 changes: 0 additions & 12 deletions infrastructure/controller/pkg/cache/BUILD

This file was deleted.

64 changes: 0 additions & 64 deletions infrastructure/controller/pkg/cache/deployed_charts.go

This file was deleted.

1 change: 0 additions & 1 deletion infrastructure/controller/pkg/endpoints/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ go_library(
importpath = "github.com/airyhq/airy/infrastructure/controller/pkg/endpoints",
visibility = ["//visibility:public"],
deps = [
"//infrastructure/controller/pkg/cache",
"//lib/go/config",
"//lib/go/k8s",
"//lib/go/payloads",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/http"
"strings"

"github.com/airyhq/airy/infrastructure/controller/pkg/cache"
"github.com/airyhq/airy/lib/go/payloads"
helmCli "github.com/mittwald/go-helm-client"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -17,10 +16,9 @@ import (
)

type ComponentsInstallUninstall struct {
Cli helmCli.Client
ClientSet *kubernetes.Clientset
Namespace string
DeployedCharts *cache.DeployedCharts
Cli helmCli.Client
ClientSet *kubernetes.Clientset
Namespace string
}

func (s *ComponentsInstallUninstall) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -87,7 +85,6 @@ func (s *ComponentsInstallUninstall) ServeHTTP(w http.ResponseWriter, r *http.Re
return
}

s.DeployedCharts.RefreshDeployedCharts()
w.WriteHeader(http.StatusAccepted)
}

Expand Down
8 changes: 3 additions & 5 deletions infrastructure/controller/pkg/endpoints/components_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ import (
"io/ioutil"
"net/http"

"github.com/airyhq/airy/infrastructure/controller/pkg/cache"
"github.com/airyhq/airy/lib/go/k8s"
"k8s.io/client-go/kubernetes"
"k8s.io/helm/cmd/helm/search"
"k8s.io/klog"
)

type ComponentsList struct {
ClientSet *kubernetes.Clientset
Namespace string
Index *search.Index
DeployedCharts *cache.DeployedCharts
ClientSet *kubernetes.Clientset
Namespace string
Index *search.Index
}

func (s *ComponentsList) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Expand Down
6 changes: 2 additions & 4 deletions infrastructure/controller/pkg/endpoints/components_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ import (
"net/http"
"strconv"

"github.com/airyhq/airy/infrastructure/controller/pkg/cache"
"github.com/airyhq/airy/lib/go/k8s"
"github.com/airyhq/airy/lib/go/payloads"
"k8s.io/client-go/kubernetes"
"k8s.io/klog"
)

type ComponentsUpdate struct {
DeployedCharts *cache.DeployedCharts
clientSet *kubernetes.Clientset
namespace string
clientSet *kubernetes.Clientset
namespace string
}

func (s *ComponentsUpdate) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Expand Down
8 changes: 3 additions & 5 deletions infrastructure/controller/pkg/endpoints/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/http"
"os"

"github.com/airyhq/airy/infrastructure/controller/pkg/cache"
"github.com/gorilla/mux"
helmCli "github.com/mittwald/go-helm-client"
"helm.sh/helm/v3/pkg/repo"
Expand Down Expand Up @@ -48,12 +47,11 @@ func Serve(clientSet *kubernetes.Clientset, namespace string, kubeConfig *rest.C
}

helmCli, helmIndex := mustGetHelmClientAndIndex(namespace, kubeConfig, clientSet, repoFilePath)
deployedCharts := cache.MustNewDeployedCharts(helmCli)

services := &Services{clientSet: clientSet, namespace: namespace}
r.Handle("/services", services)

componentsUpdate := &ComponentsUpdate{DeployedCharts: deployedCharts, clientSet: clientSet, namespace: namespace}
componentsUpdate := &ComponentsUpdate{clientSet: clientSet, namespace: namespace}
r.Handle("/components.update", componentsUpdate)

componentsDelete := &ComponentsDelete{clientSet: clientSet, namespace: namespace}
Expand All @@ -65,11 +63,11 @@ func Serve(clientSet *kubernetes.Clientset, namespace string, kubeConfig *rest.C
clusterUpdate := &ClusterUpdate{clientSet: clientSet, namespace: namespace}
r.Handle("/cluster.update", clusterUpdate)

componentsInstallUninstall := ComponentsInstallUninstall{DeployedCharts: deployedCharts, Cli: helmCli, ClientSet: clientSet, Namespace: namespace}
componentsInstallUninstall := ComponentsInstallUninstall{Cli: helmCli, ClientSet: clientSet, Namespace: namespace}
r.Handle("/components.install", &componentsInstallUninstall)
r.Handle("/components.uninstall", &componentsInstallUninstall)

componentsList := ComponentsList{DeployedCharts: deployedCharts, ClientSet: clientSet, Namespace: namespace, Index: helmIndex}
componentsList := ComponentsList{ClientSet: clientSet, Namespace: namespace, Index: helmIndex}
r.Handle("/components.list", &componentsList)

log.Fatal(http.ListenAndServe(":8080", r))
Expand Down

0 comments on commit f1585ee

Please sign in to comment.