From a429b8c6b7dc8815be80e3609bf53c27515c6201 Mon Sep 17 00:00:00 2001 From: Daniel Hu Date: Wed, 26 Oct 2022 20:51:33 +0800 Subject: [PATCH] feat: merge all helm style plugins Signed-off-by: Daniel Hu --- cmd/plugin/artifactory/main.go | 41 --------------- cmd/plugin/devlake/main.go | 41 --------------- cmd/plugin/harbor/main.go | 41 --------------- cmd/plugin/hashicorp-vault/main.go | 41 --------------- cmd/plugin/jenkins/main.go | 41 --------------- cmd/plugin/kube-prometheus/main.go | 41 --------------- cmd/plugin/openldap/main.go | 41 --------------- cmd/plugin/sonarqube/main.go | 41 --------------- cmd/plugin/tekton/main.go | 41 --------------- docs/plugins/hashicorp-vault.zh.md | 3 -- docs/plugins/helm-installer.zh.md | 8 --- docs/plugins/helm-installer/argocd.md | 3 ++ docs/plugins/helm-installer/argocd.zh.md | 3 ++ .../{ => helm-installer}/artifactory.md | 4 +- .../{ => helm-installer}/artifactory.zh.md | 4 +- docs/plugins/{ => helm-installer}/devlake.md | 4 +- .../{ => helm-installer}/devlake.zh.md | 4 +- docs/plugins/{ => helm-installer}/harbor.md | 4 +- .../plugins/{ => helm-installer}/harbor.zh.md | 4 +- .../{ => helm-installer}/helm-installer.md | 4 +- .../helm-installer/helm-installer.zh.md | 52 +++++++++++++++++++ docs/plugins/{ => helm-installer}/jenkins.md | 4 +- .../{ => helm-installer}/jenkins.zh.md | 4 +- .../{ => helm-installer}/kube-prometheus.md | 4 +- .../helm-installer/kube-prometheus.zh.md | 3 ++ docs/plugins/{ => helm-installer}/openldap.md | 4 +- docs/plugins/helm-installer/openldap.zh.md | 3 ++ .../plugins/{ => helm-installer}/sonarqube.md | 4 +- .../{ => helm-installer}/sonarqube.zh.md | 4 +- docs/plugins/{ => helm-installer}/tekton.md | 5 +- .../plugins/{ => helm-installer}/tekton.zh.md | 4 +- .../vault.md} | 4 +- docs/plugins/helm-installer/vault.zh.md | 3 ++ docs/plugins/kube-prometheus.zh.md | 3 -- docs/plugins/openldap.zh.md | 3 -- .../pkg/develop/plugin/template/NAME.md.tpl | 2 +- .../pkg/plugin/artifactory/artifactory.go | 23 -------- internal/pkg/plugin/artifactory/create.go | 30 ----------- internal/pkg/plugin/artifactory/delete.go | 25 --------- internal/pkg/plugin/artifactory/read.go | 28 ---------- internal/pkg/plugin/artifactory/update.go | 29 ----------- internal/pkg/plugin/devlake/create.go | 30 ----------- internal/pkg/plugin/devlake/delete.go | 26 ---------- internal/pkg/plugin/devlake/read.go | 28 ---------- internal/pkg/plugin/devlake/update.go | 29 ----------- internal/pkg/plugin/harbor/create.go | 30 ----------- internal/pkg/plugin/harbor/delete.go | 25 --------- internal/pkg/plugin/harbor/read.go | 29 ----------- internal/pkg/plugin/harbor/update.go | 29 ----------- internal/pkg/plugin/hashicorpvault/create.go | 31 ----------- internal/pkg/plugin/hashicorpvault/delete.go | 25 --------- .../plugin/hashicorpvault/hashicorpvault.go | 23 -------- internal/pkg/plugin/hashicorpvault/read.go | 28 ---------- internal/pkg/plugin/hashicorpvault/update.go | 29 ----------- internal/pkg/plugin/helminstaller/create.go | 4 +- .../plugin/helminstaller/defaults/argocd.go | 9 +++- .../helminstaller/defaults/artifactory.go | 37 +++++++++++++ .../helminstaller/defaults/defaultconfig.go | 6 ++- .../defaults}/devlake.go | 17 ++++-- .../defaults}/harbor.go | 18 ++++++- .../defaults}/jenkins.go | 16 ++++-- .../helminstaller/defaults/kubeprometheus.go | 37 +++++++++++++ .../plugin/helminstaller/defaults/openldap.go | 37 +++++++++++++ .../helminstaller/defaults/sonarqube.go | 36 +++++++++++++ .../plugin/helminstaller/defaults/tekton.go | 37 +++++++++++++ .../plugin/helminstaller/defaults/vault.go | 37 +++++++++++++ internal/pkg/plugin/helminstaller/delete.go | 2 +- .../pkg/plugin/helminstaller/helminstaller.go | 47 +++++++++++++---- .../helminstaller/helminstaller_test.go | 36 ++++++++++++- internal/pkg/plugin/helminstaller/read.go | 5 +- internal/pkg/plugin/helminstaller/update.go | 4 +- internal/pkg/plugin/jenkins/create.go | 34 ------------ internal/pkg/plugin/jenkins/delete.go | 27 ---------- internal/pkg/plugin/jenkins/read.go | 28 ---------- internal/pkg/plugin/jenkins/update.go | 31 ----------- internal/pkg/plugin/kubeprometheus/create.go | 31 ----------- internal/pkg/plugin/kubeprometheus/delete.go | 25 --------- .../plugin/kubeprometheus/kubeprometheus.go | 23 -------- internal/pkg/plugin/kubeprometheus/read.go | 28 ---------- internal/pkg/plugin/kubeprometheus/update.go | 29 ----------- internal/pkg/plugin/openldap/create.go | 31 ----------- internal/pkg/plugin/openldap/delete.go | 25 --------- internal/pkg/plugin/openldap/openldap.go | 23 -------- internal/pkg/plugin/openldap/read.go | 28 ---------- internal/pkg/plugin/openldap/update.go | 29 ----------- internal/pkg/plugin/sonarqube/create.go | 30 ----------- internal/pkg/plugin/sonarqube/delete.go | 25 --------- internal/pkg/plugin/sonarqube/read.go | 28 ---------- internal/pkg/plugin/sonarqube/sonar.go | 22 -------- internal/pkg/plugin/sonarqube/update.go | 29 ----------- internal/pkg/plugin/tekton/create.go | 30 ----------- internal/pkg/plugin/tekton/delete.go | 25 --------- internal/pkg/plugin/tekton/read.go | 28 ---------- internal/pkg/plugin/tekton/tekton.go | 23 -------- internal/pkg/plugin/tekton/update.go | 29 ----------- .../pkg/plugininstaller/plugininstaller.go | 11 ++-- mkdocs.yml | 5 ++ 97 files changed, 475 insertions(+), 1604 deletions(-) delete mode 100644 cmd/plugin/artifactory/main.go delete mode 100644 cmd/plugin/devlake/main.go delete mode 100644 cmd/plugin/harbor/main.go delete mode 100644 cmd/plugin/hashicorp-vault/main.go delete mode 100644 cmd/plugin/jenkins/main.go delete mode 100644 cmd/plugin/kube-prometheus/main.go delete mode 100644 cmd/plugin/openldap/main.go delete mode 100644 cmd/plugin/sonarqube/main.go delete mode 100644 cmd/plugin/tekton/main.go delete mode 100644 docs/plugins/hashicorp-vault.zh.md delete mode 100644 docs/plugins/helm-installer.zh.md create mode 100644 docs/plugins/helm-installer/argocd.md create mode 100644 docs/plugins/helm-installer/argocd.zh.md rename docs/plugins/{ => helm-installer}/artifactory.md (97%) rename docs/plugins/{ => helm-installer}/artifactory.zh.md (97%) rename docs/plugins/{ => helm-installer}/devlake.md (78%) rename docs/plugins/{ => helm-installer}/devlake.zh.md (80%) rename docs/plugins/{ => helm-installer}/harbor.md (99%) rename docs/plugins/{ => helm-installer}/harbor.zh.md (99%) rename docs/plugins/{ => helm-installer}/helm-installer.md (92%) create mode 100644 docs/plugins/helm-installer/helm-installer.zh.md rename docs/plugins/{ => helm-installer}/jenkins.md (96%) rename docs/plugins/{ => helm-installer}/jenkins.zh.md (99%) rename docs/plugins/{ => helm-installer}/kube-prometheus.md (96%) create mode 100644 docs/plugins/helm-installer/kube-prometheus.zh.md rename docs/plugins/{ => helm-installer}/openldap.md (99%) create mode 100644 docs/plugins/helm-installer/openldap.zh.md rename docs/plugins/{ => helm-installer}/sonarqube.md (83%) rename docs/plugins/{ => helm-installer}/sonarqube.zh.md (98%) rename docs/plugins/{ => helm-installer}/tekton.md (96%) rename docs/plugins/{ => helm-installer}/tekton.zh.md (96%) rename docs/plugins/{hashicorp-vault.md => helm-installer/vault.md} (98%) create mode 100644 docs/plugins/helm-installer/vault.zh.md delete mode 100644 docs/plugins/kube-prometheus.zh.md delete mode 100644 docs/plugins/openldap.zh.md delete mode 100644 internal/pkg/plugin/artifactory/artifactory.go delete mode 100644 internal/pkg/plugin/artifactory/create.go delete mode 100644 internal/pkg/plugin/artifactory/delete.go delete mode 100644 internal/pkg/plugin/artifactory/read.go delete mode 100644 internal/pkg/plugin/artifactory/update.go delete mode 100644 internal/pkg/plugin/devlake/create.go delete mode 100644 internal/pkg/plugin/devlake/delete.go delete mode 100644 internal/pkg/plugin/devlake/read.go delete mode 100644 internal/pkg/plugin/devlake/update.go delete mode 100644 internal/pkg/plugin/harbor/create.go delete mode 100644 internal/pkg/plugin/harbor/delete.go delete mode 100644 internal/pkg/plugin/harbor/read.go delete mode 100644 internal/pkg/plugin/harbor/update.go delete mode 100644 internal/pkg/plugin/hashicorpvault/create.go delete mode 100644 internal/pkg/plugin/hashicorpvault/delete.go delete mode 100644 internal/pkg/plugin/hashicorpvault/hashicorpvault.go delete mode 100644 internal/pkg/plugin/hashicorpvault/read.go delete mode 100644 internal/pkg/plugin/hashicorpvault/update.go create mode 100644 internal/pkg/plugin/helminstaller/defaults/artifactory.go rename internal/pkg/plugin/{devlake => helminstaller/defaults}/devlake.go (83%) rename internal/pkg/plugin/{harbor => helminstaller/defaults}/harbor.go (50%) rename internal/pkg/plugin/{jenkins => helminstaller/defaults}/jenkins.go (85%) create mode 100644 internal/pkg/plugin/helminstaller/defaults/kubeprometheus.go create mode 100644 internal/pkg/plugin/helminstaller/defaults/openldap.go create mode 100644 internal/pkg/plugin/helminstaller/defaults/sonarqube.go create mode 100644 internal/pkg/plugin/helminstaller/defaults/tekton.go create mode 100644 internal/pkg/plugin/helminstaller/defaults/vault.go delete mode 100644 internal/pkg/plugin/jenkins/create.go delete mode 100644 internal/pkg/plugin/jenkins/delete.go delete mode 100644 internal/pkg/plugin/jenkins/read.go delete mode 100644 internal/pkg/plugin/jenkins/update.go delete mode 100644 internal/pkg/plugin/kubeprometheus/create.go delete mode 100644 internal/pkg/plugin/kubeprometheus/delete.go delete mode 100644 internal/pkg/plugin/kubeprometheus/kubeprometheus.go delete mode 100644 internal/pkg/plugin/kubeprometheus/read.go delete mode 100644 internal/pkg/plugin/kubeprometheus/update.go delete mode 100644 internal/pkg/plugin/openldap/create.go delete mode 100644 internal/pkg/plugin/openldap/delete.go delete mode 100644 internal/pkg/plugin/openldap/openldap.go delete mode 100644 internal/pkg/plugin/openldap/read.go delete mode 100644 internal/pkg/plugin/openldap/update.go delete mode 100644 internal/pkg/plugin/sonarqube/create.go delete mode 100644 internal/pkg/plugin/sonarqube/delete.go delete mode 100644 internal/pkg/plugin/sonarqube/read.go delete mode 100644 internal/pkg/plugin/sonarqube/sonar.go delete mode 100644 internal/pkg/plugin/sonarqube/update.go delete mode 100644 internal/pkg/plugin/tekton/create.go delete mode 100644 internal/pkg/plugin/tekton/delete.go delete mode 100644 internal/pkg/plugin/tekton/read.go delete mode 100644 internal/pkg/plugin/tekton/tekton.go delete mode 100644 internal/pkg/plugin/tekton/update.go diff --git a/cmd/plugin/artifactory/main.go b/cmd/plugin/artifactory/main.go deleted file mode 100644 index 109a67268..000000000 --- a/cmd/plugin/artifactory/main.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugin/artifactory" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// NAME is the name of this DevStream plugin. -const NAME = "artifactory" - -// Plugin is the type used by DevStream core. It's a string. -type Plugin string - -// Create implements the create of artifactory. -func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return artifactory.Create(options) -} - -// Update implements the update of artifactory. -func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return artifactory.Update(options) -} - -// Delete implements the delete of artifactory. -func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { - return artifactory.Delete(options) -} - -// Read implements the read of artifactory. -func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return artifactory.Read(options) -} - -// DevStreamPlugin is the exported variable used by the DevStream core. -var DevStreamPlugin Plugin - -func main() { - log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME) -} diff --git a/cmd/plugin/devlake/main.go b/cmd/plugin/devlake/main.go deleted file mode 100644 index 82966c1f0..000000000 --- a/cmd/plugin/devlake/main.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugin/devlake" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// NAME is the name of this DevStream plugin. -const NAME = "devlake" - -// Plugin is the type used by DevStream core. It's a string. -type Plugin string - -// Create implements the create of devlake. -func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return devlake.Create(options) -} - -// Update implements the update of devlake. -func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return devlake.Update(options) -} - -// Delete implements the delete of devlake. -func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { - return devlake.Delete(options) -} - -// Read implements the read of devlake. -func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return devlake.Read(options) -} - -// DevStreamPlugin is the exported variable used by the DevStream core. -var DevStreamPlugin Plugin - -func main() { - log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME) -} diff --git a/cmd/plugin/harbor/main.go b/cmd/plugin/harbor/main.go deleted file mode 100644 index 657fd3b49..000000000 --- a/cmd/plugin/harbor/main.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugin/harbor" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// NAME is the name of this DevStream plugin. -const NAME = "harbor" - -// Plugin is the type used by DevStream core. It's a string. -type Plugin string - -// Create implements the create of harbor. -func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return harbor.Create(options) -} - -// Update implements the update of harbor. -func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return harbor.Update(options) -} - -// Delete implements the delete of harbor. -func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { - return harbor.Delete(options) -} - -// Read implements the read of harbor. -func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return harbor.Read(options) -} - -// DevStreamPlugin is the exported variable used by the DevStream core. -var DevStreamPlugin Plugin - -func main() { - log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME) -} diff --git a/cmd/plugin/hashicorp-vault/main.go b/cmd/plugin/hashicorp-vault/main.go deleted file mode 100644 index 31d7a3de5..000000000 --- a/cmd/plugin/hashicorp-vault/main.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugin/hashicorpvault" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// NAME is the name of this DevStream plugin. -const NAME = "hashicorp-vault" - -// Plugin is the type used by DevStream core. It's a string. -type Plugin string - -// Create implements the create of hashicorp-vault. -func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return hashicorpvault.Create(options) -} - -// Update implements the update of hashicorp-vault. -func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return hashicorpvault.Update(options) -} - -// Delete implements the delete of hashicorp-vault. -func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { - return hashicorpvault.Delete(options) -} - -// Read implements the read of hashicorp-vault. -func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return hashicorpvault.Read(options) -} - -// DevStreamPlugin is the exported variable used by the DevStream core. -var DevStreamPlugin Plugin - -func main() { - log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME) -} diff --git a/cmd/plugin/jenkins/main.go b/cmd/plugin/jenkins/main.go deleted file mode 100644 index 147b2e196..000000000 --- a/cmd/plugin/jenkins/main.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugin/jenkins" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// NAME is the name of this DevStream plugin. -const NAME = "jenkins" - -// Plugin is the type used by DevStream core. It's a string. -type Plugin string - -// Create implements the create of the jenkins. -func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return jenkins.Create(options) -} - -// Update implements the update of the jenkins. -func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return jenkins.Update(options) -} - -// Read implements read of the jenkins. -func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return jenkins.Read(options) -} - -// Delete implements the delete of the jenkins. -func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { - return jenkins.Delete(options) -} - -// DevStreamPlugin is the exported variable used by the DevStream core. -var DevStreamPlugin Plugin - -func main() { - log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME) -} diff --git a/cmd/plugin/kube-prometheus/main.go b/cmd/plugin/kube-prometheus/main.go deleted file mode 100644 index 8642ed586..000000000 --- a/cmd/plugin/kube-prometheus/main.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugin/kubeprometheus" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// NAME is the name of this DevStream plugin. -const NAME = "kube-prometheus" - -// Plugin is the type used by DevStream core. It's a string. -type Plugin string - -// Create implements the create of the kube-prometheus. -func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return kubeprometheus.Create(options) -} - -// Update implements the update of the kube-prometheus. -func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return kubeprometheus.Update(options) -} - -// Read implements read of the kube-prometheus. -func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return kubeprometheus.Read(options) -} - -// Delete implements the delete of the kube-prometheus. -func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { - return kubeprometheus.Delete(options) -} - -// DevStreamPlugin is the exported variable used by the DevStream core. -var DevStreamPlugin Plugin - -func main() { - log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME) -} diff --git a/cmd/plugin/openldap/main.go b/cmd/plugin/openldap/main.go deleted file mode 100644 index 9ba45ad5d..000000000 --- a/cmd/plugin/openldap/main.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugin/openldap" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// NAME is the name of this DevStream plugin. -const NAME = "openldap" - -// Plugin is the type used by DevStream core. It's a string. -type Plugin string - -// Create implements the create of OpenLDAP. -func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return openldap.Create(options) -} - -// Update implements the update of OpenLDAP. -func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return openldap.Update(options) -} - -// Delete implements the delete of OpenLDAP. -func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { - return openldap.Delete(options) -} - -// Read implements the read of OpenLDAP. -func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return openldap.Read(options) -} - -// DevStreamPlugin is the exported variable used by the DevStream core. -var DevStreamPlugin Plugin - -func main() { - log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME) -} diff --git a/cmd/plugin/sonarqube/main.go b/cmd/plugin/sonarqube/main.go deleted file mode 100644 index f09495f7b..000000000 --- a/cmd/plugin/sonarqube/main.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugin/sonarqube" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// NAME is the name of this DevStream plugin. -const NAME = "sonarqube" - -// Plugin is the type used by DevStream core. It's a string. -type Plugin string - -// Create implements the create of sonar. -func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return sonarqube.Create(options) -} - -// Update implements the update of sonar. -func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return sonarqube.Update(options) -} - -// Delete implements the delete of sonar. -func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { - return sonarqube.Delete(options) -} - -// Read implements the read of sonar. -func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return sonarqube.Read(options) -} - -// DevStreamPlugin is the exported variable used by the DevStream core. -var DevStreamPlugin Plugin - -func main() { - log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME) -} diff --git a/cmd/plugin/tekton/main.go b/cmd/plugin/tekton/main.go deleted file mode 100644 index a5d288068..000000000 --- a/cmd/plugin/tekton/main.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugin/tekton" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// NAME is the name of this DevStream plugin. -const NAME = "tekton" - -// Plugin is the type used by DevStream core. It's a string. -type Plugin string - -// Create implements the create of tekton. -func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return tekton.Create(options) -} - -// Update implements the update of tekton. -func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return tekton.Update(options) -} - -// Delete implements the delete of tekton. -func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { - return tekton.Delete(options) -} - -// Read implements the read of tekton. -func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - return tekton.Read(options) -} - -// DevStreamPlugin is the exported variable used by the DevStream core. -var DevStreamPlugin Plugin - -func main() { - log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME) -} diff --git a/docs/plugins/hashicorp-vault.zh.md b/docs/plugins/hashicorp-vault.zh.md deleted file mode 100644 index c9aa15adc..000000000 --- a/docs/plugins/hashicorp-vault.zh.md +++ /dev/null @@ -1,3 +0,0 @@ -# hashicorp-vault 插件 - -todo diff --git a/docs/plugins/helm-installer.zh.md b/docs/plugins/helm-installer.zh.md deleted file mode 100644 index 7061e8c1c..000000000 --- a/docs/plugins/helm-installer.zh.md +++ /dev/null @@ -1,8 +0,0 @@ -# helm-installer 插件 - -TODO(daniel-hutao): I'll update this the document after code refactoring finished. -## 用例 - -``` yaml ---8<-- "helm-installer.yaml" -``` diff --git a/docs/plugins/helm-installer/argocd.md b/docs/plugins/helm-installer/argocd.md new file mode 100644 index 000000000..d0ba2aefb --- /dev/null +++ b/docs/plugins/helm-installer/argocd.md @@ -0,0 +1,3 @@ +# Install Argo CD with DevStream + +//TODO(daniel-hutao): to be updated diff --git a/docs/plugins/helm-installer/argocd.zh.md b/docs/plugins/helm-installer/argocd.zh.md new file mode 100644 index 000000000..c8e9320dd --- /dev/null +++ b/docs/plugins/helm-installer/argocd.zh.md @@ -0,0 +1,3 @@ +# 使用 DevStream 部署 Argo CD + +//TODO(daniel-hutao): to be updated diff --git a/docs/plugins/artifactory.md b/docs/plugins/helm-installer/artifactory.md similarity index 97% rename from docs/plugins/artifactory.md rename to docs/plugins/helm-installer/artifactory.md index e6d6c2d57..2da82aad5 100644 --- a/docs/plugins/artifactory.md +++ b/docs/plugins/helm-installer/artifactory.md @@ -1,4 +1,6 @@ -# artifactory Plugin +# Install Artifactory with DevStream + +//TODO(daniel-hutao): to be updated This plugin installs [artifactory](https://jfrog.com/artifactory/) in an existing Kubernetes cluster using the Helm chart. diff --git a/docs/plugins/artifactory.zh.md b/docs/plugins/helm-installer/artifactory.zh.md similarity index 97% rename from docs/plugins/artifactory.zh.md rename to docs/plugins/helm-installer/artifactory.zh.md index 9884a92ec..8fad5435c 100644 --- a/docs/plugins/artifactory.zh.md +++ b/docs/plugins/helm-installer/artifactory.zh.md @@ -1,4 +1,6 @@ -# artifactory 插件 +# 使用 DevStream 部署 Artifactory + +//TODO(daniel-hutao): to be updated 这个插件使用 helm 在已有的 k8s 集群上安装 [artifactory](https://jfrog.com/artifactory/)。 diff --git a/docs/plugins/devlake.md b/docs/plugins/helm-installer/devlake.md similarity index 78% rename from docs/plugins/devlake.md rename to docs/plugins/helm-installer/devlake.md index 904ac8942..dafe0fb83 100644 --- a/docs/plugins/devlake.md +++ b/docs/plugins/helm-installer/devlake.md @@ -1,6 +1,6 @@ -# devlake Plugin +# Install DevLake with DevStream -//TODO(daniel-hutao): add document here after Chinese version be ready. +//TODO(daniel-hutao): to be updated ## Usage diff --git a/docs/plugins/devlake.zh.md b/docs/plugins/helm-installer/devlake.zh.md similarity index 80% rename from docs/plugins/devlake.zh.md rename to docs/plugins/helm-installer/devlake.zh.md index dcb8c4cbe..f9c76513c 100644 --- a/docs/plugins/devlake.zh.md +++ b/docs/plugins/helm-installer/devlake.zh.md @@ -1,6 +1,6 @@ -# devlake 插件 +# 使用 DevStream 部署 DevLake -//TODO(daniel-hutao): 本插件出于开发中状态。 +//TODO(daniel-hutao): to be updated ## 用例 diff --git a/docs/plugins/harbor.md b/docs/plugins/helm-installer/harbor.md similarity index 99% rename from docs/plugins/harbor.md rename to docs/plugins/helm-installer/harbor.md index a72451a44..57ba2d82a 100644 --- a/docs/plugins/harbor.md +++ b/docs/plugins/helm-installer/harbor.md @@ -1,4 +1,6 @@ -# harbor Plugin +# Install Harbor with DevStream + +//TODO(daniel-hutao): to be updated The `harbor` plugin is used to deploy and manage [Harbor](https://goharbor.io/). diff --git a/docs/plugins/harbor.zh.md b/docs/plugins/helm-installer/harbor.zh.md similarity index 99% rename from docs/plugins/harbor.zh.md rename to docs/plugins/helm-installer/harbor.zh.md index 19c5a71a8..f75f16ff2 100644 --- a/docs/plugins/harbor.zh.md +++ b/docs/plugins/helm-installer/harbor.zh.md @@ -1,4 +1,6 @@ -# harbor 插件 +# 使用 DevStream 部署 Harbor + +//TODO(daniel-hutao): to be updated `harbor` 插件用于部署、管理 [Harbor](https://goharbor.io/) 应用。 diff --git a/docs/plugins/helm-installer.md b/docs/plugins/helm-installer/helm-installer.md similarity index 92% rename from docs/plugins/helm-installer.md rename to docs/plugins/helm-installer/helm-installer.md index 03f38d040..2a17efc3c 100644 --- a/docs/plugins/helm-installer.md +++ b/docs/plugins/helm-installer/helm-installer.md @@ -1,6 +1,4 @@ -# helm-installer plugin - -TODO(daniel-hutao): I'll update this the document after code refactoring finished. +# helm-installer Plugin ## Usage diff --git a/docs/plugins/helm-installer/helm-installer.zh.md b/docs/plugins/helm-installer/helm-installer.zh.md new file mode 100644 index 000000000..e21582018 --- /dev/null +++ b/docs/plugins/helm-installer/helm-installer.zh.md @@ -0,0 +1,52 @@ +# helm-installer 插件 + +`helm-installer` 插件实现了比 `helm` 更加简单和容易上手的方式来快速部署提供了 Helm Chart 的应用。 + +## 快速开始 + +只需要一个最小化配置,你就可以快速使用默认配置部署一个 Helm Chart。你可以将如下配置内容保存到本地 config.yaml 文件中: + +```yaml +--- +varFile: "" +toolFile: "" +pluginDir: "" +state: + backend: local + options: + stateFile: devstream.state + +--- +tools: +- name: helm-installer + instanceID: argocd-001 +``` + +在这个配置文件里,和插件相关的配置 name 和 instanceID,前者表示你将使用 `helm-installer` 插件,后者表示插件实例名。 +请注意这个 instanceID 使用了 "argocd-" 前缀,DevStream 会识别这个前缀,尝试寻找 Argo CD 应用对应的 Chart,并设置一系列默认值,然后开始部署。 + +你可以在 [Install Argo CD with DevStream](./argocd.zh.md) 中查看 DevStream 为你设置了哪些默认值。 + +接着执行如下命令开始部署: + +```sh +./dtm init -f config.yaml +./dtm apply -f config.yaml -y +``` + +## DevStream vs Helm + +// TODO(daniel-hutao): add document here later. + +## 当前支持的工具 + +- [Install Argo CD with DevStream](./argocd.zh.md) +- [Install Artifactory with DevStream](./artifactory.zh.md) +- [Install DevLake with DevStream](./devlake.zh.md) +- [Install Harbor with DevStream](./harbor.zh.md) +- [Install Jenkins with DevStream](./jenkins.zh.md) +- [Install Kube Prometheus with DevStream](./kube-prometheus.zh.md) +- [Install OpenLDAP with DevStream](./openldap.zh.md) +- [Install SonarQube with DevStream](./sonarqube.zh.md) +- [Install Tekton with DevStream](./tekton.zh.md) +- [Install Vault with DevStream](./vault.zh.md) diff --git a/docs/plugins/jenkins.md b/docs/plugins/helm-installer/jenkins.md similarity index 96% rename from docs/plugins/jenkins.md rename to docs/plugins/helm-installer/jenkins.md index 937998db8..1971ee7e6 100644 --- a/docs/plugins/jenkins.md +++ b/docs/plugins/helm-installer/jenkins.md @@ -1,4 +1,6 @@ -# jenkins Plugin +# Install Jenkins with DevStream + +//TODO(daniel-hutao): to be updated This plugin installs [Jenkins](https://jenkins.io) in an existing Kubernetes cluster using the Helm chart. diff --git a/docs/plugins/jenkins.zh.md b/docs/plugins/helm-installer/jenkins.zh.md similarity index 99% rename from docs/plugins/jenkins.zh.md rename to docs/plugins/helm-installer/jenkins.zh.md index f1fe591eb..ef0b05ad6 100644 --- a/docs/plugins/jenkins.zh.md +++ b/docs/plugins/helm-installer/jenkins.zh.md @@ -1,4 +1,6 @@ -# jenkins 插件 +# 使用 DevStream 部署 Jenkins + +//TODO(daniel-hutao): to be updated `jenkins` 插件用于部署、管理 [Jenkins](https://www.jenkins.io) 应用。 diff --git a/docs/plugins/kube-prometheus.md b/docs/plugins/helm-installer/kube-prometheus.md similarity index 96% rename from docs/plugins/kube-prometheus.md rename to docs/plugins/helm-installer/kube-prometheus.md index 98d578f52..4dcf693a3 100644 --- a/docs/plugins/kube-prometheus.md +++ b/docs/plugins/helm-installer/kube-prometheus.md @@ -1,4 +1,6 @@ -# kube-prometheus Plugin +# Install kube-prometheus with DevStream + +//TODO(daniel-hutao): to be updated This plugin installs [kube-prometheus](https://github.com/prometheus-operator/kube-prometheus) in an existing Kubernetes cluster using the Helm chart. diff --git a/docs/plugins/helm-installer/kube-prometheus.zh.md b/docs/plugins/helm-installer/kube-prometheus.zh.md new file mode 100644 index 000000000..b3a2f2d18 --- /dev/null +++ b/docs/plugins/helm-installer/kube-prometheus.zh.md @@ -0,0 +1,3 @@ +# 使用 DevStream 部署 kube-prometheus + +//TODO(daniel-hutao): to be updated diff --git a/docs/plugins/openldap.md b/docs/plugins/helm-installer/openldap.md similarity index 99% rename from docs/plugins/openldap.md rename to docs/plugins/helm-installer/openldap.md index 0638f70fb..65661122d 100644 --- a/docs/plugins/openldap.md +++ b/docs/plugins/helm-installer/openldap.md @@ -1,4 +1,6 @@ -# openldap Plugin +# Install OpenLDAP with DevStream + +//TODO(daniel-hutao): to be updated This plugin installs [OpenLDAP](https://www.openldap.org/) in an existing Kubernetes cluster using the Helm chart. Please at least make sure your Kubernetes's version is greater than 1.18. diff --git a/docs/plugins/helm-installer/openldap.zh.md b/docs/plugins/helm-installer/openldap.zh.md new file mode 100644 index 000000000..75cc15cb5 --- /dev/null +++ b/docs/plugins/helm-installer/openldap.zh.md @@ -0,0 +1,3 @@ +# 使用 DevStream 部署 OpenLDAP + +//TODO(daniel-hutao): to be updated diff --git a/docs/plugins/sonarqube.md b/docs/plugins/helm-installer/sonarqube.md similarity index 83% rename from docs/plugins/sonarqube.md rename to docs/plugins/helm-installer/sonarqube.md index 5e032e552..a25dc827f 100644 --- a/docs/plugins/sonarqube.md +++ b/docs/plugins/helm-installer/sonarqube.md @@ -1,4 +1,6 @@ -# sonarqube Plugin +# Install SonarQube with DevStream + +//TODO(daniel-hutao): to be updated TODO(jiafeng meng): I will add this document later. diff --git a/docs/plugins/sonarqube.zh.md b/docs/plugins/helm-installer/sonarqube.zh.md similarity index 98% rename from docs/plugins/sonarqube.zh.md rename to docs/plugins/helm-installer/sonarqube.zh.md index 8f162d50b..78df74a34 100644 --- a/docs/plugins/sonarqube.zh.md +++ b/docs/plugins/helm-installer/sonarqube.zh.md @@ -1,4 +1,6 @@ -# sonarqube 插件 +# 使用 DevStream 部署 SonarQube + +//TODO(daniel-hutao): to be updated `sonarqube` 插件用于部署、管理 [SonarQube](https://www.sonarqube.org/) 应用。 diff --git a/docs/plugins/tekton.md b/docs/plugins/helm-installer/tekton.md similarity index 96% rename from docs/plugins/tekton.md rename to docs/plugins/helm-installer/tekton.md index f7a60399f..92ce1117d 100644 --- a/docs/plugins/tekton.md +++ b/docs/plugins/helm-installer/tekton.md @@ -1,4 +1,7 @@ -# tekton Plugin +# Install Tekton with DevStream + +//TODO(daniel-hutao): to be updated + This plugin installs [tekton](https://tekton.dev/) in an existing Kubernetes cluster using the Helm chart. ## Usage diff --git a/docs/plugins/tekton.zh.md b/docs/plugins/helm-installer/tekton.zh.md similarity index 96% rename from docs/plugins/tekton.zh.md rename to docs/plugins/helm-installer/tekton.zh.md index c0591c641..8749d3d0d 100644 --- a/docs/plugins/tekton.zh.md +++ b/docs/plugins/helm-installer/tekton.zh.md @@ -1,4 +1,6 @@ -# tekton 插件 +# 使用 DevStream 部署 Tekton + +//TODO(daniel-hutao): to be updated ## 用例 diff --git a/docs/plugins/hashicorp-vault.md b/docs/plugins/helm-installer/vault.md similarity index 98% rename from docs/plugins/hashicorp-vault.md rename to docs/plugins/helm-installer/vault.md index cd3db86f4..ac7b31875 100644 --- a/docs/plugins/hashicorp-vault.md +++ b/docs/plugins/helm-installer/vault.md @@ -1,4 +1,6 @@ -# hashicorp-vault Plugin +# Install Vault with DevStream + +//TODO(daniel-hutao): to be updated This plugin installs [hashicorp-vault](https://www.vaultproject.io/) in an existing Kubernetes cluster using the Helm chart for your tests or develops hashicorp-vault. diff --git a/docs/plugins/helm-installer/vault.zh.md b/docs/plugins/helm-installer/vault.zh.md new file mode 100644 index 000000000..269c0e075 --- /dev/null +++ b/docs/plugins/helm-installer/vault.zh.md @@ -0,0 +1,3 @@ +# 使用 DevStream 部署 Vault + +//TODO(daniel-hutao): to be updated diff --git a/docs/plugins/kube-prometheus.zh.md b/docs/plugins/kube-prometheus.zh.md deleted file mode 100644 index 57df07d33..000000000 --- a/docs/plugins/kube-prometheus.zh.md +++ /dev/null @@ -1,3 +0,0 @@ -# kube-prometheus 插件 - -todo diff --git a/docs/plugins/openldap.zh.md b/docs/plugins/openldap.zh.md deleted file mode 100644 index 31645c41c..000000000 --- a/docs/plugins/openldap.zh.md +++ /dev/null @@ -1,3 +0,0 @@ -# openldap 插件 - -todo diff --git a/internal/pkg/develop/plugin/template/NAME.md.tpl b/internal/pkg/develop/plugin/template/NAME.md.tpl index e0f502e34..140b2bb63 100644 --- a/internal/pkg/develop/plugin/template/NAME.md.tpl +++ b/internal/pkg/develop/plugin/template/NAME.md.tpl @@ -1,4 +1,4 @@ -# [[ .Name ]] plugin +# [[ .Name ]] Plugin TODO(dtm): Add your document here. diff --git a/internal/pkg/plugin/artifactory/artifactory.go b/internal/pkg/plugin/artifactory/artifactory.go deleted file mode 100644 index 871af387d..000000000 --- a/internal/pkg/plugin/artifactory/artifactory.go +++ /dev/null @@ -1,23 +0,0 @@ -package artifactory - -import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - helmCommon "github.com/devstream-io/devstream/pkg/util/helm" - "github.com/devstream-io/devstream/pkg/util/types" -) - -var defaultHelmConfig = helm.Options{ - Chart: helmCommon.Chart{ - ChartPath: "", - ChartName: "jfrog/artifactory", - Timeout: "10m", - UpgradeCRDs: types.Bool(true), - Wait: types.Bool(true), - ReleaseName: "artifactory", - Namespace: "artifactory", - }, - Repo: helmCommon.Repo{ - URL: "https://charts.jfrog.io", - Name: "jfrog", - }, -} diff --git a/internal/pkg/plugin/artifactory/create.go b/internal/pkg/plugin/artifactory/create.go deleted file mode 100644 index f8d57c0e8..000000000 --- a/internal/pkg/plugin/artifactory/create.go +++ /dev/null @@ -1,30 +0,0 @@ -package artifactory - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultCreateOperations, - TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/artifactory/delete.go b/internal/pkg/plugin/artifactory/delete.go deleted file mode 100644 index f13845d2e..000000000 --- a/internal/pkg/plugin/artifactory/delete.go +++ /dev/null @@ -1,25 +0,0 @@ -package artifactory - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" -) - -func Delete(options configmanager.RawOptions) (bool, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultDeleteOperations, - } - _, err := operator.Execute(options) - if err != nil { - return false, err - } - - // 2. return ture if all process success - return true, nil -} diff --git a/internal/pkg/plugin/artifactory/read.go b/internal/pkg/plugin/artifactory/read.go deleted file mode 100644 index beea2be2d..000000000 --- a/internal/pkg/plugin/artifactory/read.go +++ /dev/null @@ -1,28 +0,0 @@ -package artifactory - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/artifactory/update.go b/internal/pkg/plugin/artifactory/update.go deleted file mode 100644 index a8efe84e0..000000000 --- a/internal/pkg/plugin/artifactory/update.go +++ /dev/null @@ -1,29 +0,0 @@ -package artifactory - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/devlake/create.go b/internal/pkg/plugin/devlake/create.go deleted file mode 100644 index 237dadc15..000000000 --- a/internal/pkg/plugin/devlake/create.go +++ /dev/null @@ -1,30 +0,0 @@ -package devlake - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultCreateOperations, - TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: genDevLakeStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/devlake/delete.go b/internal/pkg/plugin/devlake/delete.go deleted file mode 100644 index 39c6b0393..000000000 --- a/internal/pkg/plugin/devlake/delete.go +++ /dev/null @@ -1,26 +0,0 @@ -package devlake - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" -) - -func Delete(options configmanager.RawOptions) (bool, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultDeleteOperations, - } - - // Execute all Operations in Operator - _, err := operator.Execute(options) - if err != nil { - return false, err - } - - return true, nil -} diff --git a/internal/pkg/plugin/devlake/read.go b/internal/pkg/plugin/devlake/read.go deleted file mode 100644 index ec8845774..000000000 --- a/internal/pkg/plugin/devlake/read.go +++ /dev/null @@ -1,28 +0,0 @@ -package devlake - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - GetStatusOperation: genDevLakeStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/devlake/update.go b/internal/pkg/plugin/devlake/update.go deleted file mode 100644 index 3c96f3157..000000000 --- a/internal/pkg/plugin/devlake/update.go +++ /dev/null @@ -1,29 +0,0 @@ -package devlake - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: genDevLakeStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/harbor/create.go b/internal/pkg/plugin/harbor/create.go deleted file mode 100644 index 8be848b3c..000000000 --- a/internal/pkg/plugin/harbor/create.go +++ /dev/null @@ -1,30 +0,0 @@ -package harbor - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultCreateOperations, - TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/harbor/delete.go b/internal/pkg/plugin/harbor/delete.go deleted file mode 100644 index dbb6a82f2..000000000 --- a/internal/pkg/plugin/harbor/delete.go +++ /dev/null @@ -1,25 +0,0 @@ -package harbor - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" -) - -func Delete(options configmanager.RawOptions) (bool, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultDeleteOperations, - } - - // Execute all Operations in Operator - _, err := operator.Execute(options) - if err != nil { - return false, err - } - return true, nil -} diff --git a/internal/pkg/plugin/harbor/read.go b/internal/pkg/plugin/harbor/read.go deleted file mode 100644 index 0d9a4333e..000000000 --- a/internal/pkg/plugin/harbor/read.go +++ /dev/null @@ -1,29 +0,0 @@ -package harbor - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/harbor/update.go b/internal/pkg/plugin/harbor/update.go deleted file mode 100644 index 1f378b71e..000000000 --- a/internal/pkg/plugin/harbor/update.go +++ /dev/null @@ -1,29 +0,0 @@ -package harbor - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/hashicorpvault/create.go b/internal/pkg/plugin/hashicorpvault/create.go deleted file mode 100644 index 101e76fb4..000000000 --- a/internal/pkg/plugin/hashicorpvault/create.go +++ /dev/null @@ -1,31 +0,0 @@ -package hashicorpvault - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// Create creates hashicorp-vault with provided options. -func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultCreateOperations, - TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/hashicorpvault/delete.go b/internal/pkg/plugin/hashicorpvault/delete.go deleted file mode 100644 index 1d374e7fb..000000000 --- a/internal/pkg/plugin/hashicorpvault/delete.go +++ /dev/null @@ -1,25 +0,0 @@ -package hashicorpvault - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" -) - -func Delete(options configmanager.RawOptions) (bool, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultDeleteOperations, - } - _, err := operator.Execute(options) - if err != nil { - return false, err - } - - // 2. return ture if all process success - return true, nil -} diff --git a/internal/pkg/plugin/hashicorpvault/hashicorpvault.go b/internal/pkg/plugin/hashicorpvault/hashicorpvault.go deleted file mode 100644 index 30cbc1679..000000000 --- a/internal/pkg/plugin/hashicorpvault/hashicorpvault.go +++ /dev/null @@ -1,23 +0,0 @@ -package hashicorpvault - -import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - helmCommon "github.com/devstream-io/devstream/pkg/util/helm" - "github.com/devstream-io/devstream/pkg/util/types" -) - -var defaultHelmConfig = helm.Options{ - Chart: helmCommon.Chart{ - ChartPath: "", - ChartName: "hashicorp/vault", - Timeout: "5m", - UpgradeCRDs: types.Bool(true), - Wait: types.Bool(true), - ReleaseName: "vault", - Namespace: "vault", - }, - Repo: helmCommon.Repo{ - URL: "https://helm.releases.hashicorp.com", - Name: "hashicorp", - }, -} diff --git a/internal/pkg/plugin/hashicorpvault/read.go b/internal/pkg/plugin/hashicorpvault/read.go deleted file mode 100644 index ea76c3c37..000000000 --- a/internal/pkg/plugin/hashicorpvault/read.go +++ /dev/null @@ -1,28 +0,0 @@ -package hashicorpvault - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/hashicorpvault/update.go b/internal/pkg/plugin/hashicorpvault/update.go deleted file mode 100644 index 7cb75040e..000000000 --- a/internal/pkg/plugin/hashicorpvault/update.go +++ /dev/null @@ -1,29 +0,0 @@ -package hashicorpvault - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/helminstaller/create.go b/internal/pkg/plugin/helminstaller/create.go index d2fe5bf91..fd896b96a 100644 --- a/internal/pkg/plugin/helminstaller/create.go +++ b/internal/pkg/plugin/helminstaller/create.go @@ -12,13 +12,13 @@ func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, erro // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ - SetDefaultConfig, + RenderDefaultConfig, RenderValuesYaml, validate, }, ExecuteOperations: helm.DefaultCreateOperations, TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, + GetStatusOperation: IndexStatusGetterFunc(options), } // Execute all Operations in Operator diff --git a/internal/pkg/plugin/helminstaller/defaults/argocd.go b/internal/pkg/plugin/helminstaller/defaults/argocd.go index a1c653aa0..320fed8fa 100644 --- a/internal/pkg/plugin/helminstaller/defaults/argocd.go +++ b/internal/pkg/plugin/helminstaller/defaults/argocd.go @@ -1,7 +1,9 @@ package defaults import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" helmCommon "github.com/devstream-io/devstream/pkg/util/helm" "github.com/devstream-io/devstream/pkg/util/types" ) @@ -13,7 +15,7 @@ var DefaultConfigWithArgoCD = helm.Options{ ChartPath: "", ChartName: "argo/argo-cd", Version: "", - Timeout: "5m", + Timeout: "10m", Wait: types.Bool(true), UpgradeCRDs: types.Bool(true), ReleaseName: "argocd", @@ -27,4 +29,9 @@ var DefaultConfigWithArgoCD = helm.Options{ func init() { DefaultOptionsMap[toolArgoCD] = &DefaultConfigWithArgoCD + StatusGetterFuncMap[toolArgoCD] = GetArgoCDStatus +} + +func GetArgoCDStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { + return helm.GetAllResourcesStatus(options) } diff --git a/internal/pkg/plugin/helminstaller/defaults/artifactory.go b/internal/pkg/plugin/helminstaller/defaults/artifactory.go new file mode 100644 index 000000000..8283c0810 --- /dev/null +++ b/internal/pkg/plugin/helminstaller/defaults/artifactory.go @@ -0,0 +1,37 @@ +package defaults + +import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" + helmCommon "github.com/devstream-io/devstream/pkg/util/helm" + "github.com/devstream-io/devstream/pkg/util/types" +) + +var toolArtifactory = "artifactory" + +var DefaultConfigWithArtifactory = helm.Options{ + Chart: helmCommon.Chart{ + ChartPath: "", + ChartName: "jfrog/artifactory", + Version: "", + Timeout: "10m", + UpgradeCRDs: types.Bool(true), + Wait: types.Bool(true), + ReleaseName: "artifactory", + Namespace: "artifactory", + }, + Repo: helmCommon.Repo{ + URL: "https://charts.jfrog.io", + Name: "jfrog", + }, +} + +func init() { + DefaultOptionsMap[toolArtifactory] = &DefaultConfigWithArtifactory + StatusGetterFuncMap[toolArtifactory] = GetArtifactoryStatus +} + +func GetArtifactoryStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { + return helm.GetAllResourcesStatus(options) +} diff --git a/internal/pkg/plugin/helminstaller/defaults/defaultconfig.go b/internal/pkg/plugin/helminstaller/defaults/defaultconfig.go index 83e313ea5..172d7c70e 100644 --- a/internal/pkg/plugin/helminstaller/defaults/defaultconfig.go +++ b/internal/pkg/plugin/helminstaller/defaults/defaultconfig.go @@ -1,5 +1,9 @@ package defaults -import "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" +import ( + "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" +) var DefaultOptionsMap = make(map[string]*helm.Options) +var StatusGetterFuncMap = make(map[string]plugininstaller.StatusGetterOperation) diff --git a/internal/pkg/plugin/devlake/devlake.go b/internal/pkg/plugin/helminstaller/defaults/devlake.go similarity index 83% rename from internal/pkg/plugin/devlake/devlake.go rename to internal/pkg/plugin/helminstaller/defaults/devlake.go index 220a15ccf..227bdff14 100644 --- a/internal/pkg/plugin/devlake/devlake.go +++ b/internal/pkg/plugin/helminstaller/defaults/devlake.go @@ -1,4 +1,4 @@ -package devlake +package defaults import ( "fmt" @@ -13,12 +13,14 @@ import ( const DevLakeSvcName = "devlake-lake" -// TODO(daniel-hutao): update the config below after devlake chart released. -var defaultHelmConfig = helm.Options{ +var toolDevLake = "devlake" + +var DefaultConfigWithDevLake = helm.Options{ Chart: helmCommon.Chart{ ChartPath: "", ChartName: "devlake/devlake", - Timeout: "5m", + Version: "", + Timeout: "10m", Wait: types.Bool(true), UpgradeCRDs: types.Bool(true), ReleaseName: "devlake", @@ -30,7 +32,12 @@ var defaultHelmConfig = helm.Options{ }, } -func genDevLakeStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { +func init() { + DefaultOptionsMap[toolDevLake] = &DefaultConfigWithDevLake + StatusGetterFuncMap[toolDevLake] = GetDevLakeStatus +} + +func GetDevLakeStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { resStatus, err := helm.GetAllResourcesStatus(options) if err != nil { return nil, err diff --git a/internal/pkg/plugin/harbor/harbor.go b/internal/pkg/plugin/helminstaller/defaults/harbor.go similarity index 50% rename from internal/pkg/plugin/harbor/harbor.go rename to internal/pkg/plugin/helminstaller/defaults/harbor.go index d1855b973..af2f3a0da 100644 --- a/internal/pkg/plugin/harbor/harbor.go +++ b/internal/pkg/plugin/helminstaller/defaults/harbor.go @@ -1,15 +1,20 @@ -package harbor +package defaults import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" helmCommon "github.com/devstream-io/devstream/pkg/util/helm" "github.com/devstream-io/devstream/pkg/util/types" ) -var defaultHelmConfig = helm.Options{ +var toolHarbor = "harbor" + +var DefaultConfigWithHarbor = helm.Options{ Chart: helmCommon.Chart{ ChartPath: "", ChartName: "harbor/harbor", + Version: "", Timeout: "10m", UpgradeCRDs: types.Bool(true), Wait: types.Bool(true), @@ -21,3 +26,12 @@ var defaultHelmConfig = helm.Options{ Name: "harbor", }, } + +func init() { + DefaultOptionsMap[toolHarbor] = &DefaultConfigWithHarbor + StatusGetterFuncMap[toolHarbor] = GetHarborStatus +} + +func GetHarborStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { + return helm.GetAllResourcesStatus(options) +} diff --git a/internal/pkg/plugin/jenkins/jenkins.go b/internal/pkg/plugin/helminstaller/defaults/jenkins.go similarity index 85% rename from internal/pkg/plugin/jenkins/jenkins.go rename to internal/pkg/plugin/helminstaller/defaults/jenkins.go index 029d5cc32..b13fb54da 100644 --- a/internal/pkg/plugin/jenkins/jenkins.go +++ b/internal/pkg/plugin/helminstaller/defaults/jenkins.go @@ -1,4 +1,4 @@ -package jenkins +package defaults import ( "fmt" @@ -11,11 +11,14 @@ import ( "github.com/devstream-io/devstream/pkg/util/types" ) -var defaultHelmConfig = helm.Options{ +var toolJenkins = "jenkins" + +var DefaultConfigWithJenkins = helm.Options{ Chart: helmCommon.Chart{ ChartPath: "", ChartName: "jenkins/jenkins", - Timeout: "5m", + Version: "", + Timeout: "10m", UpgradeCRDs: types.Bool(true), Wait: types.Bool(true), ReleaseName: "jenkins", @@ -27,7 +30,12 @@ var defaultHelmConfig = helm.Options{ }, } -func genJenkinsStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { +func init() { + DefaultOptionsMap[toolJenkins] = &DefaultConfigWithJenkins + StatusGetterFuncMap[toolJenkins] = GetJenkinsStatus +} + +func GetJenkinsStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { resStatus, err := helm.GetAllResourcesStatus(options) if err != nil { return nil, err diff --git a/internal/pkg/plugin/helminstaller/defaults/kubeprometheus.go b/internal/pkg/plugin/helminstaller/defaults/kubeprometheus.go new file mode 100644 index 000000000..9bf900f97 --- /dev/null +++ b/internal/pkg/plugin/helminstaller/defaults/kubeprometheus.go @@ -0,0 +1,37 @@ +package defaults + +import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" + helmCommon "github.com/devstream-io/devstream/pkg/util/helm" + "github.com/devstream-io/devstream/pkg/util/types" +) + +var toolKubePrometheus = "kube-prometheus" + +var DefaultConfigWithKubePrometheus = helm.Options{ + Chart: helmCommon.Chart{ + ChartPath: "", + ChartName: "prometheus-community/kube-prometheus-stack", + Version: "", + Timeout: "10m", + UpgradeCRDs: types.Bool(true), + Wait: types.Bool(true), + ReleaseName: "prometheus", + Namespace: "prometheus", + }, + Repo: helmCommon.Repo{ + URL: "https://prometheus-community.github.io/helm-charts", + Name: "prometheus-community", + }, +} + +func init() { + DefaultOptionsMap[toolKubePrometheus] = &DefaultConfigWithKubePrometheus + StatusGetterFuncMap[toolKubePrometheus] = GetKubePrometheusStatus +} + +func GetKubePrometheusStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { + return helm.GetAllResourcesStatus(options) +} diff --git a/internal/pkg/plugin/helminstaller/defaults/openldap.go b/internal/pkg/plugin/helminstaller/defaults/openldap.go new file mode 100644 index 000000000..05f02f33e --- /dev/null +++ b/internal/pkg/plugin/helminstaller/defaults/openldap.go @@ -0,0 +1,37 @@ +package defaults + +import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" + helmCommon "github.com/devstream-io/devstream/pkg/util/helm" + "github.com/devstream-io/devstream/pkg/util/types" +) + +var toolOpenLDAP = "openldap" + +var DefaultConfigWithOpenLDAP = helm.Options{ + Chart: helmCommon.Chart{ + ChartPath: "", + ChartName: "helm-openldap/openldap-stack-ha", + Version: "", + Timeout: "10m", + UpgradeCRDs: types.Bool(true), + Wait: types.Bool(true), + ReleaseName: "openldap", + Namespace: "openldap", + }, + Repo: helmCommon.Repo{ + URL: "https://jp-gouin.github.io/helm-openldap/", + Name: "helm-openldap", + }, +} + +func init() { + DefaultOptionsMap[toolOpenLDAP] = &DefaultConfigWithOpenLDAP + StatusGetterFuncMap[toolOpenLDAP] = GetOpenLDAPStatus +} + +func GetOpenLDAPStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { + return helm.GetAllResourcesStatus(options) +} diff --git a/internal/pkg/plugin/helminstaller/defaults/sonarqube.go b/internal/pkg/plugin/helminstaller/defaults/sonarqube.go new file mode 100644 index 000000000..b76a99c0f --- /dev/null +++ b/internal/pkg/plugin/helminstaller/defaults/sonarqube.go @@ -0,0 +1,36 @@ +package defaults + +import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" + helmCommon "github.com/devstream-io/devstream/pkg/util/helm" + "github.com/devstream-io/devstream/pkg/util/types" +) + +var toolSonarQube = "sonarqube" + +var DefaultConfigWithSonarQube = helm.Options{ + Chart: helmCommon.Chart{ + ChartName: "sonarqube/sonarqube", + Timeout: "10m", + Version: "", + Wait: types.Bool(true), + UpgradeCRDs: types.Bool(true), + ReleaseName: "sonarqube", + Namespace: "sonarqube", + }, + Repo: helmCommon.Repo{ + URL: "https://SonarSource.github.io/helm-chart-sonarqube", + Name: "sonarqube", + }, +} + +func init() { + DefaultOptionsMap[toolSonarQube] = &DefaultConfigWithSonarQube + StatusGetterFuncMap[toolSonarQube] = GetSonarQubeStatus +} + +func GetSonarQubeStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { + return helm.GetAllResourcesStatus(options) +} diff --git a/internal/pkg/plugin/helminstaller/defaults/tekton.go b/internal/pkg/plugin/helminstaller/defaults/tekton.go new file mode 100644 index 000000000..13f669eec --- /dev/null +++ b/internal/pkg/plugin/helminstaller/defaults/tekton.go @@ -0,0 +1,37 @@ +package defaults + +import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" + helmCommon "github.com/devstream-io/devstream/pkg/util/helm" + "github.com/devstream-io/devstream/pkg/util/types" +) + +var toolTekton = "tekton" + +var DefaultConfigWithTekton = helm.Options{ + Chart: helmCommon.Chart{ + ChartPath: "", + ChartName: "tekton/tekton-pipeline", + Version: "", + Timeout: "10m", + UpgradeCRDs: types.Bool(true), + Wait: types.Bool(true), + ReleaseName: "tekton", + Namespace: "tekton", + }, + Repo: helmCommon.Repo{ + URL: "https://steinliber.github.io/tekton-helm-chart/", + Name: "tekton", + }, +} + +func init() { + DefaultOptionsMap[toolTekton] = &DefaultConfigWithTekton + StatusGetterFuncMap[toolTekton] = GetTektonStatus +} + +func GetTektonStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { + return helm.GetAllResourcesStatus(options) +} diff --git a/internal/pkg/plugin/helminstaller/defaults/vault.go b/internal/pkg/plugin/helminstaller/defaults/vault.go new file mode 100644 index 000000000..c6389e818 --- /dev/null +++ b/internal/pkg/plugin/helminstaller/defaults/vault.go @@ -0,0 +1,37 @@ +package defaults + +import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" + helmCommon "github.com/devstream-io/devstream/pkg/util/helm" + "github.com/devstream-io/devstream/pkg/util/types" +) + +var toolVault = "vault" + +var DefaultConfigWithVault = helm.Options{ + Chart: helmCommon.Chart{ + ChartPath: "", + ChartName: "hashicorp/vault", + Version: "", + Timeout: "10m", + UpgradeCRDs: types.Bool(true), + Wait: types.Bool(true), + ReleaseName: "vault", + Namespace: "vault", + }, + Repo: helmCommon.Repo{ + URL: "https://helm.releases.hashicorp.com", + Name: "hashicorp", + }, +} + +func init() { + DefaultOptionsMap[toolVault] = &DefaultConfigWithVault + StatusGetterFuncMap[toolVault] = GetVaultStatus +} + +func GetVaultStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { + return helm.GetAllResourcesStatus(options) +} diff --git a/internal/pkg/plugin/helminstaller/delete.go b/internal/pkg/plugin/helminstaller/delete.go index fddc2226a..4f8fbf37e 100644 --- a/internal/pkg/plugin/helminstaller/delete.go +++ b/internal/pkg/plugin/helminstaller/delete.go @@ -10,7 +10,7 @@ func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ - SetDefaultConfig, + RenderDefaultConfig, RenderValuesYaml, validate, }, diff --git a/internal/pkg/plugin/helminstaller/helminstaller.go b/internal/pkg/plugin/helminstaller/helminstaller.go index d7b673583..65bfc0b63 100644 --- a/internal/pkg/plugin/helminstaller/helminstaller.go +++ b/internal/pkg/plugin/helminstaller/helminstaller.go @@ -1,6 +1,7 @@ package helminstaller import ( + "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "os" "strings" @@ -11,16 +12,7 @@ import ( "github.com/devstream-io/devstream/pkg/util/types" ) -func GetDefaultOptionsByInstanceID(instanceID string) *helm.Options { - for name, options := range defaults.DefaultOptionsMap { - if strings.Contains(instanceID, name+"-") { - return options - } - } - return nil -} - -func SetDefaultConfig(options configmanager.RawOptions) (configmanager.RawOptions, error) { +func RenderDefaultConfig(options configmanager.RawOptions) (configmanager.RawOptions, error) { helmOptions, err := helm.NewOptions(options) if err != nil { return nil, err @@ -71,3 +63,38 @@ func RenderValuesYaml(options configmanager.RawOptions) (configmanager.RawOption return types.EncodeStruct(helmOptions) } + +func IndexStatusGetterFunc(options configmanager.RawOptions) plugininstaller.StatusGetterOperation { + helmOptions, err := helm.NewOptions(options) + if err != nil { + // It's ok to return GetAllResourcesStatus here when err != nil. + return helm.GetAllResourcesStatus + } + + instanceID := helmOptions.InstanceID + statusGetterFunc := GetStatusGetterFuncByInstanceID(instanceID) + + if statusGetterFunc == nil { + return helm.GetAllResourcesStatus + } + + return statusGetterFunc +} + +func GetDefaultOptionsByInstanceID(instanceID string) *helm.Options { + for name, options := range defaults.DefaultOptionsMap { + if strings.Contains(instanceID, name+"-") { + return options + } + } + return nil +} + +func GetStatusGetterFuncByInstanceID(instanceID string) plugininstaller.StatusGetterOperation { + for name, fn := range defaults.StatusGetterFuncMap { + if strings.Contains(instanceID, name+"-") { + return fn + } + } + return nil +} diff --git a/internal/pkg/plugin/helminstaller/helminstaller_test.go b/internal/pkg/plugin/helminstaller/helminstaller_test.go index b274bd3a9..2886e355b 100644 --- a/internal/pkg/plugin/helminstaller/helminstaller_test.go +++ b/internal/pkg/plugin/helminstaller/helminstaller_test.go @@ -1,7 +1,10 @@ package helminstaller_test import ( + "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "os" + "reflect" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -30,10 +33,28 @@ var _ = Describe("helm installer test", func() { }) }) - Context("SetDefaultConfig", func() { + Context("GetStatusGetterFuncByInstanceID", func() { + defaults.StatusGetterFuncMap = map[string]plugininstaller.StatusGetterOperation{ + "foo": func(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { + return nil, nil + }, + } + + It("should exists", func() { + fn := helminstaller.GetStatusGetterFuncByInstanceID("foo-001") + Expect(fn).NotTo(BeNil()) + }) + + It("should not exists", func() { + fn := helminstaller.GetStatusGetterFuncByInstanceID("fooo") + Expect(fn).To(BeNil()) + }) + }) + + Context("RenderDefaultConfig", func() { opts := configmanager.RawOptions{} opts["instanceID"] = interface{}("argocd-001") - newOpts, err := helminstaller.SetDefaultConfig(opts) + newOpts, err := helminstaller.RenderDefaultConfig(opts) Expect(err).To(BeNil()) helmOpts, err := helm.NewOptions(newOpts) @@ -74,4 +95,15 @@ var _ = Describe("helm installer test", func() { Expect(err).To(BeNil()) }) }) + + Context("IndexStatusGetterFunc", func() { + opts1 := configmanager.RawOptions{ + "instanceID": interface{}("argocd-001"), + } + + defaults.StatusGetterFuncMap["argocd"] = defaults.GetArgoCDStatus + + fn1 := helminstaller.IndexStatusGetterFunc(opts1) + Expect(reflect.ValueOf(fn1).Pointer()).To(Equal(reflect.ValueOf(defaults.GetArgoCDStatus).Pointer())) + }) }) diff --git a/internal/pkg/plugin/helminstaller/read.go b/internal/pkg/plugin/helminstaller/read.go index ad03579af..653b3eb85 100644 --- a/internal/pkg/plugin/helminstaller/read.go +++ b/internal/pkg/plugin/helminstaller/read.go @@ -3,7 +3,6 @@ package helminstaller import ( "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,11 +11,11 @@ func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ - SetDefaultConfig, + RenderDefaultConfig, RenderValuesYaml, validate, }, - GetStatusOperation: helm.GetAllResourcesStatus, + GetStatusOperation: IndexStatusGetterFunc(options), } // Execute all Operations in Operator diff --git a/internal/pkg/plugin/helminstaller/update.go b/internal/pkg/plugin/helminstaller/update.go index 91a93217a..272f51582 100644 --- a/internal/pkg/plugin/helminstaller/update.go +++ b/internal/pkg/plugin/helminstaller/update.go @@ -12,13 +12,13 @@ func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, erro // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ - SetDefaultConfig, + RenderDefaultConfig, RenderValuesYaml, validate, }, ExecuteOperations: helm.DefaultUpdateOperations, TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, + GetStatusOperation: IndexStatusGetterFunc(options), } // Execute all Operations in Operator diff --git a/internal/pkg/plugin/jenkins/create.go b/internal/pkg/plugin/jenkins/create.go deleted file mode 100644 index 0c56f7919..000000000 --- a/internal/pkg/plugin/jenkins/create.go +++ /dev/null @@ -1,34 +0,0 @@ -package jenkins - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// Create creates jenkins with provided options. -func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: plugininstaller.ExecuteOperations{ - helm.DealWithNsWhenInstall, - helm.InstallOrUpdate, - }, - TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: genJenkinsStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/jenkins/delete.go b/internal/pkg/plugin/jenkins/delete.go deleted file mode 100644 index aa7af8623..000000000 --- a/internal/pkg/plugin/jenkins/delete.go +++ /dev/null @@ -1,27 +0,0 @@ -package jenkins - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" -) - -func Delete(options configmanager.RawOptions) (bool, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: plugininstaller.ExecuteOperations{ - helm.Delete, - }, - } - _, err := operator.Execute(options) - if err != nil { - return false, err - } - - // 2. return ture if all process success - return true, nil -} diff --git a/internal/pkg/plugin/jenkins/read.go b/internal/pkg/plugin/jenkins/read.go deleted file mode 100644 index b27c2c028..000000000 --- a/internal/pkg/plugin/jenkins/read.go +++ /dev/null @@ -1,28 +0,0 @@ -package jenkins - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - GetStatusOperation: genJenkinsStatus, - } - - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/jenkins/update.go b/internal/pkg/plugin/jenkins/update.go deleted file mode 100644 index c7b586d7c..000000000 --- a/internal/pkg/plugin/jenkins/update.go +++ /dev/null @@ -1,31 +0,0 @@ -package jenkins - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// Update updates jenkins with provided options. -func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultUpdateOperations, - TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: genJenkinsStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/kubeprometheus/create.go b/internal/pkg/plugin/kubeprometheus/create.go deleted file mode 100644 index 939b1b28a..000000000 --- a/internal/pkg/plugin/kubeprometheus/create.go +++ /dev/null @@ -1,31 +0,0 @@ -package kubeprometheus - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// Create will create prometheus in k8s -func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultCreateOperations, - TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/kubeprometheus/delete.go b/internal/pkg/plugin/kubeprometheus/delete.go deleted file mode 100644 index bc4c0a127..000000000 --- a/internal/pkg/plugin/kubeprometheus/delete.go +++ /dev/null @@ -1,25 +0,0 @@ -package kubeprometheus - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" -) - -func Delete(options configmanager.RawOptions) (bool, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultDeleteOperations, - } - _, err := operator.Execute(options) - if err != nil { - return false, err - } - - // 2. return ture if all process success - return true, nil -} diff --git a/internal/pkg/plugin/kubeprometheus/kubeprometheus.go b/internal/pkg/plugin/kubeprometheus/kubeprometheus.go deleted file mode 100644 index 18afe97e7..000000000 --- a/internal/pkg/plugin/kubeprometheus/kubeprometheus.go +++ /dev/null @@ -1,23 +0,0 @@ -package kubeprometheus - -import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - helmCommon "github.com/devstream-io/devstream/pkg/util/helm" - "github.com/devstream-io/devstream/pkg/util/types" -) - -var defaultHelmConfig = helm.Options{ - Chart: helmCommon.Chart{ - ChartPath: "", - ChartName: "prometheus-community/kube-prometheus-stack", - Timeout: "5m", - UpgradeCRDs: types.Bool(true), - Wait: types.Bool(true), - ReleaseName: "prometheus", - Namespace: "prometheus", - }, - Repo: helmCommon.Repo{ - URL: "https://prometheus-community.github.io/helm-charts", - Name: "prometheus-community", - }, -} diff --git a/internal/pkg/plugin/kubeprometheus/read.go b/internal/pkg/plugin/kubeprometheus/read.go deleted file mode 100644 index 4fba742be..000000000 --- a/internal/pkg/plugin/kubeprometheus/read.go +++ /dev/null @@ -1,28 +0,0 @@ -package kubeprometheus - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/kubeprometheus/update.go b/internal/pkg/plugin/kubeprometheus/update.go deleted file mode 100644 index cf42fb04c..000000000 --- a/internal/pkg/plugin/kubeprometheus/update.go +++ /dev/null @@ -1,29 +0,0 @@ -package kubeprometheus - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/openldap/create.go b/internal/pkg/plugin/openldap/create.go deleted file mode 100644 index a97e0bda6..000000000 --- a/internal/pkg/plugin/openldap/create.go +++ /dev/null @@ -1,31 +0,0 @@ -package openldap - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -// Create creates OpenLDAP with provided options. -func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultCreateOperations, - TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/openldap/delete.go b/internal/pkg/plugin/openldap/delete.go deleted file mode 100644 index 755f30e81..000000000 --- a/internal/pkg/plugin/openldap/delete.go +++ /dev/null @@ -1,25 +0,0 @@ -package openldap - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" -) - -func Delete(options configmanager.RawOptions) (bool, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultDeleteOperations, - } - _, err := operator.Execute(options) - if err != nil { - return false, err - } - - // 2. return ture if all process success - return true, nil -} diff --git a/internal/pkg/plugin/openldap/openldap.go b/internal/pkg/plugin/openldap/openldap.go deleted file mode 100644 index ba274c692..000000000 --- a/internal/pkg/plugin/openldap/openldap.go +++ /dev/null @@ -1,23 +0,0 @@ -package openldap - -import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - helmCommon "github.com/devstream-io/devstream/pkg/util/helm" - "github.com/devstream-io/devstream/pkg/util/types" -) - -var defaultHelmConfig = helm.Options{ - Chart: helmCommon.Chart{ - ChartPath: "", - ChartName: "helm-openldap/openldap-stack-ha", - Timeout: "5m", - UpgradeCRDs: types.Bool(true), - Wait: types.Bool(true), - ReleaseName: "openldap", - Namespace: "openldap", - }, - Repo: helmCommon.Repo{ - URL: "https://jp-gouin.github.io/helm-openldap/", - Name: "helm-openldap", - }, -} diff --git a/internal/pkg/plugin/openldap/read.go b/internal/pkg/plugin/openldap/read.go deleted file mode 100644 index 1ff578bc4..000000000 --- a/internal/pkg/plugin/openldap/read.go +++ /dev/null @@ -1,28 +0,0 @@ -package openldap - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/openldap/update.go b/internal/pkg/plugin/openldap/update.go deleted file mode 100644 index 039d6c153..000000000 --- a/internal/pkg/plugin/openldap/update.go +++ /dev/null @@ -1,29 +0,0 @@ -package openldap - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/sonarqube/create.go b/internal/pkg/plugin/sonarqube/create.go deleted file mode 100644 index 6ce556a1f..000000000 --- a/internal/pkg/plugin/sonarqube/create.go +++ /dev/null @@ -1,30 +0,0 @@ -package sonarqube - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultCreateOperations, - TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/sonarqube/delete.go b/internal/pkg/plugin/sonarqube/delete.go deleted file mode 100644 index 286652fe8..000000000 --- a/internal/pkg/plugin/sonarqube/delete.go +++ /dev/null @@ -1,25 +0,0 @@ -package sonarqube - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" -) - -func Delete(options configmanager.RawOptions) (bool, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultDeleteOperations, - } - _, err := operator.Execute(options) - if err != nil { - return false, err - } - - // 2. return ture if all process success - return true, nil -} diff --git a/internal/pkg/plugin/sonarqube/read.go b/internal/pkg/plugin/sonarqube/read.go deleted file mode 100644 index d6aab2127..000000000 --- a/internal/pkg/plugin/sonarqube/read.go +++ /dev/null @@ -1,28 +0,0 @@ -package sonarqube - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // 2. get plugin status - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/sonarqube/sonar.go b/internal/pkg/plugin/sonarqube/sonar.go deleted file mode 100644 index f5ac6ebe7..000000000 --- a/internal/pkg/plugin/sonarqube/sonar.go +++ /dev/null @@ -1,22 +0,0 @@ -package sonarqube - -import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - helmCommon "github.com/devstream-io/devstream/pkg/util/helm" - "github.com/devstream-io/devstream/pkg/util/types" -) - -var defaultHelmConfig = helm.Options{ - Chart: helmCommon.Chart{ - ChartName: "sonarqube/sonarqube", - Timeout: "20m", - Wait: types.Bool(true), - UpgradeCRDs: types.Bool(true), - ReleaseName: "sonarqube", - Namespace: "sonarqube", - }, - Repo: helmCommon.Repo{ - URL: "https://SonarSource.github.io/helm-chart-sonarqube", - Name: "sonarqube", - }, -} diff --git a/internal/pkg/plugin/sonarqube/update.go b/internal/pkg/plugin/sonarqube/update.go deleted file mode 100644 index 2a19879bf..000000000 --- a/internal/pkg/plugin/sonarqube/update.go +++ /dev/null @@ -1,29 +0,0 @@ -package sonarqube - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultCreateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/tekton/create.go b/internal/pkg/plugin/tekton/create.go deleted file mode 100644 index 0c049b597..000000000 --- a/internal/pkg/plugin/tekton/create.go +++ /dev/null @@ -1,30 +0,0 @@ -package tekton - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultCreateOperations, - TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/tekton/delete.go b/internal/pkg/plugin/tekton/delete.go deleted file mode 100644 index 20444f83b..000000000 --- a/internal/pkg/plugin/tekton/delete.go +++ /dev/null @@ -1,25 +0,0 @@ -package tekton - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" -) - -func Delete(options configmanager.RawOptions) (bool, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultDeleteOperations, - } - _, err := operator.Execute(options) - if err != nil { - return false, err - } - - // 2. return ture if all process success - return true, nil -} diff --git a/internal/pkg/plugin/tekton/read.go b/internal/pkg/plugin/tekton/read.go deleted file mode 100644 index 029a2b4f0..000000000 --- a/internal/pkg/plugin/tekton/read.go +++ /dev/null @@ -1,28 +0,0 @@ -package tekton - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugin/tekton/tekton.go b/internal/pkg/plugin/tekton/tekton.go deleted file mode 100644 index 9c0299b8b..000000000 --- a/internal/pkg/plugin/tekton/tekton.go +++ /dev/null @@ -1,23 +0,0 @@ -package tekton - -import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - helmCommon "github.com/devstream-io/devstream/pkg/util/helm" - "github.com/devstream-io/devstream/pkg/util/types" -) - -var defaultHelmConfig = helm.Options{ - Chart: helmCommon.Chart{ - ChartPath: "", - ChartName: "tekton/tekton-pipeline", - Timeout: "5m", - UpgradeCRDs: types.Bool(true), - Wait: types.Bool(true), - ReleaseName: "tekton", - Namespace: "tekton", - }, - Repo: helmCommon.Repo{ - URL: "https://steinliber.github.io/tekton-helm-chart/", - Name: "tekton", - }, -} diff --git a/internal/pkg/plugin/tekton/update.go b/internal/pkg/plugin/tekton/update.go deleted file mode 100644 index 27a215504..000000000 --- a/internal/pkg/plugin/tekton/update.go +++ /dev/null @@ -1,29 +0,0 @@ -package tekton - -import ( - "github.com/devstream-io/devstream/internal/pkg/configmanager" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" - "github.com/devstream-io/devstream/internal/pkg/statemanager" - "github.com/devstream-io/devstream/pkg/util/log" -) - -func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { - // Initialize Operator with Operations - operator := &plugininstaller.Operator{ - PreExecuteOperations: plugininstaller.PreExecuteOperations{ - helm.SetDefaultConfig(&defaultHelmConfig), - helm.Validate, - }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetAllResourcesStatus, - } - - // Execute all Operations in Operator - status, err := operator.Execute(options) - if err != nil { - return nil, err - } - log.Debugf("Return map: %v", status) - return status, nil -} diff --git a/internal/pkg/plugininstaller/plugininstaller.go b/internal/pkg/plugininstaller/plugininstaller.go index d25290ce8..fc478733b 100644 --- a/internal/pkg/plugininstaller/plugininstaller.go +++ b/internal/pkg/plugininstaller/plugininstaller.go @@ -11,15 +11,14 @@ type ( MutableOperation func(options configmanager.RawOptions) (configmanager.RawOptions, error) // BaseOperation reads options and executes operation BaseOperation func(options configmanager.RawOptions) error - // StatusOperation reads options and executes operation, then returns the status map - StatusOperation func(options configmanager.RawOptions) (statemanager.ResourceStatus, error) + // StatusGetterOperation reads options and executes operation, then returns the status map + StatusGetterOperation func(options configmanager.RawOptions) (statemanager.ResourceStatus, error) ) type ( PreExecuteOperations []MutableOperation ExecuteOperations []BaseOperation TerminateOperations []BaseOperation - GetStatusOperation StatusOperation ) type Installer interface { @@ -31,7 +30,7 @@ type Operator struct { PreExecuteOperations PreExecuteOperations ExecuteOperations ExecuteOperations TerminateOperations TerminateOperations - GetStatusOperation GetStatusOperation + GetStatusOperation StatusGetterOperation } // Execute will sequentially execute all operations in Operator @@ -70,10 +69,10 @@ func (o *Operator) Execute(options configmanager.RawOptions) (statemanager.Resou } } - // 4. Execute GetStatusOperation. + // 4. Execute StatusGetterOperation. var state map[string]interface{} if o.GetStatusOperation != nil { - log.Debugf("Start to execute GetStatusOperation...") + log.Debugf("Start to execute StatusGetterOperation...") state, err = o.GetStatusOperation(options) if err != nil { return nil, err diff --git a/mkdocs.yml b/mkdocs.yml index 05c4ae553..5d0ec7fb2 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -73,6 +73,7 @@ plugins: Road Map: "Road Map" Code Review Guide: "Code Review Guide" Overview: "Overview" + Helm Installer: "Helm Installer" zh: DTM Commands Explained in Depth: "DTM 命令详解" Plugins: "插件" @@ -84,6 +85,7 @@ plugins: Road Map: "路线图" Code Review Guide: "代码 review 指导" Overview: "概览" + Helm Installer: "Helm 安装器" - literate-nav nav: - Overview: . @@ -102,6 +104,9 @@ nav: - commands/*.md - Plugins: - plugins/plugins-list*.md + - Helm Installer: + - plugins/helm-installer/helm-installer*.md + - plugins/helm-installer/*.md - plugins/*.md - Best Practices: best-practices/ - contributing_guide*.md