From e824b7e076c5470cbb49f5767b6c3668bb2d79bc Mon Sep 17 00:00:00 2001 From: Cole Snodgrass Date: Fri, 6 Sep 2024 10:03:45 -0700 Subject: [PATCH] change helm cache diretories --- internal/cmd/local/helm/helm.go | 11 +++++++---- internal/cmd/local/paths/paths.go | 16 ++++++++++++++++ internal/cmd/local/paths/paths_test.go | 14 ++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/internal/cmd/local/helm/helm.go b/internal/cmd/local/helm/helm.go index bd5014c..af3d50d 100644 --- a/internal/cmd/local/helm/helm.go +++ b/internal/cmd/local/helm/helm.go @@ -6,6 +6,7 @@ import ( "io" "github.com/airbytehq/abctl/internal/cmd/local/localerr" + "github.com/airbytehq/abctl/internal/cmd/local/paths" helmclient "github.com/mittwald/go-helm-client" "github.com/pterm/pterm" "helm.sh/helm/v3/pkg/action" @@ -39,10 +40,12 @@ func New(kubecfg, kubectx, namespace string) (Client, error) { logger := helmLogger{} helm, err := helmclient.NewClientFromRestConf(&helmclient.RestConfClientOptions{ Options: &helmclient.Options{ - Namespace: namespace, - Output: logger, - DebugLog: logger.Debug, - Debug: true, + Namespace: namespace, + Output: logger, + DebugLog: logger.Debug, + Debug: true, + RepositoryCache: paths.HelmRepoCache, + RepositoryConfig: paths.HelmRepoConfig, }, RestConfig: restCfg, }) diff --git a/internal/cmd/local/paths/paths.go b/internal/cmd/local/paths/paths.go index 8436cc2..b2b63b2 100644 --- a/internal/cmd/local/paths/paths.go +++ b/internal/cmd/local/paths/paths.go @@ -15,14 +15,26 @@ var ( h, _ := os.UserHomeDir() return h }() + // Airbyte is the full path to the ~/.airbyte directory Airbyte = airbyte() + // AbCtl is the full path to the ~/.airbyte/abctl directory AbCtl = abctl() + // Data is the full path to the ~/.airbyte/abctl/data directory Data = data() + // Kubeconfig is the full path to the kubeconfig file Kubeconfig = kubeconfig() + + // HelmRepoConfig is the full path to where helm stores + // its repository configurations. + HelmRepoConfig = helmRepoConfig() + + // HelmRepoCache is the full path to where helm stores + // its cached data. + HelmRepoCache = helmRepoCache() ) func airbyte() string { @@ -40,3 +52,7 @@ func data() string { func kubeconfig() string { return filepath.Join(abctl(), FileKubeconfig) } + +func helmRepoConfig() string { return filepath.Join(abctl(), ".helmrepo") } + +func helmRepoCache() string { return filepath.Join(abctl(), ".helmcache") } diff --git a/internal/cmd/local/paths/paths_test.go b/internal/cmd/local/paths/paths_test.go index 04bed82..5fc1911 100644 --- a/internal/cmd/local/paths/paths_test.go +++ b/internal/cmd/local/paths/paths_test.go @@ -49,4 +49,18 @@ func Test_Paths(t *testing.T) { t.Errorf("Kubeconfig mismatch (-want +got):\n%s", d) } }) + + t.Run("HelmRepoConfig", func(t *testing.T) { + exp := filepath.Join(UserHome, ".airbyte", "abctl", ".helmrepo") + if d := cmp.Diff(exp, HelmRepoConfig); d != "" { + t.Errorf("HelmRepoConfig mismatch (-want +got):\n%s", d) + } + }) + + t.Run("HelmRepoCache", func(t *testing.T) { + exp := filepath.Join(UserHome, ".airbyte", "abctl", ".helmcache") + if d := cmp.Diff(exp, HelmRepoCache); d != "" { + t.Errorf("HelmRepoCache mismatch (-want +got):\n%s", d) + } + }) }