diff --git a/internal/pkg/plugin/argocd/create.go b/internal/pkg/plugin/argocd/create.go index bf2789b94..c37fdfce2 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..b6a6594e0 100644 --- a/internal/pkg/plugin/argocd/delete.go +++ b/internal/pkg/plugin/argocd/delete.go @@ -7,8 +7,8 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 82d81cbdf..a1b090263 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..cc045b25b 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..7289124b8 100644 --- a/internal/pkg/plugin/argocdapp/create.go +++ b/internal/pkg/plugin/argocdapp/create.go @@ -10,16 +10,16 @@ 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ kubectl.ProcessByContent( "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..8d96f8622 100644 --- a/internal/pkg/plugin/argocdapp/delete.go +++ b/internal/pkg/plugin/argocdapp/delete.go @@ -8,11 +8,11 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config install operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 73a8c2963..2d7928066 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..1a001fed0 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..0f54c9201 100644 --- a/internal/pkg/plugin/artifactory/delete.go +++ b/internal/pkg/plugin/artifactory/delete.go @@ -7,8 +7,8 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 f9c4cec61..9490ea069 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..6ebe0c0e0 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..3746a5ffa 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{ - ExecuteOperations: []plugininstaller.BaseOperation{ + runner := &plugininstaller.Operator{ + ExecuteOperations: plugininstaller.ExecuteOperations{ 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..8e2808606 100644 --- a/internal/pkg/plugin/devlake/delete.go +++ b/internal/pkg/plugin/devlake/delete.go @@ -8,8 +8,8 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ - ExecuteOperations: []plugininstaller.BaseOperation{ + runner := &plugininstaller.Operator{ + ExecuteOperations: plugininstaller.ExecuteOperations{ 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..3c83475fd 100644 --- a/internal/pkg/plugin/githubactions/golang/create.go +++ b/internal/pkg/plugin/githubactions/golang/create.go @@ -9,16 +9,16 @@ 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ 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..6ba657a66 100644 --- a/internal/pkg/plugin/githubactions/golang/delete.go +++ b/internal/pkg/plugin/githubactions/golang/delete.go @@ -7,12 +7,12 @@ import ( // Delete remove GitHub Actions workflows. func Delete(options map[string]interface{}) (bool, error) { - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 9f6ada1ea..9c2a16d38 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..9e8ca535b 100644 --- a/internal/pkg/plugin/githubactions/golang/update.go +++ b/internal/pkg/plugin/githubactions/golang/update.go @@ -8,17 +8,17 @@ import ( // Update remove and set up GitHub Actions workflows. func Update(options map[string]interface{}) (map[string]interface{}, error) { - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ deleteDockerHubInfoForPush, 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..c06384908 100644 --- a/internal/pkg/plugin/githubactions/nodejs/create.go +++ b/internal/pkg/plugin/githubactions/nodejs/create.go @@ -9,15 +9,15 @@ 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ 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..9edc1646a 100644 --- a/internal/pkg/plugin/githubactions/nodejs/delete.go +++ b/internal/pkg/plugin/githubactions/nodejs/delete.go @@ -7,12 +7,12 @@ import ( // Delete remove GitHub Actions workflows. func Delete(options map[string]interface{}) (bool, error) { - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 639abc87a..02f64c5ee 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..7586fe337 100644 --- a/internal/pkg/plugin/githubactions/nodejs/update.go +++ b/internal/pkg/plugin/githubactions/nodejs/update.go @@ -8,15 +8,15 @@ import ( // Update remove and set up GitHub Actions workflows. func Update(options map[string]interface{}) (map[string]interface{}, error) { - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ 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..3cd3afb38 100644 --- a/internal/pkg/plugin/githubactions/python/create.go +++ b/internal/pkg/plugin/githubactions/python/create.go @@ -9,16 +9,16 @@ 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ 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..8bf0f41e4 100644 --- a/internal/pkg/plugin/githubactions/python/delete.go +++ b/internal/pkg/plugin/githubactions/python/delete.go @@ -7,12 +7,12 @@ import ( // Delete remove GitHub Actions workflows. func Delete(options map[string]interface{}) (bool, error) { - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 69692ea10..6c18a835e 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..6c1d3f968 100644 --- a/internal/pkg/plugin/githubactions/python/update.go +++ b/internal/pkg/plugin/githubactions/python/update.go @@ -8,17 +8,17 @@ import ( // Update remove and set up GitHub Actions workflows. func Update(options map[string]interface{}) (map[string]interface{}, error) { - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, github.BuildWorkFlowsWrapper(workflows), }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ deleteDockerHubInfoForPush, 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..1662bc2e4 100644 --- a/internal/pkg/plugin/gitlabcedocker/create.go +++ b/internal/pkg/plugin/gitlabcedocker/create.go @@ -14,18 +14,18 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // 2. config install operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ dockerInstaller.Validate, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ dockerInstaller.Install, showHelpMsg, }, - TerminateOperations: []plugininstaller.BaseOperation{ + TerminateOperations: plugininstaller.TerminateOperations{ 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..ef894487f 100644 --- a/internal/pkg/plugin/gitlabcedocker/delete.go +++ b/internal/pkg/plugin/gitlabcedocker/delete.go @@ -13,11 +13,11 @@ func Delete(options map[string]interface{}) (bool, error) { } // 2. config delete operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 b8074aa24..222ba0778 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..e56f59189 100644 --- a/internal/pkg/plugin/gitlabcedocker/update.go +++ b/internal/pkg/plugin/gitlabcedocker/update.go @@ -18,16 +18,16 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { opts.RmDataAfterDelete = types.Bool(false) // 2. config install operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ dockerInstaller.Validate, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ dockerInstaller.DeleteAll, 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..01dc08913 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..a94f084c5 100644 --- a/internal/pkg/plugin/harbor/delete.go +++ b/internal/pkg/plugin/harbor/delete.go @@ -7,8 +7,8 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 7746db4d2..c3de25fbd 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..fff8415b2 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..42084dab5 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..c367bfe7e 100644 --- a/internal/pkg/plugin/hashicorpvault/delete.go +++ b/internal/pkg/plugin/hashicorpvault/delete.go @@ -7,8 +7,8 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 5640c7bc1..58042630d 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..179c98abc 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..8e9f87e0e 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..5be100d69 100644 --- a/internal/pkg/plugin/helmgeneric/delete.go +++ b/internal/pkg/plugin/helmgeneric/delete.go @@ -7,8 +7,8 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 3a7b3cc36..d93630594 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..9d10f424e 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..17e03e9ed 100644 --- a/internal/pkg/plugin/jenkins/create.go +++ b/internal/pkg/plugin/jenkins/create.go @@ -9,12 +9,12 @@ import ( // Create creates jenkins with provided options. func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, replaceStroageClass, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ helm.DealWithNsWhenInstall, preCreate, helm.InstallOrUpdate, @@ -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..9969a425c 100644 --- a/internal/pkg/plugin/jenkins/delete.go +++ b/internal/pkg/plugin/jenkins/delete.go @@ -7,12 +7,12 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ helm.Validate, replaceStroageClass, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ helm.Delete, helm.DealWithNsWhenInterruption, postDelete, 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..42bb5f5ab 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..e992474ac 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..fb7ad8a7d 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..ae7a6c8bb 100644 --- a/internal/pkg/plugin/kubeprometheus/delete.go +++ b/internal/pkg/plugin/kubeprometheus/delete.go @@ -7,8 +7,8 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 ea7b74117..78759a4d6 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..6e521b4f3 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..4fd142ae8 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..b9fb6f22f 100644 --- a/internal/pkg/plugin/openldap/delete.go +++ b/internal/pkg/plugin/openldap/delete.go @@ -7,8 +7,8 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 cbf30023c..5a9de0659 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..9038c0e22 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..3262d3023 100644 --- a/internal/pkg/plugin/reposcaffolding/create.go +++ b/internal/pkg/plugin/reposcaffolding/create.go @@ -8,15 +8,15 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ reposcaffolding.Validate, reposcaffolding.SetDefaultTemplateRepo, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ 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..4dc407db0 100644 --- a/internal/pkg/plugin/reposcaffolding/delete.go +++ b/internal/pkg/plugin/reposcaffolding/delete.go @@ -7,12 +7,12 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 8cf3cd2c9..2bc43effd 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..a4831b426 100644 --- a/internal/pkg/plugin/reposcaffolding/update.go +++ b/internal/pkg/plugin/reposcaffolding/update.go @@ -7,16 +7,16 @@ import ( ) func Update(options map[string]interface{}) (map[string]interface{}, error) { - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ reposcaffolding.Validate, reposcaffolding.SetDefaultTemplateRepo, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ 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..064d57106 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..bb54cf95e 100644 --- a/internal/pkg/plugin/tekton/delete.go +++ b/internal/pkg/plugin/tekton/delete.go @@ -7,8 +7,8 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config delete operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 9042c3b32..d2528fa6f 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..f77213ce8 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..88b5acc4a 100644 --- a/internal/pkg/plugin/zentao/create.go +++ b/internal/pkg/plugin/zentao/create.go @@ -7,11 +7,11 @@ import ( func Create(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ goclient.Validate, }, - ExecuteOperations: []plugininstaller.BaseOperation{ + ExecuteOperations: plugininstaller.ExecuteOperations{ goclient.DealWithNsWhenInstall, goclient.CreatePersistentVolumeWrapper(defaultPVPath), goclient.CreatePersistentVolumeClaim, @@ -19,10 +19,10 @@ 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, }, - 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..008abcb76 100644 --- a/internal/pkg/plugin/zentao/delete.go +++ b/internal/pkg/plugin/zentao/delete.go @@ -7,11 +7,11 @@ import ( func Delete(options map[string]interface{}) (bool, error) { // 1. config install operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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 104e2c022..54f51a1dd 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{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + PreExecuteOperations: plugininstaller.PreExecuteOperations{ 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..6458a6f11 100644 --- a/internal/pkg/plugin/zentao/update.go +++ b/internal/pkg/plugin/zentao/update.go @@ -7,20 +7,20 @@ import ( func Update(options map[string]interface{}) (map[string]interface{}, error) { // 1. config install operations - runner := &plugininstaller.Runner{ - PreExecuteOperations: []plugininstaller.MutableOperation{ + runner := &plugininstaller.Operator{ + 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, }, - GetStatusOperation: goclient.GetState, + GetStateOperation: goclient.GetState, } // 2. execute installer get status and error 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 0595da3cd..1e6cdadf3 100644 --- a/internal/pkg/plugininstaller/plugininstaller.go +++ b/internal/pkg/plugininstaller/plugininstaller.go @@ -5,74 +5,74 @@ 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 ( + 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 Runner. -func NewInstaller(preExecOps []MutableOperation, execOps, termiOps []BaseOperation, getStatusOps StatusOperation) Installer { - return &Runner{ - PreExecuteOperations: preExecOps, - ExecuteOperations: execOps, - TerminateOperations: termiOps, - GetStatusOperation: getStatusOps, - } -} - -// Runner is the basic type of Installer, It organize func to run in order -type Runner struct { - PreExecuteOperations []MutableOperation - ExecuteOperations []BaseOperation - TerminateOperations []BaseOperation - GetStatusOperation StatusOperation +// Operator knows all the operations and can execute them in order +type Operator struct { + PreExecuteOperations PreExecuteOperations + ExecuteOperations ExecuteOperations + TerminateOperations TerminateOperations + GetStateOperation GetStateOperation } -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 }