From 33c62a8e544d6a1e255d6b25545210ab612e3bf1 Mon Sep 17 00:00:00 2001 From: Daniel Hu Date: Tue, 9 Aug 2022 22:32:51 +0800 Subject: [PATCH 1/2] refactor: plugininstaller refactoring and logs optimization Signed-off-by: Daniel Hu --- internal/pkg/plugin/argocd/create.go | 4 +- internal/pkg/plugin/argocd/delete.go | 2 +- internal/pkg/plugin/argocd/read.go | 4 +- internal/pkg/plugin/argocd/update.go | 6 +- internal/pkg/plugin/argocdapp/create.go | 4 +- internal/pkg/plugin/argocdapp/delete.go | 2 +- internal/pkg/plugin/argocdapp/read.go | 4 +- internal/pkg/plugin/artifactory/create.go | 4 +- internal/pkg/plugin/artifactory/delete.go | 2 +- internal/pkg/plugin/artifactory/read.go | 4 +- internal/pkg/plugin/artifactory/update.go | 6 +- internal/pkg/plugin/devlake/create.go | 4 +- internal/pkg/plugin/devlake/delete.go | 2 +- internal/pkg/plugin/devlake/read.go | 4 +- .../pkg/plugin/githubactions/golang/create.go | 4 +- .../pkg/plugin/githubactions/golang/delete.go | 2 +- .../pkg/plugin/githubactions/golang/read.go | 4 +- .../pkg/plugin/githubactions/golang/update.go | 4 +- .../pkg/plugin/githubactions/nodejs/create.go | 4 +- .../pkg/plugin/githubactions/nodejs/delete.go | 2 +- .../pkg/plugin/githubactions/nodejs/read.go | 4 +- .../pkg/plugin/githubactions/nodejs/update.go | 4 +- .../pkg/plugin/githubactions/python/create.go | 4 +- .../pkg/plugin/githubactions/python/delete.go | 2 +- .../pkg/plugin/githubactions/python/read.go | 4 +- .../pkg/plugin/githubactions/python/update.go | 4 +- internal/pkg/plugin/gitlabcedocker/create.go | 4 +- internal/pkg/plugin/gitlabcedocker/delete.go | 2 +- internal/pkg/plugin/gitlabcedocker/read.go | 4 +- internal/pkg/plugin/gitlabcedocker/update.go | 4 +- internal/pkg/plugin/harbor/create.go | 4 +- internal/pkg/plugin/harbor/delete.go | 2 +- internal/pkg/plugin/harbor/read.go | 4 +- internal/pkg/plugin/harbor/update.go | 6 +- internal/pkg/plugin/hashicorpvault/create.go | 4 +- internal/pkg/plugin/hashicorpvault/delete.go | 2 +- internal/pkg/plugin/hashicorpvault/read.go | 4 +- internal/pkg/plugin/hashicorpvault/update.go | 6 +- internal/pkg/plugin/helmgeneric/create.go | 4 +- internal/pkg/plugin/helmgeneric/delete.go | 2 +- internal/pkg/plugin/helmgeneric/read.go | 4 +- internal/pkg/plugin/helmgeneric/update.go | 6 +- internal/pkg/plugin/jenkins/create.go | 4 +- internal/pkg/plugin/jenkins/delete.go | 2 +- internal/pkg/plugin/jenkins/jenkins.go | 2 +- internal/pkg/plugin/jenkins/read.go | 4 +- internal/pkg/plugin/jenkins/update.go | 4 +- internal/pkg/plugin/kubeprometheus/create.go | 4 +- internal/pkg/plugin/kubeprometheus/delete.go | 2 +- internal/pkg/plugin/kubeprometheus/read.go | 4 +- internal/pkg/plugin/kubeprometheus/update.go | 6 +- internal/pkg/plugin/openldap/create.go | 4 +- internal/pkg/plugin/openldap/delete.go | 2 +- internal/pkg/plugin/openldap/read.go | 4 +- internal/pkg/plugin/openldap/update.go | 6 +- internal/pkg/plugin/reposcaffolding/create.go | 4 +- internal/pkg/plugin/reposcaffolding/delete.go | 2 +- internal/pkg/plugin/reposcaffolding/read.go | 4 +- internal/pkg/plugin/reposcaffolding/update.go | 4 +- internal/pkg/plugin/tekton/create.go | 4 +- internal/pkg/plugin/tekton/delete.go | 2 +- internal/pkg/plugin/tekton/read.go | 4 +- internal/pkg/plugin/tekton/update.go | 6 +- internal/pkg/plugin/zentao/create.go | 4 +- internal/pkg/plugin/zentao/delete.go | 2 +- internal/pkg/plugin/zentao/read.go | 4 +- internal/pkg/plugin/zentao/update.go | 4 +- .../pkg/plugininstaller/plugininstaller.go | 71 ++++++++++--------- 68 files changed, 161 insertions(+), 158 deletions(-) diff --git a/internal/pkg/plugin/argocd/create.go b/internal/pkg/plugin/argocd/create.go index bf2789b94..c2724cdaa 100644 --- a/internal/pkg/plugin/argocd/create.go +++ b/internal/pkg/plugin/argocd/create.go @@ -9,14 +9,14 @@ import ( // Create creates ArgoCD with provided options. func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.SetDefaultConfig(&defaultHelmConfig), helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/argocd/delete.go b/internal/pkg/plugin/argocd/delete.go index f39ed557f..bc211adbe 100644 --- a/internal/pkg/plugin/argocd/delete.go +++ b/internal/pkg/plugin/argocd/delete.go @@ -7,7 +7,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.SetDefaultConfig(&defaultHelmConfig), helm.Validate, diff --git a/internal/pkg/plugin/argocd/read.go b/internal/pkg/plugin/argocd/read.go index 82d81cbdf..ab8945b19 100644 --- a/internal/pkg/plugin/argocd/read.go +++ b/internal/pkg/plugin/argocd/read.go @@ -12,12 +12,12 @@ const ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.SetDefaultConfig(&defaultHelmConfig), helm.Validate, }, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } // 2. get plugin status diff --git a/internal/pkg/plugin/argocd/update.go b/internal/pkg/plugin/argocd/update.go index 2080e60d6..b8b9c4ac7 100644 --- a/internal/pkg/plugin/argocd/update.go +++ b/internal/pkg/plugin/argocd/update.go @@ -8,13 +8,13 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.SetDefaultConfig(&defaultHelmConfig), helm.Validate, }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetPluginAllState, + ExecuteOperations: helm.DefaultUpdateOperations, + GetStateOperation: helm.GetPluginAllState, } // 2. update by helm config and get status diff --git a/internal/pkg/plugin/argocdapp/create.go b/internal/pkg/plugin/argocdapp/create.go index a6c8e0e5a..de1afb15d 100644 --- a/internal/pkg/plugin/argocdapp/create.go +++ b/internal/pkg/plugin/argocdapp/create.go @@ -10,7 +10,7 @@ import ( // Create creates an ArgoCD app YAML and applys it. func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ validate, }, @@ -19,7 +19,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { "create", file.NewTemplate().FromContent(templateFileLoc), ), }, - GetStatusOperation: getStaticState, + GetStateOperation: getStaticState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/argocdapp/delete.go b/internal/pkg/plugin/argocdapp/delete.go index 87ac7f354..188f9d314 100644 --- a/internal/pkg/plugin/argocdapp/delete.go +++ b/internal/pkg/plugin/argocdapp/delete.go @@ -8,7 +8,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ validate, }, diff --git a/internal/pkg/plugin/argocdapp/read.go b/internal/pkg/plugin/argocdapp/read.go index 73a8c2963..33a0c1daf 100644 --- a/internal/pkg/plugin/argocdapp/read.go +++ b/internal/pkg/plugin/argocdapp/read.go @@ -6,11 +6,11 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ validate, }, - GetStatusOperation: getDynamicState, + GetStateOperation: getDynamicState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/artifactory/create.go b/internal/pkg/plugin/artifactory/create.go index 54121ce85..f49130edb 100644 --- a/internal/pkg/plugin/artifactory/create.go +++ b/internal/pkg/plugin/artifactory/create.go @@ -8,13 +8,13 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/artifactory/delete.go b/internal/pkg/plugin/artifactory/delete.go index 4c9faf7fd..a4cb321b5 100644 --- a/internal/pkg/plugin/artifactory/delete.go +++ b/internal/pkg/plugin/artifactory/delete.go @@ -7,7 +7,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, diff --git a/internal/pkg/plugin/artifactory/read.go b/internal/pkg/plugin/artifactory/read.go index f9c4cec61..663244520 100644 --- a/internal/pkg/plugin/artifactory/read.go +++ b/internal/pkg/plugin/artifactory/read.go @@ -8,11 +8,11 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/artifactory/update.go b/internal/pkg/plugin/artifactory/update.go index 5778176c0..ab0aecca4 100644 --- a/internal/pkg/plugin/artifactory/update.go +++ b/internal/pkg/plugin/artifactory/update.go @@ -8,12 +8,12 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetPluginAllState, + ExecuteOperations: helm.DefaultUpdateOperations, + GetStateOperation: helm.GetPluginAllState, } // 2. execute update get status and error diff --git a/internal/pkg/plugin/devlake/create.go b/internal/pkg/plugin/devlake/create.go index 86affe362..80e049cd4 100644 --- a/internal/pkg/plugin/devlake/create.go +++ b/internal/pkg/plugin/devlake/create.go @@ -9,13 +9,13 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ ExecuteOperations: []plugininstaller.BaseOperation{ kubectl.ProcessByContent( "create", file.NewTemplate().FromRemote(devLakeInstallYAMLDownloadURL), ), }, - GetStatusOperation: getStaticState, + GetStateOperation: getStaticState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/devlake/delete.go b/internal/pkg/plugin/devlake/delete.go index 204d1b4a2..35e561f10 100644 --- a/internal/pkg/plugin/devlake/delete.go +++ b/internal/pkg/plugin/devlake/delete.go @@ -8,7 +8,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ ExecuteOperations: []plugininstaller.BaseOperation{ kubectl.ProcessByContent( "delete", file.NewTemplate().FromRemote(devLakeInstallYAMLDownloadURL), diff --git a/internal/pkg/plugin/devlake/read.go b/internal/pkg/plugin/devlake/read.go index 8ba24b090..82151bf08 100644 --- a/internal/pkg/plugin/devlake/read.go +++ b/internal/pkg/plugin/devlake/read.go @@ -4,8 +4,8 @@ import "github.com/devstream-io/devstream/internal/pkg/plugininstaller" func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ - GetStatusOperation: getDynamicState, + runner := &plugininstaller.Operator{ + GetStateOperation: getDynamicState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/githubactions/golang/create.go b/internal/pkg/plugin/githubactions/golang/create.go index 0c1e34734..fc9b6d84b 100644 --- a/internal/pkg/plugin/githubactions/golang/create.go +++ b/internal/pkg/plugin/githubactions/golang/create.go @@ -9,7 +9,7 @@ import ( // Create sets up GitHub Actions workflow(s). func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ validate, github.BuildWorkFlowsWrapper(workflows), @@ -18,7 +18,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { createDockerHubInfoForPush, github.ProcessAction("create"), }, - GetStatusOperation: github.GetStaticWorkFlowState, + GetStateOperation: github.GetStaticWorkFlowState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/githubactions/golang/delete.go b/internal/pkg/plugin/githubactions/golang/delete.go index 0f7ed495e..5bb2e5dbf 100644 --- a/internal/pkg/plugin/githubactions/golang/delete.go +++ b/internal/pkg/plugin/githubactions/golang/delete.go @@ -7,7 +7,7 @@ import ( // Delete remove GitHub Actions workflows. func Delete(options map[string]interface{}) (bool, error) { - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ validate, github.BuildWorkFlowsWrapper(workflows), diff --git a/internal/pkg/plugin/githubactions/golang/read.go b/internal/pkg/plugin/githubactions/golang/read.go index 9f6ada1ea..249992397 100644 --- a/internal/pkg/plugin/githubactions/golang/read.go +++ b/internal/pkg/plugin/githubactions/golang/read.go @@ -6,12 +6,12 @@ import ( ) func Read(options map[string]interface{}) (map[string]interface{}, error) { - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ validate, github.BuildWorkFlowsWrapper(workflows), }, - GetStatusOperation: github.GetActionState, + GetStateOperation: github.GetActionState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/githubactions/golang/update.go b/internal/pkg/plugin/githubactions/golang/update.go index efa0a4cfc..cca24454d 100644 --- a/internal/pkg/plugin/githubactions/golang/update.go +++ b/internal/pkg/plugin/githubactions/golang/update.go @@ -8,7 +8,7 @@ import ( // Update remove and set up GitHub Actions workflows. func Update(options map[string]interface{}) (map[string]interface{}, error) { - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ validate, github.BuildWorkFlowsWrapper(workflows), @@ -18,7 +18,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { createDockerHubInfoForPush, github.ProcessAction("update"), }, - GetStatusOperation: github.GetActionState, + GetStateOperation: github.GetActionState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/githubactions/nodejs/create.go b/internal/pkg/plugin/githubactions/nodejs/create.go index 2e3ecec13..33e014fc9 100644 --- a/internal/pkg/plugin/githubactions/nodejs/create.go +++ b/internal/pkg/plugin/githubactions/nodejs/create.go @@ -9,7 +9,7 @@ import ( // Create sets up GitHub Actions workflow(s). func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ github.Validate, github.BuildWorkFlowsWrapper(workflows), @@ -17,7 +17,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { ExecuteOperations: []plugininstaller.BaseOperation{ github.ProcessAction("create"), }, - GetStatusOperation: github.GetStaticWorkFlowState, + GetStateOperation: github.GetStaticWorkFlowState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/githubactions/nodejs/delete.go b/internal/pkg/plugin/githubactions/nodejs/delete.go index 466e203c4..bd2f1b2c5 100644 --- a/internal/pkg/plugin/githubactions/nodejs/delete.go +++ b/internal/pkg/plugin/githubactions/nodejs/delete.go @@ -7,7 +7,7 @@ import ( // Delete remove GitHub Actions workflows. func Delete(options map[string]interface{}) (bool, error) { - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ github.Validate, github.BuildWorkFlowsWrapper(workflows), diff --git a/internal/pkg/plugin/githubactions/nodejs/read.go b/internal/pkg/plugin/githubactions/nodejs/read.go index 639abc87a..9c3e555b9 100644 --- a/internal/pkg/plugin/githubactions/nodejs/read.go +++ b/internal/pkg/plugin/githubactions/nodejs/read.go @@ -6,12 +6,12 @@ import ( ) func Read(options map[string]interface{}) (map[string]interface{}, error) { - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, - GetStatusOperation: github.GetActionState, + GetStateOperation: github.GetActionState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/githubactions/nodejs/update.go b/internal/pkg/plugin/githubactions/nodejs/update.go index f615c89dc..66cfa2830 100644 --- a/internal/pkg/plugin/githubactions/nodejs/update.go +++ b/internal/pkg/plugin/githubactions/nodejs/update.go @@ -8,7 +8,7 @@ import ( // Update remove and set up GitHub Actions workflows. func Update(options map[string]interface{}) (map[string]interface{}, error) { - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ github.Validate, github.BuildWorkFlowsWrapper(workflows), @@ -16,7 +16,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { ExecuteOperations: []plugininstaller.BaseOperation{ github.ProcessAction("update"), }, - GetStatusOperation: github.GetActionState, + GetStateOperation: github.GetActionState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/githubactions/python/create.go b/internal/pkg/plugin/githubactions/python/create.go index 2f5dfedcb..a625b24e9 100644 --- a/internal/pkg/plugin/githubactions/python/create.go +++ b/internal/pkg/plugin/githubactions/python/create.go @@ -9,7 +9,7 @@ import ( // Create sets up GitHub Actions workflow(s). func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ github.Validate, github.BuildWorkFlowsWrapper(workflows), @@ -18,7 +18,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { createDockerHubInfoForPush, github.ProcessAction("create"), }, - GetStatusOperation: github.GetStaticWorkFlowState, + GetStateOperation: github.GetStaticWorkFlowState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/githubactions/python/delete.go b/internal/pkg/plugin/githubactions/python/delete.go index e4444d8c9..e1a92e5ed 100644 --- a/internal/pkg/plugin/githubactions/python/delete.go +++ b/internal/pkg/plugin/githubactions/python/delete.go @@ -7,7 +7,7 @@ import ( // Delete remove GitHub Actions workflows. func Delete(options map[string]interface{}) (bool, error) { - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ github.Validate, github.BuildWorkFlowsWrapper(workflows), diff --git a/internal/pkg/plugin/githubactions/python/read.go b/internal/pkg/plugin/githubactions/python/read.go index 69692ea10..4ccc703ed 100644 --- a/internal/pkg/plugin/githubactions/python/read.go +++ b/internal/pkg/plugin/githubactions/python/read.go @@ -6,12 +6,12 @@ import ( ) func Read(options map[string]interface{}) (map[string]interface{}, error) { - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, - GetStatusOperation: github.GetActionState, + GetStateOperation: github.GetActionState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/githubactions/python/update.go b/internal/pkg/plugin/githubactions/python/update.go index bd299ed29..692582d10 100644 --- a/internal/pkg/plugin/githubactions/python/update.go +++ b/internal/pkg/plugin/githubactions/python/update.go @@ -8,7 +8,7 @@ import ( // Update remove and set up GitHub Actions workflows. func Update(options map[string]interface{}) (map[string]interface{}, error) { - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ github.Validate, github.BuildWorkFlowsWrapper(workflows), @@ -18,7 +18,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { createDockerHubInfoForPush, github.ProcessAction("update"), }, - GetStatusOperation: github.GetActionState, + GetStateOperation: github.GetActionState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/gitlabcedocker/create.go b/internal/pkg/plugin/gitlabcedocker/create.go index a3c2df0d1..36519f0f3 100644 --- a/internal/pkg/plugin/gitlabcedocker/create.go +++ b/internal/pkg/plugin/gitlabcedocker/create.go @@ -14,7 +14,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // 2. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ dockerInstaller.Validate, }, @@ -25,7 +25,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { TerminateOperations: []plugininstaller.BaseOperation{ dockerInstaller.ClearWhenInterruption, }, - GetStatusOperation: dockerInstaller.GetStaticStateFromOptions, + GetStateOperation: dockerInstaller.GetStaticStateFromOptions, } // 3. execute installer get status and error diff --git a/internal/pkg/plugin/gitlabcedocker/delete.go b/internal/pkg/plugin/gitlabcedocker/delete.go index e5eecbc3e..8792ea7d1 100644 --- a/internal/pkg/plugin/gitlabcedocker/delete.go +++ b/internal/pkg/plugin/gitlabcedocker/delete.go @@ -13,7 +13,7 @@ func Delete(options map[string]interface{}) (bool, error) { } // 2. config delete operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ dockerInstaller.Validate, }, diff --git a/internal/pkg/plugin/gitlabcedocker/read.go b/internal/pkg/plugin/gitlabcedocker/read.go index b8074aa24..6c35204dd 100644 --- a/internal/pkg/plugin/gitlabcedocker/read.go +++ b/internal/pkg/plugin/gitlabcedocker/read.go @@ -14,11 +14,11 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { } // 2. config read operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ dockerInstaller.Validate, }, - GetStatusOperation: dockerInstaller.GetRunningState, + GetStateOperation: dockerInstaller.GetRunningState, } // 3. get status diff --git a/internal/pkg/plugin/gitlabcedocker/update.go b/internal/pkg/plugin/gitlabcedocker/update.go index 843a6f5ee..279149b69 100644 --- a/internal/pkg/plugin/gitlabcedocker/update.go +++ b/internal/pkg/plugin/gitlabcedocker/update.go @@ -18,7 +18,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { opts.RmDataAfterDelete = types.Bool(false) // 2. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ dockerInstaller.Validate, }, @@ -27,7 +27,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { dockerInstaller.Install, showHelpMsg, }, - GetStatusOperation: dockerInstaller.GetRunningState, + GetStateOperation: dockerInstaller.GetRunningState, } // 3. update and get status diff --git a/internal/pkg/plugin/harbor/create.go b/internal/pkg/plugin/harbor/create.go index ba222d0ce..6d29700f0 100644 --- a/internal/pkg/plugin/harbor/create.go +++ b/internal/pkg/plugin/harbor/create.go @@ -8,13 +8,13 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/harbor/delete.go b/internal/pkg/plugin/harbor/delete.go index 0ed21169b..81e2915d1 100644 --- a/internal/pkg/plugin/harbor/delete.go +++ b/internal/pkg/plugin/harbor/delete.go @@ -7,7 +7,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, diff --git a/internal/pkg/plugin/harbor/read.go b/internal/pkg/plugin/harbor/read.go index 7746db4d2..8eb2f1a62 100644 --- a/internal/pkg/plugin/harbor/read.go +++ b/internal/pkg/plugin/harbor/read.go @@ -8,11 +8,11 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/harbor/update.go b/internal/pkg/plugin/harbor/update.go index 180282163..bef4204c5 100644 --- a/internal/pkg/plugin/harbor/update.go +++ b/internal/pkg/plugin/harbor/update.go @@ -8,12 +8,12 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetPluginAllState, + ExecuteOperations: helm.DefaultUpdateOperations, + GetStateOperation: helm.GetPluginAllState, } // 2. execute update get status and error diff --git a/internal/pkg/plugin/hashicorpvault/create.go b/internal/pkg/plugin/hashicorpvault/create.go index f7fad91b2..497f0d55d 100644 --- a/internal/pkg/plugin/hashicorpvault/create.go +++ b/internal/pkg/plugin/hashicorpvault/create.go @@ -9,13 +9,13 @@ import ( // Create creates hashicorp-vault with provided options. func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/hashicorpvault/delete.go b/internal/pkg/plugin/hashicorpvault/delete.go index a61518aa2..cdc9eceb2 100644 --- a/internal/pkg/plugin/hashicorpvault/delete.go +++ b/internal/pkg/plugin/hashicorpvault/delete.go @@ -7,7 +7,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, diff --git a/internal/pkg/plugin/hashicorpvault/read.go b/internal/pkg/plugin/hashicorpvault/read.go index 5640c7bc1..6c9ce8cbb 100644 --- a/internal/pkg/plugin/hashicorpvault/read.go +++ b/internal/pkg/plugin/hashicorpvault/read.go @@ -8,11 +8,11 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/hashicorpvault/update.go b/internal/pkg/plugin/hashicorpvault/update.go index 2201706a0..0aea53487 100644 --- a/internal/pkg/plugin/hashicorpvault/update.go +++ b/internal/pkg/plugin/hashicorpvault/update.go @@ -8,12 +8,12 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetPluginAllState, + ExecuteOperations: helm.DefaultUpdateOperations, + GetStateOperation: helm.GetPluginAllState, } // 2. execute update get status and error diff --git a/internal/pkg/plugin/helmgeneric/create.go b/internal/pkg/plugin/helmgeneric/create.go index 16b108132..a4a911c87 100644 --- a/internal/pkg/plugin/helmgeneric/create.go +++ b/internal/pkg/plugin/helmgeneric/create.go @@ -9,13 +9,13 @@ import ( // Create creates helmgeneric with provided options. func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: getEmptyState, + GetStateOperation: getEmptyState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/helmgeneric/delete.go b/internal/pkg/plugin/helmgeneric/delete.go index 6351e1394..387c0e7f2 100644 --- a/internal/pkg/plugin/helmgeneric/delete.go +++ b/internal/pkg/plugin/helmgeneric/delete.go @@ -7,7 +7,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, diff --git a/internal/pkg/plugin/helmgeneric/read.go b/internal/pkg/plugin/helmgeneric/read.go index 3a7b3cc36..2216be9ba 100644 --- a/internal/pkg/plugin/helmgeneric/read.go +++ b/internal/pkg/plugin/helmgeneric/read.go @@ -8,11 +8,11 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - GetStatusOperation: getEmptyState, + GetStateOperation: getEmptyState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/helmgeneric/update.go b/internal/pkg/plugin/helmgeneric/update.go index ecc5cbe44..b37f6a6fb 100644 --- a/internal/pkg/plugin/helmgeneric/update.go +++ b/internal/pkg/plugin/helmgeneric/update.go @@ -8,12 +8,12 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: getEmptyState, + ExecuteOperations: helm.DefaultUpdateOperations, + GetStateOperation: getEmptyState, } // 2. execute update get status and error diff --git a/internal/pkg/plugin/jenkins/create.go b/internal/pkg/plugin/jenkins/create.go index 4269d5d19..facce73b0 100644 --- a/internal/pkg/plugin/jenkins/create.go +++ b/internal/pkg/plugin/jenkins/create.go @@ -9,7 +9,7 @@ import ( // Create creates jenkins with provided options. func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, replaceStroageClass, @@ -24,7 +24,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { showJenkinsUrl, }, TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: getHelmResourceAndCustomResource, + GetStateOperation: getHelmResourceAndCustomResource, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/jenkins/delete.go b/internal/pkg/plugin/jenkins/delete.go index d716600b9..0fd49e18d 100644 --- a/internal/pkg/plugin/jenkins/delete.go +++ b/internal/pkg/plugin/jenkins/delete.go @@ -7,7 +7,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, replaceStroageClass, diff --git a/internal/pkg/plugin/jenkins/jenkins.go b/internal/pkg/plugin/jenkins/jenkins.go index d92d7f91e..3b37b7981 100644 --- a/internal/pkg/plugin/jenkins/jenkins.go +++ b/internal/pkg/plugin/jenkins/jenkins.go @@ -7,7 +7,7 @@ import ( // getHelmResourceAndCustomResource wraps helm resource and custom resource, // this is due to the limitation of `plugininstaller`, -// now `plugininstaller.GetStatusOperation` only support one resource get function, +// now `plugininstaller.GetStateOperation` only support one resource get function, // if we want to use both existing resource get function(such as helm's methods) and custom function, // we have to wrap them into one function. func getHelmResourceAndCustomResource(options plugininstaller.RawOptions) (map[string]interface{}, error) { diff --git a/internal/pkg/plugin/jenkins/read.go b/internal/pkg/plugin/jenkins/read.go index 42848188d..6534c5549 100644 --- a/internal/pkg/plugin/jenkins/read.go +++ b/internal/pkg/plugin/jenkins/read.go @@ -8,12 +8,12 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, replaceStroageClass, }, - GetStatusOperation: getHelmResourceAndCustomResource, + GetStateOperation: getHelmResourceAndCustomResource, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/jenkins/update.go b/internal/pkg/plugin/jenkins/update.go index 6a60cc375..db9d19601 100644 --- a/internal/pkg/plugin/jenkins/update.go +++ b/internal/pkg/plugin/jenkins/update.go @@ -9,14 +9,14 @@ import ( // Update updates jenkins with provided options. func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, replaceStroageClass, }, ExecuteOperations: helm.DefaultUpdateOperations, TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: getHelmResourceAndCustomResource, + GetStateOperation: getHelmResourceAndCustomResource, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/kubeprometheus/create.go b/internal/pkg/plugin/kubeprometheus/create.go index 3c83161f1..d8eaf3aff 100644 --- a/internal/pkg/plugin/kubeprometheus/create.go +++ b/internal/pkg/plugin/kubeprometheus/create.go @@ -9,13 +9,13 @@ import ( // Create will create prometheus in k8s func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/kubeprometheus/delete.go b/internal/pkg/plugin/kubeprometheus/delete.go index 28aac4828..2edc66f27 100644 --- a/internal/pkg/plugin/kubeprometheus/delete.go +++ b/internal/pkg/plugin/kubeprometheus/delete.go @@ -7,7 +7,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, diff --git a/internal/pkg/plugin/kubeprometheus/read.go b/internal/pkg/plugin/kubeprometheus/read.go index ea7b74117..e07e75b58 100644 --- a/internal/pkg/plugin/kubeprometheus/read.go +++ b/internal/pkg/plugin/kubeprometheus/read.go @@ -8,11 +8,11 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/kubeprometheus/update.go b/internal/pkg/plugin/kubeprometheus/update.go index d099ba68a..82754fba1 100644 --- a/internal/pkg/plugin/kubeprometheus/update.go +++ b/internal/pkg/plugin/kubeprometheus/update.go @@ -8,12 +8,12 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetPluginAllState, + ExecuteOperations: helm.DefaultUpdateOperations, + GetStateOperation: helm.GetPluginAllState, } // 2. execute update get status and error diff --git a/internal/pkg/plugin/openldap/create.go b/internal/pkg/plugin/openldap/create.go index 104b67de6..06775f885 100644 --- a/internal/pkg/plugin/openldap/create.go +++ b/internal/pkg/plugin/openldap/create.go @@ -9,13 +9,13 @@ import ( // Create creates OpenLDAP with provided options. func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/openldap/delete.go b/internal/pkg/plugin/openldap/delete.go index f884e88b9..66afd77bf 100644 --- a/internal/pkg/plugin/openldap/delete.go +++ b/internal/pkg/plugin/openldap/delete.go @@ -7,7 +7,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, diff --git a/internal/pkg/plugin/openldap/read.go b/internal/pkg/plugin/openldap/read.go index cbf30023c..f80333c30 100644 --- a/internal/pkg/plugin/openldap/read.go +++ b/internal/pkg/plugin/openldap/read.go @@ -8,11 +8,11 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/openldap/update.go b/internal/pkg/plugin/openldap/update.go index 82731d6fe..648ede023 100644 --- a/internal/pkg/plugin/openldap/update.go +++ b/internal/pkg/plugin/openldap/update.go @@ -8,12 +8,12 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetPluginAllState, + ExecuteOperations: helm.DefaultUpdateOperations, + GetStateOperation: helm.GetPluginAllState, } // 2. execute update get status and error diff --git a/internal/pkg/plugin/reposcaffolding/create.go b/internal/pkg/plugin/reposcaffolding/create.go index 357adac72..0827b2f8d 100644 --- a/internal/pkg/plugin/reposcaffolding/create.go +++ b/internal/pkg/plugin/reposcaffolding/create.go @@ -8,7 +8,7 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ reposcaffolding.Validate, reposcaffolding.SetDefaultTemplateRepo, @@ -16,7 +16,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { ExecuteOperations: []plugininstaller.BaseOperation{ reposcaffolding.InstallRepo, }, - GetStatusOperation: reposcaffolding.GetStaticState, + GetStateOperation: reposcaffolding.GetStaticState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/reposcaffolding/delete.go b/internal/pkg/plugin/reposcaffolding/delete.go index 7a00e45da..bbe1e57d7 100644 --- a/internal/pkg/plugin/reposcaffolding/delete.go +++ b/internal/pkg/plugin/reposcaffolding/delete.go @@ -7,7 +7,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ reposcaffolding.Validate, reposcaffolding.SetDefaultTemplateRepo, diff --git a/internal/pkg/plugin/reposcaffolding/read.go b/internal/pkg/plugin/reposcaffolding/read.go index 8cf3cd2c9..e6127e5aa 100644 --- a/internal/pkg/plugin/reposcaffolding/read.go +++ b/internal/pkg/plugin/reposcaffolding/read.go @@ -7,12 +7,12 @@ import ( ) func Read(options map[string]interface{}) (map[string]interface{}, error) { - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ reposcaffolding.Validate, reposcaffolding.SetDefaultTemplateRepo, }, - GetStatusOperation: reposcaffolding.GetDynamicState, + GetStateOperation: reposcaffolding.GetDynamicState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/reposcaffolding/update.go b/internal/pkg/plugin/reposcaffolding/update.go index 62ca1f77e..745f98999 100644 --- a/internal/pkg/plugin/reposcaffolding/update.go +++ b/internal/pkg/plugin/reposcaffolding/update.go @@ -7,7 +7,7 @@ import ( ) func Update(options map[string]interface{}) (map[string]interface{}, error) { - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ reposcaffolding.Validate, reposcaffolding.SetDefaultTemplateRepo, @@ -16,7 +16,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { reposcaffolding.DeleteRepo, reposcaffolding.InstallRepo, }, - GetStatusOperation: reposcaffolding.GetStaticState, + GetStateOperation: reposcaffolding.GetStaticState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/tekton/create.go b/internal/pkg/plugin/tekton/create.go index 81f3f6212..94ce4559e 100644 --- a/internal/pkg/plugin/tekton/create.go +++ b/internal/pkg/plugin/tekton/create.go @@ -8,13 +8,13 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, TerminateOperations: helm.DefaultTerminateOperations, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/tekton/delete.go b/internal/pkg/plugin/tekton/delete.go index c29020624..f1f73917a 100644 --- a/internal/pkg/plugin/tekton/delete.go +++ b/internal/pkg/plugin/tekton/delete.go @@ -7,7 +7,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, diff --git a/internal/pkg/plugin/tekton/read.go b/internal/pkg/plugin/tekton/read.go index 9042c3b32..e2f7d8441 100644 --- a/internal/pkg/plugin/tekton/read.go +++ b/internal/pkg/plugin/tekton/read.go @@ -8,11 +8,11 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - GetStatusOperation: helm.GetPluginAllState, + GetStateOperation: helm.GetPluginAllState, } status, err := runner.Execute(plugininstaller.RawOptions(options)) diff --git a/internal/pkg/plugin/tekton/update.go b/internal/pkg/plugin/tekton/update.go index 4fc2e93ea..c0abc5054 100644 --- a/internal/pkg/plugin/tekton/update.go +++ b/internal/pkg/plugin/tekton/update.go @@ -8,12 +8,12 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ helm.Validate, }, - ExecuteOperations: helm.DefaultUpdateOperations, - GetStatusOperation: helm.GetPluginAllState, + ExecuteOperations: helm.DefaultUpdateOperations, + GetStateOperation: helm.GetPluginAllState, } // 2. execute update get status and error diff --git a/internal/pkg/plugin/zentao/create.go b/internal/pkg/plugin/zentao/create.go index 63f2770e0..19ce0fafd 100644 --- a/internal/pkg/plugin/zentao/create.go +++ b/internal/pkg/plugin/zentao/create.go @@ -7,7 +7,7 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ goclient.Validate, }, @@ -22,7 +22,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { TerminateOperations: []plugininstaller.BaseOperation{ goclient.DealWithErrWhenInstall, }, - GetStatusOperation: goclient.GetState, + GetStateOperation: goclient.GetState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/zentao/delete.go b/internal/pkg/plugin/zentao/delete.go index cc14584b8..984c0d70e 100644 --- a/internal/pkg/plugin/zentao/delete.go +++ b/internal/pkg/plugin/zentao/delete.go @@ -7,7 +7,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ goclient.Validate, }, diff --git a/internal/pkg/plugin/zentao/read.go b/internal/pkg/plugin/zentao/read.go index 104e2c022..2941e2886 100644 --- a/internal/pkg/plugin/zentao/read.go +++ b/internal/pkg/plugin/zentao/read.go @@ -7,11 +7,11 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ goclient.Validate, }, - GetStatusOperation: goclient.GetState, + GetStateOperation: goclient.GetState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugin/zentao/update.go b/internal/pkg/plugin/zentao/update.go index 8cb238ee7..55a2ee71d 100644 --- a/internal/pkg/plugin/zentao/update.go +++ b/internal/pkg/plugin/zentao/update.go @@ -7,7 +7,7 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ + runner := &plugininstaller.Operator{ PreExecuteOperations: []plugininstaller.MutableOperation{ goclient.Validate, }, @@ -20,7 +20,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { TerminateOperations: []plugininstaller.BaseOperation{ goclient.DealWithErrWhenInstall, }, - GetStatusOperation: goclient.GetState, + GetStateOperation: goclient.GetState, } // 2. execute installer get status and error diff --git a/internal/pkg/plugininstaller/plugininstaller.go b/internal/pkg/plugininstaller/plugininstaller.go index 0595da3cd..f5967d4e3 100644 --- a/internal/pkg/plugininstaller/plugininstaller.go +++ b/internal/pkg/plugininstaller/plugininstaller.go @@ -5,74 +5,77 @@ import "github.com/devstream-io/devstream/pkg/util/log" type RawOptions map[string]interface{} type ( - // MutableOperation will changes options if it is needed + // MutableOperation can be used to change options if it is needed MutableOperation func(options RawOptions) (RawOptions, error) - // BaseOperation only reads options and executes operation + // BaseOperation reads options and executes operation BaseOperation func(options RawOptions) error - // StatusOperation only reads options and executes operation - StatusOperation func(options RawOptions) (map[string]interface{}, error) + // StateOperation reads options and executes operation, then returns the state map + StateOperation func(options RawOptions) (map[string]interface{}, error) ) type Installer interface { Execute(options RawOptions) (map[string]interface{}, error) } -// TODO(daniel-hutao): refactor all caller to use NewInstaller() instead of call Runner. -func NewInstaller(preExecOps []MutableOperation, execOps, termiOps []BaseOperation, getStatusOps StatusOperation) Installer { - return &Runner{ +// TODO(daniel-hutao): refactor all caller to use NewInstaller() instead of call Operator. +func NewInstaller(preExecOps []MutableOperation, execOps, termiOps []BaseOperation, getStatusOps StateOperation) Installer { + return &Operator{ PreExecuteOperations: preExecOps, ExecuteOperations: execOps, TerminateOperations: termiOps, - GetStatusOperation: getStatusOps, + GetStateOperation: getStatusOps, } } -// Runner is the basic type of Installer, It organize func to run in order -type Runner struct { +// Operator knows all the operations and can execute them in order +type Operator struct { PreExecuteOperations []MutableOperation ExecuteOperations []BaseOperation TerminateOperations []BaseOperation - GetStatusOperation StatusOperation + GetStateOperation StateOperation } -func (runner *Runner) Execute(options RawOptions) (map[string]interface{}, error) { +// Execute will sequentially execute all operations in Operator +func (o *Operator) Execute(options RawOptions) (map[string]interface{}, error) { var err error - // 1. Run PreExecuteOperations first, these func can change options - log.Debugf("Start Execute PreInstall Operations...") - for _, preInstallOperation := range runner.PreExecuteOperations { - options, err = preInstallOperation(options) + // 1. Execute PreExecuteOperations. It may changes the options. + log.Debugf("Start to execute PreExecuteOperations...") + for _, preOps := range o.PreExecuteOperations { + options, err = preOps(options) if err != nil { return nil, err } } - // 2. register terminate function if encounter in install - var installError error + + // 2. Register defer func so that in case ExecuteOperations fails, it can execute TerminateOperations + var execErr error defer func() { - if installError == nil { + if execErr == nil { return } - log.Debugf("Start to execute terminating operations...") - for _, terminateOperation := range runner.TerminateOperations { + log.Debugf("Start to execute TerminateOperations...") + for _, terminateOperation := range o.TerminateOperations { err := terminateOperation(options) if err != nil { - log.Errorf("Failed to deal with namespace: %s.", err) + log.Errorf("Failed to execute TerminateOperations: %s.", err) } } }() - log.Debugf("Start to execute install operations...") - // 3. Run ExecuteOperations in order, these func can't change options - for _, installOperation := range runner.ExecuteOperations { - installError = installOperation(options) - if installError != nil { - return nil, installError + // 3. Execute ExecuteOperations in order. It won't change the options. + log.Debugf("Start to execute ExecuteOperations...") + for _, execOps := range o.ExecuteOperations { + execErr = execOps(options) + if execErr != nil { + return nil, execErr } } - // 4. Get Status for this execution step - var status map[string]interface{} - if runner.GetStatusOperation != nil { - log.Debugf("Start to execute getting status operations...") - status, err = runner.GetStatusOperation(options) + + // 4. Execute GetStateOperation. + var state map[string]interface{} + if o.GetStateOperation != nil { + log.Debugf("Start to execute GetStateOperation...") + state, err = o.GetStateOperation(options) } - return status, err + return state, err } From 61bccd0d4f7215d4f55c18f015f7405cd46a646a Mon Sep 17 00:00:00 2001 From: Daniel Hu Date: Tue, 9 Aug 2022 22:49:38 +0800 Subject: [PATCH 2/2] refactor: simplify the naming of Operations to make it easier for the caller Signed-off-by: Daniel Hu --- internal/pkg/plugin/argocd/create.go | 2 +- internal/pkg/plugin/argocd/delete.go | 2 +- internal/pkg/plugin/argocd/read.go | 2 +- internal/pkg/plugin/argocd/update.go | 2 +- internal/pkg/plugin/argocdapp/create.go | 4 +-- internal/pkg/plugin/argocdapp/delete.go | 4 +-- internal/pkg/plugin/argocdapp/read.go | 2 +- internal/pkg/plugin/artifactory/create.go | 2 +- internal/pkg/plugin/artifactory/delete.go | 2 +- internal/pkg/plugin/artifactory/read.go | 2 +- internal/pkg/plugin/artifactory/update.go | 2 +- internal/pkg/plugin/devlake/create.go | 2 +- internal/pkg/plugin/devlake/delete.go | 2 +- .../pkg/plugin/githubactions/golang/create.go | 4 +-- .../pkg/plugin/githubactions/golang/delete.go | 4 +-- .../pkg/plugin/githubactions/golang/read.go | 2 +- .../pkg/plugin/githubactions/golang/update.go | 4 +-- .../pkg/plugin/githubactions/nodejs/create.go | 4 +-- .../pkg/plugin/githubactions/nodejs/delete.go | 4 +-- .../pkg/plugin/githubactions/nodejs/read.go | 2 +- .../pkg/plugin/githubactions/nodejs/update.go | 4 +-- .../pkg/plugin/githubactions/python/create.go | 4 +-- .../pkg/plugin/githubactions/python/delete.go | 4 +-- .../pkg/plugin/githubactions/python/read.go | 2 +- .../pkg/plugin/githubactions/python/update.go | 4 +-- internal/pkg/plugin/gitlabcedocker/create.go | 6 ++--- internal/pkg/plugin/gitlabcedocker/delete.go | 4 +-- internal/pkg/plugin/gitlabcedocker/read.go | 2 +- internal/pkg/plugin/gitlabcedocker/update.go | 4 +-- internal/pkg/plugin/harbor/create.go | 2 +- internal/pkg/plugin/harbor/delete.go | 2 +- internal/pkg/plugin/harbor/read.go | 2 +- internal/pkg/plugin/harbor/update.go | 2 +- internal/pkg/plugin/hashicorpvault/create.go | 2 +- internal/pkg/plugin/hashicorpvault/delete.go | 2 +- internal/pkg/plugin/hashicorpvault/read.go | 2 +- internal/pkg/plugin/hashicorpvault/update.go | 2 +- internal/pkg/plugin/helmgeneric/create.go | 2 +- internal/pkg/plugin/helmgeneric/delete.go | 2 +- internal/pkg/plugin/helmgeneric/read.go | 2 +- internal/pkg/plugin/helmgeneric/update.go | 2 +- internal/pkg/plugin/jenkins/create.go | 4 +-- internal/pkg/plugin/jenkins/delete.go | 4 +-- internal/pkg/plugin/jenkins/read.go | 2 +- internal/pkg/plugin/jenkins/update.go | 2 +- internal/pkg/plugin/kubeprometheus/create.go | 2 +- internal/pkg/plugin/kubeprometheus/delete.go | 2 +- internal/pkg/plugin/kubeprometheus/read.go | 2 +- internal/pkg/plugin/kubeprometheus/update.go | 2 +- internal/pkg/plugin/openldap/create.go | 2 +- internal/pkg/plugin/openldap/delete.go | 2 +- internal/pkg/plugin/openldap/read.go | 2 +- internal/pkg/plugin/openldap/update.go | 2 +- internal/pkg/plugin/reposcaffolding/create.go | 4 +-- internal/pkg/plugin/reposcaffolding/delete.go | 4 +-- internal/pkg/plugin/reposcaffolding/read.go | 2 +- internal/pkg/plugin/reposcaffolding/update.go | 4 +-- internal/pkg/plugin/tekton/create.go | 2 +- internal/pkg/plugin/tekton/delete.go | 2 +- internal/pkg/plugin/tekton/read.go | 2 +- internal/pkg/plugin/tekton/update.go | 2 +- internal/pkg/plugin/zentao/create.go | 6 ++--- internal/pkg/plugin/zentao/delete.go | 4 +-- internal/pkg/plugin/zentao/read.go | 2 +- internal/pkg/plugin/zentao/update.go | 6 ++--- .../pkg/plugininstaller/helm/installer.go | 8 +++--- .../pkg/plugininstaller/plugininstaller.go | 25 ++++++++----------- 67 files changed, 105 insertions(+), 108 deletions(-) diff --git a/internal/pkg/plugin/argocd/create.go b/internal/pkg/plugin/argocd/create.go index c2724cdaa..c37fdfce2 100644 --- a/internal/pkg/plugin/argocd/create.go +++ b/internal/pkg/plugin/argocd/create.go @@ -10,7 +10,7 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.SetDefaultConfig(&defaultHelmConfig), helm.Validate, }, diff --git a/internal/pkg/plugin/argocd/delete.go b/internal/pkg/plugin/argocd/delete.go index bc211adbe..b6a6594e0 100644 --- a/internal/pkg/plugin/argocd/delete.go +++ b/internal/pkg/plugin/argocd/delete.go @@ -8,7 +8,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.SetDefaultConfig(&defaultHelmConfig), helm.Validate, }, diff --git a/internal/pkg/plugin/argocd/read.go b/internal/pkg/plugin/argocd/read.go index ab8945b19..a1b090263 100644 --- a/internal/pkg/plugin/argocd/read.go +++ b/internal/pkg/plugin/argocd/read.go @@ -13,7 +13,7 @@ const ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.SetDefaultConfig(&defaultHelmConfig), helm.Validate, }, diff --git a/internal/pkg/plugin/argocd/update.go b/internal/pkg/plugin/argocd/update.go index b8b9c4ac7..cc045b25b 100644 --- a/internal/pkg/plugin/argocd/update.go +++ b/internal/pkg/plugin/argocd/update.go @@ -9,7 +9,7 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.SetDefaultConfig(&defaultHelmConfig), helm.Validate, }, diff --git a/internal/pkg/plugin/argocdapp/create.go b/internal/pkg/plugin/argocdapp/create.go index de1afb15d..7289124b8 100644 --- a/internal/pkg/plugin/argocdapp/create.go +++ b/internal/pkg/plugin/argocdapp/create.go @@ -11,10 +11,10 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ kubectl.ProcessByContent( "create", file.NewTemplate().FromContent(templateFileLoc), ), diff --git a/internal/pkg/plugin/argocdapp/delete.go b/internal/pkg/plugin/argocdapp/delete.go index 188f9d314..8d96f8622 100644 --- a/internal/pkg/plugin/argocdapp/delete.go +++ b/internal/pkg/plugin/argocdapp/delete.go @@ -9,10 +9,10 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ kubectl.ProcessByContent( "delete", file.NewTemplate().FromContent(templateFileLoc), ), diff --git a/internal/pkg/plugin/argocdapp/read.go b/internal/pkg/plugin/argocdapp/read.go index 33a0c1daf..2d7928066 100644 --- a/internal/pkg/plugin/argocdapp/read.go +++ b/internal/pkg/plugin/argocdapp/read.go @@ -7,7 +7,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, }, GetStateOperation: getDynamicState, diff --git a/internal/pkg/plugin/artifactory/create.go b/internal/pkg/plugin/artifactory/create.go index f49130edb..1a001fed0 100644 --- a/internal/pkg/plugin/artifactory/create.go +++ b/internal/pkg/plugin/artifactory/create.go @@ -9,7 +9,7 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, diff --git a/internal/pkg/plugin/artifactory/delete.go b/internal/pkg/plugin/artifactory/delete.go index a4cb321b5..0f54c9201 100644 --- a/internal/pkg/plugin/artifactory/delete.go +++ b/internal/pkg/plugin/artifactory/delete.go @@ -8,7 +8,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultDeleteOperations, diff --git a/internal/pkg/plugin/artifactory/read.go b/internal/pkg/plugin/artifactory/read.go index 663244520..9490ea069 100644 --- a/internal/pkg/plugin/artifactory/read.go +++ b/internal/pkg/plugin/artifactory/read.go @@ -9,7 +9,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, GetStateOperation: helm.GetPluginAllState, diff --git a/internal/pkg/plugin/artifactory/update.go b/internal/pkg/plugin/artifactory/update.go index ab0aecca4..6ebe0c0e0 100644 --- a/internal/pkg/plugin/artifactory/update.go +++ b/internal/pkg/plugin/artifactory/update.go @@ -9,7 +9,7 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultUpdateOperations, diff --git a/internal/pkg/plugin/devlake/create.go b/internal/pkg/plugin/devlake/create.go index 80e049cd4..3746a5ffa 100644 --- a/internal/pkg/plugin/devlake/create.go +++ b/internal/pkg/plugin/devlake/create.go @@ -10,7 +10,7 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ kubectl.ProcessByContent( "create", file.NewTemplate().FromRemote(devLakeInstallYAMLDownloadURL), ), diff --git a/internal/pkg/plugin/devlake/delete.go b/internal/pkg/plugin/devlake/delete.go index 35e561f10..8e2808606 100644 --- a/internal/pkg/plugin/devlake/delete.go +++ b/internal/pkg/plugin/devlake/delete.go @@ -9,7 +9,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations runner := &plugininstaller.Operator{ - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ kubectl.ProcessByContent( "delete", file.NewTemplate().FromRemote(devLakeInstallYAMLDownloadURL), ), diff --git a/internal/pkg/plugin/githubactions/golang/create.go b/internal/pkg/plugin/githubactions/golang/create.go index fc9b6d84b..3c83475fd 100644 --- a/internal/pkg/plugin/githubactions/golang/create.go +++ b/internal/pkg/plugin/githubactions/golang/create.go @@ -10,11 +10,11 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ createDockerHubInfoForPush, github.ProcessAction("create"), }, diff --git a/internal/pkg/plugin/githubactions/golang/delete.go b/internal/pkg/plugin/githubactions/golang/delete.go index 5bb2e5dbf..6ba657a66 100644 --- a/internal/pkg/plugin/githubactions/golang/delete.go +++ b/internal/pkg/plugin/githubactions/golang/delete.go @@ -8,11 +8,11 @@ import ( // Delete remove GitHub Actions workflows. func Delete(options map[string]interface{}) (bool, error) { runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ deleteDockerHubInfoForPush, github.ProcessAction("delete"), }, diff --git a/internal/pkg/plugin/githubactions/golang/read.go b/internal/pkg/plugin/githubactions/golang/read.go index 249992397..9c2a16d38 100644 --- a/internal/pkg/plugin/githubactions/golang/read.go +++ b/internal/pkg/plugin/githubactions/golang/read.go @@ -7,7 +7,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, github.BuildWorkFlowsWrapper(workflows), }, diff --git a/internal/pkg/plugin/githubactions/golang/update.go b/internal/pkg/plugin/githubactions/golang/update.go index cca24454d..9e8ca535b 100644 --- a/internal/pkg/plugin/githubactions/golang/update.go +++ b/internal/pkg/plugin/githubactions/golang/update.go @@ -9,11 +9,11 @@ import ( // Update remove and set up GitHub Actions workflows. func Update(options map[string]interface{}) (map[string]interface{}, error) { runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ deleteDockerHubInfoForPush, createDockerHubInfoForPush, github.ProcessAction("update"), diff --git a/internal/pkg/plugin/githubactions/nodejs/create.go b/internal/pkg/plugin/githubactions/nodejs/create.go index 33e014fc9..c06384908 100644 --- a/internal/pkg/plugin/githubactions/nodejs/create.go +++ b/internal/pkg/plugin/githubactions/nodejs/create.go @@ -10,11 +10,11 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ github.ProcessAction("create"), }, GetStateOperation: github.GetStaticWorkFlowState, diff --git a/internal/pkg/plugin/githubactions/nodejs/delete.go b/internal/pkg/plugin/githubactions/nodejs/delete.go index bd2f1b2c5..9edc1646a 100644 --- a/internal/pkg/plugin/githubactions/nodejs/delete.go +++ b/internal/pkg/plugin/githubactions/nodejs/delete.go @@ -8,11 +8,11 @@ import ( // Delete remove GitHub Actions workflows. func Delete(options map[string]interface{}) (bool, error) { runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ github.ProcessAction("delete"), }, } diff --git a/internal/pkg/plugin/githubactions/nodejs/read.go b/internal/pkg/plugin/githubactions/nodejs/read.go index 9c3e555b9..02f64c5ee 100644 --- a/internal/pkg/plugin/githubactions/nodejs/read.go +++ b/internal/pkg/plugin/githubactions/nodejs/read.go @@ -7,7 +7,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, diff --git a/internal/pkg/plugin/githubactions/nodejs/update.go b/internal/pkg/plugin/githubactions/nodejs/update.go index 66cfa2830..7586fe337 100644 --- a/internal/pkg/plugin/githubactions/nodejs/update.go +++ b/internal/pkg/plugin/githubactions/nodejs/update.go @@ -9,11 +9,11 @@ import ( // Update remove and set up GitHub Actions workflows. func Update(options map[string]interface{}) (map[string]interface{}, error) { runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ github.ProcessAction("update"), }, GetStateOperation: github.GetActionState, diff --git a/internal/pkg/plugin/githubactions/python/create.go b/internal/pkg/plugin/githubactions/python/create.go index a625b24e9..3cd3afb38 100644 --- a/internal/pkg/plugin/githubactions/python/create.go +++ b/internal/pkg/plugin/githubactions/python/create.go @@ -10,11 +10,11 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ createDockerHubInfoForPush, github.ProcessAction("create"), }, diff --git a/internal/pkg/plugin/githubactions/python/delete.go b/internal/pkg/plugin/githubactions/python/delete.go index e1a92e5ed..8bf0f41e4 100644 --- a/internal/pkg/plugin/githubactions/python/delete.go +++ b/internal/pkg/plugin/githubactions/python/delete.go @@ -8,11 +8,11 @@ import ( // Delete remove GitHub Actions workflows. func Delete(options map[string]interface{}) (bool, error) { runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ deleteDockerHubInfoForPush, github.ProcessAction("delete"), }, diff --git a/internal/pkg/plugin/githubactions/python/read.go b/internal/pkg/plugin/githubactions/python/read.go index 4ccc703ed..6c18a835e 100644 --- a/internal/pkg/plugin/githubactions/python/read.go +++ b/internal/pkg/plugin/githubactions/python/read.go @@ -7,7 +7,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, diff --git a/internal/pkg/plugin/githubactions/python/update.go b/internal/pkg/plugin/githubactions/python/update.go index 692582d10..6c1d3f968 100644 --- a/internal/pkg/plugin/githubactions/python/update.go +++ b/internal/pkg/plugin/githubactions/python/update.go @@ -9,11 +9,11 @@ import ( // Update remove and set up GitHub Actions workflows. func Update(options map[string]interface{}) (map[string]interface{}, error) { runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ deleteDockerHubInfoForPush, createDockerHubInfoForPush, github.ProcessAction("update"), diff --git a/internal/pkg/plugin/gitlabcedocker/create.go b/internal/pkg/plugin/gitlabcedocker/create.go index 36519f0f3..1662bc2e4 100644 --- a/internal/pkg/plugin/gitlabcedocker/create.go +++ b/internal/pkg/plugin/gitlabcedocker/create.go @@ -15,14 +15,14 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { // 2. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ dockerInstaller.Validate, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ dockerInstaller.Install, showHelpMsg, }, - TerminateOperations: []plugininstaller.BaseOperation{ + TerminateOperations: plugininstaller.TerminateOperations{ dockerInstaller.ClearWhenInterruption, }, GetStateOperation: dockerInstaller.GetStaticStateFromOptions, diff --git a/internal/pkg/plugin/gitlabcedocker/delete.go b/internal/pkg/plugin/gitlabcedocker/delete.go index 8792ea7d1..ef894487f 100644 --- a/internal/pkg/plugin/gitlabcedocker/delete.go +++ b/internal/pkg/plugin/gitlabcedocker/delete.go @@ -14,10 +14,10 @@ func Delete(options map[string]interface{}) (bool, error) { // 2. config delete operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ dockerInstaller.Validate, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ dockerInstaller.DeleteAll, }, } diff --git a/internal/pkg/plugin/gitlabcedocker/read.go b/internal/pkg/plugin/gitlabcedocker/read.go index 6c35204dd..222ba0778 100644 --- a/internal/pkg/plugin/gitlabcedocker/read.go +++ b/internal/pkg/plugin/gitlabcedocker/read.go @@ -15,7 +15,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { // 2. config read operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ dockerInstaller.Validate, }, GetStateOperation: dockerInstaller.GetRunningState, diff --git a/internal/pkg/plugin/gitlabcedocker/update.go b/internal/pkg/plugin/gitlabcedocker/update.go index 279149b69..e56f59189 100644 --- a/internal/pkg/plugin/gitlabcedocker/update.go +++ b/internal/pkg/plugin/gitlabcedocker/update.go @@ -19,10 +19,10 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { // 2. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ dockerInstaller.Validate, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ dockerInstaller.DeleteAll, dockerInstaller.Install, showHelpMsg, diff --git a/internal/pkg/plugin/harbor/create.go b/internal/pkg/plugin/harbor/create.go index 6d29700f0..01dc08913 100644 --- a/internal/pkg/plugin/harbor/create.go +++ b/internal/pkg/plugin/harbor/create.go @@ -9,7 +9,7 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, diff --git a/internal/pkg/plugin/harbor/delete.go b/internal/pkg/plugin/harbor/delete.go index 81e2915d1..a94f084c5 100644 --- a/internal/pkg/plugin/harbor/delete.go +++ b/internal/pkg/plugin/harbor/delete.go @@ -8,7 +8,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultDeleteOperations, diff --git a/internal/pkg/plugin/harbor/read.go b/internal/pkg/plugin/harbor/read.go index 8eb2f1a62..c3de25fbd 100644 --- a/internal/pkg/plugin/harbor/read.go +++ b/internal/pkg/plugin/harbor/read.go @@ -9,7 +9,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, GetStateOperation: helm.GetPluginAllState, diff --git a/internal/pkg/plugin/harbor/update.go b/internal/pkg/plugin/harbor/update.go index bef4204c5..fff8415b2 100644 --- a/internal/pkg/plugin/harbor/update.go +++ b/internal/pkg/plugin/harbor/update.go @@ -9,7 +9,7 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultUpdateOperations, diff --git a/internal/pkg/plugin/hashicorpvault/create.go b/internal/pkg/plugin/hashicorpvault/create.go index 497f0d55d..42084dab5 100644 --- a/internal/pkg/plugin/hashicorpvault/create.go +++ b/internal/pkg/plugin/hashicorpvault/create.go @@ -10,7 +10,7 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, diff --git a/internal/pkg/plugin/hashicorpvault/delete.go b/internal/pkg/plugin/hashicorpvault/delete.go index cdc9eceb2..c367bfe7e 100644 --- a/internal/pkg/plugin/hashicorpvault/delete.go +++ b/internal/pkg/plugin/hashicorpvault/delete.go @@ -8,7 +8,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultDeleteOperations, diff --git a/internal/pkg/plugin/hashicorpvault/read.go b/internal/pkg/plugin/hashicorpvault/read.go index 6c9ce8cbb..58042630d 100644 --- a/internal/pkg/plugin/hashicorpvault/read.go +++ b/internal/pkg/plugin/hashicorpvault/read.go @@ -9,7 +9,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, GetStateOperation: helm.GetPluginAllState, diff --git a/internal/pkg/plugin/hashicorpvault/update.go b/internal/pkg/plugin/hashicorpvault/update.go index 0aea53487..179c98abc 100644 --- a/internal/pkg/plugin/hashicorpvault/update.go +++ b/internal/pkg/plugin/hashicorpvault/update.go @@ -9,7 +9,7 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultUpdateOperations, diff --git a/internal/pkg/plugin/helmgeneric/create.go b/internal/pkg/plugin/helmgeneric/create.go index a4a911c87..8e9f87e0e 100644 --- a/internal/pkg/plugin/helmgeneric/create.go +++ b/internal/pkg/plugin/helmgeneric/create.go @@ -10,7 +10,7 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, diff --git a/internal/pkg/plugin/helmgeneric/delete.go b/internal/pkg/plugin/helmgeneric/delete.go index 387c0e7f2..5be100d69 100644 --- a/internal/pkg/plugin/helmgeneric/delete.go +++ b/internal/pkg/plugin/helmgeneric/delete.go @@ -8,7 +8,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultDeleteOperations, diff --git a/internal/pkg/plugin/helmgeneric/read.go b/internal/pkg/plugin/helmgeneric/read.go index 2216be9ba..d93630594 100644 --- a/internal/pkg/plugin/helmgeneric/read.go +++ b/internal/pkg/plugin/helmgeneric/read.go @@ -9,7 +9,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, GetStateOperation: getEmptyState, diff --git a/internal/pkg/plugin/helmgeneric/update.go b/internal/pkg/plugin/helmgeneric/update.go index b37f6a6fb..9d10f424e 100644 --- a/internal/pkg/plugin/helmgeneric/update.go +++ b/internal/pkg/plugin/helmgeneric/update.go @@ -9,7 +9,7 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultUpdateOperations, diff --git a/internal/pkg/plugin/jenkins/create.go b/internal/pkg/plugin/jenkins/create.go index facce73b0..17e03e9ed 100644 --- a/internal/pkg/plugin/jenkins/create.go +++ b/internal/pkg/plugin/jenkins/create.go @@ -10,11 +10,11 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, replaceStroageClass, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ helm.DealWithNsWhenInstall, preCreate, helm.InstallOrUpdate, diff --git a/internal/pkg/plugin/jenkins/delete.go b/internal/pkg/plugin/jenkins/delete.go index 0fd49e18d..9969a425c 100644 --- a/internal/pkg/plugin/jenkins/delete.go +++ b/internal/pkg/plugin/jenkins/delete.go @@ -8,11 +8,11 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, replaceStroageClass, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ helm.Delete, helm.DealWithNsWhenInterruption, postDelete, diff --git a/internal/pkg/plugin/jenkins/read.go b/internal/pkg/plugin/jenkins/read.go index 6534c5549..42bb5f5ab 100644 --- a/internal/pkg/plugin/jenkins/read.go +++ b/internal/pkg/plugin/jenkins/read.go @@ -9,7 +9,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, replaceStroageClass, }, diff --git a/internal/pkg/plugin/jenkins/update.go b/internal/pkg/plugin/jenkins/update.go index db9d19601..e992474ac 100644 --- a/internal/pkg/plugin/jenkins/update.go +++ b/internal/pkg/plugin/jenkins/update.go @@ -10,7 +10,7 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, replaceStroageClass, }, diff --git a/internal/pkg/plugin/kubeprometheus/create.go b/internal/pkg/plugin/kubeprometheus/create.go index d8eaf3aff..fb7ad8a7d 100644 --- a/internal/pkg/plugin/kubeprometheus/create.go +++ b/internal/pkg/plugin/kubeprometheus/create.go @@ -10,7 +10,7 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, diff --git a/internal/pkg/plugin/kubeprometheus/delete.go b/internal/pkg/plugin/kubeprometheus/delete.go index 2edc66f27..ae7a6c8bb 100644 --- a/internal/pkg/plugin/kubeprometheus/delete.go +++ b/internal/pkg/plugin/kubeprometheus/delete.go @@ -8,7 +8,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultDeleteOperations, diff --git a/internal/pkg/plugin/kubeprometheus/read.go b/internal/pkg/plugin/kubeprometheus/read.go index e07e75b58..78759a4d6 100644 --- a/internal/pkg/plugin/kubeprometheus/read.go +++ b/internal/pkg/plugin/kubeprometheus/read.go @@ -9,7 +9,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, GetStateOperation: helm.GetPluginAllState, diff --git a/internal/pkg/plugin/kubeprometheus/update.go b/internal/pkg/plugin/kubeprometheus/update.go index 82754fba1..6e521b4f3 100644 --- a/internal/pkg/plugin/kubeprometheus/update.go +++ b/internal/pkg/plugin/kubeprometheus/update.go @@ -9,7 +9,7 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultUpdateOperations, diff --git a/internal/pkg/plugin/openldap/create.go b/internal/pkg/plugin/openldap/create.go index 06775f885..4fd142ae8 100644 --- a/internal/pkg/plugin/openldap/create.go +++ b/internal/pkg/plugin/openldap/create.go @@ -10,7 +10,7 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, diff --git a/internal/pkg/plugin/openldap/delete.go b/internal/pkg/plugin/openldap/delete.go index 66afd77bf..b9fb6f22f 100644 --- a/internal/pkg/plugin/openldap/delete.go +++ b/internal/pkg/plugin/openldap/delete.go @@ -8,7 +8,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultDeleteOperations, diff --git a/internal/pkg/plugin/openldap/read.go b/internal/pkg/plugin/openldap/read.go index f80333c30..5a9de0659 100644 --- a/internal/pkg/plugin/openldap/read.go +++ b/internal/pkg/plugin/openldap/read.go @@ -9,7 +9,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, GetStateOperation: helm.GetPluginAllState, diff --git a/internal/pkg/plugin/openldap/update.go b/internal/pkg/plugin/openldap/update.go index 648ede023..9038c0e22 100644 --- a/internal/pkg/plugin/openldap/update.go +++ b/internal/pkg/plugin/openldap/update.go @@ -9,7 +9,7 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultUpdateOperations, diff --git a/internal/pkg/plugin/reposcaffolding/create.go b/internal/pkg/plugin/reposcaffolding/create.go index 0827b2f8d..3262d3023 100644 --- a/internal/pkg/plugin/reposcaffolding/create.go +++ b/internal/pkg/plugin/reposcaffolding/create.go @@ -9,11 +9,11 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ reposcaffolding.Validate, reposcaffolding.SetDefaultTemplateRepo, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ reposcaffolding.InstallRepo, }, GetStateOperation: reposcaffolding.GetStaticState, diff --git a/internal/pkg/plugin/reposcaffolding/delete.go b/internal/pkg/plugin/reposcaffolding/delete.go index bbe1e57d7..4dc407db0 100644 --- a/internal/pkg/plugin/reposcaffolding/delete.go +++ b/internal/pkg/plugin/reposcaffolding/delete.go @@ -8,11 +8,11 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ reposcaffolding.Validate, reposcaffolding.SetDefaultTemplateRepo, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ reposcaffolding.DeleteRepo, }, } diff --git a/internal/pkg/plugin/reposcaffolding/read.go b/internal/pkg/plugin/reposcaffolding/read.go index e6127e5aa..2bc43effd 100644 --- a/internal/pkg/plugin/reposcaffolding/read.go +++ b/internal/pkg/plugin/reposcaffolding/read.go @@ -8,7 +8,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ reposcaffolding.Validate, reposcaffolding.SetDefaultTemplateRepo, }, diff --git a/internal/pkg/plugin/reposcaffolding/update.go b/internal/pkg/plugin/reposcaffolding/update.go index 745f98999..a4831b426 100644 --- a/internal/pkg/plugin/reposcaffolding/update.go +++ b/internal/pkg/plugin/reposcaffolding/update.go @@ -8,11 +8,11 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ reposcaffolding.Validate, reposcaffolding.SetDefaultTemplateRepo, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ reposcaffolding.DeleteRepo, reposcaffolding.InstallRepo, }, diff --git a/internal/pkg/plugin/tekton/create.go b/internal/pkg/plugin/tekton/create.go index 94ce4559e..064d57106 100644 --- a/internal/pkg/plugin/tekton/create.go +++ b/internal/pkg/plugin/tekton/create.go @@ -9,7 +9,7 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultCreateOperations, diff --git a/internal/pkg/plugin/tekton/delete.go b/internal/pkg/plugin/tekton/delete.go index f1f73917a..bb54cf95e 100644 --- a/internal/pkg/plugin/tekton/delete.go +++ b/internal/pkg/plugin/tekton/delete.go @@ -8,7 +8,7 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultDeleteOperations, diff --git a/internal/pkg/plugin/tekton/read.go b/internal/pkg/plugin/tekton/read.go index e2f7d8441..d2528fa6f 100644 --- a/internal/pkg/plugin/tekton/read.go +++ b/internal/pkg/plugin/tekton/read.go @@ -9,7 +9,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config read operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, GetStateOperation: helm.GetPluginAllState, diff --git a/internal/pkg/plugin/tekton/update.go b/internal/pkg/plugin/tekton/update.go index c0abc5054..f77213ce8 100644 --- a/internal/pkg/plugin/tekton/update.go +++ b/internal/pkg/plugin/tekton/update.go @@ -9,7 +9,7 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config update operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, }, ExecuteOperations: helm.DefaultUpdateOperations, diff --git a/internal/pkg/plugin/zentao/create.go b/internal/pkg/plugin/zentao/create.go index 19ce0fafd..88b5acc4a 100644 --- a/internal/pkg/plugin/zentao/create.go +++ b/internal/pkg/plugin/zentao/create.go @@ -8,10 +8,10 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ goclient.Validate, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ goclient.DealWithNsWhenInstall, goclient.CreatePersistentVolumeWrapper(defaultPVPath), goclient.CreatePersistentVolumeClaim, @@ -19,7 +19,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { goclient.CreateServiceWrapperLabelAndPorts(defaultZentaolabels, &defaultSVCPort), goclient.WaitForReady(retryTimes), }, - TerminateOperations: []plugininstaller.BaseOperation{ + TerminateOperations: plugininstaller.TerminateOperations{ goclient.DealWithErrWhenInstall, }, GetStateOperation: goclient.GetState, diff --git a/internal/pkg/plugin/zentao/delete.go b/internal/pkg/plugin/zentao/delete.go index 984c0d70e..008abcb76 100644 --- a/internal/pkg/plugin/zentao/delete.go +++ b/internal/pkg/plugin/zentao/delete.go @@ -8,10 +8,10 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ goclient.Validate, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ goclient.Delete, }, } diff --git a/internal/pkg/plugin/zentao/read.go b/internal/pkg/plugin/zentao/read.go index 2941e2886..54f51a1dd 100644 --- a/internal/pkg/plugin/zentao/read.go +++ b/internal/pkg/plugin/zentao/read.go @@ -8,7 +8,7 @@ import ( func Read(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ goclient.Validate, }, GetStateOperation: goclient.GetState, diff --git a/internal/pkg/plugin/zentao/update.go b/internal/pkg/plugin/zentao/update.go index 55a2ee71d..6458a6f11 100644 --- a/internal/pkg/plugin/zentao/update.go +++ b/internal/pkg/plugin/zentao/update.go @@ -8,16 +8,16 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations runner := &plugininstaller.Operator{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ goclient.Validate, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ goclient.DeleteApp, goclient.CreateDeploymentWrapperLabelAndContainerPorts(defaultZentaolabels, &defaultZentaoPorts, defaultName), goclient.CreateServiceWrapperLabelAndPorts(defaultZentaolabels, &defaultSVCPort), goclient.WaitForReady(retryTimes), }, - TerminateOperations: []plugininstaller.BaseOperation{ + TerminateOperations: plugininstaller.TerminateOperations{ goclient.DealWithErrWhenInstall, }, GetStateOperation: goclient.GetState, diff --git a/internal/pkg/plugininstaller/helm/installer.go b/internal/pkg/plugininstaller/helm/installer.go index f36d28d37..170f1bbc9 100644 --- a/internal/pkg/plugininstaller/helm/installer.go +++ b/internal/pkg/plugininstaller/helm/installer.go @@ -8,18 +8,18 @@ import ( ) var ( - DefaultCreateOperations = []plugininstaller.BaseOperation{ + DefaultCreateOperations = plugininstaller.ExecuteOperations{ DealWithNsWhenInstall, InstallOrUpdate, } - DefaultUpdateOperations = []plugininstaller.BaseOperation{ + DefaultUpdateOperations = plugininstaller.ExecuteOperations{ InstallOrUpdate, } - DefaultDeleteOperations = []plugininstaller.BaseOperation{ + DefaultDeleteOperations = plugininstaller.ExecuteOperations{ Delete, DealWithNsWhenInterruption, } - DefaultTerminateOperations = []plugininstaller.BaseOperation{ + DefaultTerminateOperations = plugininstaller.TerminateOperations{ Delete, DealWithNsWhenInterruption, } diff --git a/internal/pkg/plugininstaller/plugininstaller.go b/internal/pkg/plugininstaller/plugininstaller.go index f5967d4e3..1e6cdadf3 100644 --- a/internal/pkg/plugininstaller/plugininstaller.go +++ b/internal/pkg/plugininstaller/plugininstaller.go @@ -13,26 +13,23 @@ type ( StateOperation func(options RawOptions) (map[string]interface{}, error) ) +type ( + PreExecuteOperations []MutableOperation + ExecuteOperations []BaseOperation + TerminateOperations []BaseOperation + GetStateOperation StateOperation +) + type Installer interface { Execute(options RawOptions) (map[string]interface{}, error) } -// TODO(daniel-hutao): refactor all caller to use NewInstaller() instead of call Operator. -func NewInstaller(preExecOps []MutableOperation, execOps, termiOps []BaseOperation, getStatusOps StateOperation) Installer { - return &Operator{ - PreExecuteOperations: preExecOps, - ExecuteOperations: execOps, - TerminateOperations: termiOps, - GetStateOperation: getStatusOps, - } -} - // Operator knows all the operations and can execute them in order type Operator struct { - PreExecuteOperations []MutableOperation - ExecuteOperations []BaseOperation - TerminateOperations []BaseOperation - GetStateOperation StateOperation + PreExecuteOperations PreExecuteOperations + ExecuteOperations ExecuteOperations + TerminateOperations TerminateOperations + GetStateOperation GetStateOperation } // Execute will sequentially execute all operations in Operator