Skip to content

Commit

Permalink
refactor: plugininstaller refactoring and logs optimization
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Hu <tao.hu@merico.dev>
  • Loading branch information
daniel-hutao committed Aug 9, 2022
1 parent a45b3e8 commit 33c62a8
Show file tree
Hide file tree
Showing 68 changed files with 161 additions and 158 deletions.
4 changes: 2 additions & 2 deletions internal/pkg/plugin/argocd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/argocd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/argocd/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/plugin/argocd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/argocdapp/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/argocdapp/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/argocdapp/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/artifactory/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/artifactory/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/artifactory/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/plugin/artifactory/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/devlake/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/devlake/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/devlake/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/githubactions/golang/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/githubactions/golang/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/githubactions/golang/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/githubactions/golang/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/githubactions/nodejs/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
runner := &plugininstaller.Operator{
PreExecuteOperations: []plugininstaller.MutableOperation{
github.Validate,
github.BuildWorkFlowsWrapper(workflows),
},
ExecuteOperations: []plugininstaller.BaseOperation{
github.ProcessAction("create"),
},
GetStatusOperation: github.GetStaticWorkFlowState,
GetStateOperation: github.GetStaticWorkFlowState,
}

// 2. execute installer get status and error
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/githubactions/nodejs/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/githubactions/nodejs/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/githubactions/nodejs/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
runner := &plugininstaller.Operator{
PreExecuteOperations: []plugininstaller.MutableOperation{
github.Validate,
github.BuildWorkFlowsWrapper(workflows),
},
ExecuteOperations: []plugininstaller.BaseOperation{
github.ProcessAction("update"),
},
GetStatusOperation: github.GetActionState,
GetStateOperation: github.GetActionState,
}

status, err := runner.Execute(plugininstaller.RawOptions(options))
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/githubactions/python/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/githubactions/python/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/githubactions/python/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/githubactions/python/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/plugin/gitlabcedocker/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/plugin/gitlabcedocker/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
Loading

0 comments on commit 33c62a8

Please sign in to comment.