From bc9c0f73d3a807edf06a3d43dffd1a11938157fe Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Mon, 5 Feb 2024 20:31:40 +0100 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=92=A8=20cache=20templates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cyclops-ctrl/cmd/main/main.go | 7 ++- cyclops-ctrl/go.mod | 3 + cyclops-ctrl/go.sum | 11 ++++ cyclops-ctrl/internal/controller/modules.go | 20 ++++--- cyclops-ctrl/internal/controller/templates.go | 14 +++-- cyclops-ctrl/internal/handler/handler.go | 13 ++++- .../modulecontroller/module_controller.go | 9 ++- .../internal/template/cache/inmemory.go | 50 ++++++++++++++++ cyclops-ctrl/internal/template/git.go | 8 +-- cyclops-ctrl/internal/template/helm.go | 26 ++++----- cyclops-ctrl/internal/template/oci.go | 8 +-- cyclops-ctrl/internal/template/template.go | 57 ++++++++++++++----- 12 files changed, 174 insertions(+), 52 deletions(-) create mode 100644 cyclops-ctrl/internal/template/cache/inmemory.go diff --git a/cyclops-ctrl/cmd/main/main.go b/cyclops-ctrl/cmd/main/main.go index e8075785..0bcbe1b6 100644 --- a/cyclops-ctrl/cmd/main/main.go +++ b/cyclops-ctrl/cmd/main/main.go @@ -3,6 +3,8 @@ package main import ( "flag" "fmt" + "github.com/cyclops-ui/cycops-ctrl/internal/template" + "github.com/cyclops-ui/cycops-ctrl/internal/template/cache" "os" "k8s.io/apimachinery/pkg/runtime" @@ -63,7 +65,9 @@ func main() { //panic(err) } - handler, err := handler.New(templatesStorage, k8sClient) + templatesRepo := template.NewRepo(cache.NewInMemoryTemplatesCache()) + + handler, err := handler.New(templatesStorage, templatesRepo, k8sClient) if err != nil { panic(err) } @@ -86,6 +90,7 @@ func main() { if err = (modulecontroller.NewModuleReconciler( mgr.GetClient(), mgr.GetScheme(), + templatesRepo, templatesStorage, k8sClient, )).SetupWithManager(mgr); err != nil { diff --git a/cyclops-ctrl/go.mod b/cyclops-ctrl/go.mod index caf01bd3..4b109633 100644 --- a/cyclops-ctrl/go.mod +++ b/cyclops-ctrl/go.mod @@ -36,6 +36,7 @@ require ( github.com/containerd/containerd v1.7.0 // indirect github.com/cyphar/filepath-securejoin v0.2.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/docker/cli v20.10.21+incompatible // indirect github.com/docker/distribution v2.8.1+incompatible // indirect @@ -44,6 +45,7 @@ require ( github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-metrics v0.0.1 // indirect github.com/docker/go-units v0.5.0 // indirect + github.com/dustin/go-humanize v1.0.0 // indirect github.com/emicklei/go-restful/v3 v3.10.1 // indirect github.com/emirpasic/gods v1.12.0 // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect @@ -62,6 +64,7 @@ require ( github.com/gobwas/glob v0.2.3 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/glog v1.0.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/gnostic-models v0.6.8 // indirect diff --git a/cyclops-ctrl/go.sum b/cyclops-ctrl/go.sum index c732ab42..196b13e8 100644 --- a/cyclops-ctrl/go.sum +++ b/cyclops-ctrl/go.sum @@ -34,6 +34,7 @@ github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXe github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= @@ -54,6 +55,9 @@ github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxG github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= +github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2 h1:aBfCb7iqHmDEIp6fBvC/hQUddQfg+3qdYjwzaiP9Hnc= @@ -73,6 +77,8 @@ github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHz github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1 h1:ZClxb8laGDf5arXfYcAtECDFgAgHklGI8CxgjHnXKJ4= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= @@ -129,6 +135,9 @@ github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -289,6 +298,7 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -395,6 +405,7 @@ golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= diff --git a/cyclops-ctrl/internal/controller/modules.go b/cyclops-ctrl/internal/controller/modules.go index 6906d344..ae4e12f7 100644 --- a/cyclops-ctrl/internal/controller/modules.go +++ b/cyclops-ctrl/internal/controller/modules.go @@ -17,12 +17,18 @@ import ( type Modules struct { kubernetesClient *k8sclient.KubernetesClient + templatesRepo *template.Repo templates *templates.Storage } -func NewModulesController(templates *templates.Storage, kubernetes *k8sclient.KubernetesClient) *Modules { +func NewModulesController( + templates *templates.Storage, + templatesRepo *template.Repo, + kubernetes *k8sclient.KubernetesClient, +) *Modules { return &Modules{ kubernetesClient: kubernetes, + templatesRepo: templatesRepo, templates: templates, } } @@ -109,7 +115,7 @@ func (m *Modules) Manifest(ctx *gin.Context) { return } - targetTemplate, err := template.GetTemplate( + targetTemplate, err := m.templatesRepo.GetTemplate( request.TemplateRef.URL, request.TemplateRef.Path, request.TemplateRef.Version, @@ -143,7 +149,7 @@ func (m *Modules) CurrentManifest(ctx *gin.Context) { return } - targetTemplate, err := template.GetTemplate( + targetTemplate, err := m.templatesRepo.GetTemplate( module.Spec.TemplateRef.URL, module.Spec.TemplateRef.Path, module.Spec.TemplateRef.Version, @@ -275,7 +281,7 @@ func (m *Modules) ResourcesForModule(ctx *gin.Context) { return } - t, err := template.GetTemplate( + t, err := m.templatesRepo.GetTemplate( module.Spec.TemplateRef.URL, module.Spec.TemplateRef.Path, module.Spec.TemplateRef.Version, @@ -313,7 +319,7 @@ func (m *Modules) Template(ctx *gin.Context) { return } - currentTemplate, err := template.GetTemplate( + currentTemplate, err := m.templatesRepo.GetTemplate( module.Spec.TemplateRef.URL, module.Spec.TemplateRef.Path, module.Spec.TemplateRef.Version, @@ -331,7 +337,7 @@ func (m *Modules) Template(ctx *gin.Context) { return } - proposedTemplate, err := template.GetTemplate( + proposedTemplate, err := m.templatesRepo.GetTemplate( module.Spec.TemplateRef.URL, module.Spec.TemplateRef.Path, module.Spec.TemplateRef.Version, @@ -367,7 +373,7 @@ func (m *Modules) HelmTemplate(ctx *gin.Context) { return } - currentTemplate, err := template.GetTemplate( + currentTemplate, err := m.templatesRepo.GetTemplate( module.Spec.TemplateRef.URL, module.Spec.TemplateRef.Path, module.Spec.TemplateRef.Version, diff --git a/cyclops-ctrl/internal/controller/templates.go b/cyclops-ctrl/internal/controller/templates.go index 371dfec8..01a78d0a 100644 --- a/cyclops-ctrl/internal/controller/templates.go +++ b/cyclops-ctrl/internal/controller/templates.go @@ -19,12 +19,18 @@ import ( type Templates struct { templates *templates.Storage + templatesRepo *template.Repo kubernetesClient *k8sclient.KubernetesClient } -func NewTemplatesController(templatesStorage *templates.Storage, kubernetes *k8sclient.KubernetesClient) *Templates { +func NewTemplatesController( + templates *templates.Storage, + templatesRepo *template.Repo, + kubernetes *k8sclient.KubernetesClient, +) *Templates { return &Templates{ - templates: templatesStorage, + templatesRepo: templatesRepo, + templates: templates, kubernetesClient: kubernetes, } } @@ -141,7 +147,7 @@ func (c *Templates) GetTemplate(ctx *gin.Context) { return } - t, err := template.GetTemplate(repo, path, commit) + t, err := c.templatesRepo.GetTemplate(repo, path, commit) if err != nil { fmt.Println(err) ctx.JSON(http.StatusBadRequest, dto.NewError("Error loading template", err.Error())) @@ -163,7 +169,7 @@ func (c *Templates) GetTemplateInitialValues(ctx *gin.Context) { return } - initial, err := template.GetTemplateInitialValues(repo, path, commit) + initial, err := c.templatesRepo.GetTemplateInitialValues(repo, path, commit) if err != nil { fmt.Println(err) ctx.JSON(http.StatusBadRequest, dto.NewError("Error loading template initial values", err.Error())) diff --git a/cyclops-ctrl/internal/handler/handler.go b/cyclops-ctrl/internal/handler/handler.go index 8543c92c..a87c9576 100644 --- a/cyclops-ctrl/internal/handler/handler.go +++ b/cyclops-ctrl/internal/handler/handler.go @@ -8,17 +8,24 @@ import ( "github.com/cyclops-ui/cycops-ctrl/internal/cluster/k8sclient" "github.com/cyclops-ui/cycops-ctrl/internal/controller" "github.com/cyclops-ui/cycops-ctrl/internal/storage/templates" + templaterepo "github.com/cyclops-ui/cycops-ctrl/internal/template" ) type Handler struct { router *gin.Engine + templatesRepo *templaterepo.Repo templatesStorage *templates.Storage k8sClient *k8sclient.KubernetesClient } -func New(templates *templates.Storage, kubernetesClient *k8sclient.KubernetesClient) (*Handler, error) { +func New( + templates *templates.Storage, + templatesRepo *templaterepo.Repo, + kubernetesClient *k8sclient.KubernetesClient, +) (*Handler, error) { return &Handler{ + templatesRepo: templatesRepo, templatesStorage: templates, k8sClient: kubernetesClient, router: gin.New(), @@ -28,8 +35,8 @@ func New(templates *templates.Storage, kubernetesClient *k8sclient.KubernetesCli func (h *Handler) Start() error { gin.SetMode(gin.DebugMode) - templatesController := controller.NewTemplatesController(h.templatesStorage, h.k8sClient) - modulesController := controller.NewModulesController(h.templatesStorage, h.k8sClient) + templatesController := controller.NewTemplatesController(h.templatesStorage, h.templatesRepo, h.k8sClient) + modulesController := controller.NewModulesController(h.templatesStorage, h.templatesRepo, h.k8sClient) clusterController := controller.NewClusterController(h.k8sClient) h.router = gin.New() diff --git a/cyclops-ctrl/internal/modulecontroller/module_controller.go b/cyclops-ctrl/internal/modulecontroller/module_controller.go index 859362c9..83e62d17 100644 --- a/cyclops-ctrl/internal/modulecontroller/module_controller.go +++ b/cyclops-ctrl/internal/modulecontroller/module_controller.go @@ -34,7 +34,7 @@ import ( "github.com/cyclops-ui/cycops-ctrl/internal/cluster/k8sclient" "github.com/cyclops-ui/cycops-ctrl/internal/models" "github.com/cyclops-ui/cycops-ctrl/internal/storage/templates" - "github.com/cyclops-ui/cycops-ctrl/internal/template" + templaterepo "github.com/cyclops-ui/cycops-ctrl/internal/template" ) // ModuleReconciler reconciles a Module object @@ -42,6 +42,7 @@ type ModuleReconciler struct { client.Client Scheme *runtime.Scheme + templatesRepo *templaterepo.Repo templates *templates.Storage kubernetesClient *k8sclient.KubernetesClient @@ -51,12 +52,14 @@ type ModuleReconciler struct { func NewModuleReconciler( client client.Client, scheme *runtime.Scheme, + templatesRepo *templaterepo.Repo, templates *templates.Storage, kubernetesClient *k8sclient.KubernetesClient, ) *ModuleReconciler { return &ModuleReconciler{ Client: client, Scheme: scheme, + templatesRepo: templatesRepo, templates: templates, kubernetesClient: kubernetesClient, logger: ctrl.Log.WithName("reconciler"), @@ -130,7 +133,7 @@ func (r *ModuleReconciler) moduleToResources(name string) error { return err } - template, err := template.GetTemplate( + template, err := r.templatesRepo.GetTemplate( module.Spec.TemplateRef.URL, module.Spec.TemplateRef.Path, module.Spec.TemplateRef.Version, @@ -147,7 +150,7 @@ func (r *ModuleReconciler) moduleToResources(name string) error { } func (r *ModuleReconciler) generateResources(kClient *k8sclient.KubernetesClient, module cyclopsv1alpha1.Module, moduleTemplate *models.Template) error { - out, err := template.HelmTemplate(module, moduleTemplate) + out, err := templaterepo.HelmTemplate(module, moduleTemplate) if err != nil { return err } diff --git a/cyclops-ctrl/internal/template/cache/inmemory.go b/cyclops-ctrl/internal/template/cache/inmemory.go new file mode 100644 index 00000000..4798b7d3 --- /dev/null +++ b/cyclops-ctrl/internal/template/cache/inmemory.go @@ -0,0 +1,50 @@ +package cache + +import ( + "fmt" + "github.com/cyclops-ui/cycops-ctrl/internal/models" + "github.com/dgraph-io/ristretto" + "unsafe" +) + +type Templates struct { + cache *ristretto.Cache +} + +func NewInMemoryTemplatesCache() Templates { + cache, err := ristretto.NewCache(&ristretto.Config{ + NumCounters: 1e7, // number of keys to track frequency of (10M). + MaxCost: 1 << 30, // maximum cost of cache (1GB). + BufferItems: 64, // number of keys per Get buffer. + }) + if err != nil { + panic(err) + } + + return Templates{ + cache: cache, + } +} + +func (t Templates) Get(repo, path, version string) (*models.Template, bool) { + value, found := t.cache.Get(templateKey(repo, path, version)) + if !found { + return nil, false + } + + template, ok := value.(models.Template) + if !ok { + return nil, false + } + + return &template, ok +} + +func (t Templates) Set(repo, path, version string, template *models.Template) { + t.cache.Set(templateKey(repo, path, version), *template, int64(unsafe.Sizeof(*template))) + t.cache.Wait() +} + +func templateKey(repo, path, version string) string { + return fmt.Sprintf("%v/%v@%v", repo, path, version) +} diff --git a/cyclops-ctrl/internal/template/git.go b/cyclops-ctrl/internal/template/git.go index 4b9dbbff..cba02f3d 100644 --- a/cyclops-ctrl/internal/template/git.go +++ b/cyclops-ctrl/internal/template/git.go @@ -24,7 +24,7 @@ import ( "github.com/cyclops-ui/cycops-ctrl/internal/models/helm" ) -func LoadTemplate(repoURL, path, commit string) (*models.Template, error) { +func (r Repo) LoadTemplate(repoURL, path, commit string) (*models.Template, error) { fs, err := clone(repoURL, commit) if err != nil { return nil, err @@ -93,7 +93,7 @@ func LoadTemplate(repoURL, path, commit string) (*models.Template, error) { // endregion // region load dependencies - dependencies, err := loadDependencies(metadata) + dependencies, err := r.loadDependencies(metadata) if err != nil { return nil, err } @@ -111,7 +111,7 @@ func LoadTemplate(repoURL, path, commit string) (*models.Template, error) { }, nil } -func LoadInitialTemplateValues(repoURL, path, commit string) (map[interface{}]interface{}, error) { +func (r Repo) LoadInitialTemplateValues(repoURL, path, commit string) (map[interface{}]interface{}, error) { fs, err := clone(repoURL, commit) if err != nil { return nil, err @@ -152,7 +152,7 @@ func LoadInitialTemplateValues(repoURL, path, commit string) (map[interface{}]in initialValues = make(map[interface{}]interface{}) } - depInitialValues, err := loadDependenciesInitialValues(metadata) + depInitialValues, err := r.loadDependenciesInitialValues(metadata) if err != nil { return nil, err } diff --git a/cyclops-ctrl/internal/template/helm.go b/cyclops-ctrl/internal/template/helm.go index 43ea6fd7..17c02624 100644 --- a/cyclops-ctrl/internal/template/helm.go +++ b/cyclops-ctrl/internal/template/helm.go @@ -23,7 +23,7 @@ import ( "github.com/cyclops-ui/cycops-ctrl/internal/models/helm" ) -func LoadHelmChart(repo, chart, version string) (*models.Template, error) { +func (r Repo) LoadHelmChart(repo, chart, version string) (*models.Template, error) { var tgzData []byte var err error if registry.IsOCI(repo) { @@ -32,7 +32,7 @@ func LoadHelmChart(repo, chart, version string) (*models.Template, error) { return nil, err } } else { - tgzData, err = loadFromHelmChartRepo(repo, chart, version) + tgzData, err = r.loadFromHelmChartRepo(repo, chart, version) if err != nil { return nil, err } @@ -43,10 +43,10 @@ func LoadHelmChart(repo, chart, version string) (*models.Template, error) { return nil, err } - return mapHelmChart(chart, extractedFiles) + return r.mapHelmChart(chart, extractedFiles) } -func LoadHelmChartInitialValues(repo, chart, version string) (map[interface{}]interface{}, error) { +func (r Repo) LoadHelmChartInitialValues(repo, chart, version string) (map[interface{}]interface{}, error) { var tgzData []byte var err error if registry.IsOCI(repo) { @@ -55,7 +55,7 @@ func LoadHelmChartInitialValues(repo, chart, version string) (map[interface{}]in return nil, err } } else { - tgzData, err = loadFromHelmChartRepo(repo, chart, version) + tgzData, err = r.loadFromHelmChartRepo(repo, chart, version) if err != nil { return nil, err } @@ -82,7 +82,7 @@ func LoadHelmChartInitialValues(repo, chart, version string) (map[interface{}]in return nil, err } - return mapHelmChartInitialValues(extractedFiles) + return r.mapHelmChartInitialValues(extractedFiles) } func IsHelmRepo(repo string) (bool, error) { @@ -106,7 +106,7 @@ func IsHelmRepo(repo string) (bool, error) { return resp.StatusCode == http.StatusOK, nil } -func loadFromHelmChartRepo(repo, chart, version string) ([]byte, error) { +func (r Repo) loadFromHelmChartRepo(repo, chart, version string) ([]byte, error) { tgzURL, err := getTarUrl(repo, chart, version) if err != nil { return nil, err @@ -115,7 +115,7 @@ func loadFromHelmChartRepo(repo, chart, version string) ([]byte, error) { return downloadFile(tgzURL) } -func mapHelmChart(chartName string, files map[string][]byte) (*models.Template, error) { +func (r Repo) mapHelmChart(chartName string, files map[string][]byte) (*models.Template, error) { metadataBytes := []byte{} schemaBytes := []byte{} manifestParts := make([]string, 0) @@ -171,7 +171,7 @@ func mapHelmChart(chartName string, files map[string][]byte) (*models.Template, } // region load dependencies - dependencies, err := loadDependencies(metadata) + dependencies, err := r.loadDependencies(metadata) if err != nil { return &models.Template{}, err } @@ -181,7 +181,7 @@ func mapHelmChart(chartName string, files map[string][]byte) (*models.Template, continue } - dep, err := mapHelmChart(depName, files) + dep, err := r.mapHelmChart(depName, files) if err != nil { return nil, err } @@ -202,7 +202,7 @@ func mapHelmChart(chartName string, files map[string][]byte) (*models.Template, }, nil } -func mapHelmChartInitialValues(files map[string][]byte) (map[interface{}]interface{}, error) { +func (r Repo) mapHelmChartInitialValues(files map[string][]byte) (map[interface{}]interface{}, error) { metadataBytes := []byte{} valuesBytes := []byte{} dependenciesFromChartsDir := make(map[string]map[string][]byte, 0) @@ -243,7 +243,7 @@ func mapHelmChartInitialValues(files map[string][]byte) (map[interface{}]interfa // region load dependencies for depName, files := range dependenciesFromChartsDir { - dep, err := mapHelmChartInitialValues(files) + dep, err := r.mapHelmChartInitialValues(files) if err != nil { return nil, err } @@ -251,7 +251,7 @@ func mapHelmChartInitialValues(files map[string][]byte) (map[interface{}]interfa values[depName] = dep } - dependenciesFromMeta, err := loadDependenciesInitialValues(metadata) + dependenciesFromMeta, err := r.loadDependenciesInitialValues(metadata) if err != nil { return nil, err } diff --git a/cyclops-ctrl/internal/template/oci.go b/cyclops-ctrl/internal/template/oci.go index 635b7455..c500cc1a 100644 --- a/cyclops-ctrl/internal/template/oci.go +++ b/cyclops-ctrl/internal/template/oci.go @@ -13,7 +13,7 @@ import ( "github.com/pkg/errors" ) -func LoadOCIHelmChart(repo, chart, version string) (*models.Template, error) { +func (r Repo) LoadOCIHelmChart(repo, chart, version string) (*models.Template, error) { var tgzData []byte tgzData, err := loadOCIHelmChartBytes(repo, chart, version) if err != nil { @@ -25,10 +25,10 @@ func LoadOCIHelmChart(repo, chart, version string) (*models.Template, error) { return nil, err } - return mapHelmChart(chart, extractedFiles) + return r.mapHelmChart(chart, extractedFiles) } -func LoadOCIHelmChartInitialValues(repo, chart, version string) (map[interface{}]interface{}, error) { +func (r Repo) LoadOCIHelmChartInitialValues(repo, chart, version string) (map[interface{}]interface{}, error) { tgzData, err := loadOCIHelmChartBytes(repo, chart, version) if err != nil { return nil, err @@ -55,7 +55,7 @@ func LoadOCIHelmChartInitialValues(repo, chart, version string) (map[interface{} return nil, err } - return mapHelmChartInitialValues(extractedFiles) + return r.mapHelmChartInitialValues(extractedFiles) } func loadOCIHelmChartBytes(repo, chart, version string) ([]byte, error) { diff --git a/cyclops-ctrl/internal/template/template.go b/cyclops-ctrl/internal/template/template.go index f2c5e1c9..6823ce05 100644 --- a/cyclops-ctrl/internal/template/template.go +++ b/cyclops-ctrl/internal/template/template.go @@ -7,10 +7,36 @@ import ( "helm.sh/helm/v3/pkg/registry" ) -func GetTemplate(repo, path, version string) (*models.Template, error) { +type Repo struct { + cache templateCache +} + +type templateCache interface { + Get(repo, path, version string) (*models.Template, bool) + Set(repo, path, version string, template *models.Template) +} + +func NewRepo(tc templateCache) *Repo { + return &Repo{ + cache: tc, + } +} + +func (r Repo) GetTemplate(repo, path, version string) (*models.Template, error) { + cached, ok := r.cache.Get(repo, path, version) + if ok { + return cached, nil + } + // region load OCI chart if registry.IsOCI(repo) { - return LoadOCIHelmChart(repo, path, version) + template, err := r.LoadOCIHelmChart(repo, path, version) + if err != nil { + return nil, err + } + + r.cache.Set(repo, path, version, template) + return template, nil } // endregion @@ -21,18 +47,23 @@ func GetTemplate(repo, path, version string) (*models.Template, error) { } if isHelmRepo { - return LoadHelmChart(repo, path, version) + return r.LoadHelmChart(repo, path, version) } // endregion - // fallback to cloning from git - return LoadTemplate(repo, path, version) + template, err := r.LoadTemplate(repo, path, version) + if err != nil { + return nil, err + } + + r.cache.Set(repo, path, version, template) + return template, nil } -func GetTemplateInitialValues(repo, path, version string) ([]byte, error) { +func (r Repo) GetTemplateInitialValues(repo, path, version string) ([]byte, error) { // region load OCI chart if registry.IsOCI(repo) { - initial, err := LoadOCIHelmChartInitialValues(repo, path, version) + initial, err := r.LoadOCIHelmChartInitialValues(repo, path, version) if err != nil { return nil, err } @@ -48,7 +79,7 @@ func GetTemplateInitialValues(repo, path, version string) ([]byte, error) { } if isHelmRepo { - initial, err := LoadHelmChartInitialValues(repo, path, version) + initial, err := r.LoadHelmChartInitialValues(repo, path, version) if err != nil { return nil, err } @@ -58,7 +89,7 @@ func GetTemplateInitialValues(repo, path, version string) ([]byte, error) { // endregion // fallback to cloning from git - initial, err := LoadInitialTemplateValues(repo, path, version) + initial, err := r.LoadInitialTemplateValues(repo, path, version) if err != nil { return nil, err } @@ -66,10 +97,10 @@ func GetTemplateInitialValues(repo, path, version string) ([]byte, error) { return json.Marshal(initial) } -func loadDependencies(metadata helmchart.Metadata) ([]*models.Template, error) { +func (r Repo) loadDependencies(metadata helmchart.Metadata) ([]*models.Template, error) { deps := make([]*models.Template, 0) for _, dependency := range metadata.Dependencies { - dep, err := GetTemplate(dependency.Repository, dependency.Name, dependency.Version) + dep, err := r.GetTemplate(dependency.Repository, dependency.Name, dependency.Version) if err != nil { return nil, err } @@ -80,10 +111,10 @@ func loadDependencies(metadata helmchart.Metadata) ([]*models.Template, error) { return deps, nil } -func loadDependenciesInitialValues(metadata helmchart.Metadata) (map[interface{}]interface{}, error) { +func (r Repo) loadDependenciesInitialValues(metadata helmchart.Metadata) (map[interface{}]interface{}, error) { initialValues := make(map[interface{}]interface{}) for _, dependency := range metadata.Dependencies { - depInitialValues, err := GetTemplateInitialValues(dependency.Repository, dependency.Name, dependency.Version) + depInitialValues, err := r.GetTemplateInitialValues(dependency.Repository, dependency.Name, dependency.Version) if err != nil { return nil, err } From aa6c2540418a4a83aaed3848bb5561cd61f886d3 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Tue, 6 Feb 2024 17:34:10 +0100 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=92=A8=20cache=20templates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cyclops-ctrl/go.mod | 46 ++++--- cyclops-ctrl/go.sum | 143 +++++++++++--------- cyclops-ctrl/internal/controller/modules.go | 3 +- cyclops-ctrl/internal/template/git.go | 54 +++++++- cyclops-ctrl/internal/template/helm.go | 61 ++++++++- cyclops-ctrl/internal/template/oci.go | 29 +++- cyclops-ctrl/internal/template/template.go | 22 +-- 7 files changed, 243 insertions(+), 115 deletions(-) diff --git a/cyclops-ctrl/go.mod b/cyclops-ctrl/go.mod index 4b109633..9cb3617e 100644 --- a/cyclops-ctrl/go.mod +++ b/cyclops-ctrl/go.mod @@ -4,16 +4,17 @@ go 1.19 require ( github.com/Masterminds/semver/v3 v3.2.0 + github.com/dgraph-io/ristretto v0.1.1 github.com/gin-gonic/gin v1.9.1 + github.com/go-git/go-billy/v5 v5.5.0 + github.com/go-git/go-git/v5 v5.11.0 github.com/go-logr/logr v1.2.4 github.com/go-redis/redis/v8 v8.11.5 github.com/json-iterator/go v1.1.12 - github.com/onsi/ginkgo/v2 v2.9.5 - github.com/onsi/gomega v1.27.7 + github.com/onsi/ginkgo/v2 v2.11.0 + github.com/onsi/gomega v1.27.10 github.com/pkg/errors v0.9.1 - golang.org/x/net v0.17.0 - gopkg.in/src-d/go-billy.v4 v4.3.2 - gopkg.in/src-d/go-git.v4 v4.13.1 + golang.org/x/net v0.19.0 gopkg.in/yaml.v2 v2.4.0 helm.sh/helm/v3 v3.11.3 k8s.io/api v0.28.2 @@ -24,19 +25,22 @@ require ( ) require ( + dario.cat/mergo v1.0.0 // indirect github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/BurntSushi/toml v1.2.1 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bytedance/sonic v1.9.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/cloudflare/circl v1.3.3 // indirect github.com/containerd/containerd v1.7.0 // indirect - github.com/cyphar/filepath-securejoin v0.2.3 // indirect + github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/docker/cli v20.10.21+incompatible // indirect github.com/docker/distribution v2.8.1+incompatible // indirect @@ -47,11 +51,12 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/emicklei/go-restful/v3 v3.10.1 // indirect - github.com/emirpasic/gods v1.12.0 // indirect + github.com/emirpasic/gods v1.18.1 // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/zapr v1.2.4 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect @@ -68,7 +73,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect github.com/google/uuid v1.3.0 // indirect @@ -77,7 +82,7 @@ require ( github.com/imdario/mergo v0.3.13 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/klauspost/compress v1.16.0 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/leodido/go-urn v1.2.4 // indirect @@ -85,7 +90,6 @@ require ( github.com/mattn/go-isatty v0.0.19 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/moby/locker v1.0.1 // indirect github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect @@ -96,19 +100,20 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/prometheus/client_golang v1.15.1 // indirect github.com/prometheus/client_model v0.4.0 // indirect github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect - github.com/sergi/go-diff v1.0.0 // indirect + github.com/sergi/go-diff v1.1.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/sirupsen/logrus v1.9.0 // indirect + github.com/skeema/knownhosts v1.2.1 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/src-d/gcfg v1.4.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect - github.com/xanzy/ssh-agent v0.2.1 // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect @@ -118,14 +123,15 @@ require ( go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.14.0 // indirect + golang.org/x/crypto v0.16.0 // indirect + golang.org/x/mod v0.12.0 // indirect golang.org/x/oauth2 v0.8.0 // indirect - golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/sync v0.3.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/term v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.9.1 // indirect + golang.org/x/tools v0.13.0 // indirect gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect diff --git a/cyclops-ctrl/go.sum b/cyclops-ctrl/go.sum index 196b13e8..896e759a 100644 --- a/cyclops-ctrl/go.sum +++ b/cyclops-ctrl/go.sum @@ -1,3 +1,5 @@ +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1INOIyr5hWOWhvpmQpY6tKjeG0hT1s3AMC/9fic= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1/go.mod h1:VzwV+t+dZ9j/H867F1M2ziD+yLHtB46oM35FxxMJ4d0= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= @@ -10,17 +12,17 @@ github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7Y github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= -github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= +github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.10.0-rc.7 h1:HBytQPxcv8Oy4244zbQbe6hnOnx544eL5QPUqhJldz8= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= -github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= -github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= -github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -31,6 +33,7 @@ github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuP github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd h1:rFt+Y/IK1aEZkEHchZRSq9OQbsSzIT/OrI8YFFmRIng= github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembjv71DPz3uX/V/6MMlSyD9JBQ6kQ= github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o= +github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= @@ -43,20 +46,22 @@ github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583j github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= github.com/containerd/containerd v1.7.0 h1:G/ZQr3gMZs6ZT0qPUZ15znx5QSdQdASW11nXTLTM2Pg= github.com/containerd/containerd v1.7.0/go.mod h1:QfR7Efgb/6X2BDpTPJRvPTYDE9rsF0FsXX9J8sIs/sc= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= -github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= -github.com/cyphar/filepath-securejoin v0.2.3 h1:YX6ebbZCZP7VkM3scTTokDgBL2TY741X51MTk3ycuNI= -github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= @@ -79,15 +84,15 @@ github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1 h1:ZClxb8laGDf5arXfYcAtECDFgAgHklGI8CxgjHnXKJ4= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= -github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= @@ -97,8 +102,14 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= -github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= -github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= +github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= +github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= +github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= @@ -151,8 +162,8 @@ github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvR github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -183,8 +194,8 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY= -github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= @@ -198,7 +209,6 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= @@ -214,8 +224,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfr github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -238,18 +246,19 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q= -github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k= -github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU= -github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4= +github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= +github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b h1:YWuSjZCQAPM8UUBLkYUk1e+rZcvWHJmFb6i6rM44Xs8= github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= -github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -274,26 +283,26 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= +github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4= -github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -306,14 +315,14 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= -github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= @@ -345,36 +354,41 @@ golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUu golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -384,19 +398,21 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= -golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -407,33 +423,40 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= -golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -453,21 +476,17 @@ google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg= -gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98= -gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg= -gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g= -gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE= -gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/cyclops-ctrl/internal/controller/modules.go b/cyclops-ctrl/internal/controller/modules.go index ae4e12f7..5bc4405d 100644 --- a/cyclops-ctrl/internal/controller/modules.go +++ b/cyclops-ctrl/internal/controller/modules.go @@ -6,13 +6,14 @@ import ( "os" "strings" + "github.com/gin-gonic/gin" + "github.com/cyclops-ui/cycops-ctrl/api/v1alpha1" "github.com/cyclops-ui/cycops-ctrl/internal/cluster/k8sclient" "github.com/cyclops-ui/cycops-ctrl/internal/mapper" "github.com/cyclops-ui/cycops-ctrl/internal/models/dto" "github.com/cyclops-ui/cycops-ctrl/internal/storage/templates" "github.com/cyclops-ui/cycops-ctrl/internal/template" - "github.com/gin-gonic/gin" ) type Modules struct { diff --git a/cyclops-ctrl/internal/template/git.go b/cyclops-ctrl/internal/template/git.go index cba02f3d..38144638 100644 --- a/cyclops-ctrl/internal/template/git.go +++ b/cyclops-ctrl/internal/template/git.go @@ -6,16 +6,18 @@ import ( "encoding/json" "fmt" "io" + "log" path2 "path" "path/filepath" "strings" + "github.com/go-git/go-billy/v5" + "github.com/go-git/go-billy/v5/memfs" + "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/config" + "github.com/go-git/go-git/v5/plumbing" + "github.com/go-git/go-git/v5/storage/memory" "github.com/pkg/errors" - "gopkg.in/src-d/go-billy.v4" - "gopkg.in/src-d/go-billy.v4/memfs" - git "gopkg.in/src-d/go-git.v4" - "gopkg.in/src-d/go-git.v4/plumbing" - "gopkg.in/src-d/go-git.v4/storage/memory" "gopkg.in/yaml.v2" "helm.sh/helm/v3/pkg/chart" @@ -25,6 +27,16 @@ import ( ) func (r Repo) LoadTemplate(repoURL, path, commit string) (*models.Template, error) { + commitSHA, err := resolveRef(repoURL, commit) + if err != nil { + return nil, err + } + + cached, ok := r.cache.Get(repoURL, path, commitSHA) + if ok { + return cached, nil + } + fs, err := clone(repoURL, commit) if err != nil { return nil, err @@ -99,7 +111,7 @@ func (r Repo) LoadTemplate(repoURL, path, commit string) (*models.Template, erro } // endregion - return &models.Template{ + template := &models.Template{ Name: "", Manifest: strings.Join(manifests, "---\n"), Fields: mapper.HelmSchemaToFields(schema, dependencies), @@ -108,7 +120,11 @@ func (r Repo) LoadTemplate(repoURL, path, commit string) (*models.Template, erro Version: "", Files: chartFiles, Dependencies: dependencies, - }, nil + } + + r.cache.Set(repoURL, path, commitSHA, template) + + return template, err } func (r Repo) LoadInitialTemplateValues(repoURL, path, commit string) (map[interface{}]interface{}, error) { @@ -165,6 +181,30 @@ func (r Repo) LoadInitialTemplateValues(repoURL, path, commit string) (map[inter return initialValues, nil } +func resolveRef(repo, version string) (string, error) { + rem := git.NewRemote(memory.NewStorage(), &config.RemoteConfig{ + Name: "origin", + URLs: []string{repo}, + }) + + // We can then use every Remote functions to retrieve wanted information + refs, err := rem.List(&git.ListOptions{ + PeelingOption: git.AppendPeeled, + }) + if err != nil { + log.Fatal(err) + } + + // Filters the references list and only keeps tags + for _, ref := range refs { + if ref.Name().Short() == version { + return ref.Hash().String(), nil + } + } + + return version, nil +} + func readValuesFile(fs billy.Filesystem, path string) ([]byte, error) { valuesFile, err := fs.Open(path2.Join(path, "values.yaml")) if err != nil { diff --git a/cyclops-ctrl/internal/template/helm.go b/cyclops-ctrl/internal/template/helm.go index 17c02624..94297b49 100644 --- a/cyclops-ctrl/internal/template/helm.go +++ b/cyclops-ctrl/internal/template/helm.go @@ -24,8 +24,28 @@ import ( ) func (r Repo) LoadHelmChart(repo, chart, version string) (*models.Template, error) { - var tgzData []byte var err error + var strictVersion string + if !isValidVersion(version) { + if registry.IsOCI(repo) { + strictVersion, err = getOCIStrictVersion(repo, chart, version) + if err != nil { + return nil, err + } + } else { + strictVersion, err = getRepoStrictVersion(repo, chart, version) + if err != nil { + return nil, err + } + } + } + + cached, ok := r.cache.Get(repo, chart, strictVersion) + if ok { + return cached, nil + } + + var tgzData []byte if registry.IsOCI(repo) { tgzData, err = loadOCIHelmChartBytes(repo, chart, version) if err != nil { @@ -43,7 +63,14 @@ func (r Repo) LoadHelmChart(repo, chart, version string) (*models.Template, erro return nil, err } - return r.mapHelmChart(chart, extractedFiles) + template, err := r.mapHelmChart(chart, extractedFiles) + if err != nil { + return nil, err + } + + r.cache.Set(repo, chart, strictVersion, template) + + return template, nil } func (r Repo) LoadHelmChartInitialValues(repo, chart, version string) (map[interface{}]interface{}, error) { @@ -309,6 +336,36 @@ func getTarUrl(repo, chart, version string) (string, error) { return "", errors.New(fmt.Sprintf("version %v not found in chart %v and repo %v", version, chart, repo)) } +func getRepoStrictVersion(repo, chart, version string) (string, error) { + indexURL, err := url.JoinPath(repo, "index.yaml") + if err != nil { + return "", err + } + + response, err := http.Get(indexURL) + if err != nil { + return "", err + } + defer response.Body.Close() + + body, err := ioutil.ReadAll(response.Body) + if err != nil { + return "", err + } + + var data helm.Index + err = yaml.Unmarshal(body, &data) + if err != nil { + return "", err + } + + if _, ok := data.Entries[chart]; !ok { + return "", errors.New(fmt.Sprintf("chart %v not found in repo %v", chart, repo)) + } + + return resolveVersion(data.Entries[chart], version) +} + func resolveVersion(indexEntries []helm.IndexEntry, version string) (string, error) { if isValidVersion(version) { return version, nil diff --git a/cyclops-ctrl/internal/template/oci.go b/cyclops-ctrl/internal/template/oci.go index c500cc1a..677fb516 100644 --- a/cyclops-ctrl/internal/template/oci.go +++ b/cyclops-ctrl/internal/template/oci.go @@ -14,8 +14,22 @@ import ( ) func (r Repo) LoadOCIHelmChart(repo, chart, version string) (*models.Template, error) { + var err error + strictVersion := version + if !isValidVersion(version) { + strictVersion, err = getOCIStrictVersion(repo, chart, version) + if err != nil { + return nil, err + } + } + + cached, ok := r.cache.Get(repo, chart, strictVersion) + if ok { + return cached, nil + } + var tgzData []byte - tgzData, err := loadOCIHelmChartBytes(repo, chart, version) + tgzData, err = loadOCIHelmChartBytes(repo, chart, version) if err != nil { return nil, err } @@ -25,7 +39,14 @@ func (r Repo) LoadOCIHelmChart(repo, chart, version string) (*models.Template, e return nil, err } - return r.mapHelmChart(chart, extractedFiles) + template, err := r.mapHelmChart(chart, extractedFiles) + if err != nil { + return nil, err + } + + r.cache.Set(repo, chart, strictVersion, template) + + return template, nil } func (r Repo) LoadOCIHelmChartInitialValues(repo, chart, version string) (map[interface{}]interface{}, error) { @@ -61,7 +82,7 @@ func (r Repo) LoadOCIHelmChartInitialValues(repo, chart, version string) (map[in func loadOCIHelmChartBytes(repo, chart, version string) ([]byte, error) { var err error if !isValidVersion(version) { - version, err = getStrictVersion(repo, chart, version) + version, err = getOCIStrictVersion(repo, chart, version) if err != nil { return nil, err } @@ -185,7 +206,7 @@ func fetchDigest(repo, chart, version, token string) (string, error) { return resp.Header.Get("docker-content-digest"), nil } -func getStrictVersion(repo, chart, version string) (string, error) { +func getOCIStrictVersion(repo, chart, version string) (string, error) { token, err := authorizeOCITags(repo, chart) if err != nil { return "", err diff --git a/cyclops-ctrl/internal/template/template.go b/cyclops-ctrl/internal/template/template.go index 6823ce05..d1288b16 100644 --- a/cyclops-ctrl/internal/template/template.go +++ b/cyclops-ctrl/internal/template/template.go @@ -23,20 +23,9 @@ func NewRepo(tc templateCache) *Repo { } func (r Repo) GetTemplate(repo, path, version string) (*models.Template, error) { - cached, ok := r.cache.Get(repo, path, version) - if ok { - return cached, nil - } - // region load OCI chart if registry.IsOCI(repo) { - template, err := r.LoadOCIHelmChart(repo, path, version) - if err != nil { - return nil, err - } - - r.cache.Set(repo, path, version, template) - return template, nil + return r.LoadOCIHelmChart(repo, path, version) } // endregion @@ -51,13 +40,8 @@ func (r Repo) GetTemplate(repo, path, version string) (*models.Template, error) } // endregion - template, err := r.LoadTemplate(repo, path, version) - if err != nil { - return nil, err - } - - r.cache.Set(repo, path, version, template) - return template, nil + // fallback to cloning from git + return r.LoadTemplate(repo, path, version) } func (r Repo) GetTemplateInitialValues(repo, path, version string) ([]byte, error) { From f75229915410f3d27424864f247e48eb2e783eb9 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Tue, 6 Feb 2024 20:40:56 +0100 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=92=A8=20cache=20templates=20initial?= =?UTF-8?q?=20values?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/template/cache/inmemory.go | 42 ++++++++++++++--- cyclops-ctrl/internal/template/git.go | 16 ++++++- cyclops-ctrl/internal/template/helm.go | 45 ++++++++++++------- cyclops-ctrl/internal/template/oci.go | 41 +++++++++-------- cyclops-ctrl/internal/template/template.go | 13 ++++-- 5 files changed, 111 insertions(+), 46 deletions(-) diff --git a/cyclops-ctrl/internal/template/cache/inmemory.go b/cyclops-ctrl/internal/template/cache/inmemory.go index 4798b7d3..48882666 100644 --- a/cyclops-ctrl/internal/template/cache/inmemory.go +++ b/cyclops-ctrl/internal/template/cache/inmemory.go @@ -1,10 +1,12 @@ package cache import ( + "encoding/json" "fmt" - "github.com/cyclops-ui/cycops-ctrl/internal/models" + "github.com/dgraph-io/ristretto" - "unsafe" + + "github.com/cyclops-ui/cycops-ctrl/internal/models" ) type Templates struct { @@ -26,7 +28,7 @@ func NewInMemoryTemplatesCache() Templates { } } -func (t Templates) Get(repo, path, version string) (*models.Template, bool) { +func (t Templates) GetTemplate(repo, path, version string) (*models.Template, bool) { value, found := t.cache.Get(templateKey(repo, path, version)) if !found { return nil, false @@ -40,11 +42,39 @@ func (t Templates) Get(repo, path, version string) (*models.Template, bool) { return &template, ok } -func (t Templates) Set(repo, path, version string, template *models.Template) { - t.cache.Set(templateKey(repo, path, version), *template, int64(unsafe.Sizeof(*template))) +func (t Templates) SetTemplate(repo, path, version string, template *models.Template) { + data, err := json.Marshal(template) + if err != nil { + return + } + + t.cache.Set(templateKey(repo, path, version), *template, int64(len(data))) + t.cache.Wait() +} + +func (t Templates) GetTemplateInitialValues(repo, path, version string) (map[interface{}]interface{}, bool) { + data, found := t.cache.Get(initialValuesKey(repo, path, version)) + if !found { + return nil, false + } + + values, ok := data.(map[interface{}]interface{}) + if !ok { + return nil, false + } + + return values, ok +} + +func (t Templates) SetTemplateInitialValues(repo, path, version string, values map[interface{}]interface{}) { + t.cache.Set(initialValuesKey(repo, path, version), values, int64(len(values))) t.cache.Wait() } func templateKey(repo, path, version string) string { - return fmt.Sprintf("%v/%v@%v", repo, path, version) + return fmt.Sprintf("template:%v/%v@%v", repo, path, version) +} + +func initialValuesKey(repo, path, version string) string { + return fmt.Sprintf("initialValues:%v/%v@%v", repo, path, version) } diff --git a/cyclops-ctrl/internal/template/git.go b/cyclops-ctrl/internal/template/git.go index 38144638..f2db766a 100644 --- a/cyclops-ctrl/internal/template/git.go +++ b/cyclops-ctrl/internal/template/git.go @@ -32,7 +32,7 @@ func (r Repo) LoadTemplate(repoURL, path, commit string) (*models.Template, erro return nil, err } - cached, ok := r.cache.Get(repoURL, path, commitSHA) + cached, ok := r.cache.GetTemplate(repoURL, path, commitSHA) if ok { return cached, nil } @@ -122,12 +122,22 @@ func (r Repo) LoadTemplate(repoURL, path, commit string) (*models.Template, erro Dependencies: dependencies, } - r.cache.Set(repoURL, path, commitSHA, template) + r.cache.SetTemplate(repoURL, path, commitSHA, template) return template, err } func (r Repo) LoadInitialTemplateValues(repoURL, path, commit string) (map[interface{}]interface{}, error) { + commitSHA, err := resolveRef(repoURL, commit) + if err != nil { + return nil, err + } + + cached, ok := r.cache.GetTemplateInitialValues(repoURL, path, commitSHA) + if ok { + return cached, nil + } + fs, err := clone(repoURL, commit) if err != nil { return nil, err @@ -178,6 +188,8 @@ func (r Repo) LoadInitialTemplateValues(repoURL, path, commit string) (map[inter } // endregion + r.cache.SetTemplateInitialValues(repoURL, path, commitSHA, initialValues) + return initialValues, nil } diff --git a/cyclops-ctrl/internal/template/helm.go b/cyclops-ctrl/internal/template/helm.go index 94297b49..22a0f12e 100644 --- a/cyclops-ctrl/internal/template/helm.go +++ b/cyclops-ctrl/internal/template/helm.go @@ -40,7 +40,7 @@ func (r Repo) LoadHelmChart(repo, chart, version string) (*models.Template, erro } } - cached, ok := r.cache.Get(repo, chart, strictVersion) + cached, ok := r.cache.GetTemplate(repo, chart, strictVersion) if ok { return cached, nil } @@ -68,14 +68,34 @@ func (r Repo) LoadHelmChart(repo, chart, version string) (*models.Template, erro return nil, err } - r.cache.Set(repo, chart, strictVersion, template) + r.cache.SetTemplate(repo, chart, strictVersion, template) return template, nil } func (r Repo) LoadHelmChartInitialValues(repo, chart, version string) (map[interface{}]interface{}, error) { - var tgzData []byte var err error + var strictVersion string + if !isValidVersion(version) { + if registry.IsOCI(repo) { + strictVersion, err = getOCIStrictVersion(repo, chart, version) + if err != nil { + return nil, err + } + } else { + strictVersion, err = getRepoStrictVersion(repo, chart, version) + if err != nil { + return nil, err + } + } + } + + cached, ok := r.cache.GetTemplateInitialValues(repo, chart, strictVersion) + if ok { + return cached, nil + } + + var tgzData []byte if registry.IsOCI(repo) { tgzData, err = loadOCIHelmChartBytes(repo, chart, version) if err != nil { @@ -93,23 +113,14 @@ func (r Repo) LoadHelmChartInitialValues(repo, chart, version string) (map[inter return nil, err } - valuesBytes := []byte{} - - for name, content := range extractedFiles { - parts := strings.Split(name, "/") - - if len(parts) == 2 && parts[1] == "values.yaml" { - valuesBytes = content - break - } - } - - var values map[interface{}]interface{} - if err := yaml.Unmarshal(valuesBytes, &values); err != nil { + initial, err := r.mapHelmChartInitialValues(extractedFiles) + if err != nil { return nil, err } - return r.mapHelmChartInitialValues(extractedFiles) + r.cache.SetTemplateInitialValues(repo, chart, strictVersion, initial) + + return initial, nil } func IsHelmRepo(repo string) (bool, error) { diff --git a/cyclops-ctrl/internal/template/oci.go b/cyclops-ctrl/internal/template/oci.go index 677fb516..625e8ccb 100644 --- a/cyclops-ctrl/internal/template/oci.go +++ b/cyclops-ctrl/internal/template/oci.go @@ -2,15 +2,15 @@ package template import ( "fmt" - "gopkg.in/yaml.v2" "io/ioutil" "net/http" "net/url" "strings" - "github.com/cyclops-ui/cycops-ctrl/internal/models" json "github.com/json-iterator/go" "github.com/pkg/errors" + + "github.com/cyclops-ui/cycops-ctrl/internal/models" ) func (r Repo) LoadOCIHelmChart(repo, chart, version string) (*models.Template, error) { @@ -23,7 +23,7 @@ func (r Repo) LoadOCIHelmChart(repo, chart, version string) (*models.Template, e } } - cached, ok := r.cache.Get(repo, chart, strictVersion) + cached, ok := r.cache.GetTemplate(repo, chart, strictVersion) if ok { return cached, nil } @@ -44,12 +44,26 @@ func (r Repo) LoadOCIHelmChart(repo, chart, version string) (*models.Template, e return nil, err } - r.cache.Set(repo, chart, strictVersion, template) + r.cache.SetTemplate(repo, chart, strictVersion, template) return template, nil } func (r Repo) LoadOCIHelmChartInitialValues(repo, chart, version string) (map[interface{}]interface{}, error) { + var err error + strictVersion := version + if !isValidVersion(version) { + strictVersion, err = getOCIStrictVersion(repo, chart, version) + if err != nil { + return nil, err + } + } + + cached, ok := r.cache.GetTemplateInitialValues(repo, chart, strictVersion) + if ok { + return cached, nil + } + tgzData, err := loadOCIHelmChartBytes(repo, chart, version) if err != nil { return nil, err @@ -60,23 +74,14 @@ func (r Repo) LoadOCIHelmChartInitialValues(repo, chart, version string) (map[in return nil, err } - valuesBytes := []byte{} - - for name, content := range extractedFiles { - parts := strings.Split(name, "/") - - if len(parts) == 2 && parts[1] == "values.yaml" { - valuesBytes = content - break - } - } - - var values map[interface{}]interface{} - if err := yaml.Unmarshal(valuesBytes, &values); err != nil { + initial, err := r.mapHelmChartInitialValues(extractedFiles) + if err != nil { return nil, err } - return r.mapHelmChartInitialValues(extractedFiles) + r.cache.SetTemplateInitialValues(repo, chart, strictVersion, initial) + + return initial, nil } func loadOCIHelmChartBytes(repo, chart, version string) ([]byte, error) { diff --git a/cyclops-ctrl/internal/template/template.go b/cyclops-ctrl/internal/template/template.go index d1288b16..032f5f5e 100644 --- a/cyclops-ctrl/internal/template/template.go +++ b/cyclops-ctrl/internal/template/template.go @@ -12,8 +12,10 @@ type Repo struct { } type templateCache interface { - Get(repo, path, version string) (*models.Template, bool) - Set(repo, path, version string, template *models.Template) + GetTemplate(repo, path, version string) (*models.Template, bool) + SetTemplate(repo, path, version string, template *models.Template) + GetTemplateInitialValues(repo, path, version string) (map[interface{}]interface{}, bool) + SetTemplateInitialValues(repo, path, version string, values map[interface{}]interface{}) } func NewRepo(tc templateCache) *Repo { @@ -98,11 +100,16 @@ func (r Repo) loadDependencies(metadata helmchart.Metadata) ([]*models.Template, func (r Repo) loadDependenciesInitialValues(metadata helmchart.Metadata) (map[interface{}]interface{}, error) { initialValues := make(map[interface{}]interface{}) for _, dependency := range metadata.Dependencies { - depInitialValues, err := r.GetTemplateInitialValues(dependency.Repository, dependency.Name, dependency.Version) + depInitialValuesData, err := r.GetTemplateInitialValues(dependency.Repository, dependency.Name, dependency.Version) if err != nil { return nil, err } + var depInitialValues interface{} + if err := json.Unmarshal(depInitialValuesData, &depInitialValues); err != nil { + panic(err) + } + initialValues[dependency.Name] = depInitialValues } From ffff11fc658b359b684be4dcd13801baff9771b2 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Wed, 7 Feb 2024 19:20:47 +0000 Subject: [PATCH 4/5] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20update=20cyclops=20to?= =?UTF-8?q?=20v0.0.1-alpha.13-rc-cache-templates.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install/cyclops-install.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/cyclops-install.yaml b/install/cyclops-install.yaml index 6816148b..62c5adb7 100644 --- a/install/cyclops-install.yaml +++ b/install/cyclops-install.yaml @@ -249,7 +249,7 @@ spec: spec: containers: - name: cyclops-ui - image: cyclopsui/cyclops-ui:v0.0.1-alpha.13-rc-4 + image: cyclopsui/cyclops-ui:v0.0.1-alpha.13-rc-cache-templates.1 ports: - containerPort: 80 env: @@ -295,7 +295,7 @@ spec: serviceAccountName: cyclops-ctrl containers: - name: cyclops-ctrl - image: cyclopsui/cyclops-ctrl:v0.0.1-alpha.13-rc-4 + image: cyclopsui/cyclops-ctrl:v0.0.1-alpha.13-rc-cache-templates.1 ports: - containerPort: 8080 env: From 9f64f2a8f5b1bd0aff54aa419970dd5548f40144 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Fri, 9 Feb 2024 17:48:34 +0100 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=92=A8=20default=20strict=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cyclops-ctrl/internal/template/helm.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cyclops-ctrl/internal/template/helm.go b/cyclops-ctrl/internal/template/helm.go index 22a0f12e..0eece01d 100644 --- a/cyclops-ctrl/internal/template/helm.go +++ b/cyclops-ctrl/internal/template/helm.go @@ -25,7 +25,7 @@ import ( func (r Repo) LoadHelmChart(repo, chart, version string) (*models.Template, error) { var err error - var strictVersion string + strictVersion := version if !isValidVersion(version) { if registry.IsOCI(repo) { strictVersion, err = getOCIStrictVersion(repo, chart, version) @@ -75,7 +75,7 @@ func (r Repo) LoadHelmChart(repo, chart, version string) (*models.Template, erro func (r Repo) LoadHelmChartInitialValues(repo, chart, version string) (map[interface{}]interface{}, error) { var err error - var strictVersion string + strictVersion := version if !isValidVersion(version) { if registry.IsOCI(repo) { strictVersion, err = getOCIStrictVersion(repo, chart, version)