From 81fc6b27dcb871f8553d1a7b87319672d3aec8db Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Sat, 20 Jan 2024 00:42:23 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=EF=B8=8Fchange=20k8s=20components=20refres?= =?UTF-8?q?h=20rate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cyclops-ui/src/components/k8s-resources/ConfigMap.tsx | 2 +- cyclops-ui/src/components/k8s-resources/Deployment.tsx | 2 +- cyclops-ui/src/components/k8s-resources/Pod.tsx | 2 +- cyclops-ui/src/components/k8s-resources/Service.tsx | 2 +- cyclops-ui/src/components/k8s-resources/StatefulSet.tsx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cyclops-ui/src/components/k8s-resources/ConfigMap.tsx b/cyclops-ui/src/components/k8s-resources/ConfigMap.tsx index 0ef75939..f159214a 100644 --- a/cyclops-ui/src/components/k8s-resources/ConfigMap.tsx +++ b/cyclops-ui/src/components/k8s-resources/ConfigMap.tsx @@ -41,7 +41,7 @@ const ConfigMap = ({name, namespace}: Props) => { useEffect(() => { fetchConfigMap() - const interval = setInterval(() => fetchConfigMap(), 10000) + const interval = setInterval(() => fetchConfigMap(), ) return () => { clearInterval(interval); } diff --git a/cyclops-ui/src/components/k8s-resources/Deployment.tsx b/cyclops-ui/src/components/k8s-resources/Deployment.tsx index 0cf83e90..dcfcb27f 100644 --- a/cyclops-ui/src/components/k8s-resources/Deployment.tsx +++ b/cyclops-ui/src/components/k8s-resources/Deployment.tsx @@ -54,7 +54,7 @@ const Deployment = ({name, namespace}: Props) => { useEffect(() => { fetchDeployment() - const interval = setInterval(() => fetchDeployment(), 10000) + const interval = setInterval(() => fetchDeployment(), 15000) return () => { clearInterval(interval); } diff --git a/cyclops-ui/src/components/k8s-resources/Pod.tsx b/cyclops-ui/src/components/k8s-resources/Pod.tsx index 494f4c7d..a6b90492 100644 --- a/cyclops-ui/src/components/k8s-resources/Pod.tsx +++ b/cyclops-ui/src/components/k8s-resources/Pod.tsx @@ -77,7 +77,7 @@ const Pod = ({name, namespace}: Props) => { useEffect(() => { fetchPod() - const interval = setInterval(() => fetchPod(), 10000) + const interval = setInterval(() => fetchPod(), 15000) return () => { clearInterval(interval); } diff --git a/cyclops-ui/src/components/k8s-resources/Service.tsx b/cyclops-ui/src/components/k8s-resources/Service.tsx index e69119dc..564bddfe 100644 --- a/cyclops-ui/src/components/k8s-resources/Service.tsx +++ b/cyclops-ui/src/components/k8s-resources/Service.tsx @@ -53,7 +53,7 @@ const Service = ({name, namespace}: Props) => { useEffect(() => { fetchService() - const interval = setInterval(() => fetchService(), 10000) + const interval = setInterval(() => fetchService(), 15000) return () => { clearInterval(interval); } diff --git a/cyclops-ui/src/components/k8s-resources/StatefulSet.tsx b/cyclops-ui/src/components/k8s-resources/StatefulSet.tsx index 0e8a645c..f454b622 100644 --- a/cyclops-ui/src/components/k8s-resources/StatefulSet.tsx +++ b/cyclops-ui/src/components/k8s-resources/StatefulSet.tsx @@ -54,7 +54,7 @@ const StatefulSet = ({name, namespace}: Props) => { useEffect(() => { fetchStatefulSet() - const interval = setInterval(() => fetchStatefulSet(), 10000) + const interval = setInterval(() => fetchStatefulSet(), 15000) return () => { clearInterval(interval); } From 40d3d19c23d9e1d7895a012c9ac1ecdec3a1b951 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Sat, 20 Jan 2024 00:47:38 +0100 Subject: [PATCH 2/4] migrate UI to multiple template sources --- .../src/components/pages/ModuleDetails.tsx | 39 ++++------- .../src/components/pages/edit_module.tsx | 69 +++++++------------ cyclops-ui/src/components/pages/modules.tsx | 10 +-- .../src/components/pages/new_module.tsx | 52 +++++++------- 4 files changed, 67 insertions(+), 103 deletions(-) diff --git a/cyclops-ui/src/components/pages/ModuleDetails.tsx b/cyclops-ui/src/components/pages/ModuleDetails.tsx index 09f0d49e..da1b95b9 100644 --- a/cyclops-ui/src/components/pages/ModuleDetails.tsx +++ b/cyclops-ui/src/components/pages/ModuleDetails.tsx @@ -74,13 +74,9 @@ interface module { name: String, namespace: String, template: { - name: String, + repo: String, + path: String, version: String, - git: { - repo: String, - path: String, - commit: String, - } } } @@ -98,13 +94,9 @@ const ModuleDetails = () => { name: "", namespace: "", template: { - name: "", + repo: "", + path: "", version: "", - git: { - repo: "", - path: "", - commit: "", - } } }); @@ -190,7 +182,7 @@ const ModuleDetails = () => { useEffect(() => { fetchModule() fetchModuleResources() - const interval = setInterval(() => fetchModuleResources(), 5000) + const interval = setInterval(() => fetchModuleResources(), 15000) return () => { clearInterval(interval); } @@ -401,11 +393,11 @@ const ModuleDetails = () => { const moduleLoading = () => { if (loadModule) { let commit = ""; - let commitLink = module.template.git.repo + `/tree/main/` + module.template.git.path; + let commitLink = module.template.repo + `/tree/main/` + module.template.path; - if (module.template.git.commit && module.template.git.commit !== "") { - commit = " @ " + module.template.git.commit - commitLink = module.template.git.repo + `/tree/` + module.template.git.commit + `/` + module.template.git.path; + if (module.template.version && module.template.version !== "") { + commit = " @ " + module.template.version + commitLink = module.template.repo + `/tree/` + module.template.version + `/` + module.template.path; } return
@@ -425,17 +417,10 @@ const ModuleDetails = () => { - { module.template.name.length !== 0 && - - - { module.template.name.length !== 0 && module.template.name + '@' + module.template.version } - - } - - { module.template.name.length === 0 && - + { commitLink.startsWith("https://github.com") && + - { module.template.name.length === 0 && ' Template ref' + commit} + { module.template.path.length !== 0 && module.template.path + commit } } diff --git a/cyclops-ui/src/components/pages/edit_module.tsx b/cyclops-ui/src/components/pages/edit_module.tsx index ef5d99aa..ea9cff53 100644 --- a/cyclops-ui/src/components/pages/edit_module.tsx +++ b/cyclops-ui/src/components/pages/edit_module.tsx @@ -48,12 +48,9 @@ const EditModule = () => { name: "", values: {}, template: { - name: "", + repo: "", + path: "", version: "", - git: { - repo: "", - path: "", - } } }); @@ -165,46 +162,30 @@ const EditModule = () => { axios.get(window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST + `/modules/` + moduleName).then(res => { setLoadValues(true) - if (module.name.length !== 0 ) { - axios.get(window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST + `/create-config/` + res.data.template + `?version=` + res.data.version).then(res => { - setConfig(res.data); - }).catch(error => { - setLoading(false); - if (error.response === undefined) { - setError({ - message: String(error), - description: "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST - }) - } else { - setError(error.response.data); - } - }); - } else { - axios.get(window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST + `/templates/git?repo=` + res.data.template.git.repo + `&path=` + res.data.template.git.path + `&commit=` + res.data.template.git.commit).then(templatesRes => { - setConfig(templatesRes.data); - setLoadTemplate(true); - - let values = mapsToArray(templatesRes.data.fields, res.data.values); - - setModule({ - name: res.data.name, - values: values, - template: res.data.template, - }); - form.setFieldsValue(values); - }).catch(error => { - setLoading(false); - setLoadTemplate(true); - if (error.response === undefined) { - setError({ - message: String(error), - description: "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST - }) - } else { - setError(error.response.data); - } + axios.get(window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST + `/templates?repo=` + res.data.template.repo + `&path=` + res.data.template.path + `&commit=` + res.data.template.version).then(templatesRes => { + setConfig(templatesRes.data); + setLoadTemplate(true); + + let values = mapsToArray(templatesRes.data.fields, res.data.values); + + setModule({ + name: res.data.name, + values: values, + template: res.data.template, }); - } + form.setFieldsValue(values); + }).catch(error => { + setLoading(false); + setLoadTemplate(true); + if (error.response === undefined) { + setError({ + message: String(error), + description: "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST + }) + } else { + setError(error.response.data); + } + }); // form.setFieldsValue(res.data.values); // form.setFieldValue('chains.0.name', "ja sam prvi name") diff --git a/cyclops-ui/src/components/pages/modules.tsx b/cyclops-ui/src/components/pages/modules.tsx index ee87c219..16896098 100644 --- a/cyclops-ui/src/components/pages/modules.tsx +++ b/cyclops-ui/src/components/pages/modules.tsx @@ -132,8 +132,8 @@ const Modules = () => { display: "block" }}> Repo: - - {module.template.name.length === 0 && " " + module.template.git.repo} + + {" " + module.template.repo} @@ -145,8 +145,8 @@ const Modules = () => { display: "block" }}> Path: - - { module.template.name.length === 0 && " " + module.template.git.path } + + { " " + module.template.path } @@ -157,7 +157,7 @@ const Modules = () => { textOverflow: "ellipsis", display: "block" }}> - Version: {getTemplateVersion(module.template.git.commit)} + Version: {getTemplateVersion(module.template.version)} diff --git a/cyclops-ui/src/components/pages/new_module.tsx b/cyclops-ui/src/components/pages/new_module.tsx index 5185804f..6fb4131c 100644 --- a/cyclops-ui/src/components/pages/new_module.tsx +++ b/cyclops-ui/src/components/pages/new_module.tsx @@ -13,7 +13,9 @@ import { Space, Switch, Typography, - Tooltip, message, Modal, CollapseProps, Checkbox, Tag + Tooltip, + message, + Modal } from 'antd'; import axios from 'axios'; import {useNavigate} from 'react-router'; @@ -52,10 +54,10 @@ const NewModule = () => { dependencies: [] }) - const [gitTemplate, setGitTemplate] = useState({ + const [template, setTemplate] = useState({ repo: "", path: "", - commit: "", + version: "", }) const [error, setError] = useState({ @@ -90,10 +92,10 @@ const NewModule = () => { if (window.__RUNTIME_CONFIG__.REACT_APP_DEFAULT_TEMPLATE_REPO && window.__RUNTIME_CONFIG__.REACT_APP_DEFAULT_TEMPLATE_REPO.length > 0) { - setGitTemplate({ + setTemplate({ repo: window.__RUNTIME_CONFIG__.REACT_APP_DEFAULT_TEMPLATE_REPO, path: window.__RUNTIME_CONFIG__.REACT_APP_DEFAULT_TEMPLATE_PATH, - commit: window.__RUNTIME_CONFIG__.REACT_APP_DEFAULT_TEMPLATE_VERSION, + version: window.__RUNTIME_CONFIG__.REACT_APP_DEFAULT_TEMPLATE_VERSION, }) loadTemplate( @@ -240,13 +242,9 @@ const NewModule = () => { name: moduleName, values: values, template: { - name: config.name, - version: config.version, - git: { - repo: gitTemplate.repo, - path: gitTemplate.path, - commit: gitTemplate.commit, - } + repo: template.repo, + path: template.path, + version: template.version, }, }) .then(res => { @@ -328,7 +326,7 @@ const NewModule = () => { let tmpConfig: any = {} - await axios.get(window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST + `/templates/git?repo=` + repo + `&path=` + path + `&commit=` + commit).then(templatesRes => { + await axios.get(window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST + `/templates?repo=` + repo + `&path=` + path + `&commit=` + commit).then(templatesRes => { setConfig(templatesRes.data); tmpConfig = templatesRes.data; @@ -352,7 +350,7 @@ const NewModule = () => { } }); - axios.get(window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST + `/templates/git/initial?repo=` + repo + `&path=` + path + `&commit=` + commit).then(res => { + axios.get(window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST + `/templates/initial?repo=` + repo + `&path=` + path + `&commit=` + commit).then(res => { form.setFieldsValue(mapsToArray(tmpConfig.fields, res.data)) setError({ @@ -859,10 +857,10 @@ const NewModule = () => { placeholder={"Repository"} style={{width: '40%'}} onChange={(value: any) => { - setGitTemplate({ + setTemplate({ repo: value.target.value, - path: gitTemplate.path, - commit: gitTemplate.commit, + path: template.path, + version: template.version, }) }} defaultValue={window.__RUNTIME_CONFIG__.REACT_APP_DEFAULT_TEMPLATE_REPO} @@ -872,10 +870,10 @@ const NewModule = () => { placeholder={"Path"} style={{width: '20%'}} onChange={(value: any) => { - setGitTemplate({ - repo: gitTemplate.repo, + setTemplate({ + repo: template.repo, path: value.target.value, - commit: gitTemplate.commit, + version: template.version, }) }} defaultValue={window.__RUNTIME_CONFIG__.REACT_APP_DEFAULT_TEMPLATE_PATH} @@ -885,10 +883,10 @@ const NewModule = () => { placeholder={"Version"} style={{width: '10%'}} onChange={(value: any) => { - setGitTemplate({ - repo: gitTemplate.repo, - path: gitTemplate.path, - commit: value.target.value + setTemplate({ + repo: template.repo, + path: template.path, + version: value.target.value }) }} defaultValue={window.__RUNTIME_CONFIG__.REACT_APP_DEFAULT_TEMPLATE_VERSION} @@ -898,9 +896,9 @@ const NewModule = () => { type="primary" htmlType="button" onClick={async () => {await loadTemplate( - gitTemplate.repo, - gitTemplate.path, - gitTemplate.commit, + template.repo, + template.path, + template.version, )}} loading={loadingTemplate} > From 15f1aedb927e074d11e08d203b9c9b4259473711 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Sat, 20 Jan 2024 00:52:32 +0100 Subject: [PATCH 3/4] remove git template reference from Module CRD --- cyclops-ctrl/api/v1alpha1/module_types.go | 6 +-- .../api/v1alpha1/zz_generated.deepcopy.go | 1 - .../crd/bases/cyclops-ui.com_modules.yaml | 42 +++++-------------- install/CRDs/cyclops-module.yaml | 42 +++++-------------- install/cyclops-install.yaml | 42 +++++-------------- 5 files changed, 33 insertions(+), 100 deletions(-) diff --git a/cyclops-ctrl/api/v1alpha1/module_types.go b/cyclops-ctrl/api/v1alpha1/module_types.go index 0745209a..c7a20891 100644 --- a/cyclops-ctrl/api/v1alpha1/module_types.go +++ b/cyclops-ctrl/api/v1alpha1/module_types.go @@ -39,9 +39,9 @@ type ModuleValue struct { } type TemplateRef struct { - Name string `json:"name"` - Version string `json:"version"` - TemplateGitRef TemplateGitRef `json:"git"` + URL string `json:"repo"` + Path string `json:"path"` + Version string `json:"version"` } type TemplateGitRef struct { diff --git a/cyclops-ctrl/api/v1alpha1/zz_generated.deepcopy.go b/cyclops-ctrl/api/v1alpha1/zz_generated.deepcopy.go index 4b8ad1c0..b46645f2 100644 --- a/cyclops-ctrl/api/v1alpha1/zz_generated.deepcopy.go +++ b/cyclops-ctrl/api/v1alpha1/zz_generated.deepcopy.go @@ -201,7 +201,6 @@ func (in *TemplateGitRef) DeepCopy() *TemplateGitRef { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TemplateRef) DeepCopyInto(out *TemplateRef) { *out = *in - out.TemplateGitRef = in.TemplateGitRef } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TemplateRef. diff --git a/cyclops-ctrl/config/crd/bases/cyclops-ui.com_modules.yaml b/cyclops-ctrl/config/crd/bases/cyclops-ui.com_modules.yaml index f76b382c..de4a89a6 100644 --- a/cyclops-ctrl/config/crd/bases/cyclops-ui.com_modules.yaml +++ b/cyclops-ctrl/config/crd/bases/cyclops-ui.com_modules.yaml @@ -33,26 +33,15 @@ spec: type: integer template: properties: - git: - properties: - commit: - type: string - path: - type: string - repo: - type: string - required: - - commit - - path - - repo - type: object - name: + path: + type: string + repo: type: string version: type: string required: - - git - - name + - path + - repo - version type: object values: @@ -75,26 +64,15 @@ spec: properties: template: properties: - git: - properties: - commit: - type: string - path: - type: string - repo: - type: string - required: - - commit - - path - - repo - type: object - name: + path: + type: string + repo: type: string version: type: string required: - - git - - name + - path + - repo - version type: object values: diff --git a/install/CRDs/cyclops-module.yaml b/install/CRDs/cyclops-module.yaml index 9384ceb2..9711da8d 100644 --- a/install/CRDs/cyclops-module.yaml +++ b/install/CRDs/cyclops-module.yaml @@ -31,26 +31,15 @@ spec: type: integer template: properties: - git: - properties: - commit: - type: string - path: - type: string - repo: - type: string - required: - - commit - - path - - repo - type: object - name: + path: + type: string + repo: type: string version: type: string required: - - git - - name + - path + - repo - version type: object values: @@ -73,26 +62,15 @@ spec: properties: template: properties: - git: - properties: - commit: - type: string - path: - type: string - repo: - type: string - required: - - commit - - path - - repo - type: object - name: + path: + type: string + repo: type: string version: type: string required: - - git - - name + - path + - repo - version type: object values: diff --git a/install/cyclops-install.yaml b/install/cyclops-install.yaml index ec4e4f68..748e0df6 100644 --- a/install/cyclops-install.yaml +++ b/install/cyclops-install.yaml @@ -31,26 +31,15 @@ spec: type: integer template: properties: - git: - properties: - commit: - type: string - path: - type: string - repo: - type: string - required: - - commit - - path - - repo - type: object - name: + path: + type: string + repo: type: string version: type: string required: - - git - - name + - path + - repo - version type: object values: @@ -73,26 +62,15 @@ spec: properties: template: properties: - git: - properties: - commit: - type: string - path: - type: string - repo: - type: string - required: - - commit - - path - - repo - type: object - name: + path: + type: string + repo: type: string version: type: string required: - - git - - name + - path + - repo - version type: object values: From 3341d8b96c299d428b7890b03fc82c6ee0ce3ec6 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Sat, 20 Jan 2024 01:00:14 +0100 Subject: [PATCH 4/4] refactor templates to accept different sources --- cyclops-ctrl/go.mod | 39 +++--- cyclops-ctrl/go.sum | 86 ++++++------- .../internal/cluster/k8sclient/modules.go | 2 +- cyclops-ctrl/internal/controller/modules.go | 38 ++++-- cyclops-ctrl/internal/controller/templates.go | 38 ++---- cyclops-ctrl/internal/handler/handler.go | 4 +- cyclops-ctrl/internal/mapper/modules.go | 16 +-- cyclops-ctrl/internal/models/dto/modules.go | 12 +- .../modulecontroller/module_controller.go | 12 +- .../internal/storage/templates/templates.go | 16 ++- .../templates.go => template/git.go} | 42 +++---- .../helmclient.go => template/helm.go} | 45 +++---- .../internal/{helmclient => template}/oci.go | 57 ++++++++- cyclops-ctrl/internal/template/render.go | 75 ++++++++++++ .../{helmclient => template}/semver.go | 2 +- cyclops-ctrl/internal/template/template.go | 114 +++++++++++------- 16 files changed, 358 insertions(+), 240 deletions(-) rename cyclops-ctrl/internal/{git/templates/templates.go => template/git.go} (83%) rename cyclops-ctrl/internal/{helmclient/helmclient.go => template/helm.go} (88%) rename cyclops-ctrl/internal/{helmclient => template}/oci.go (88%) create mode 100644 cyclops-ctrl/internal/template/render.go rename cyclops-ctrl/internal/{helmclient => template}/semver.go (98%) diff --git a/cyclops-ctrl/go.mod b/cyclops-ctrl/go.mod index 05638725..caf01bd3 100644 --- a/cyclops-ctrl/go.mod +++ b/cyclops-ctrl/go.mod @@ -24,24 +24,22 @@ require ( ) require ( - github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // 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/hcsshim v0.11.4 // 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/containerd/containerd v1.7.11 // indirect - github.com/containerd/log v0.1.0 // indirect + 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/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/docker/cli v23.0.3+incompatible // indirect + github.com/docker/cli v20.10.21+incompatible // indirect github.com/docker/distribution v2.8.1+incompatible // indirect - github.com/docker/docker v23.0.8+incompatible // indirect + github.com/docker/docker v20.10.24+incompatible // indirect github.com/docker/docker-credential-helpers v0.7.0 // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-metrics v0.0.1 // indirect @@ -49,7 +47,6 @@ require ( 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 - github.com/felixge/httpsnoop v1.0.3 // 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 @@ -102,7 +99,7 @@ require ( github.com/prometheus/procfs v0.9.0 // indirect github.com/sergi/go-diff v1.0.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect + github.com/sirupsen/logrus v1.9.0 // 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 @@ -112,27 +109,25 @@ require ( 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 - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect - go.opentelemetry.io/otel v1.19.0 // indirect - go.opentelemetry.io/otel/metric v1.19.0 // indirect - go.opentelemetry.io/otel/trace v1.19.0 // indirect + go.opentelemetry.io/otel v1.14.0 // indirect + go.opentelemetry.io/otel/trace v1.14.0 // indirect go.uber.org/atomic v1.7.0 // indirect 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.17.0 // indirect - golang.org/x/oauth2 v0.10.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/crypto v0.14.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/time v0.3.0 // indirect - golang.org/x/tools v0.10.0 // indirect + golang.org/x/tools v0.9.1 // indirect gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect - google.golang.org/grpc v1.58.3 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect + google.golang.org/grpc v1.53.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/cyclops-ctrl/go.sum b/cyclops-ctrl/go.sum index be6be700..c732ab42 100644 --- a/cyclops-ctrl/go.sum +++ b/cyclops-ctrl/go.sum @@ -1,5 +1,5 @@ -github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= -github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= +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= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= @@ -10,9 +10,8 @@ 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.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= -github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= +github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= +github.com/Microsoft/hcsshim v0.10.0-rc.7 h1:HBytQPxcv8Oy4244zbQbe6hnOnx544eL5QPUqhJldz8= 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= @@ -44,11 +43,9 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR 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/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= -github.com/containerd/containerd v1.7.11 h1:lfGKw3eU35sjV0aG2eYZTiwFEY1pCzxdzicHP3SZILw= -github.com/containerd/containerd v1.7.11/go.mod h1:5UluHxHTX2rdvYuZ5OJTC5m/KJNs0Zs9wVoJm9zf5ZE= -github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM= -github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= -github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= +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= @@ -60,12 +57,12 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs 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= -github.com/docker/cli v23.0.3+incompatible h1:Zcse1DuDqBdgI7OQDV8Go7b83xLgfhW1eza4HfEdxpY= -github.com/docker/cli v23.0.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v20.10.21+incompatible h1:qVkgyYUnOLQ98LtXBrwd/duVqPT2X4SHndOuGsfwyhU= +github.com/docker/cli v20.10.21+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v23.0.8+incompatible h1:z4ZCIwfqHgOEwhxmAWugSL1PFtPQmLP60EVhJYJPaX8= -github.com/docker/docker v23.0.8+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE= +github.com/docker/docker v20.10.24+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -84,7 +81,6 @@ github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCv 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/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= 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= @@ -276,8 +272,8 @@ github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR 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.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= 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= @@ -300,8 +296,8 @@ 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= @@ -323,14 +319,10 @@ github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43 h1:+lm10QQTN github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50 h1:hlE8//ciYMztlGpl/VA+Zm1AcTPHYkHJPbHqE6WJUXE= github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f h1:ERexzlUfuTvpE74urLSbIQW0Z/6hF9t8U4NsJLaioAY= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 h1:x8Z78aZx8cOF0+Kkazoc7lwUNMGy0LrzEMxTm4BbTxg= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0/go.mod h1:62CPTSry9QZtOaSsE3tOzhx6LzDhHnXJ6xHeMNNiM6Q= -go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= -go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= -go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= -go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= -go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= -go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= +go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= +go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= +go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M= +go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= @@ -350,14 +342,14 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U 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.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= 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.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= 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= @@ -373,8 +365,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug 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/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= -golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= +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= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -382,8 +374,8 @@ 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.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +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/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= @@ -405,20 +397,20 @@ 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.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.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/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= -golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +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/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.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.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +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/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= @@ -429,8 +421,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY 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.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg= -golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM= +golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= +golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= 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= @@ -439,14 +431,14 @@ gomodules.xyz/jsonpatch/v2 v2.3.0 h1:8NFhfS6gzxNqjLIYnZxg319wZ5Qjnx4m/CcX+Klzazc gomodules.xyz/jsonpatch/v2 v2.3.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= -google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= -google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= +google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= +google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= +google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= 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= diff --git a/cyclops-ctrl/internal/cluster/k8sclient/modules.go b/cyclops-ctrl/internal/cluster/k8sclient/modules.go index 2f5de5cc..56d9e5fe 100644 --- a/cyclops-ctrl/internal/cluster/k8sclient/modules.go +++ b/cyclops-ctrl/internal/cluster/k8sclient/modules.go @@ -126,7 +126,7 @@ func (k *KubernetesClient) GetResourcesForModule(name string) ([]dto.Resource, e func (k *KubernetesClient) GetDeletedResources( resources []dto.Resource, module cyclopsv1alpha1.Module, - template models.Template, + template *models.Template, ) ([]dto.Resource, error) { manifest, err := template2.HelmTemplate(module, template) if err != nil { diff --git a/cyclops-ctrl/internal/controller/modules.go b/cyclops-ctrl/internal/controller/modules.go index 1a2ddc78..6906d344 100644 --- a/cyclops-ctrl/internal/controller/modules.go +++ b/cyclops-ctrl/internal/controller/modules.go @@ -109,7 +109,11 @@ func (m *Modules) Manifest(ctx *gin.Context) { return } - targetTemplate, err := m.templates.GetConfig(request.TemplateRef) + targetTemplate, err := template.GetTemplate( + request.TemplateRef.URL, + request.TemplateRef.Path, + request.TemplateRef.Version, + ) if err != nil { fmt.Println(err) ctx.Status(http.StatusInternalServerError) @@ -139,7 +143,11 @@ func (m *Modules) CurrentManifest(ctx *gin.Context) { return } - targetTemplate, err := m.templates.GetConfig(module.Spec.TemplateRef) + targetTemplate, err := template.GetTemplate( + module.Spec.TemplateRef.URL, + module.Spec.TemplateRef.Path, + module.Spec.TemplateRef.Version, + ) if err != nil { fmt.Println(err) ctx.Status(http.StatusInternalServerError) @@ -267,7 +275,11 @@ func (m *Modules) ResourcesForModule(ctx *gin.Context) { return } - template, err := m.templates.GetConfig(module.Spec.TemplateRef) + t, err := template.GetTemplate( + module.Spec.TemplateRef.URL, + module.Spec.TemplateRef.Path, + module.Spec.TemplateRef.Version, + ) if err != nil { fmt.Println(err) ctx.JSON(http.StatusInternalServerError, dto.NewError("Error fetching template", err.Error())) @@ -281,7 +293,7 @@ func (m *Modules) ResourcesForModule(ctx *gin.Context) { return } - resources, err = m.kubernetesClient.GetDeletedResources(resources, *module, template) + resources, err = m.kubernetesClient.GetDeletedResources(resources, *module, t) if err != nil { fmt.Println(err) ctx.JSON(http.StatusInternalServerError, dto.NewError("Error fetching deleted module resources", err.Error())) @@ -301,7 +313,11 @@ func (m *Modules) Template(ctx *gin.Context) { return } - currentTemplate, err := m.templates.GetConfig(module.Spec.TemplateRef) + currentTemplate, err := template.GetTemplate( + module.Spec.TemplateRef.URL, + module.Spec.TemplateRef.Path, + module.Spec.TemplateRef.Version, + ) if err != nil { fmt.Println(err) ctx.JSON(http.StatusInternalServerError, dto.NewError("Error fetching template", err.Error())) @@ -315,7 +331,11 @@ func (m *Modules) Template(ctx *gin.Context) { return } - proposedTemplate, err := m.templates.GetConfig(module.Spec.TemplateRef) + proposedTemplate, err := template.GetTemplate( + module.Spec.TemplateRef.URL, + module.Spec.TemplateRef.Path, + module.Spec.TemplateRef.Version, + ) if err != nil { fmt.Println(err) ctx.JSON(http.StatusInternalServerError, dto.NewError("Error creating proposed template", err.Error())) @@ -347,7 +367,11 @@ func (m *Modules) HelmTemplate(ctx *gin.Context) { return } - currentTemplate, err := m.templates.GetConfig(module.Spec.TemplateRef) + currentTemplate, err := template.GetTemplate( + module.Spec.TemplateRef.URL, + module.Spec.TemplateRef.Path, + module.Spec.TemplateRef.Version, + ) if err != nil { fmt.Println(err) ctx.JSON(http.StatusInternalServerError, dto.NewError("Error fetching template", err.Error())) diff --git a/cyclops-ctrl/internal/controller/templates.go b/cyclops-ctrl/internal/controller/templates.go index dfd6356f..371dfec8 100644 --- a/cyclops-ctrl/internal/controller/templates.go +++ b/cyclops-ctrl/internal/controller/templates.go @@ -7,15 +7,14 @@ import ( "time" "github.com/gin-gonic/gin" - json "github.com/json-iterator/go" cyclopsv1alpha1 "github.com/cyclops-ui/cycops-ctrl/api/v1alpha1" "github.com/cyclops-ui/cycops-ctrl/internal/cluster/k8sclient" - git "github.com/cyclops-ui/cycops-ctrl/internal/git/templates" "github.com/cyclops-ui/cycops-ctrl/internal/mapper" "github.com/cyclops-ui/cycops-ctrl/internal/models" "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" ) type Templates struct { @@ -74,18 +73,6 @@ func (c *Templates) GetConfiguration(ctx *gin.Context) { name := ctx.Param("name") version := ctx.Query("version") - // TODO delete this is for testing - if name == "git" { - template, err := git.LoadTemplate("https://github.com/cyclops-ui/templates", "application", "") - if err != nil { - panic(err) - } - - ctx.Header("Access-Control-Allow-Origin", "*") - ctx.JSON(http.StatusOK, template) - return - } - configuration, err := c.templates.GetConfigByVersion(name, version) if err != nil { fmt.Println(err) @@ -102,7 +89,7 @@ func (c *Templates) GetConfiguration(ctx *gin.Context) { related := make([]cyclopsv1alpha1.Module, 0) for _, module := range modules { - if name != module.Spec.TemplateRef.Name { + if name != module.Spec.TemplateRef.Path { continue } @@ -142,7 +129,7 @@ func (c *Templates) GetConfigurationsVersions(ctx *gin.Context) { ctx.JSON(http.StatusOK, versions) } -func (c *Templates) GetTemplateFromGit(ctx *gin.Context) { +func (c *Templates) GetTemplate(ctx *gin.Context) { ctx.Header("Access-Control-Allow-Origin", "*") repo := ctx.Query("repo") @@ -154,17 +141,17 @@ func (c *Templates) GetTemplateFromGit(ctx *gin.Context) { return } - template, err := git.LoadTemplate(repo, path, commit) + t, err := template.GetTemplate(repo, path, commit) if err != nil { fmt.Println(err) ctx.JSON(http.StatusBadRequest, dto.NewError("Error loading template", err.Error())) return } - ctx.JSON(http.StatusOK, template) + ctx.JSON(http.StatusOK, t) } -func (c *Templates) GetTemplateInitialValuesFromGit(ctx *gin.Context) { +func (c *Templates) GetTemplateInitialValues(ctx *gin.Context) { ctx.Header("Access-Control-Allow-Origin", "*") repo := ctx.Query("repo") @@ -176,19 +163,12 @@ func (c *Templates) GetTemplateInitialValuesFromGit(ctx *gin.Context) { return } - initial, err := git.LoadInitialTemplateValues(repo, path, commit) - if err != nil { - fmt.Println(err) - ctx.JSON(http.StatusBadRequest, dto.NewError("Error loading template", err.Error())) - return - } - - data, err := json.Marshal(initial) + initial, err := template.GetTemplateInitialValues(repo, path, commit) if err != nil { fmt.Println(err) - ctx.JSON(http.StatusInternalServerError, dto.NewError("Error marshaling data template", err.Error())) + ctx.JSON(http.StatusBadRequest, dto.NewError("Error loading template initial values", err.Error())) return } - ctx.Data(http.StatusOK, gin.MIMEJSON, data) + ctx.Data(http.StatusOK, gin.MIMEJSON, initial) } diff --git a/cyclops-ctrl/internal/handler/handler.go b/cyclops-ctrl/internal/handler/handler.go index 8d5960f5..8543c92c 100644 --- a/cyclops-ctrl/internal/handler/handler.go +++ b/cyclops-ctrl/internal/handler/handler.go @@ -41,8 +41,8 @@ func (h *Handler) Start() error { h.router.GET("/create-config/:name", templatesController.GetConfiguration) h.router.GET("/configuration-details", templatesController.GetConfigurationsDetails) h.router.GET("/configuration/:name/versions", templatesController.GetConfigurationsVersions) - h.router.GET("/templates/git", templatesController.GetTemplateFromGit) - h.router.GET("/templates/git/initial", templatesController.GetTemplateInitialValuesFromGit) + h.router.GET("/templates", templatesController.GetTemplate) + h.router.GET("/templates/initial", templatesController.GetTemplateInitialValues) // modules h.router.GET("/modules/:name", modulesController.GetModule) diff --git a/cyclops-ctrl/internal/mapper/modules.go b/cyclops-ctrl/internal/mapper/modules.go index d5324a19..a5904afb 100644 --- a/cyclops-ctrl/internal/mapper/modules.go +++ b/cyclops-ctrl/internal/mapper/modules.go @@ -65,25 +65,17 @@ func ModuleListToDTO(modules []cyclopsv1alpha1.Module) []dto.Module { func DtoTemplateRefToK8s(dto dto.Template) cyclopsv1alpha1.TemplateRef { return cyclopsv1alpha1.TemplateRef{ - Name: dto.Name, + URL: dto.URL, + Path: dto.Path, Version: dto.Version, - TemplateGitRef: cyclopsv1alpha1.TemplateGitRef{ - Repo: dto.GitRef.Repo, - Path: dto.GitRef.Path, - Commit: dto.GitRef.Commit, - }, } } func k8sTemplateRefToDTO(templateRef cyclopsv1alpha1.TemplateRef) dto.Template { return dto.Template{ - Name: templateRef.Name, + URL: templateRef.URL, + Path: templateRef.Path, Version: templateRef.Version, - GitRef: dto.TemplateGitRef{ - Repo: templateRef.TemplateGitRef.Repo, - Path: templateRef.TemplateGitRef.Path, - Commit: templateRef.TemplateGitRef.Commit, - }, } } diff --git a/cyclops-ctrl/internal/models/dto/modules.go b/cyclops-ctrl/internal/models/dto/modules.go index 0bb0dff8..10f738d0 100644 --- a/cyclops-ctrl/internal/models/dto/modules.go +++ b/cyclops-ctrl/internal/models/dto/modules.go @@ -10,15 +10,9 @@ type Module struct { } type Template struct { - Name string `json:"name"` - Version string `json:"version"` - GitRef TemplateGitRef `json:"git"` -} - -type TemplateGitRef struct { - Repo string `json:"repo"` - Path string `json:"path"` - Commit string `json:"commit"` + URL string `json:"repo"` + Path string `json:"path"` + Version string `json:"version"` } type TemplatesResponse struct { diff --git a/cyclops-ctrl/internal/modulecontroller/module_controller.go b/cyclops-ctrl/internal/modulecontroller/module_controller.go index 8e53fcf0..859362c9 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" - template2 "github.com/cyclops-ui/cycops-ctrl/internal/template" + "github.com/cyclops-ui/cycops-ctrl/internal/template" ) // ModuleReconciler reconciles a Module object @@ -130,7 +130,11 @@ func (r *ModuleReconciler) moduleToResources(name string) error { return err } - template, err := r.templates.GetConfig(module.Spec.TemplateRef) + template, err := template.GetTemplate( + module.Spec.TemplateRef.URL, + module.Spec.TemplateRef.Path, + module.Spec.TemplateRef.Version, + ) if err != nil { return err } @@ -142,8 +146,8 @@ func (r *ModuleReconciler) moduleToResources(name string) error { return nil } -func (r *ModuleReconciler) generateResources(kClient *k8sclient.KubernetesClient, module cyclopsv1alpha1.Module, moduleTemplate models.Template) error { - out, err := template2.HelmTemplate(module, moduleTemplate) +func (r *ModuleReconciler) generateResources(kClient *k8sclient.KubernetesClient, module cyclopsv1alpha1.Module, moduleTemplate *models.Template) error { + out, err := template.HelmTemplate(module, moduleTemplate) if err != nil { return err } diff --git a/cyclops-ctrl/internal/storage/templates/templates.go b/cyclops-ctrl/internal/storage/templates/templates.go index 8660f335..e159b771 100644 --- a/cyclops-ctrl/internal/storage/templates/templates.go +++ b/cyclops-ctrl/internal/storage/templates/templates.go @@ -7,8 +7,6 @@ import ( "github.com/go-redis/redis/v8" - cyclopsv1alpha1 "github.com/cyclops-ui/cycops-ctrl/api/v1alpha1" - git "github.com/cyclops-ui/cycops-ctrl/internal/git/templates" "github.com/cyclops-ui/cycops-ctrl/internal/models" ) @@ -68,13 +66,13 @@ func (s *Storage) GetConfigByVersion(name, version string) (models.Template, err return config, nil } -func (s *Storage) GetConfig(ref cyclopsv1alpha1.TemplateRef) (models.Template, error) { - if ref.TemplateGitRef.Repo != "" { - return git.LoadTemplate(ref.TemplateGitRef.Repo, ref.TemplateGitRef.Path, ref.TemplateGitRef.Commit) - } - - return s.GetConfigByVersion(ref.Name, ref.Version) -} +//func (s *Storage) GetConfig(ref cyclopsv1alpha1.TemplateRef) (models.Template, error) { +// if ref.URL != "" { +// return git.LoadTemplate(ref.URL, ref.Path, ref.Version) +// } +// +// return s.GetConfigByVersion(ref.Path, ref.Version) +//} func (s *Storage) ListConfigLatest() (out []models.Template, err error) { keys, err := s.client.Keys(context.TODO(), "config:*").Result() diff --git a/cyclops-ctrl/internal/git/templates/templates.go b/cyclops-ctrl/internal/template/git.go similarity index 83% rename from cyclops-ctrl/internal/git/templates/templates.go rename to cyclops-ctrl/internal/template/git.go index 47593170..4b9dbbff 100644 --- a/cyclops-ctrl/internal/git/templates/templates.go +++ b/cyclops-ctrl/internal/template/git.go @@ -1,4 +1,4 @@ -package git +package template import ( "bufio" @@ -10,10 +10,6 @@ import ( "path/filepath" "strings" - "github.com/cyclops-ui/cycops-ctrl/internal/helmclient" - "github.com/cyclops-ui/cycops-ctrl/internal/mapper" - "github.com/cyclops-ui/cycops-ctrl/internal/models" - "github.com/cyclops-ui/cycops-ctrl/internal/models/helm" "github.com/pkg/errors" "gopkg.in/src-d/go-billy.v4" "gopkg.in/src-d/go-billy.v4/memfs" @@ -22,29 +18,33 @@ import ( "gopkg.in/src-d/go-git.v4/storage/memory" "gopkg.in/yaml.v2" "helm.sh/helm/v3/pkg/chart" + + "github.com/cyclops-ui/cycops-ctrl/internal/mapper" + "github.com/cyclops-ui/cycops-ctrl/internal/models" + "github.com/cyclops-ui/cycops-ctrl/internal/models/helm" ) -func LoadTemplate(repoURL, path, commit string) (models.Template, error) { +func LoadTemplate(repoURL, path, commit string) (*models.Template, error) { fs, err := clone(repoURL, commit) if err != nil { - return models.Template{}, err + return nil, err } // load helm chart metadata chartMetadata, err := fs.Open(path2.Join(path, "Chart.yaml")) if err != nil { - return models.Template{}, errors.Wrap(err, "could not read 'Chart.yaml' file; it should be placed in the repo/path you provided; make sure you provided the correct path") + return nil, errors.Wrap(err, "could not read 'Chart.yaml' file; it should be placed in the repo/path you provided; make sure you provided the correct path") } var chartMetadataBuffer bytes.Buffer _, err = io.Copy(bufio.NewWriter(&chartMetadataBuffer), chartMetadata) if err != nil { - return models.Template{}, err + return nil, err } var metadata chart.Metadata if err := yaml.Unmarshal(chartMetadataBuffer.Bytes(), &metadata); err != nil { - return models.Template{}, err + return nil, err } // endregion @@ -53,53 +53,53 @@ func LoadTemplate(repoURL, path, commit string) (models.Template, error) { _, err = fs.ReadDir(templatesPath) if err != nil { - return models.Template{}, errors.Wrap(err, "could not find 'templates' dir; it should be placed in the repo/path you provided; make sure 'templates' directory exists") + return nil, errors.Wrap(err, "could not find 'templates' dir; it should be placed in the repo/path you provided; make sure 'templates' directory exists") } manifests, err := concatenateTemplates(templatesPath, fs) if err != nil { - return models.Template{}, errors.Wrap(err, "failed to load template files") + return nil, errors.Wrap(err, "failed to load template files") } // endregion // region read files filesFs, err := fs.Chroot(path) if err != nil { - return models.Template{}, errors.Wrap(err, "could not find 'templates' dir; it should be placed in the repo/path you provided; make sure 'templates' directory exists") + return nil, errors.Wrap(err, "could not find 'templates' dir; it should be placed in the repo/path you provided; make sure 'templates' directory exists") } chartFiles, err := readFiles("", filesFs) if err != nil { - return models.Template{}, errors.Wrap(err, "failed to read template files") + return nil, errors.Wrap(err, "failed to read template files") } // endregion // region read schema schemaFile, err := fs.Open(path2.Join(path, "values.schema.json")) if err != nil { - return models.Template{}, errors.Wrap(err, "could not read 'values.schema.json' file; it should be placed in the repo/path you provided; make sure 'templates' directory exists") + return nil, errors.Wrap(err, "could not read 'values.schema.json' file; it should be placed in the repo/path you provided; make sure 'templates' directory exists") } var schemaChartBuffer bytes.Buffer _, err = io.Copy(bufio.NewWriter(&schemaChartBuffer), schemaFile) if err != nil { - return models.Template{}, err + return nil, err } var schema helm.Property if err := json.Unmarshal(schemaChartBuffer.Bytes(), &schema); err != nil { - return models.Template{}, err + return nil, err } // endregion // region load dependencies - dependencies, err := helmclient.LoadDependencies(metadata) + dependencies, err := loadDependencies(metadata) if err != nil { - return models.Template{}, err + return nil, err } // endregion - return models.Template{ + return &models.Template{ Name: "", Manifest: strings.Join(manifests, "---\n"), Fields: mapper.HelmSchemaToFields(schema, dependencies), @@ -152,7 +152,7 @@ func LoadInitialTemplateValues(repoURL, path, commit string) (map[interface{}]in initialValues = make(map[interface{}]interface{}) } - depInitialValues, err := helmclient.LoadDependenciesInitialValues(metadata) + depInitialValues, err := loadDependenciesInitialValues(metadata) if err != nil { return nil, err } diff --git a/cyclops-ctrl/internal/helmclient/helmclient.go b/cyclops-ctrl/internal/template/helm.go similarity index 88% rename from cyclops-ctrl/internal/helmclient/helmclient.go rename to cyclops-ctrl/internal/template/helm.go index 21172230..43ea6fd7 100644 --- a/cyclops-ctrl/internal/helmclient/helmclient.go +++ b/cyclops-ctrl/internal/template/helm.go @@ -1,4 +1,4 @@ -package helmclient +package template import ( "archive/tar" @@ -27,7 +27,7 @@ func LoadHelmChart(repo, chart, version string) (*models.Template, error) { var tgzData []byte var err error if registry.IsOCI(repo) { - tgzData, err = LoadOCIHelmChart(repo, chart, version) + tgzData, err = loadOCIHelmChartBytes(repo, chart, version) if err != nil { return nil, err } @@ -50,7 +50,7 @@ func LoadHelmChartInitialValues(repo, chart, version string) (map[interface{}]in var tgzData []byte var err error if registry.IsOCI(repo) { - tgzData, err = LoadOCIHelmChart(repo, chart, version) + tgzData, err = loadOCIHelmChartBytes(repo, chart, version) if err != nil { return nil, err } @@ -85,32 +85,25 @@ func LoadHelmChartInitialValues(repo, chart, version string) (map[interface{}]in return mapHelmChartInitialValues(extractedFiles) } -func LoadDependencies(metadata helmchart.Metadata) ([]*models.Template, error) { - deps := make([]*models.Template, 0) - for _, dependency := range metadata.Dependencies { - dep, err := LoadHelmChart(dependency.Repository, dependency.Name, dependency.Version) - if err != nil { - return nil, err - } - - deps = append(deps, dep) +func IsHelmRepo(repo string) (bool, error) { + indexURL, err := url.JoinPath(repo, "index.yaml") + if err != nil { + return false, err } - return deps, nil -} - -func LoadDependenciesInitialValues(metadata helmchart.Metadata) (map[interface{}]interface{}, error) { - initialValues := make(map[interface{}]interface{}) - for _, dependency := range metadata.Dependencies { - depInitialValues, err := LoadHelmChartInitialValues(dependency.Repository, dependency.Name, dependency.Version) - if err != nil { - return nil, err - } + req, err := http.NewRequest(http.MethodHead, indexURL, nil) + if err != nil { + return false, err + } - initialValues[dependency.Name] = depInitialValues + client := &http.Client{} + resp, err := client.Do(req) + if err != nil { + return false, err } + defer resp.Body.Close() - return initialValues, nil + return resp.StatusCode == http.StatusOK, nil } func loadFromHelmChartRepo(repo, chart, version string) ([]byte, error) { @@ -178,7 +171,7 @@ func mapHelmChart(chartName string, files map[string][]byte) (*models.Template, } // region load dependencies - dependencies, err := LoadDependencies(metadata) + dependencies, err := loadDependencies(metadata) if err != nil { return &models.Template{}, err } @@ -258,7 +251,7 @@ func mapHelmChartInitialValues(files map[string][]byte) (map[interface{}]interfa values[depName] = dep } - dependenciesFromMeta, err := LoadDependenciesInitialValues(metadata) + dependenciesFromMeta, err := loadDependenciesInitialValues(metadata) if err != nil { return nil, err } diff --git a/cyclops-ctrl/internal/helmclient/oci.go b/cyclops-ctrl/internal/template/oci.go similarity index 88% rename from cyclops-ctrl/internal/helmclient/oci.go rename to cyclops-ctrl/internal/template/oci.go index 12fb4826..635b7455 100644 --- a/cyclops-ctrl/internal/helmclient/oci.go +++ b/cyclops-ctrl/internal/template/oci.go @@ -1,16 +1,64 @@ -package helmclient +package template import ( "fmt" - json "github.com/json-iterator/go" - "github.com/pkg/errors" + "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" ) -func LoadOCIHelmChart(repo, chart, version string) ([]byte, error) { +func LoadOCIHelmChart(repo, chart, version string) (*models.Template, error) { + var tgzData []byte + tgzData, err := loadOCIHelmChartBytes(repo, chart, version) + if err != nil { + return nil, err + } + + extractedFiles, err := unpackTgzInMemory(tgzData) + if err != nil { + return nil, err + } + + return mapHelmChart(chart, extractedFiles) +} + +func LoadOCIHelmChartInitialValues(repo, chart, version string) (map[interface{}]interface{}, error) { + tgzData, err := loadOCIHelmChartBytes(repo, chart, version) + if err != nil { + return nil, err + } + + extractedFiles, err := unpackTgzInMemory(tgzData) + if err != nil { + 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 { + return nil, err + } + + return mapHelmChartInitialValues(extractedFiles) +} + +func loadOCIHelmChartBytes(repo, chart, version string) ([]byte, error) { var err error if !isValidVersion(version) { version, err = getStrictVersion(repo, chart, version) @@ -334,7 +382,6 @@ func parseAuthenticateHeader(header string) (realm, service, scope string) { pairs := strings.Split(header, ",") for _, pair := range pairs { - fmt.Println(pair) keyValue := strings.SplitN(pair, "=", 2) if len(keyValue) == 2 { key := strings.TrimSpace(keyValue[0]) diff --git a/cyclops-ctrl/internal/template/render.go b/cyclops-ctrl/internal/template/render.go new file mode 100644 index 00000000..01dd5486 --- /dev/null +++ b/cyclops-ctrl/internal/template/render.go @@ -0,0 +1,75 @@ +package template + +import ( + cyclopsv1alpha1 "github.com/cyclops-ui/cycops-ctrl/api/v1alpha1" + "github.com/cyclops-ui/cycops-ctrl/internal/models" + json "github.com/json-iterator/go" + "helm.sh/helm/v3/pkg/chart" + "helm.sh/helm/v3/pkg/chartutil" + "helm.sh/helm/v3/pkg/engine" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" +) + +func HelmTemplate(module cyclopsv1alpha1.Module, moduleTemplate *models.Template) (string, error) { + if moduleTemplate == nil { + return "", nil + } + + chart := &chart.Chart{ + Raw: []*chart.File{}, + Metadata: &chart.Metadata{}, + Lock: &chart.Lock{}, + Values: map[string]interface{}{}, + Schema: []byte{}, + Files: moduleTemplate.Files, + Templates: []*chart.File{ + { + Name: "all.yaml", + Data: []byte(moduleTemplate.Manifest), + }, + }, + } + + values := make(chartutil.Values) + if err := json.Unmarshal(module.Spec.Values.Raw, &values); err != nil { + return "", err + } + + top := make(chartutil.Values) + top["Values"] = values + top["Release"] = map[string]interface{}{ + "Name": "", + "Namespace": "", + } + + out, err := engine.Render(chart, top) + if err != nil { + //fmt.Println(moduleTemplate.Manifest) + return "", err + } + + manifest := out["all.yaml"] + + for _, dependency := range moduleTemplate.Dependencies { + data, err := json.Marshal(values[dependency.Name]) + if err != nil { + return "", err + } + + dependencyManifest, err := HelmTemplate(cyclopsv1alpha1.Module{ + Spec: cyclopsv1alpha1.ModuleSpec{ + Values: apiextensionsv1.JSON{ + Raw: data, + }, + }, + }, dependency) + if err != nil { + return "", err + } + + manifest += "\n---\n" + manifest += dependencyManifest + } + + return manifest, err +} diff --git a/cyclops-ctrl/internal/helmclient/semver.go b/cyclops-ctrl/internal/template/semver.go similarity index 98% rename from cyclops-ctrl/internal/helmclient/semver.go rename to cyclops-ctrl/internal/template/semver.go index 10a761e4..1efc9097 100644 --- a/cyclops-ctrl/internal/helmclient/semver.go +++ b/cyclops-ctrl/internal/template/semver.go @@ -1,4 +1,4 @@ -package helmclient +package template import ( "fmt" diff --git a/cyclops-ctrl/internal/template/template.go b/cyclops-ctrl/internal/template/template.go index b2335e98..f2c5e1c9 100644 --- a/cyclops-ctrl/internal/template/template.go +++ b/cyclops-ctrl/internal/template/template.go @@ -1,71 +1,95 @@ package template import ( - cyclopsv1alpha1 "github.com/cyclops-ui/cycops-ctrl/api/v1alpha1" "github.com/cyclops-ui/cycops-ctrl/internal/models" json "github.com/json-iterator/go" - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/chartutil" - "helm.sh/helm/v3/pkg/engine" - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + helmchart "helm.sh/helm/v3/pkg/chart" + "helm.sh/helm/v3/pkg/registry" ) -func HelmTemplate(module cyclopsv1alpha1.Module, moduleTemplate models.Template) (string, error) { - chart := &chart.Chart{ - Raw: []*chart.File{}, - Metadata: &chart.Metadata{}, - Lock: &chart.Lock{}, - Values: map[string]interface{}{}, - Schema: []byte{}, - Files: moduleTemplate.Files, - Templates: []*chart.File{ - { - Name: "all.yaml", - Data: []byte(moduleTemplate.Manifest), - }, - }, +func GetTemplate(repo, path, version string) (*models.Template, error) { + // region load OCI chart + if registry.IsOCI(repo) { + return LoadOCIHelmChart(repo, path, version) } + // endregion - values := make(chartutil.Values) - if err := json.Unmarshal(module.Spec.Values.Raw, &values); err != nil { - return "", err + // region load from Helm repo + isHelmRepo, err := IsHelmRepo(repo) + if err != nil { + return nil, err } - top := make(chartutil.Values) - top["Values"] = values - top["Release"] = map[string]interface{}{ - "Name": "", - "Namespace": "", + if isHelmRepo { + return LoadHelmChart(repo, path, version) } + // endregion + + // fallback to cloning from git + return LoadTemplate(repo, path, version) +} + +func GetTemplateInitialValues(repo, path, version string) ([]byte, error) { + // region load OCI chart + if registry.IsOCI(repo) { + initial, err := LoadOCIHelmChartInitialValues(repo, path, version) + if err != nil { + return nil, err + } - out, err := engine.Render(chart, top) + return json.Marshal(initial) + } + // endregion + + // region load from Helm repo + isHelmRepo, err := IsHelmRepo(repo) if err != nil { - //fmt.Println(moduleTemplate.Manifest) - return "", err + return nil, err } - manifest := out["all.yaml"] + if isHelmRepo { + initial, err := LoadHelmChartInitialValues(repo, path, version) + if err != nil { + return nil, err + } - for _, dependency := range moduleTemplate.Dependencies { - data, err := json.Marshal(values[dependency.Name]) + return json.Marshal(initial) + } + // endregion + + // fallback to cloning from git + initial, err := LoadInitialTemplateValues(repo, path, version) + if err != nil { + return nil, err + } + + return json.Marshal(initial) +} + +func 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) if err != nil { - return "", err + return nil, err } - dependencyManifest, err := HelmTemplate(cyclopsv1alpha1.Module{ - Spec: cyclopsv1alpha1.ModuleSpec{ - Values: apiextensionsv1.JSON{ - Raw: data, - }, - }, - }, *dependency) + deps = append(deps, dep) + } + + return deps, nil +} + +func 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) if err != nil { - return "", err + return nil, err } - manifest += "\n---\n" - manifest += dependencyManifest + initialValues[dependency.Name] = depInitialValues } - return manifest, err + return initialValues, nil }