diff --git a/cmd/plugin/argocd/main.go b/cmd/plugin/argocd/main.go index d716c7789..256c99e73 100644 --- a/cmd/plugin/argocd/main.go +++ b/cmd/plugin/argocd/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/argocd" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "argocd" type Plugin string // Create implements the create of ArgoCD. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return argocd.Create(options) } // Update implements the update of ArgoCD. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return argocd.Update(options) } // Delete implements the delete of ArgoCD. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return argocd.Delete(options) } // Read implements the read of ArgoCD. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return argocd.Read(options) } diff --git a/cmd/plugin/argocdapp/main.go b/cmd/plugin/argocdapp/main.go index 6032feb12..9b6041cca 100644 --- a/cmd/plugin/argocdapp/main.go +++ b/cmd/plugin/argocdapp/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/argocdapp" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "argocdapp" type Plugin string // Create implements the installation of an ArgoCD app. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return argocdapp.Create(options) } // Update implements the installation of an ArgoCD app. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return argocdapp.Update(options) } // Read implements the healthy check of ArgoCD app. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return argocdapp.Read(options) } // Delete Deletes the installation of an ArgoCD app. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return argocdapp.Delete(options) } diff --git a/cmd/plugin/artifactory/main.go b/cmd/plugin/artifactory/main.go index b46f661db..109a67268 100644 --- a/cmd/plugin/artifactory/main.go +++ b/cmd/plugin/artifactory/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/artifactory" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "artifactory" type Plugin string // Create implements the create of artifactory. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return artifactory.Create(options) } // Update implements the update of artifactory. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return artifactory.Update(options) } // Delete implements the delete of artifactory. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return artifactory.Delete(options) } // Read implements the read of artifactory. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return artifactory.Read(options) } diff --git a/cmd/plugin/ci-generic/main.go b/cmd/plugin/ci-generic/main.go index 127ad6865..5632f8ab2 100644 --- a/cmd/plugin/ci-generic/main.go +++ b/cmd/plugin/ci-generic/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/cigeneric" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "ci-generic" type Plugin string // Create implements the create of ci-generic. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return cigeneric.Create(options) } // Update implements the update of ci-generic. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return cigeneric.Update(options) } // Delete implements the delete of ci-generic. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return cigeneric.Delete(options) } // Read implements the read of ci-generic. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return cigeneric.Read(options) } diff --git a/cmd/plugin/devlake-config/main.go b/cmd/plugin/devlake-config/main.go index b976651ba..0ca594263 100644 --- a/cmd/plugin/devlake-config/main.go +++ b/cmd/plugin/devlake-config/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/devlakeconfig" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "devlake-config" type Plugin string // Create implements the create of devlake-config. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return devlakeconfig.Create(options) } // Update implements the update of devlake-config. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return devlakeconfig.Update(options) } // Delete implements the delete of devlake-config. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return devlakeconfig.Delete(options) } // Read implements the read of devlake-config. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return devlakeconfig.Read(options) } diff --git a/cmd/plugin/devlake/main.go b/cmd/plugin/devlake/main.go index d0044f59a..82966c1f0 100644 --- a/cmd/plugin/devlake/main.go +++ b/cmd/plugin/devlake/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/devlake" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "devlake" type Plugin string // Create implements the create of devlake. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return devlake.Create(options) } // Update implements the update of devlake. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return devlake.Update(options) } // Delete implements the delete of devlake. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return devlake.Delete(options) } // Read implements the read of devlake. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return devlake.Read(options) } diff --git a/cmd/plugin/githubactions-golang/main.go b/cmd/plugin/githubactions-golang/main.go index 19faa5dc6..3ab947d64 100644 --- a/cmd/plugin/githubactions-golang/main.go +++ b/cmd/plugin/githubactions-golang/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/githubactions/golang" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "githubactions-golang" type Plugin string // Create implements the installation of some GitHub Actions workflows. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return golang.Create(options) } // Update implements the installation of some GitHub Actions workflows. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return golang.Update(options) } // Read implements the healthy check of GitHub Actions workflows. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return golang.Read(options) } // Delete implements the installation of some GitHub Actions workflows. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return golang.Delete(options) } diff --git a/cmd/plugin/githubactions-nodejs/main.go b/cmd/plugin/githubactions-nodejs/main.go index 679f7abc9..c8717bc74 100644 --- a/cmd/plugin/githubactions-nodejs/main.go +++ b/cmd/plugin/githubactions-nodejs/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/githubactions/nodejs" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "githubactions-nodejs" type Plugin string // Create implements the installation of some GitHub Actions workflows. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return nodejs.Create(options) } // Update implements the installation of some GitHub Actions workflows. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return nodejs.Update(options) } // Read implements the healthy check of GitHub Actions workflows. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return nodejs.Read(options) } // Delete implements the installation of some GitHub Actions workflows. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return nodejs.Delete(options) } diff --git a/cmd/plugin/githubactions-python/main.go b/cmd/plugin/githubactions-python/main.go index 99fb35975..ecb041fd0 100644 --- a/cmd/plugin/githubactions-python/main.go +++ b/cmd/plugin/githubactions-python/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/githubactions/python" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "githubactions-python" type Plugin string // Create implements the installation of some GitHub Actions workflows. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return python.Create(options) } // Update implements the installation of some GitHub Actions workflows. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return python.Update(options) } // Read implements the healthy check of GitHub Actions workflows. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return python.Read(options) } // Delete implements the installation of some GitHub Actions workflows. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return python.Delete(options) } diff --git a/cmd/plugin/gitlab-ce-docker/main.go b/cmd/plugin/gitlab-ce-docker/main.go index b63ca1243..db1e7318d 100644 --- a/cmd/plugin/gitlab-ce-docker/main.go +++ b/cmd/plugin/gitlab-ce-docker/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/gitlabcedocker" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "gitlab-ce-docker" type Plugin string // Create implements the create of gitlab-ce-docker. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return gitlabcedocker.Create(options) } // Update implements the update of gitlab-ce-docker. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return gitlabcedocker.Update(options) } // Delete implements the delete of gitlab-ce-docker. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return gitlabcedocker.Delete(options) } // Read implements the read of gitlab-ce-docker. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return gitlabcedocker.Read(options) } diff --git a/cmd/plugin/gitlabci-generic/main.go b/cmd/plugin/gitlabci-generic/main.go index 610d1b0a7..11e1be343 100644 --- a/cmd/plugin/gitlabci-generic/main.go +++ b/cmd/plugin/gitlabci-generic/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/gitlabci/generic" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "gitlabci-generic" type Plugin string // Create implements the create of gitlabci-generic. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return generic.Create(options) } // Update implements the update of gitlabci-generic. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return generic.Update(options) } // Delete implements the delete of gitlabci-generic. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return generic.Delete(options) } // Read implements the read of gitlabci-generic. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return generic.Read(options) } diff --git a/cmd/plugin/gitlabci-golang/main.go b/cmd/plugin/gitlabci-golang/main.go index 39eb22539..cd1ed4cb1 100644 --- a/cmd/plugin/gitlabci-golang/main.go +++ b/cmd/plugin/gitlabci-golang/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/gitlabci/golang" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "gitlabci-golang" type Plugin string // Create creates a GitLab CI workflow for Golang. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return golang.Create(options) } // Update updates the GitLab CI workflow for Golang. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return golang.Update(options) } // Read gets the state of the GitLab CI workflow for Golang. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return golang.Read(options) } // Delete deletes the GitLab CI workflow. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return golang.Delete(options) } diff --git a/cmd/plugin/gitlabci-java/main.go b/cmd/plugin/gitlabci-java/main.go index c6953ea83..4ab3c8fea 100644 --- a/cmd/plugin/gitlabci-java/main.go +++ b/cmd/plugin/gitlabci-java/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/gitlabci/java" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "gitlabci-java" type Plugin string // Create implements the create of gitlabci-java. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return java.Create(options) } // Update implements the update of gitlabci-java. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return java.Update(options) } // Delete implements the delete of gitlabci-java. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return java.Delete(options) } // Read implements the read of gitlabci-java. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return java.Read(options) } diff --git a/cmd/plugin/harbor-docker/main.go b/cmd/plugin/harbor-docker/main.go index 2ca633af3..319e5468e 100644 --- a/cmd/plugin/harbor-docker/main.go +++ b/cmd/plugin/harbor-docker/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/harbordocker" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "harbor-docker" type Plugin string // Create implements the create of harbor-docker. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return harbordocker.Create(options) } // Update implements the update of harbor-docker. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return harbordocker.Update(options) } // Delete implements the delete of harbor-docker. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return harbordocker.Delete(options) } // Read implements the read of harbor-docker. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return harbordocker.Read(options) } diff --git a/cmd/plugin/harbor/main.go b/cmd/plugin/harbor/main.go index 0d006f874..657fd3b49 100644 --- a/cmd/plugin/harbor/main.go +++ b/cmd/plugin/harbor/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/harbor" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "harbor" type Plugin string // Create implements the create of harbor. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return harbor.Create(options) } // Update implements the update of harbor. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return harbor.Update(options) } // Delete implements the delete of harbor. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return harbor.Delete(options) } // Read implements the read of harbor. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return harbor.Read(options) } diff --git a/cmd/plugin/hashicorp-vault/main.go b/cmd/plugin/hashicorp-vault/main.go index fa38312dc..31d7a3de5 100644 --- a/cmd/plugin/hashicorp-vault/main.go +++ b/cmd/plugin/hashicorp-vault/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/hashicorpvault" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "hashicorp-vault" type Plugin string // Create implements the create of hashicorp-vault. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return hashicorpvault.Create(options) } // Update implements the update of hashicorp-vault. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return hashicorpvault.Update(options) } // Delete implements the delete of hashicorp-vault. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return hashicorpvault.Delete(options) } // Read implements the read of hashicorp-vault. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return hashicorpvault.Read(options) } diff --git a/cmd/plugin/helm-generic/main.go b/cmd/plugin/helm-generic/main.go index 28e188590..203bb03e4 100644 --- a/cmd/plugin/helm-generic/main.go +++ b/cmd/plugin/helm-generic/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/helmgeneric" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "helm-generic" type Plugin string // Create implements the create of helm-generic. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return helmgeneric.Create(options) } // Update implements the update of helm-generic. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return helmgeneric.Update(options) } // Delete implements the delete of helm-generic. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return helmgeneric.Delete(options) } // Read implements the read of helm-generic. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return helmgeneric.Read(options) } diff --git a/cmd/plugin/jenkins-pipeline/main.go b/cmd/plugin/jenkins-pipeline/main.go index 4aa090788..370fb9f09 100644 --- a/cmd/plugin/jenkins-pipeline/main.go +++ b/cmd/plugin/jenkins-pipeline/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/jenkinspipeline" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "jenkins-pipeline" type Plugin string // Create implements the create of jenkins-pipeline. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return jenkinspipeline.Create(options) } // Update implements the update of jenkins-pipeline. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return jenkinspipeline.Update(options) } // Delete implements the delete of jenkins-pipeline. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return jenkinspipeline.Delete(options) } // Read implements the read of jenkins-pipeline. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return jenkinspipeline.Read(options) } diff --git a/cmd/plugin/jenkins/main.go b/cmd/plugin/jenkins/main.go index 7c4ec0971..147b2e196 100644 --- a/cmd/plugin/jenkins/main.go +++ b/cmd/plugin/jenkins/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/jenkins" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "jenkins" type Plugin string // Create implements the create of the jenkins. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return jenkins.Create(options) } // Update implements the update of the jenkins. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return jenkins.Update(options) } // Read implements read of the jenkins. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return jenkins.Read(options) } // Delete implements the delete of the jenkins. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return jenkins.Delete(options) } diff --git a/cmd/plugin/jira-github-integ/main.go b/cmd/plugin/jira-github-integ/main.go index c07f69dd3..b55c6b9d2 100644 --- a/cmd/plugin/jira-github-integ/main.go +++ b/cmd/plugin/jira-github-integ/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/jiragithub" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "jira-github-integ" type Plugin string // Create implements the installation of some jira-github-integ workflows. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return jiragithub.Create(options) } // Update implements the installation of some jira-github-integ workflows. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return jiragithub.Update(options) } // Read implements the healthy check of jira-github-integ workflows. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return jiragithub.Read(options) } // Delete implements the installation of some jira-github-integ workflows. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return jiragithub.Delete(options) } diff --git a/cmd/plugin/kube-prometheus/main.go b/cmd/plugin/kube-prometheus/main.go index 8310e0db1..8642ed586 100644 --- a/cmd/plugin/kube-prometheus/main.go +++ b/cmd/plugin/kube-prometheus/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/kubeprometheus" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "kube-prometheus" type Plugin string // Create implements the create of the kube-prometheus. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return kubeprometheus.Create(options) } // Update implements the update of the kube-prometheus. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return kubeprometheus.Update(options) } // Read implements read of the kube-prometheus. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return kubeprometheus.Read(options) } // Delete implements the delete of the kube-prometheus. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return kubeprometheus.Delete(options) } diff --git a/cmd/plugin/openldap/main.go b/cmd/plugin/openldap/main.go index 48fb02325..9ba45ad5d 100644 --- a/cmd/plugin/openldap/main.go +++ b/cmd/plugin/openldap/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/openldap" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "openldap" type Plugin string // Create implements the create of OpenLDAP. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return openldap.Create(options) } // Update implements the update of OpenLDAP. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return openldap.Update(options) } // Delete implements the delete of OpenLDAP. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return openldap.Delete(options) } // Read implements the read of OpenLDAP. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return openldap.Read(options) } diff --git a/cmd/plugin/repo-scaffolding/main.go b/cmd/plugin/repo-scaffolding/main.go index 4f9889d58..865a2067b 100644 --- a/cmd/plugin/repo-scaffolding/main.go +++ b/cmd/plugin/repo-scaffolding/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/reposcaffolding" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "repo-scaffolding" type Plugin string // Create implements the create of repo-scaffolding. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return reposcaffolding.Create(options) } // Update implements the update of repo-scaffolding. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return reposcaffolding.Update(options) } // Delete implements the delete of repo-scaffolding. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return reposcaffolding.Delete(options) } // Read implements the read of repo-scaffolding. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return reposcaffolding.Read(options) } diff --git a/cmd/plugin/sonarqube/main.go b/cmd/plugin/sonarqube/main.go index 3ea8b4ba9..f09495f7b 100644 --- a/cmd/plugin/sonarqube/main.go +++ b/cmd/plugin/sonarqube/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/sonarqube" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "sonarqube" type Plugin string // Create implements the create of sonar. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return sonarqube.Create(options) } // Update implements the update of sonar. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return sonarqube.Update(options) } // Delete implements the delete of sonar. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return sonarqube.Delete(options) } // Read implements the read of sonar. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return sonarqube.Read(options) } diff --git a/cmd/plugin/tekton/main.go b/cmd/plugin/tekton/main.go index 6c609b478..a5d288068 100644 --- a/cmd/plugin/tekton/main.go +++ b/cmd/plugin/tekton/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/tekton" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "tekton" type Plugin string // Create implements the create of tekton. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return tekton.Create(options) } // Update implements the update of tekton. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return tekton.Update(options) } // Delete implements the delete of tekton. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return tekton.Delete(options) } // Read implements the read of tekton. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return tekton.Read(options) } diff --git a/cmd/plugin/trello-github-integ/main.go b/cmd/plugin/trello-github-integ/main.go index 370787015..f3b7ef826 100644 --- a/cmd/plugin/trello-github-integ/main.go +++ b/cmd/plugin/trello-github-integ/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/trellogithub" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "trello-github-integ" type Plugin string // Create implements the installation of some trello-github-integ workflows. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return trellogithub.Create(options) } // Update implements the installation of some trello-github-integ workflows. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return trellogithub.Update(options) } // Read implements the healthy check of trello-github-integ workflows. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return trellogithub.Read(options) } // Delete implements the installation of some trello-github-integ workflows. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return trellogithub.Delete(options) } diff --git a/cmd/plugin/trello/main.go b/cmd/plugin/trello/main.go index 25040cae0..85b446202 100644 --- a/cmd/plugin/trello/main.go +++ b/cmd/plugin/trello/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/trello" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "trello" type Plugin string // Create implements the creation of trello board. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return trello.Create(options) } // Update implements the creation of trello board. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return trello.Update(options) } // Read implements the healthy check of trello board. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return trello.Read(options) } // Delete implements the creation of trello board. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return trello.Delete(options) } diff --git a/cmd/plugin/zentao/main.go b/cmd/plugin/zentao/main.go index b49bfe119..4ce8aa1ba 100644 --- a/cmd/plugin/zentao/main.go +++ b/cmd/plugin/zentao/main.go @@ -1,7 +1,9 @@ package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/zentao" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -12,22 +14,22 @@ const NAME = "zentao" type Plugin string // Create implements the create of zentao. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return zentao.Create(options) } // Update implements the update of zentao. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return zentao.Update(options) } // Delete implements the delete of zentao. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return zentao.Delete(options) } // Read implements the read of zentao. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return zentao.Read(options) } diff --git a/docs/development/creating-a-plugin.md b/docs/development/creating-a-plugin.md index f4ad9405f..2b6de38a7 100644 --- a/docs/development/creating-a-plugin.md +++ b/docs/development/creating-a-plugin.md @@ -41,7 +41,7 @@ At the moment, there are 4 interfaces, which might be subject to change. Current ### 2.2 Return Value -`Create`, `Read`, and `Update` interfaces return two values `(map[string]interface{}, error)`; the first being the "state". +`Create`, `Read`, and `Update` interfaces return two values `(statemanager.ResourceStatus, error)`; the first being the "state". `Delete` interface returns two values `(bool, error)`. It returns `(true, nil)` if there is no error; otherwise `(false, error)` will be returned. diff --git a/docs/development/creating-a-plugin.zh.md b/docs/development/creating-a-plugin.zh.md index ecb15a772..58a48564b 100644 --- a/docs/development/creating-a-plugin.zh.md +++ b/docs/development/creating-a-plugin.zh.md @@ -41,7 +41,7 @@ ### 2.2 返回值 -`create`、`read`和`update`方法返回两个值`(map[string]interface{}, error)`;第一个是 "状态"。 +`create`、`read`和`update`方法返回两个值`(statemanager.ResourceStatus, error)`;第一个是 "状态"。 `delete'接口返回两个值`(bool, error)`。如果没有错误,它返回`(true, nil)`;否则将返回`(false, error)`。 diff --git a/internal/pkg/configmanager/toolconfig.go b/internal/pkg/configmanager/toolconfig.go index c30ccebfa..d55f536a2 100644 --- a/internal/pkg/configmanager/toolconfig.go +++ b/internal/pkg/configmanager/toolconfig.go @@ -10,6 +10,8 @@ import ( "github.com/devstream-io/devstream/pkg/util/validator" ) +type RawOptions map[string]interface{} + // Tool is the struct for one section of the DevStream tool file (part of the config.) type Tool struct { Name string `yaml:"name" validate:"required"` @@ -18,9 +20,9 @@ type Tool struct { // contain only lowercase alphanumeric characters, '-' or '.' // start with an alphanumeric character // end with an alphanumeric character - InstanceID string `yaml:"instanceID" validate:"required,dns1123subdomain"` - DependsOn []string `yaml:"dependsOn"` - Options map[string]interface{} `yaml:"options"` + InstanceID string `yaml:"instanceID" validate:"required,dns1123subdomain"` + DependsOn []string `yaml:"dependsOn"` + Options RawOptions `yaml:"options"` } func (t *Tool) Validate() []error { @@ -32,7 +34,7 @@ func (t *Tool) DeepCopy() *Tool { Name: t.Name, InstanceID: t.InstanceID, DependsOn: t.DependsOn, - Options: map[string]interface{}{}, + Options: RawOptions{}, } for k, v := range t.Options { retTool.Options[k] = v diff --git a/internal/pkg/develop/plugin/template/create.go b/internal/pkg/develop/plugin/template/create.go index 034b6c10d..054a5f789 100644 --- a/internal/pkg/develop/plugin/template/create.go +++ b/internal/pkg/develop/plugin/template/create.go @@ -10,7 +10,7 @@ import ( "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -22,14 +22,14 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { TerminateOperations: plugininstaller.TerminateOperations{ // TODO(dtm): Add your TerminateOperations here. }, - GetStatusOperation: func(options plugininstaller.RawOptions) (statemanager.ResourceState, error) { + GetStatusOperation: func(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // TODO(dtm): Add your GetStatusOperation here. return nil, nil }, } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/develop/plugin/template/delete.go b/internal/pkg/develop/plugin/template/delete.go index ae1f9f94d..e13f0b73d 100644 --- a/internal/pkg/develop/plugin/template/delete.go +++ b/internal/pkg/develop/plugin/template/delete.go @@ -5,10 +5,11 @@ var deleteGoDirTpl = "internal/pkg/plugin/[[ .Name | dirFormat ]]/" var deleteGoContentTpl = `package [[ .Name | format ]] import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -20,7 +21,7 @@ func Delete(options map[string]interface{}) (bool, error) { } // Execute all Operations in Operator - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/develop/plugin/template/main.go b/internal/pkg/develop/plugin/template/main.go index 11dfa5103..864f88967 100644 --- a/internal/pkg/develop/plugin/template/main.go +++ b/internal/pkg/develop/plugin/template/main.go @@ -5,7 +5,9 @@ var mainGoDirTpl = "cmd/plugin/[[ .Name ]]/" var mainGoContentTpl = `package main import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/[[ .Name | format ]]" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -16,22 +18,22 @@ const NAME = "[[ .Name ]]" type Plugin string // Create implements the create of [[ .Name ]]. -func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return [[ .Name | format ]].Create(options) } // Update implements the update of [[ .Name ]]. -func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return [[ .Name | format ]].Update(options) } // Delete implements the delete of [[ .Name ]]. -func (p Plugin) Delete(options map[string]interface{}) (bool, error) { +func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) { return [[ .Name | format ]].Delete(options) } // Read implements the read of [[ .Name ]]. -func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { +func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return [[ .Name | format ]].Read(options) } diff --git a/internal/pkg/develop/plugin/template/options.go b/internal/pkg/develop/plugin/template/options.go index d806592ee..327525132 100644 --- a/internal/pkg/develop/plugin/template/options.go +++ b/internal/pkg/develop/plugin/template/options.go @@ -17,7 +17,7 @@ type Options struct { } // NewOptions create options by raw options -func NewOptions(options plugininstaller.RawOptions) (Options, error) { +func NewOptions(options configmanager.RawOptions) (Options, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return opts, err diff --git a/internal/pkg/develop/plugin/template/read.go b/internal/pkg/develop/plugin/template/read.go index 343772a58..ad3273c31 100644 --- a/internal/pkg/develop/plugin/template/read.go +++ b/internal/pkg/develop/plugin/template/read.go @@ -10,20 +10,20 @@ import ( "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ // TODO(dtm): Add your PreExecuteOperations here. }, - GetStatusOperation: func(options plugininstaller.RawOptions) (statemanager.ResourceState, error) { + GetStatusOperation: func(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // TODO(dtm): Add your GetStatusOperation here. return nil, nil }, } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/develop/plugin/template/update.go b/internal/pkg/develop/plugin/template/update.go index da554c5c8..f3579b8ba 100644 --- a/internal/pkg/develop/plugin/template/update.go +++ b/internal/pkg/develop/plugin/template/update.go @@ -10,7 +10,7 @@ import ( "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -22,14 +22,14 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { TerminateOperations: plugininstaller.TerminateOperations{ // TODO(dtm): Add your TerminateOperations here. }, - GetStatusOperation: func(options plugininstaller.RawOptions) (statemanager.ResourceState, error) { + GetStatusOperation: func(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // TODO(dtm): Add your GetStatusOperation here. return nil, nil }, } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/develop/plugin/template/validate.go b/internal/pkg/develop/plugin/template/validate.go index 99ddd5bab..364ec5328 100644 --- a/internal/pkg/develop/plugin/template/validate.go +++ b/internal/pkg/develop/plugin/template/validate.go @@ -13,7 +13,7 @@ import ( ) // validate validates the options provided by the core. -func validate(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func validate(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugin/argocd/create.go b/internal/pkg/plugin/argocd/create.go index c1da951d4..9643f4ce5 100644 --- a/internal/pkg/plugin/argocd/create.go +++ b/internal/pkg/plugin/argocd/create.go @@ -1,13 +1,15 @@ package argocd import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Create creates ArgoCD with provided options. -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -20,7 +22,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/argocd/delete.go b/internal/pkg/plugin/argocd/delete.go index 1837e0d6b..9417adb8b 100644 --- a/internal/pkg/plugin/argocd/delete.go +++ b/internal/pkg/plugin/argocd/delete.go @@ -1,11 +1,12 @@ package argocd import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -14,7 +15,7 @@ func Delete(options map[string]interface{}) (bool, error) { }, ExecuteOperations: helm.DefaultDeleteOperations, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/argocd/read.go b/internal/pkg/plugin/argocd/read.go index 228f9b6e2..94c68df6c 100644 --- a/internal/pkg/plugin/argocd/read.go +++ b/internal/pkg/plugin/argocd/read.go @@ -1,8 +1,10 @@ package argocd import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -10,7 +12,7 @@ const ( ArgocdDefaultNamespace = "argocd" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -21,7 +23,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { } // 2. get plugin status - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/argocd/update.go b/internal/pkg/plugin/argocd/update.go index b80b04d37..b48b6567e 100644 --- a/internal/pkg/plugin/argocd/update.go +++ b/internal/pkg/plugin/argocd/update.go @@ -1,12 +1,14 @@ package argocd import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -18,7 +20,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // 2. update by helm config and get status - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/argocdapp/create.go b/internal/pkg/plugin/argocdapp/create.go index b5750ab10..5c401b801 100644 --- a/internal/pkg/plugin/argocdapp/create.go +++ b/internal/pkg/plugin/argocdapp/create.go @@ -1,14 +1,16 @@ package argocdapp import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/kubectl" + "github.com/devstream-io/devstream/internal/pkg/statemanager" kubectlUtil "github.com/devstream-io/devstream/pkg/util/kubectl" "github.com/devstream-io/devstream/pkg/util/log" ) // Create creates an ArgoCD app YAML and applys it. -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -21,7 +23,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/argocdapp/delete.go b/internal/pkg/plugin/argocdapp/delete.go index b6a1ed9ed..d2a421d89 100644 --- a/internal/pkg/plugin/argocdapp/delete.go +++ b/internal/pkg/plugin/argocdapp/delete.go @@ -1,12 +1,13 @@ package argocdapp import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/kubectl" kubectlUtil "github.com/devstream-io/devstream/pkg/util/kubectl" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -18,7 +19,7 @@ func Delete(options map[string]interface{}) (bool, error) { } // Execute all Operations in Operator - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/argocdapp/options.go b/internal/pkg/plugin/argocdapp/options.go index ad2c5170a..f964d576e 100644 --- a/internal/pkg/plugin/argocdapp/options.go +++ b/internal/pkg/plugin/argocdapp/options.go @@ -3,7 +3,7 @@ package argocdapp import ( "github.com/mitchellh/mapstructure" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" ) // Param is the struct for parameters used by the argocdapp package. @@ -33,7 +33,7 @@ type Source struct { } // / NewOptions create options by raw options -func NewOptions(options plugininstaller.RawOptions) (Options, error) { +func NewOptions(options configmanager.RawOptions) (Options, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return opts, err diff --git a/internal/pkg/plugin/argocdapp/read.go b/internal/pkg/plugin/argocdapp/read.go index f1968d2dc..aad59ace0 100644 --- a/internal/pkg/plugin/argocdapp/read.go +++ b/internal/pkg/plugin/argocdapp/read.go @@ -1,10 +1,12 @@ package argocdapp import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/statemanager" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -14,7 +16,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/argocdapp/state.go b/internal/pkg/plugin/argocdapp/state.go index e5d7e6cb7..a4cc812eb 100644 --- a/internal/pkg/plugin/argocdapp/state.go +++ b/internal/pkg/plugin/argocdapp/state.go @@ -5,38 +5,38 @@ import ( "github.com/cenkalti/backoff" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/k8s" ) -func getStaticStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func getStaticStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { opts, err := NewOptions(options) if err != nil { return nil, err } - res := make(map[string]interface{}) + resStatus := make(statemanager.ResourceStatus) - res["app"] = map[string]interface{}{ + resStatus["app"] = map[string]interface{}{ "name": opts.App.Name, "namespace": opts.App.Namespace, } - res["src"] = map[string]interface{}{ + resStatus["src"] = map[string]interface{}{ "repoURL": opts.Source.RepoURL, "path": opts.Source.Path, "valueFile": opts.Source.Valuefile, } - res["dest"] = map[string]interface{}{ + resStatus["dest"] = map[string]interface{}{ "server": opts.Destination.Server, "namespace": opts.Destination.Namespace, } - return res, nil + return resStatus, nil } -func getDynamicStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func getDynamicStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { opts, err := NewOptions(options) if err != nil { return nil, err @@ -44,7 +44,7 @@ func getDynamicStatus(options plugininstaller.RawOptions) (statemanager.Resource retStatus := make(statemanager.ResourceStatus) operation := func() error { - err := getArgoCDAppFromK8sAndSetState(retStatus, opts.App.Name, opts.App.Namespace) + err := getArgoCDAppFromK8sAndSetStatus(retStatus, opts.App.Name, opts.App.Namespace) if err != nil { return err } @@ -59,7 +59,7 @@ func getDynamicStatus(options plugininstaller.RawOptions) (statemanager.Resource return retStatus, nil } -func getArgoCDAppFromK8sAndSetState(state map[string]interface{}, name, namespace string) error { +func getArgoCDAppFromK8sAndSetStatus(status statemanager.ResourceStatus, name, namespace string) error { kubeClient, err := k8s.NewClient() if err != nil { return err @@ -71,9 +71,9 @@ func getArgoCDAppFromK8sAndSetState(state map[string]interface{}, name, namespac } d := kubeClient.DescribeArgocdApp(app) - state["app"] = d["app"] - state["src"] = d["src"] - state["dest"] = d["dest"] + status["app"] = d["app"] + status["src"] = d["src"] + status["dest"] = d["dest"] return nil } diff --git a/internal/pkg/plugin/argocdapp/update.go b/internal/pkg/plugin/argocdapp/update.go index 0b68ee6df..51afc0031 100644 --- a/internal/pkg/plugin/argocdapp/update.go +++ b/internal/pkg/plugin/argocdapp/update.go @@ -1,5 +1,10 @@ package argocdapp -func Update(options map[string]interface{}) (map[string]interface{}, error) { +import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" +) + +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return Create(options) } diff --git a/internal/pkg/plugin/argocdapp/validate.go b/internal/pkg/plugin/argocdapp/validate.go index 7b2d1db09..3690af6eb 100644 --- a/internal/pkg/plugin/argocdapp/validate.go +++ b/internal/pkg/plugin/argocdapp/validate.go @@ -3,13 +3,13 @@ package argocdapp import ( "fmt" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/validator" ) // validate validates the options provided by the core. -func validate(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func validate(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugin/artifactory/create.go b/internal/pkg/plugin/artifactory/create.go index 1f82c1d63..f8d57c0e8 100644 --- a/internal/pkg/plugin/artifactory/create.go +++ b/internal/pkg/plugin/artifactory/create.go @@ -1,12 +1,14 @@ package artifactory import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -19,7 +21,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/artifactory/delete.go b/internal/pkg/plugin/artifactory/delete.go index 2afdac599..f13845d2e 100644 --- a/internal/pkg/plugin/artifactory/delete.go +++ b/internal/pkg/plugin/artifactory/delete.go @@ -1,11 +1,12 @@ package artifactory import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -14,7 +15,7 @@ func Delete(options map[string]interface{}) (bool, error) { }, ExecuteOperations: helm.DefaultDeleteOperations, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/artifactory/read.go b/internal/pkg/plugin/artifactory/read.go index ff7da78a9..beea2be2d 100644 --- a/internal/pkg/plugin/artifactory/read.go +++ b/internal/pkg/plugin/artifactory/read.go @@ -1,12 +1,14 @@ package artifactory import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -16,7 +18,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: helm.GetAllResourcesStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/artifactory/update.go b/internal/pkg/plugin/artifactory/update.go index bf8c8cbd9..a8efe84e0 100644 --- a/internal/pkg/plugin/artifactory/update.go +++ b/internal/pkg/plugin/artifactory/update.go @@ -1,12 +1,14 @@ package artifactory import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -18,7 +20,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/cigeneric/create.go b/internal/pkg/plugin/cigeneric/create.go index 5ec528c45..ce8c33c2f 100644 --- a/internal/pkg/plugin/cigeneric/create.go +++ b/internal/pkg/plugin/cigeneric/create.go @@ -1,12 +1,14 @@ package cigeneric import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -19,7 +21,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/cigeneric/delete.go b/internal/pkg/plugin/cigeneric/delete.go index 2ca9e420e..776e973a5 100644 --- a/internal/pkg/plugin/cigeneric/delete.go +++ b/internal/pkg/plugin/cigeneric/delete.go @@ -1,11 +1,12 @@ package cigeneric import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -17,7 +18,7 @@ func Delete(options map[string]interface{}) (bool, error) { } // Execute all Operations in Operator - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/cigeneric/read.go b/internal/pkg/plugin/cigeneric/read.go index 861625a32..b164bfbac 100644 --- a/internal/pkg/plugin/cigeneric/read.go +++ b/internal/pkg/plugin/cigeneric/read.go @@ -1,12 +1,14 @@ package cigeneric import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ ci.Validate, @@ -14,7 +16,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: ci.GetCIFileStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/cigeneric/update.go b/internal/pkg/plugin/cigeneric/update.go index 06fca0fc7..defa4c13a 100644 --- a/internal/pkg/plugin/cigeneric/update.go +++ b/internal/pkg/plugin/cigeneric/update.go @@ -1,5 +1,10 @@ package cigeneric -func Update(options map[string]interface{}) (map[string]interface{}, error) { +import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" +) + +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return Create(options) } diff --git a/internal/pkg/plugin/devlake/create.go b/internal/pkg/plugin/devlake/create.go index 985bc797e..237dadc15 100644 --- a/internal/pkg/plugin/devlake/create.go +++ b/internal/pkg/plugin/devlake/create.go @@ -1,12 +1,14 @@ package devlake import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -19,7 +21,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/devlake/delete.go b/internal/pkg/plugin/devlake/delete.go index fabe2aef5..39c6b0393 100644 --- a/internal/pkg/plugin/devlake/delete.go +++ b/internal/pkg/plugin/devlake/delete.go @@ -1,11 +1,12 @@ package devlake import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -16,7 +17,7 @@ func Delete(options map[string]interface{}) (bool, error) { } // Execute all Operations in Operator - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/devlake/devlake.go b/internal/pkg/plugin/devlake/devlake.go index bd9fe2e1e..220a15ccf 100644 --- a/internal/pkg/plugin/devlake/devlake.go +++ b/internal/pkg/plugin/devlake/devlake.go @@ -3,7 +3,7 @@ package devlake import ( "fmt" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" "github.com/devstream-io/devstream/internal/pkg/statemanager" helmCommon "github.com/devstream-io/devstream/pkg/util/helm" @@ -30,7 +30,7 @@ var defaultHelmConfig = helm.Options{ }, } -func genDevLakeStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func genDevLakeStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { resStatus, err := helm.GetAllResourcesStatus(options) if err != nil { return nil, err @@ -50,7 +50,7 @@ func genDevLakeStatus(options plugininstaller.RawOptions) (statemanager.Resource return nil, err } url := fmt.Sprintf("http://%s:8080", ip) - outputs := map[string]interface{}{ + outputs := statemanager.ResourceOutputs{ "devlake_url": url, } resStatus.SetOutputs(outputs) diff --git a/internal/pkg/plugin/devlake/read.go b/internal/pkg/plugin/devlake/read.go index 63c1e4f16..ec8845774 100644 --- a/internal/pkg/plugin/devlake/read.go +++ b/internal/pkg/plugin/devlake/read.go @@ -1,12 +1,14 @@ package devlake import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -17,7 +19,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/devlake/update.go b/internal/pkg/plugin/devlake/update.go index 32ccad8c7..3c96f3157 100644 --- a/internal/pkg/plugin/devlake/update.go +++ b/internal/pkg/plugin/devlake/update.go @@ -1,12 +1,14 @@ package devlake import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -18,7 +20,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/devlakeconfig/create.go b/internal/pkg/plugin/devlakeconfig/create.go index fc1177e3b..e50ffc4b1 100644 --- a/internal/pkg/plugin/devlakeconfig/create.go +++ b/internal/pkg/plugin/devlakeconfig/create.go @@ -1,11 +1,13 @@ package devlakeconfig import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -22,7 +24,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/devlakeconfig/delete.go b/internal/pkg/plugin/devlakeconfig/delete.go index 0839d0060..c488dc099 100644 --- a/internal/pkg/plugin/devlakeconfig/delete.go +++ b/internal/pkg/plugin/devlakeconfig/delete.go @@ -1,10 +1,11 @@ package devlakeconfig import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -17,7 +18,7 @@ func Delete(options map[string]interface{}) (bool, error) { } // Execute all Operations in Operator - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/devlakeconfig/devlakeconfig.go b/internal/pkg/plugin/devlakeconfig/devlakeconfig.go index c87351877..f6a0e7433 100644 --- a/internal/pkg/plugin/devlakeconfig/devlakeconfig.go +++ b/internal/pkg/plugin/devlakeconfig/devlakeconfig.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -17,7 +17,7 @@ var httpClient = &http.Client{ Timeout: 5 * time.Second, } -func RenderAuthConfig(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func RenderAuthConfig(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewOptions(options) if err != nil { return nil, err @@ -36,7 +36,7 @@ func RenderAuthConfig(options plugininstaller.RawOptions) (plugininstaller.RawOp return opts.Encode() } -func ApplyConfig(options plugininstaller.RawOptions) error { +func ApplyConfig(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err @@ -93,17 +93,17 @@ func createConnection(url string, bodyWithJson []byte) error { return fmt.Errorf(resp.Status) } -func DeleteConfig(options plugininstaller.RawOptions) error { +func DeleteConfig(options configmanager.RawOptions) error { // TODO(daniel-hutao): implement later return nil } -func UpdateConfig(options plugininstaller.RawOptions) error { +func UpdateConfig(options configmanager.RawOptions) error { // TODO(daniel-hutao): implement later return nil } -func GetStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func GetStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { resStatus := statemanager.ResourceStatus(options) return resStatus, nil } diff --git a/internal/pkg/plugin/devlakeconfig/options.go b/internal/pkg/plugin/devlakeconfig/options.go index 17994326c..258cb7611 100644 --- a/internal/pkg/plugin/devlakeconfig/options.go +++ b/internal/pkg/plugin/devlakeconfig/options.go @@ -3,8 +3,8 @@ package devlakeconfig import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/devlakeconfig/staging" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" ) // Options is the struct for configurations of the devlake-config plugin. @@ -14,7 +14,7 @@ type Options struct { } // NewOptions create options by raw options -func NewOptions(options plugininstaller.RawOptions) (Options, error) { +func NewOptions(options configmanager.RawOptions) (Options, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return opts, err @@ -53,8 +53,8 @@ type Auth struct { staging.AppKey `mapstructure:",squash"` } -func (o *Options) Encode() (map[string]interface{}, error) { - var options map[string]interface{} +func (o *Options) Encode() (configmanager.RawOptions, error) { + var options configmanager.RawOptions if err := mapstructure.Decode(o, &options); err != nil { return nil, err } diff --git a/internal/pkg/plugin/devlakeconfig/read.go b/internal/pkg/plugin/devlakeconfig/read.go index 19af27b97..5119d5139 100644 --- a/internal/pkg/plugin/devlakeconfig/read.go +++ b/internal/pkg/plugin/devlakeconfig/read.go @@ -1,11 +1,13 @@ package devlakeconfig import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -16,7 +18,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/devlakeconfig/update.go b/internal/pkg/plugin/devlakeconfig/update.go index 86faee80d..4a7216400 100644 --- a/internal/pkg/plugin/devlakeconfig/update.go +++ b/internal/pkg/plugin/devlakeconfig/update.go @@ -1,11 +1,13 @@ package devlakeconfig import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -22,7 +24,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/devlakeconfig/validate.go b/internal/pkg/plugin/devlakeconfig/validate.go index 3c23d084f..18c43b6ca 100644 --- a/internal/pkg/plugin/devlakeconfig/validate.go +++ b/internal/pkg/plugin/devlakeconfig/validate.go @@ -3,13 +3,13 @@ package devlakeconfig import ( "fmt" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/validator" ) // validate validates the options provided by the core. -func validate(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func validate(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugin/githubactions/golang/create.go b/internal/pkg/plugin/githubactions/golang/create.go index 37f90bc97..cda33a978 100644 --- a/internal/pkg/plugin/githubactions/golang/create.go +++ b/internal/pkg/plugin/githubactions/golang/create.go @@ -1,13 +1,15 @@ package golang import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Create sets up GitHub Actions workflow(s). -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -22,7 +24,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/githubactions/golang/delete.go b/internal/pkg/plugin/githubactions/golang/delete.go index 7f51999e7..c534dcf8d 100644 --- a/internal/pkg/plugin/githubactions/golang/delete.go +++ b/internal/pkg/plugin/githubactions/golang/delete.go @@ -1,12 +1,13 @@ package golang import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" ) // Delete remove GitHub Actions workflows. -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, @@ -18,7 +19,7 @@ func Delete(options map[string]interface{}) (bool, error) { }, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/githubactions/golang/precreate.go b/internal/pkg/plugin/githubactions/golang/precreate.go index d20da7684..495d7ef14 100644 --- a/internal/pkg/plugin/githubactions/golang/precreate.go +++ b/internal/pkg/plugin/githubactions/golang/precreate.go @@ -5,11 +5,11 @@ import ( "github.com/spf13/viper" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" ) -func createDockerHubInfoForPush(options plugininstaller.RawOptions) error { +func createDockerHubInfoForPush(options configmanager.RawOptions) error { opts, err := github.NewGithubActionOptions(options) if err != nil { return err @@ -37,7 +37,7 @@ func createDockerHubInfoForPush(options plugininstaller.RawOptions) error { return nil } -func deleteDockerHubInfoForPush(options plugininstaller.RawOptions) error { +func deleteDockerHubInfoForPush(options configmanager.RawOptions) error { opts, err := github.NewGithubActionOptions(options) if err != nil { return err diff --git a/internal/pkg/plugin/githubactions/golang/read.go b/internal/pkg/plugin/githubactions/golang/read.go index 20148bd91..e9d65fd44 100644 --- a/internal/pkg/plugin/githubactions/golang/read.go +++ b/internal/pkg/plugin/githubactions/golang/read.go @@ -1,11 +1,13 @@ package golang import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" + "github.com/devstream-io/devstream/internal/pkg/statemanager" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, @@ -14,7 +16,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: github.GetActionStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/githubactions/golang/update.go b/internal/pkg/plugin/githubactions/golang/update.go index 31ede157c..f80fa5bbb 100644 --- a/internal/pkg/plugin/githubactions/golang/update.go +++ b/internal/pkg/plugin/githubactions/golang/update.go @@ -1,13 +1,15 @@ package golang import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Update remove and set up GitHub Actions workflows. -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ validate, @@ -21,7 +23,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: github.GetActionStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/githubactions/golang/validate.go b/internal/pkg/plugin/githubactions/golang/validate.go index b40d82c1f..27a9816bc 100644 --- a/internal/pkg/plugin/githubactions/golang/validate.go +++ b/internal/pkg/plugin/githubactions/golang/validate.go @@ -3,13 +3,13 @@ package golang import ( "fmt" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/validator" ) -func validate(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func validate(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := github.NewGithubActionOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugin/githubactions/nodejs/create.go b/internal/pkg/plugin/githubactions/nodejs/create.go index a0dc6718d..33531325a 100644 --- a/internal/pkg/plugin/githubactions/nodejs/create.go +++ b/internal/pkg/plugin/githubactions/nodejs/create.go @@ -1,13 +1,15 @@ package nodejs import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Create sets up GitHub Actions workflow(s). -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -21,7 +23,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/githubactions/nodejs/delete.go b/internal/pkg/plugin/githubactions/nodejs/delete.go index dcda12137..33eeaceef 100644 --- a/internal/pkg/plugin/githubactions/nodejs/delete.go +++ b/internal/pkg/plugin/githubactions/nodejs/delete.go @@ -1,12 +1,13 @@ package nodejs import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" ) // Delete remove GitHub Actions workflows. -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, @@ -17,7 +18,7 @@ func Delete(options map[string]interface{}) (bool, error) { }, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/githubactions/nodejs/read.go b/internal/pkg/plugin/githubactions/nodejs/read.go index d543ef1b8..d9986ffad 100644 --- a/internal/pkg/plugin/githubactions/nodejs/read.go +++ b/internal/pkg/plugin/githubactions/nodejs/read.go @@ -1,11 +1,13 @@ package nodejs import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" + "github.com/devstream-io/devstream/internal/pkg/statemanager" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, @@ -14,7 +16,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: github.GetActionStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/githubactions/nodejs/update.go b/internal/pkg/plugin/githubactions/nodejs/update.go index 6899ab5ba..594659805 100644 --- a/internal/pkg/plugin/githubactions/nodejs/update.go +++ b/internal/pkg/plugin/githubactions/nodejs/update.go @@ -1,13 +1,15 @@ package nodejs import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Update remove and set up GitHub Actions workflows. -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, @@ -19,7 +21,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: github.GetActionStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/githubactions/python/create.go b/internal/pkg/plugin/githubactions/python/create.go index 62d5827b7..4d185222a 100644 --- a/internal/pkg/plugin/githubactions/python/create.go +++ b/internal/pkg/plugin/githubactions/python/create.go @@ -1,13 +1,15 @@ package python import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Create sets up GitHub Actions workflow(s). -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -22,7 +24,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/githubactions/python/delete.go b/internal/pkg/plugin/githubactions/python/delete.go index e0cbc8408..6dd38036f 100644 --- a/internal/pkg/plugin/githubactions/python/delete.go +++ b/internal/pkg/plugin/githubactions/python/delete.go @@ -1,12 +1,13 @@ package python import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" ) // Delete remove GitHub Actions workflows. -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, @@ -18,7 +19,7 @@ func Delete(options map[string]interface{}) (bool, error) { }, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/githubactions/python/precreate.go b/internal/pkg/plugin/githubactions/python/precreate.go index 0cdbccb7a..4fadc9fa0 100644 --- a/internal/pkg/plugin/githubactions/python/precreate.go +++ b/internal/pkg/plugin/githubactions/python/precreate.go @@ -5,11 +5,11 @@ import ( "github.com/spf13/viper" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" ) -func createDockerHubInfoForPush(options plugininstaller.RawOptions) error { +func createDockerHubInfoForPush(options configmanager.RawOptions) error { opts, err := github.NewGithubActionOptions(options) if err != nil { return err @@ -33,7 +33,7 @@ func createDockerHubInfoForPush(options plugininstaller.RawOptions) error { return nil } -func deleteDockerHubInfoForPush(options plugininstaller.RawOptions) error { +func deleteDockerHubInfoForPush(options configmanager.RawOptions) error { opts, err := github.NewGithubActionOptions(options) if err != nil { return err diff --git a/internal/pkg/plugin/githubactions/python/read.go b/internal/pkg/plugin/githubactions/python/read.go index 996a7d285..e330c2ee4 100644 --- a/internal/pkg/plugin/githubactions/python/read.go +++ b/internal/pkg/plugin/githubactions/python/read.go @@ -1,11 +1,13 @@ package python import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" + "github.com/devstream-io/devstream/internal/pkg/statemanager" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, @@ -14,7 +16,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: github.GetActionStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/githubactions/python/update.go b/internal/pkg/plugin/githubactions/python/update.go index 04a1c144d..697425394 100644 --- a/internal/pkg/plugin/githubactions/python/update.go +++ b/internal/pkg/plugin/githubactions/python/update.go @@ -1,13 +1,15 @@ package python import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/github" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Update remove and set up GitHub Actions workflows. -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ github.Validate, @@ -21,7 +23,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: github.GetActionStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/gitlabcedocker/create.go b/internal/pkg/plugin/gitlabcedocker/create.go index 1c15f69df..997aa456e 100644 --- a/internal/pkg/plugin/gitlabcedocker/create.go +++ b/internal/pkg/plugin/gitlabcedocker/create.go @@ -1,13 +1,15 @@ package gitlabcedocker import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" dockerInstaller "github.com/devstream-io/devstream/internal/pkg/plugininstaller/docker" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/types" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // 1. create config and pre-handle operations opts, err := validateAndDefault(options) if err != nil { diff --git a/internal/pkg/plugin/gitlabcedocker/delete.go b/internal/pkg/plugin/gitlabcedocker/delete.go index 32bcd1503..5883a7242 100644 --- a/internal/pkg/plugin/gitlabcedocker/delete.go +++ b/internal/pkg/plugin/gitlabcedocker/delete.go @@ -1,12 +1,13 @@ package gitlabcedocker import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" dockerInstaller "github.com/devstream-io/devstream/internal/pkg/plugininstaller/docker" "github.com/devstream-io/devstream/pkg/util/types" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // 1. create config and pre-handle operations opts, err := validateAndDefault(options) if err != nil { diff --git a/internal/pkg/plugin/gitlabcedocker/options.go b/internal/pkg/plugin/gitlabcedocker/options.go index 0958a75ab..9efe837de 100644 --- a/internal/pkg/plugin/gitlabcedocker/options.go +++ b/internal/pkg/plugin/gitlabcedocker/options.go @@ -4,7 +4,7 @@ import ( "fmt" "path/filepath" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" dockerInstaller "github.com/devstream-io/devstream/internal/pkg/plugininstaller/docker" "github.com/devstream-io/devstream/pkg/util/docker" "github.com/devstream-io/devstream/pkg/util/log" @@ -56,7 +56,7 @@ func (opts *Options) setGitLabURL() { gitlabURL = fmt.Sprintf("http://%s:%d", opts.Hostname, opts.HTTPPort) } -func showHelpMsg(options plugininstaller.RawOptions) error { +func showHelpMsg(options configmanager.RawOptions) error { log.Infof("GitLab access URL: %s", gitlabURL) log.Infof("GitLab initial root password: execute the command -> docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password") diff --git a/internal/pkg/plugin/gitlabcedocker/read.go b/internal/pkg/plugin/gitlabcedocker/read.go index 5b07a2cfc..d547b0a14 100644 --- a/internal/pkg/plugin/gitlabcedocker/read.go +++ b/internal/pkg/plugin/gitlabcedocker/read.go @@ -1,13 +1,15 @@ package gitlabcedocker import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" dockerInstaller "github.com/devstream-io/devstream/internal/pkg/plugininstaller/docker" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/types" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // 1. create config and pre-handle operations opts, err := validateAndDefault(options) if err != nil { diff --git a/internal/pkg/plugin/gitlabcedocker/update.go b/internal/pkg/plugin/gitlabcedocker/update.go index a81515d62..a4e2706f9 100644 --- a/internal/pkg/plugin/gitlabcedocker/update.go +++ b/internal/pkg/plugin/gitlabcedocker/update.go @@ -1,13 +1,15 @@ package gitlabcedocker import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" dockerInstaller "github.com/devstream-io/devstream/internal/pkg/plugininstaller/docker" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/types" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // 1. create config and pre-handle operations opts, err := validateAndDefault(options) if err != nil { diff --git a/internal/pkg/plugin/gitlabcedocker/validate.go b/internal/pkg/plugin/gitlabcedocker/validate.go index 08f53e1da..7695d613e 100644 --- a/internal/pkg/plugin/gitlabcedocker/validate.go +++ b/internal/pkg/plugin/gitlabcedocker/validate.go @@ -5,13 +5,15 @@ import ( "os" "path/filepath" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/mitchellh/mapstructure" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/validator" ) -func validateAndDefault(options map[string]interface{}) (*Options, error) { +func validateAndDefault(options configmanager.RawOptions) (*Options, error) { var opts *Options if err := mapstructure.Decode(options, &opts); err != nil { return nil, err diff --git a/internal/pkg/plugin/gitlabci/generic/create.go b/internal/pkg/plugin/gitlabci/generic/create.go index e8683456c..1a9818e6b 100644 --- a/internal/pkg/plugin/gitlabci/generic/create.go +++ b/internal/pkg/plugin/gitlabci/generic/create.go @@ -1,13 +1,15 @@ package generic import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/gitlabci" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ ci.SetDefaultConfig(gitlabci.DefaultCIOptions), @@ -20,7 +22,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/gitlabci/generic/delete.go b/internal/pkg/plugin/gitlabci/generic/delete.go index 40a700c2e..eebdd8c98 100644 --- a/internal/pkg/plugin/gitlabci/generic/delete.go +++ b/internal/pkg/plugin/gitlabci/generic/delete.go @@ -1,12 +1,13 @@ package generic import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/gitlabci" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ ci.SetDefaultConfig(gitlabci.DefaultCIOptions), @@ -18,7 +19,7 @@ func Delete(options map[string]interface{}) (bool, error) { } // Execute all Operations in Operator - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/gitlabci/generic/read.go b/internal/pkg/plugin/gitlabci/generic/read.go index d07d570af..069f42c77 100644 --- a/internal/pkg/plugin/gitlabci/generic/read.go +++ b/internal/pkg/plugin/gitlabci/generic/read.go @@ -1,13 +1,15 @@ package generic import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/gitlabci" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ ci.SetDefaultConfig(gitlabci.DefaultCIOptions), @@ -16,7 +18,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: ci.GetCIFileStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/gitlabci/generic/update.go b/internal/pkg/plugin/gitlabci/generic/update.go index 0c79cc921..d28183ef7 100644 --- a/internal/pkg/plugin/gitlabci/generic/update.go +++ b/internal/pkg/plugin/gitlabci/generic/update.go @@ -1,5 +1,10 @@ package generic -func Update(options map[string]interface{}) (map[string]interface{}, error) { +import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" +) + +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return Create(options) } diff --git a/internal/pkg/plugin/gitlabci/golang/create.go b/internal/pkg/plugin/gitlabci/golang/create.go index a5094ef5e..18a9b0ebd 100644 --- a/internal/pkg/plugin/gitlabci/golang/create.go +++ b/internal/pkg/plugin/gitlabci/golang/create.go @@ -1,13 +1,15 @@ package golang import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/gitlabci" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ ci.SetDefaultConfig(gitlabci.DefaultCIOptions), @@ -21,7 +23,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/gitlabci/golang/delete.go b/internal/pkg/plugin/gitlabci/golang/delete.go index 29ba4b2c4..95053a5c0 100644 --- a/internal/pkg/plugin/gitlabci/golang/delete.go +++ b/internal/pkg/plugin/gitlabci/golang/delete.go @@ -1,12 +1,13 @@ package golang import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/gitlabci" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ ci.SetDefaultConfig(gitlabci.DefaultCIOptions), @@ -19,7 +20,7 @@ func Delete(options map[string]interface{}) (bool, error) { } // Execute all Operations in Operator - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/gitlabci/golang/golang.go b/internal/pkg/plugin/gitlabci/golang/golang.go index 08c32d81a..3d132df24 100644 --- a/internal/pkg/plugin/gitlabci/golang/golang.go +++ b/internal/pkg/plugin/gitlabci/golang/golang.go @@ -1,13 +1,13 @@ package golang import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" "github.com/devstream-io/devstream/pkg/util/scm/gitlab" "github.com/devstream-io/devstream/pkg/util/types" ) -func setCIContent(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func setCIContent(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := ci.NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugin/gitlabci/golang/read.go b/internal/pkg/plugin/gitlabci/golang/read.go index df3254fc8..d3aa28b84 100644 --- a/internal/pkg/plugin/gitlabci/golang/read.go +++ b/internal/pkg/plugin/gitlabci/golang/read.go @@ -1,13 +1,15 @@ package golang import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugin/gitlabci" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ ci.SetDefaultConfig(gitlabci.DefaultCIOptions), @@ -17,7 +19,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: ci.GetCIFileStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/gitlabci/golang/update.go b/internal/pkg/plugin/gitlabci/golang/update.go index 896dc9027..54e31f908 100644 --- a/internal/pkg/plugin/gitlabci/golang/update.go +++ b/internal/pkg/plugin/gitlabci/golang/update.go @@ -1,5 +1,10 @@ package golang -func Update(options map[string]interface{}) (map[string]interface{}, error) { +import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" +) + +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return Create(options) } diff --git a/internal/pkg/plugin/gitlabci/java/create.go b/internal/pkg/plugin/gitlabci/java/create.go index 19e1ce7ce..78412de06 100644 --- a/internal/pkg/plugin/gitlabci/java/create.go +++ b/internal/pkg/plugin/gitlabci/java/create.go @@ -5,11 +5,13 @@ import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/scm/git" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return nil, err diff --git a/internal/pkg/plugin/gitlabci/java/delete.go b/internal/pkg/plugin/gitlabci/java/delete.go index aba4c42d3..20788b7ad 100644 --- a/internal/pkg/plugin/gitlabci/java/delete.go +++ b/internal/pkg/plugin/gitlabci/java/delete.go @@ -5,11 +5,12 @@ import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/scm/git" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return false, err diff --git a/internal/pkg/plugin/gitlabci/java/read.go b/internal/pkg/plugin/gitlabci/java/read.go index 1e5daf04a..2b832ce87 100644 --- a/internal/pkg/plugin/gitlabci/java/read.go +++ b/internal/pkg/plugin/gitlabci/java/read.go @@ -5,10 +5,12 @@ import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return nil, err diff --git a/internal/pkg/plugin/gitlabci/java/update.go b/internal/pkg/plugin/gitlabci/java/update.go index b8f7d6761..d26a7bab9 100644 --- a/internal/pkg/plugin/gitlabci/java/update.go +++ b/internal/pkg/plugin/gitlabci/java/update.go @@ -5,11 +5,13 @@ import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/scm/git" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return nil, err diff --git a/internal/pkg/plugin/harbor/create.go b/internal/pkg/plugin/harbor/create.go index f54b7f7fa..8be848b3c 100644 --- a/internal/pkg/plugin/harbor/create.go +++ b/internal/pkg/plugin/harbor/create.go @@ -1,12 +1,14 @@ package harbor import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -19,7 +21,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/harbor/delete.go b/internal/pkg/plugin/harbor/delete.go index 686c004bb..dbb6a82f2 100644 --- a/internal/pkg/plugin/harbor/delete.go +++ b/internal/pkg/plugin/harbor/delete.go @@ -1,11 +1,12 @@ package harbor import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -16,7 +17,7 @@ func Delete(options map[string]interface{}) (bool, error) { } // Execute all Operations in Operator - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/harbor/read.go b/internal/pkg/plugin/harbor/read.go index 9bb0c5059..0d9a4333e 100644 --- a/internal/pkg/plugin/harbor/read.go +++ b/internal/pkg/plugin/harbor/read.go @@ -1,12 +1,14 @@ package harbor import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -17,7 +19,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/harbor/update.go b/internal/pkg/plugin/harbor/update.go index 64317b588..1f378b71e 100644 --- a/internal/pkg/plugin/harbor/update.go +++ b/internal/pkg/plugin/harbor/update.go @@ -1,12 +1,14 @@ package harbor import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -18,7 +20,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/harbordocker/create.go b/internal/pkg/plugin/harbordocker/create.go index 0c0723cb6..708ca8902 100644 --- a/internal/pkg/plugin/harbordocker/create.go +++ b/internal/pkg/plugin/harbordocker/create.go @@ -1,12 +1,14 @@ package harbordocker import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" dockerInstaller "github.com/devstream-io/devstream/internal/pkg/plugininstaller/docker" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -19,7 +21,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - state, err := operator.Execute(plugininstaller.RawOptions(options)) + state, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/harbordocker/delete.go b/internal/pkg/plugin/harbordocker/delete.go index 719b6af86..a3ed371aa 100644 --- a/internal/pkg/plugin/harbordocker/delete.go +++ b/internal/pkg/plugin/harbordocker/delete.go @@ -1,11 +1,12 @@ package harbordocker import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" dockerInstaller "github.com/devstream-io/devstream/internal/pkg/plugininstaller/docker" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -18,7 +19,7 @@ func Delete(options map[string]interface{}) (bool, error) { } // Execute all Operations in Operator - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/harbordocker/harbordocker.go b/internal/pkg/plugin/harbordocker/harbordocker.go index 7af4831cd..16fa7dc29 100644 --- a/internal/pkg/plugin/harbordocker/harbordocker.go +++ b/internal/pkg/plugin/harbordocker/harbordocker.go @@ -6,7 +6,7 @@ import ( "github.com/mitchellh/mapstructure" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/docker/dockersh" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/template" @@ -37,7 +37,7 @@ var scripts = map[string]string{ HarborScriptPrepareFileName: ScriptPrepare, } -func Install(options plugininstaller.RawOptions) error { +func Install(options configmanager.RawOptions) error { if err := writeScripts(); err != nil { return err } @@ -51,7 +51,7 @@ func Install(options plugininstaller.RawOptions) error { } // renderConfig will render HarborConfigTemplate and then write it to disk. -func renderConfig(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func renderConfig(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts := Options{} if err := mapstructure.Decode(options, &opts); err != nil { return nil, err diff --git a/internal/pkg/plugin/harbordocker/read.go b/internal/pkg/plugin/harbordocker/read.go index ceca57198..f6c3ceb67 100644 --- a/internal/pkg/plugin/harbordocker/read.go +++ b/internal/pkg/plugin/harbordocker/read.go @@ -1,12 +1,14 @@ package harbordocker import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" dockerInstaller "github.com/devstream-io/devstream/internal/pkg/plugininstaller/docker" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -16,7 +18,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - state, err := operator.Execute(plugininstaller.RawOptions(options)) + state, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/harbordocker/update.go b/internal/pkg/plugin/harbordocker/update.go index a13c7ee63..b8f574b9c 100644 --- a/internal/pkg/plugin/harbordocker/update.go +++ b/internal/pkg/plugin/harbordocker/update.go @@ -1,12 +1,14 @@ package harbordocker import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" dockerInstaller "github.com/devstream-io/devstream/internal/pkg/plugininstaller/docker" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -20,7 +22,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - state, err := operator.Execute(plugininstaller.RawOptions(options)) + state, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/hashicorpvault/create.go b/internal/pkg/plugin/hashicorpvault/create.go index 9ebd18b78..101e76fb4 100644 --- a/internal/pkg/plugin/hashicorpvault/create.go +++ b/internal/pkg/plugin/hashicorpvault/create.go @@ -1,13 +1,15 @@ package hashicorpvault import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Create creates hashicorp-vault with provided options. -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -20,7 +22,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/hashicorpvault/delete.go b/internal/pkg/plugin/hashicorpvault/delete.go index fba1f57e1..1d374e7fb 100644 --- a/internal/pkg/plugin/hashicorpvault/delete.go +++ b/internal/pkg/plugin/hashicorpvault/delete.go @@ -1,11 +1,12 @@ package hashicorpvault import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -14,7 +15,7 @@ func Delete(options map[string]interface{}) (bool, error) { }, ExecuteOperations: helm.DefaultDeleteOperations, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/hashicorpvault/read.go b/internal/pkg/plugin/hashicorpvault/read.go index dee3a43c7..ea76c3c37 100644 --- a/internal/pkg/plugin/hashicorpvault/read.go +++ b/internal/pkg/plugin/hashicorpvault/read.go @@ -1,12 +1,14 @@ package hashicorpvault import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -16,7 +18,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: helm.GetAllResourcesStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/hashicorpvault/update.go b/internal/pkg/plugin/hashicorpvault/update.go index c97be2ce8..7cb75040e 100644 --- a/internal/pkg/plugin/hashicorpvault/update.go +++ b/internal/pkg/plugin/hashicorpvault/update.go @@ -1,12 +1,14 @@ package hashicorpvault import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -18,7 +20,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/helmgeneric/create.go b/internal/pkg/plugin/helmgeneric/create.go index edff5079e..1d2f74a94 100644 --- a/internal/pkg/plugin/helmgeneric/create.go +++ b/internal/pkg/plugin/helmgeneric/create.go @@ -1,13 +1,15 @@ package helmgeneric import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Create creates helmgeneric with provided options. -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -19,7 +21,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/helmgeneric/delete.go b/internal/pkg/plugin/helmgeneric/delete.go index 82cc0322c..d992bf674 100644 --- a/internal/pkg/plugin/helmgeneric/delete.go +++ b/internal/pkg/plugin/helmgeneric/delete.go @@ -1,11 +1,12 @@ package helmgeneric import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -13,7 +14,7 @@ func Delete(options map[string]interface{}) (bool, error) { }, ExecuteOperations: helm.DefaultDeleteOperations, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/helmgeneric/read.go b/internal/pkg/plugin/helmgeneric/read.go index ddf52b754..8f8c638be 100644 --- a/internal/pkg/plugin/helmgeneric/read.go +++ b/internal/pkg/plugin/helmgeneric/read.go @@ -1,12 +1,14 @@ package helmgeneric import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -15,7 +17,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: getEmptyStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/helmgeneric/state.go b/internal/pkg/plugin/helmgeneric/state.go index a49bab599..af5da6f0e 100644 --- a/internal/pkg/plugin/helmgeneric/state.go +++ b/internal/pkg/plugin/helmgeneric/state.go @@ -1,12 +1,12 @@ package helmgeneric import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/statemanager" ) // return empty -func getEmptyStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func getEmptyStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { retStatus := make(statemanager.ResourceStatus) return retStatus, nil } diff --git a/internal/pkg/plugin/helmgeneric/update.go b/internal/pkg/plugin/helmgeneric/update.go index 343df4b0f..4fadc5633 100644 --- a/internal/pkg/plugin/helmgeneric/update.go +++ b/internal/pkg/plugin/helmgeneric/update.go @@ -1,12 +1,14 @@ package helmgeneric import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -17,7 +19,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/jenkins/create.go b/internal/pkg/plugin/jenkins/create.go index 06524bc9c..0c56f7919 100644 --- a/internal/pkg/plugin/jenkins/create.go +++ b/internal/pkg/plugin/jenkins/create.go @@ -1,13 +1,15 @@ package jenkins import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Create creates jenkins with provided options. -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -23,7 +25,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/jenkins/delete.go b/internal/pkg/plugin/jenkins/delete.go index 9cd2bcc08..aa7af8623 100644 --- a/internal/pkg/plugin/jenkins/delete.go +++ b/internal/pkg/plugin/jenkins/delete.go @@ -1,11 +1,12 @@ package jenkins import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -16,7 +17,7 @@ func Delete(options map[string]interface{}) (bool, error) { helm.Delete, }, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/jenkins/jenkins.go b/internal/pkg/plugin/jenkins/jenkins.go index 49f5a2db5..029d5cc32 100644 --- a/internal/pkg/plugin/jenkins/jenkins.go +++ b/internal/pkg/plugin/jenkins/jenkins.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" "github.com/devstream-io/devstream/internal/pkg/statemanager" helmCommon "github.com/devstream-io/devstream/pkg/util/helm" @@ -27,7 +27,7 @@ var defaultHelmConfig = helm.Options{ }, } -func genJenkinsStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func genJenkinsStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { resStatus, err := helm.GetAllResourcesStatus(options) if err != nil { return nil, err @@ -48,7 +48,7 @@ func genJenkinsStatus(options plugininstaller.RawOptions) (statemanager.Resource // svc_name.svc_ns:svc_port url := fmt.Sprintf("http://%s.%s:8080", svcName, opt.Chart.Namespace) - outputs := map[string]interface{}{ + outputs := statemanager.ResourceOutputs{ "jenkins_url": url, } @@ -59,7 +59,7 @@ func genJenkinsStatus(options plugininstaller.RawOptions) (statemanager.Resource // See https://github.com/devstream-io/devstream/pull/1025#discussion_r952277174 and // https://github.com/devstream-io/devstream/pull/1027#discussion_r953415932 for more info. -func genJenkinsSvcName(options plugininstaller.RawOptions) (string, error) { +func genJenkinsSvcName(options configmanager.RawOptions) (string, error) { opts, err := helm.NewOptions(options) if err != nil { return "", err diff --git a/internal/pkg/plugin/jenkins/read.go b/internal/pkg/plugin/jenkins/read.go index 8bb353525..b27c2c028 100644 --- a/internal/pkg/plugin/jenkins/read.go +++ b/internal/pkg/plugin/jenkins/read.go @@ -1,12 +1,14 @@ package jenkins import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -16,7 +18,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: genJenkinsStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/jenkins/update.go b/internal/pkg/plugin/jenkins/update.go index 20207da78..c7b586d7c 100644 --- a/internal/pkg/plugin/jenkins/update.go +++ b/internal/pkg/plugin/jenkins/update.go @@ -1,13 +1,15 @@ package jenkins import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Update updates jenkins with provided options. -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -20,7 +22,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/jenkinspipeline/create.go b/internal/pkg/plugin/jenkinspipeline/create.go index e8076afdd..e68a4cb43 100644 --- a/internal/pkg/plugin/jenkinspipeline/create.go +++ b/internal/pkg/plugin/jenkinspipeline/create.go @@ -1,13 +1,15 @@ package jenkinspipeline import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/jenkins" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -24,7 +26,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/jenkinspipeline/delete.go b/internal/pkg/plugin/jenkinspipeline/delete.go index 5f98fdf32..b09440ac6 100644 --- a/internal/pkg/plugin/jenkinspipeline/delete.go +++ b/internal/pkg/plugin/jenkinspipeline/delete.go @@ -1,12 +1,13 @@ package jenkinspipeline import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/jenkins" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -19,7 +20,7 @@ func Delete(options map[string]interface{}) (bool, error) { jenkins.DeleteJob, }, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/jenkinspipeline/read.go b/internal/pkg/plugin/jenkinspipeline/read.go index b958fd266..4d3c76b1c 100644 --- a/internal/pkg/plugin/jenkinspipeline/read.go +++ b/internal/pkg/plugin/jenkinspipeline/read.go @@ -1,12 +1,14 @@ package jenkinspipeline import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/jenkins" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ jenkins.SetJobDefaultConfig, @@ -15,7 +17,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: jenkins.GetStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/jenkinspipeline/update.go b/internal/pkg/plugin/jenkinspipeline/update.go index a1bb941b7..024dbbe24 100644 --- a/internal/pkg/plugin/jenkinspipeline/update.go +++ b/internal/pkg/plugin/jenkinspipeline/update.go @@ -1,5 +1,10 @@ package jenkinspipeline -func Update(options map[string]interface{}) (map[string]interface{}, error) { +import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" +) + +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { return Create(options) } diff --git a/internal/pkg/plugin/jiragithub/create.go b/internal/pkg/plugin/jiragithub/create.go index 92b610426..9b78b11d3 100644 --- a/internal/pkg/plugin/jiragithub/create.go +++ b/internal/pkg/plugin/jiragithub/create.go @@ -5,13 +5,15 @@ import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/scm/git" "github.com/devstream-io/devstream/pkg/util/scm/github" ) // Create sets up jira-github-integ workflows. -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { var opts Options err := mapstructure.Decode(options, &opts) if err != nil { @@ -50,11 +52,11 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { return nil, err } - return BuildState(opts.Owner, opts.Repo), nil + return BuildStatus(opts.Owner, opts.Repo), nil } -func BuildState(owner, repo string) map[string]interface{} { - res := make(map[string]interface{}) - res["workflowDir"] = fmt.Sprintf("/repos/%s/%s/contents/.github/workflows", owner, repo) - return res +func BuildStatus(owner, repo string) statemanager.ResourceStatus { + resStatus := make(statemanager.ResourceStatus) + resStatus["workflowDir"] = fmt.Sprintf("/repos/%s/%s/contents/.github/workflows", owner, repo) + return resStatus } diff --git a/internal/pkg/plugin/jiragithub/delete.go b/internal/pkg/plugin/jiragithub/delete.go index 8042d5d08..1cee7cffa 100644 --- a/internal/pkg/plugin/jiragithub/delete.go +++ b/internal/pkg/plugin/jiragithub/delete.go @@ -5,13 +5,14 @@ import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/scm/git" "github.com/devstream-io/devstream/pkg/util/scm/github" ) // Delete remove jira-github-integ workflows. -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { var opts Options err := mapstructure.Decode(options, &opts) if err != nil { diff --git a/internal/pkg/plugin/jiragithub/read.go b/internal/pkg/plugin/jiragithub/read.go index 767ff203f..a5a660078 100644 --- a/internal/pkg/plugin/jiragithub/read.go +++ b/internal/pkg/plugin/jiragithub/read.go @@ -5,13 +5,15 @@ import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/scm/git" "github.com/devstream-io/devstream/pkg/util/scm/github" ) // Read get jira-github-integ workflows. -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { var opts Options err := mapstructure.Decode(options, &opts) if err != nil { @@ -41,11 +43,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { return nil, err } - return BuildReadState(path), nil -} - -func BuildReadState(path string) map[string]interface{} { - res := make(map[string]interface{}) - res["workflowDir"] = path - return res + resStatus := make(statemanager.ResourceStatus) + resStatus["workflowDir"] = path + return resStatus, nil } diff --git a/internal/pkg/plugin/jiragithub/update.go b/internal/pkg/plugin/jiragithub/update.go index 5aa29044d..425978bc1 100644 --- a/internal/pkg/plugin/jiragithub/update.go +++ b/internal/pkg/plugin/jiragithub/update.go @@ -5,13 +5,15 @@ import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/scm/git" "github.com/devstream-io/devstream/pkg/util/scm/github" ) // Update remove and set up jira-github-integ workflows. -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { var opts Options err := mapstructure.Decode(options, &opts) if err != nil { @@ -50,5 +52,5 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { return nil, err } - return BuildState(opts.Owner, opts.Repo), nil + return BuildStatus(opts.Owner, opts.Repo), nil } diff --git a/internal/pkg/plugin/kubeprometheus/create.go b/internal/pkg/plugin/kubeprometheus/create.go index 3b7c4d337..939b1b28a 100644 --- a/internal/pkg/plugin/kubeprometheus/create.go +++ b/internal/pkg/plugin/kubeprometheus/create.go @@ -1,13 +1,15 @@ package kubeprometheus import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Create will create prometheus in k8s -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -20,7 +22,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/kubeprometheus/delete.go b/internal/pkg/plugin/kubeprometheus/delete.go index 786f9f258..bc4c0a127 100644 --- a/internal/pkg/plugin/kubeprometheus/delete.go +++ b/internal/pkg/plugin/kubeprometheus/delete.go @@ -1,11 +1,12 @@ package kubeprometheus import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -14,7 +15,7 @@ func Delete(options map[string]interface{}) (bool, error) { }, ExecuteOperations: helm.DefaultDeleteOperations, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/kubeprometheus/read.go b/internal/pkg/plugin/kubeprometheus/read.go index 3c3c482be..4fba742be 100644 --- a/internal/pkg/plugin/kubeprometheus/read.go +++ b/internal/pkg/plugin/kubeprometheus/read.go @@ -1,12 +1,14 @@ package kubeprometheus import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -16,7 +18,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: helm.GetAllResourcesStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/kubeprometheus/update.go b/internal/pkg/plugin/kubeprometheus/update.go index 7a68ead97..cf42fb04c 100644 --- a/internal/pkg/plugin/kubeprometheus/update.go +++ b/internal/pkg/plugin/kubeprometheus/update.go @@ -1,12 +1,14 @@ package kubeprometheus import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -18,7 +20,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/openldap/create.go b/internal/pkg/plugin/openldap/create.go index 7b2a48753..a97e0bda6 100644 --- a/internal/pkg/plugin/openldap/create.go +++ b/internal/pkg/plugin/openldap/create.go @@ -1,13 +1,15 @@ package openldap import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Create creates OpenLDAP with provided options. -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -20,7 +22,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/openldap/delete.go b/internal/pkg/plugin/openldap/delete.go index 39fa60663..755f30e81 100644 --- a/internal/pkg/plugin/openldap/delete.go +++ b/internal/pkg/plugin/openldap/delete.go @@ -1,11 +1,12 @@ package openldap import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -14,7 +15,7 @@ func Delete(options map[string]interface{}) (bool, error) { }, ExecuteOperations: helm.DefaultDeleteOperations, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/openldap/read.go b/internal/pkg/plugin/openldap/read.go index 8d2f728ad..1ff578bc4 100644 --- a/internal/pkg/plugin/openldap/read.go +++ b/internal/pkg/plugin/openldap/read.go @@ -1,12 +1,14 @@ package openldap import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -16,7 +18,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: helm.GetAllResourcesStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/openldap/update.go b/internal/pkg/plugin/openldap/update.go index 801330bc2..039d6c153 100644 --- a/internal/pkg/plugin/openldap/update.go +++ b/internal/pkg/plugin/openldap/update.go @@ -1,12 +1,14 @@ package openldap import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -18,7 +20,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/reposcaffolding/create.go b/internal/pkg/plugin/reposcaffolding/create.go index 5b12e61e7..869c51b60 100644 --- a/internal/pkg/plugin/reposcaffolding/create.go +++ b/internal/pkg/plugin/reposcaffolding/create.go @@ -1,12 +1,14 @@ package reposcaffolding import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/reposcaffolding" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -19,7 +21,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/reposcaffolding/delete.go b/internal/pkg/plugin/reposcaffolding/delete.go index de7febcc5..24c752e17 100644 --- a/internal/pkg/plugin/reposcaffolding/delete.go +++ b/internal/pkg/plugin/reposcaffolding/delete.go @@ -1,11 +1,12 @@ package reposcaffolding import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/reposcaffolding" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -15,7 +16,7 @@ func Delete(options map[string]interface{}) (bool, error) { reposcaffolding.DeleteRepo, }, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/reposcaffolding/read.go b/internal/pkg/plugin/reposcaffolding/read.go index 8b907737f..332fdd8e0 100644 --- a/internal/pkg/plugin/reposcaffolding/read.go +++ b/internal/pkg/plugin/reposcaffolding/read.go @@ -1,12 +1,14 @@ package reposcaffolding import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/reposcaffolding" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ reposcaffolding.Validate, @@ -14,7 +16,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: reposcaffolding.GetDynamicStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/reposcaffolding/update.go b/internal/pkg/plugin/reposcaffolding/update.go index 9c5ebe4c3..15d0d1b40 100644 --- a/internal/pkg/plugin/reposcaffolding/update.go +++ b/internal/pkg/plugin/reposcaffolding/update.go @@ -1,12 +1,14 @@ package reposcaffolding import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/reposcaffolding" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ reposcaffolding.Validate, @@ -19,7 +21,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/sonarqube/create.go b/internal/pkg/plugin/sonarqube/create.go index 9b7a9dabc..6ce556a1f 100644 --- a/internal/pkg/plugin/sonarqube/create.go +++ b/internal/pkg/plugin/sonarqube/create.go @@ -1,12 +1,14 @@ package sonarqube import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -19,7 +21,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/sonarqube/delete.go b/internal/pkg/plugin/sonarqube/delete.go index 84a6bd03a..286652fe8 100644 --- a/internal/pkg/plugin/sonarqube/delete.go +++ b/internal/pkg/plugin/sonarqube/delete.go @@ -1,11 +1,12 @@ package sonarqube import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -14,7 +15,7 @@ func Delete(options map[string]interface{}) (bool, error) { }, ExecuteOperations: helm.DefaultDeleteOperations, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/sonarqube/read.go b/internal/pkg/plugin/sonarqube/read.go index 239fd2620..d6aab2127 100644 --- a/internal/pkg/plugin/sonarqube/read.go +++ b/internal/pkg/plugin/sonarqube/read.go @@ -1,12 +1,14 @@ package sonarqube import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -17,7 +19,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { } // 2. get plugin status - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/sonarqube/update.go b/internal/pkg/plugin/sonarqube/update.go index ad5ac6ca2..2a19879bf 100644 --- a/internal/pkg/plugin/sonarqube/update.go +++ b/internal/pkg/plugin/sonarqube/update.go @@ -1,12 +1,14 @@ package sonarqube import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -18,7 +20,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/tekton/create.go b/internal/pkg/plugin/tekton/create.go index 4af1ad094..0c049b597 100644 --- a/internal/pkg/plugin/tekton/create.go +++ b/internal/pkg/plugin/tekton/create.go @@ -1,12 +1,14 @@ package tekton import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -19,7 +21,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/tekton/delete.go b/internal/pkg/plugin/tekton/delete.go index cc4ec39bb..20444f83b 100644 --- a/internal/pkg/plugin/tekton/delete.go +++ b/internal/pkg/plugin/tekton/delete.go @@ -1,11 +1,12 @@ package tekton import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -14,7 +15,7 @@ func Delete(options map[string]interface{}) (bool, error) { }, ExecuteOperations: helm.DefaultDeleteOperations, } - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/tekton/read.go b/internal/pkg/plugin/tekton/read.go index 604d633ee..029a2b4f0 100644 --- a/internal/pkg/plugin/tekton/read.go +++ b/internal/pkg/plugin/tekton/read.go @@ -1,12 +1,14 @@ package tekton import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -16,7 +18,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { GetStatusOperation: helm.GetAllResourcesStatus, } - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/tekton/update.go b/internal/pkg/plugin/tekton/update.go index 285624920..27a215504 100644 --- a/internal/pkg/plugin/tekton/update.go +++ b/internal/pkg/plugin/tekton/update.go @@ -1,12 +1,14 @@ package tekton import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -18,7 +20,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/trello/create.go b/internal/pkg/plugin/trello/create.go index 1d3340208..8abefd63b 100644 --- a/internal/pkg/plugin/trello/create.go +++ b/internal/pkg/plugin/trello/create.go @@ -5,11 +5,13 @@ import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Create creates Tello board and lists(todo/doing/done). -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { diff --git a/internal/pkg/plugin/trello/delete.go b/internal/pkg/plugin/trello/delete.go index 003d3a028..3769bfc19 100644 --- a/internal/pkg/plugin/trello/delete.go +++ b/internal/pkg/plugin/trello/delete.go @@ -5,11 +5,12 @@ import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Delete delete trello board and lists -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return false, err diff --git a/internal/pkg/plugin/trello/read.go b/internal/pkg/plugin/trello/read.go index f31dd6a51..792cd527a 100644 --- a/internal/pkg/plugin/trello/read.go +++ b/internal/pkg/plugin/trello/read.go @@ -5,10 +5,12 @@ import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { @@ -22,5 +24,5 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { return nil, fmt.Errorf("opts are illegal") } - return buildReadState(&opts) + return buildReadStatus(&opts) } diff --git a/internal/pkg/plugin/trello/trello.go b/internal/pkg/plugin/trello/trello.go index 64b0dde86..e6791d3a9 100644 --- a/internal/pkg/plugin/trello/trello.go +++ b/internal/pkg/plugin/trello/trello.go @@ -97,7 +97,7 @@ func buildStatus(opts *Options, ti *TrelloItemId) statemanager.ResourceStatus { resStatus["doingListId"] = ti.doingListId resStatus["doneListId"] = ti.doneListId - outputs := make(map[string]interface{}) + outputs := make(statemanager.ResourceOutputs) outputs["boardId"] = ti.boardId outputs["todoListId"] = ti.todoListId outputs["doingListId"] = ti.doingListId @@ -108,7 +108,7 @@ func buildStatus(opts *Options, ti *TrelloItemId) statemanager.ResourceStatus { return resStatus } -func buildReadState(opts *Options) (map[string]interface{}, error) { +func buildReadStatus(opts *Options) (statemanager.ResourceStatus, error) { c, err := trello.NewClient() if err != nil { return nil, err @@ -119,7 +119,7 @@ func buildReadState(opts *Options) (map[string]interface{}, error) { } resStatus := statemanager.ResourceStatus(listIds) - output := make(map[string]interface{}) + output := make(statemanager.ResourceOutputs) output["boardId"] = fmt.Sprint(listIds["boardId"]) output["todoListId"] = fmt.Sprint(listIds["todoListId"]) output["doingListId"] = fmt.Sprint(listIds["doingListId"]) diff --git a/internal/pkg/plugin/trello/update.go b/internal/pkg/plugin/trello/update.go index c8ee844e8..f38bf8c16 100644 --- a/internal/pkg/plugin/trello/update.go +++ b/internal/pkg/plugin/trello/update.go @@ -5,11 +5,13 @@ import ( "github.com/mitchellh/mapstructure" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Update recreate trello board and lists. -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return nil, err diff --git a/internal/pkg/plugin/trellogithub/create.go b/internal/pkg/plugin/trellogithub/create.go index 57a4d1c60..62daee423 100644 --- a/internal/pkg/plugin/trellogithub/create.go +++ b/internal/pkg/plugin/trellogithub/create.go @@ -1,11 +1,13 @@ package trellogithub import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Create sets up trello-github-integ workflows. -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { tg, err := NewTrelloGithub(options) if err != nil { return nil, err diff --git a/internal/pkg/plugin/trellogithub/delete.go b/internal/pkg/plugin/trellogithub/delete.go index 0af715d31..07f14e696 100644 --- a/internal/pkg/plugin/trellogithub/delete.go +++ b/internal/pkg/plugin/trellogithub/delete.go @@ -1,7 +1,9 @@ package trellogithub +import "github.com/devstream-io/devstream/internal/pkg/configmanager" + // Delete remove trello-github-integ workflows. -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { tg, err := NewTrelloGithub(options) if err != nil { return false, err diff --git a/internal/pkg/plugin/trellogithub/read.go b/internal/pkg/plugin/trellogithub/read.go index 9796fe0f2..390c02e56 100644 --- a/internal/pkg/plugin/trellogithub/read.go +++ b/internal/pkg/plugin/trellogithub/read.go @@ -1,11 +1,13 @@ package trellogithub import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/scm/github" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { tg, err := NewTrelloGithub(options) if err != nil { return nil, err diff --git a/internal/pkg/plugin/trellogithub/trellogithub.go b/internal/pkg/plugin/trellogithub/trellogithub.go index f54e72a20..72cf83536 100644 --- a/internal/pkg/plugin/trellogithub/trellogithub.go +++ b/internal/pkg/plugin/trellogithub/trellogithub.go @@ -4,6 +4,8 @@ import ( "context" "fmt" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + mapset "github.com/deckarep/golang-set/v2" "github.com/mitchellh/mapstructure" @@ -26,7 +28,7 @@ type TrelloItemId struct { doneListId string } -func NewTrelloGithub(options map[string]interface{}) (*TrelloGithub, error) { +func NewTrelloGithub(options configmanager.RawOptions) (*TrelloGithub, error) { ctx := context.Background() var opts Options diff --git a/internal/pkg/plugin/trellogithub/update.go b/internal/pkg/plugin/trellogithub/update.go index 124e4b349..8d7c57109 100644 --- a/internal/pkg/plugin/trellogithub/update.go +++ b/internal/pkg/plugin/trellogithub/update.go @@ -1,11 +1,13 @@ package trellogithub import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) // Update remove and set up trello-github-integ workflows. -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { tg, err := NewTrelloGithub(options) if err != nil { return nil, err diff --git a/internal/pkg/plugin/zentao/create.go b/internal/pkg/plugin/zentao/create.go index 0930ea643..59ff779fe 100644 --- a/internal/pkg/plugin/zentao/create.go +++ b/internal/pkg/plugin/zentao/create.go @@ -1,11 +1,13 @@ package zentao import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/goclient" + "github.com/devstream-io/devstream/internal/pkg/statemanager" ) -func Create(options map[string]interface{}) (map[string]interface{}, error) { +func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -26,7 +28,7 @@ func Create(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/zentao/delete.go b/internal/pkg/plugin/zentao/delete.go index a544bd897..92446840c 100644 --- a/internal/pkg/plugin/zentao/delete.go +++ b/internal/pkg/plugin/zentao/delete.go @@ -1,11 +1,12 @@ package zentao import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/goclient" ) -func Delete(options map[string]interface{}) (bool, error) { +func Delete(options configmanager.RawOptions) (bool, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -17,7 +18,7 @@ func Delete(options map[string]interface{}) (bool, error) { } // Execute all Operations in Operator - _, err := operator.Execute(plugininstaller.RawOptions(options)) + _, err := operator.Execute(options) if err != nil { return false, err } diff --git a/internal/pkg/plugin/zentao/read.go b/internal/pkg/plugin/zentao/read.go index fcd63a1c3..b186df78b 100644 --- a/internal/pkg/plugin/zentao/read.go +++ b/internal/pkg/plugin/zentao/read.go @@ -1,11 +1,13 @@ package zentao import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/goclient" + "github.com/devstream-io/devstream/internal/pkg/statemanager" ) -func Read(options map[string]interface{}) (map[string]interface{}, error) { +func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -15,7 +17,7 @@ func Read(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/plugin/zentao/update.go b/internal/pkg/plugin/zentao/update.go index 6079046b2..8a477fbf0 100644 --- a/internal/pkg/plugin/zentao/update.go +++ b/internal/pkg/plugin/zentao/update.go @@ -1,11 +1,13 @@ package zentao import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/goclient" + "github.com/devstream-io/devstream/internal/pkg/statemanager" ) -func Update(options map[string]interface{}) (map[string]interface{}, error) { +func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { // Initialize Operator with Operations operator := &plugininstaller.Operator{ PreExecuteOperations: plugininstaller.PreExecuteOperations{ @@ -24,7 +26,7 @@ func Update(options map[string]interface{}) (map[string]interface{}, error) { } // Execute all Operations in Operator - status, err := operator.Execute(plugininstaller.RawOptions(options)) + status, err := operator.Execute(options) if err != nil { return nil, err } diff --git a/internal/pkg/pluginengine/change.go b/internal/pkg/pluginengine/change.go index d93f8acc4..9d49c1009 100644 --- a/internal/pkg/pluginengine/change.go +++ b/internal/pkg/pluginengine/change.go @@ -22,7 +22,7 @@ type ChangeResult struct { Succeeded bool Error error Time string - ReturnValue map[string]interface{} + ReturnValue statemanager.ResourceStatus } func (c *Change) String() string { @@ -67,7 +67,7 @@ func execute(smgr statemanager.Manager, changes []*Change, reverse bool) map[str var succeeded bool var err error - var returnValue map[string]interface{} + var returnValue statemanager.ResourceStatus log.Debugf("Tool's raw changes are: %v.", c.Tool.Options) diff --git a/internal/pkg/pluginengine/outputs.go b/internal/pkg/pluginengine/outputs.go index dade2b341..679b74d26 100644 --- a/internal/pkg/pluginengine/outputs.go +++ b/internal/pkg/pluginengine/outputs.go @@ -4,32 +4,34 @@ import ( "fmt" "regexp" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/statemanager" + "github.com/devstream-io/devstream/pkg/util/log" ) // HandleOutputsReferences renders outputs references in config file recursively. // The parameter options will be changed. -func HandleOutputsReferences(smgr statemanager.Manager, options map[string]interface{}) []error { +func HandleOutputsReferences(smgr statemanager.Manager, options configmanager.RawOptions) []error { errorsList := make([]error, 0) for optionKey, optionValue := range options { // only process string values in the options // since all outputs references are strings, not ints, not booleans, not maps if optionValueStr, ok := optionValue.(string); ok { + log.Debugf("Before: %s: %s", optionKey, optionValueStr) match, toolName, instanceID, outputReferenceKey := getToolNamePluginOutputKey(optionValueStr) // do nothing, if the value string isn't in the format of a valid output reference if !match { continue } - outputs, err := smgr.GetOutputs(statemanager.GenerateStateKeyByToolNameAndInstanceID(toolName, instanceID)) if err != nil { errorsList = append(errorsList, err) continue } - - if val, ok := outputs.(map[string]interface{})[outputReferenceKey]; ok { + if val, ok := outputs[outputReferenceKey]; ok { options[optionKey] = replaceOutputKeyWithValue(optionValueStr, val.(string)) + log.Debugf("After: %s: %s", optionKey, options[optionKey]) } else { errorsList = append(errorsList, fmt.Errorf("can't find Output reference key %s", outputReferenceKey)) } @@ -37,10 +39,14 @@ func HandleOutputsReferences(smgr statemanager.Manager, options map[string]inter // recursive if the value is a map (which means Tool.Option is a nested map) optionValueMap, ok := optionValue.(map[string]interface{}) + log.Debugf("Got nested map: %v", optionValueMap) if ok { errorsList = append(errorsList, HandleOutputsReferences(smgr, optionValueMap)...) } } + + log.Debugf("Final options: %v.", options) + return errorsList } diff --git a/internal/pkg/pluginengine/plugin.go b/internal/pkg/pluginengine/plugin.go index 3e91a41a5..a9e93d92d 100644 --- a/internal/pkg/pluginengine/plugin.go +++ b/internal/pkg/pluginengine/plugin.go @@ -3,21 +3,23 @@ package pluginengine import ( "github.com/spf13/viper" + "github.com/devstream-io/devstream/internal/pkg/statemanager" + "github.com/devstream-io/devstream/internal/pkg/configmanager" ) // DevStreamPlugin is a struct, on which Create/Read/Update/Delete interfaces are defined. type DevStreamPlugin interface { // Create, Read, and Update return two results, the first being the "state" - Create(map[string]interface{}) (map[string]interface{}, error) - Read(map[string]interface{}) (map[string]interface{}, error) - Update(map[string]interface{}) (map[string]interface{}, error) + Create(configmanager.RawOptions) (statemanager.ResourceStatus, error) + Read(configmanager.RawOptions) (statemanager.ResourceStatus, error) + Update(configmanager.RawOptions) (statemanager.ResourceStatus, error) // Delete returns (true, nil) if there is no error; otherwise it returns (false, error) - Delete(map[string]interface{}) (bool, error) + Delete(configmanager.RawOptions) (bool, error) } // Create loads the plugin and calls the Create method of that plugin. -func Create(tool *configmanager.Tool) (map[string]interface{}, error) { +func Create(tool *configmanager.Tool) (statemanager.ResourceStatus, error) { pluginDir := viper.GetString("plugin-dir") p, err := loadPlugin(pluginDir, tool) if err != nil { @@ -27,7 +29,7 @@ func Create(tool *configmanager.Tool) (map[string]interface{}, error) { } // Update loads the plugin and calls the Update method of that plugin. -func Update(tool *configmanager.Tool) (map[string]interface{}, error) { +func Update(tool *configmanager.Tool) (statemanager.ResourceStatus, error) { pluginDir := viper.GetString("plugin-dir") p, err := loadPlugin(pluginDir, tool) if err != nil { @@ -36,7 +38,7 @@ func Update(tool *configmanager.Tool) (map[string]interface{}, error) { return p.Update(tool.Options) } -func Read(tool *configmanager.Tool) (map[string]interface{}, error) { +func Read(tool *configmanager.Tool) (statemanager.ResourceStatus, error) { pluginDir := viper.GetString("plugin-dir") p, err := loadPlugin(pluginDir, tool) if err != nil { diff --git a/internal/pkg/pluginengine/pluginengine_test.go b/internal/pkg/pluginengine/pluginengine_test.go index 1ba003fe8..2f475e636 100644 --- a/internal/pkg/pluginengine/pluginengine_test.go +++ b/internal/pkg/pluginengine/pluginengine_test.go @@ -101,24 +101,24 @@ var _ = Describe("Pluginengine", func() { It("should handle outputs correctly", func() { resStatus := &statemanager.ResourceStatus{} - resStatus.SetOutputs(map[string]interface{}{ + resStatus.SetOutputs(statemanager.ResourceOutputs{ "boardId": expectedBoardId, "todoListId": expectedTodoListId, }) trelloState := statemanager.State{ InstanceID: "mytrelloboard", Name: "trello", - Options: map[string]interface{}{}, + Options: configmanager.RawOptions{}, ResourceStatus: *resStatus, } err = smgr.AddState(trelloKey, trelloState) Expect(err).NotTo(HaveOccurred()) - dependantOptions := map[string]interface{}{ + dependantOptions := configmanager.RawOptions{ "boardId": fmt.Sprintf("${{ %s.%s.outputs.boardId }}", trelloName, trelloInstance), "todoListId": fmt.Sprintf("${{ %s.%s.outputs.todoListId }}", trelloName, trelloInstance), } - expectResult := map[string]interface{}{ + expectResult := configmanager.RawOptions{ "boardId": expectedBoardId, "todoListId": expectedTodoListId, } @@ -131,9 +131,9 @@ var _ = Describe("Pluginengine", func() { trelloState := statemanager.State{ InstanceID: "mytrelloboard", Name: "trello", - Options: map[string]interface{}{}, - ResourceStatus: map[string]interface{}{ - "outputs": map[string]interface{}{ + Options: configmanager.RawOptions{}, + ResourceStatus: statemanager.ResourceStatus{ + "outputs": statemanager.ResourceOutputs{ "boardId": expectedBoardId, }, }, @@ -177,9 +177,9 @@ var _ = Describe("Pluginengine", func() { trelloState := statemanager.State{ Name: "trello", InstanceID: "mytrelloboard", - Options: map[string]interface{}{}, - ResourceStatus: map[string]interface{}{ - "outputs": map[string]interface{}{ + Options: configmanager.RawOptions{}, + ResourceStatus: statemanager.ResourceStatus{ + "outputs": statemanager.ResourceOutputs{ "boardId": expectedBoardId, "todoListId": expectedTodoListId, }, @@ -205,11 +205,11 @@ var _ = Describe("Pluginengine", func() { It("should work for nested maps", func() { trelloState := statemanager.State{ - Name: "trello", - InstanceID: "mytrelloboard", - Options: map[string]interface{}{}, - ResourceStatus: map[string]interface{}{ - "outputs": map[string]interface{}{ + Name: trelloName, + InstanceID: trelloInstance, + Options: configmanager.RawOptions{}, + ResourceStatus: statemanager.ResourceStatus{ + "outputs": statemanager.ResourceOutputs{ "boardId": expectedBoardId, }, }, @@ -217,12 +217,12 @@ var _ = Describe("Pluginengine", func() { err = smgr.AddState(trelloKey, trelloState) Expect(err).NotTo(HaveOccurred()) - dependantOptions := map[string]interface{}{ + dependantOptions := configmanager.RawOptions{ "outerKey": map[string]interface{}{ "innerKey": fmt.Sprintf("${{ %s.%s.outputs.boardId }}", trelloName, trelloInstance), }, } - expectResult := map[string]interface{}{ + expectResult := configmanager.RawOptions{ "outerKey": map[string]interface{}{ "innerKey": expectedBoardId, }, diff --git a/internal/pkg/plugininstaller/ci/installer.go b/internal/pkg/plugininstaller/ci/installer.go index 24e0d4491..4705f2fa0 100644 --- a/internal/pkg/plugininstaller/ci/installer.go +++ b/internal/pkg/plugininstaller/ci/installer.go @@ -3,10 +3,9 @@ package ci import ( "errors" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/scm" "github.com/devstream-io/devstream/pkg/util/scm/git" - - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" ) const ( @@ -16,7 +15,7 @@ const ( defaultBranch = "feat-repo-ci-update" ) -func PushCIFiles(options plugininstaller.RawOptions) error { +func PushCIFiles(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err @@ -40,7 +39,7 @@ func PushCIFiles(options plugininstaller.RawOptions) error { return err } -func DeleteCIFiles(options plugininstaller.RawOptions) error { +func DeleteCIFiles(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err diff --git a/internal/pkg/plugininstaller/ci/option.go b/internal/pkg/plugininstaller/ci/option.go index f98e0efa8..b2b8b73d5 100644 --- a/internal/pkg/plugininstaller/ci/option.go +++ b/internal/pkg/plugininstaller/ci/option.go @@ -3,7 +3,7 @@ package ci import ( "github.com/mitchellh/mapstructure" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/scm" "github.com/devstream-io/devstream/pkg/util/types" ) @@ -13,7 +13,7 @@ type Options struct { ProjectRepo *scm.Repo `mapstructure:"projectRepo" validate:"required"` } -func NewOptions(options plugininstaller.RawOptions) (*Options, error) { +func NewOptions(options configmanager.RawOptions) (*Options, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/ci/option_test.go b/internal/pkg/plugininstaller/ci/option_test.go index d0cdaa7fb..206351056 100644 --- a/internal/pkg/plugininstaller/ci/option_test.go +++ b/internal/pkg/plugininstaller/ci/option_test.go @@ -4,14 +4,14 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci/server" "github.com/devstream-io/devstream/pkg/util/scm" ) var _ = Describe("Options struct", func() { var ( - rawOptions plugininstaller.RawOptions + rawOptions configmanager.RawOptions defaultOpts, opts *Options ) BeforeEach(func() { @@ -35,7 +35,7 @@ var _ = Describe("Options struct", func() { Context("NewOptions method", func() { When("options is valid", func() { BeforeEach(func() { - rawOptions = plugininstaller.RawOptions{ + rawOptions = configmanager.RawOptions{ "ci": map[string]interface{}{ "type": "gitlab", "content": "test", diff --git a/internal/pkg/plugininstaller/ci/state.go b/internal/pkg/plugininstaller/ci/state.go index b7940d957..816540567 100644 --- a/internal/pkg/plugininstaller/ci/state.go +++ b/internal/pkg/plugininstaller/ci/state.go @@ -1,14 +1,14 @@ package ci import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/scm" "github.com/devstream-io/devstream/pkg/util/scm/git" ) -func GetCIFileStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func GetCIFileStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/ci/validate.go b/internal/pkg/plugininstaller/ci/validate.go index bb58e38e3..0ff932182 100644 --- a/internal/pkg/plugininstaller/ci/validate.go +++ b/internal/pkg/plugininstaller/ci/validate.go @@ -1,13 +1,14 @@ package ci import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/pkg/util/types" "github.com/devstream-io/devstream/pkg/util/validator" ) // Validate validates the options provided by the dtm-core. -func Validate(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func Validate(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewOptions(options) if err != nil { return nil, err @@ -21,7 +22,7 @@ func Validate(options plugininstaller.RawOptions) (plugininstaller.RawOptions, e // SetDefaultConfig will update options empty values base on import options func SetDefaultConfig(defaultConfig *Options) plugininstaller.MutableOperation { - return func(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { + return func(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/ci/validate_test.go b/internal/pkg/plugininstaller/ci/validate_test.go index 7d81d22ae..62394eee8 100644 --- a/internal/pkg/plugininstaller/ci/validate_test.go +++ b/internal/pkg/plugininstaller/ci/validate_test.go @@ -4,12 +4,14 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" "github.com/devstream-io/devstream/pkg/util/scm" ) var _ = Describe("Validate func", func() { - var option map[string]interface{} + var option configmanager.RawOptions When("options is not valid", func() { It("should return error", func() { ciTypeNotExistOptions := map[string]any{ diff --git a/internal/pkg/plugininstaller/docker/compose.go b/internal/pkg/plugininstaller/docker/compose.go index 76fb62782..497651e9e 100644 --- a/internal/pkg/plugininstaller/docker/compose.go +++ b/internal/pkg/plugininstaller/docker/compose.go @@ -3,11 +3,11 @@ package docker import ( "fmt" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/statemanager" ) -func ComposeUp(options plugininstaller.RawOptions) error { +func ComposeUp(options configmanager.RawOptions) error { if err := op.ComposeUp(); err != nil { return fmt.Errorf("failed to run containers: %s", err) } @@ -15,7 +15,7 @@ func ComposeUp(options plugininstaller.RawOptions) error { return nil } -func ComposeDown(options plugininstaller.RawOptions) error { +func ComposeDown(options configmanager.RawOptions) error { if err := op.ComposeDown(); err != nil { return fmt.Errorf("failed to down containers: %s", err) } @@ -23,7 +23,7 @@ func ComposeDown(options plugininstaller.RawOptions) error { return nil } -func ComposeStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func ComposeStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { state, err := op.ComposeState() if err != nil { return nil, fmt.Errorf("failed to get containers state: %s", err) diff --git a/internal/pkg/plugininstaller/docker/installer.go b/internal/pkg/plugininstaller/docker/installer.go index 5361a97dd..3bf03bf7b 100644 --- a/internal/pkg/plugininstaller/docker/installer.go +++ b/internal/pkg/plugininstaller/docker/installer.go @@ -5,7 +5,7 @@ import ( "go.uber.org/multierr" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/docker" "github.com/devstream-io/devstream/pkg/util/docker/dockersh" "github.com/devstream-io/devstream/pkg/util/log" @@ -14,7 +14,7 @@ import ( var op docker.Operator = &dockersh.ShellOperator{} // Install runs the docker container -func Install(options plugininstaller.RawOptions) error { +func Install(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err @@ -48,7 +48,7 @@ func Install(options plugininstaller.RawOptions) error { } // ClearWhenInterruption will delete the container if the container fails to run -func ClearWhenInterruption(options plugininstaller.RawOptions) error { +func ClearWhenInterruption(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err @@ -84,7 +84,7 @@ func ClearWhenInterruption(options plugininstaller.RawOptions) error { } // DeleteAll will delete the container/volumes -func DeleteAll(options plugininstaller.RawOptions) error { +func DeleteAll(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err diff --git a/internal/pkg/plugininstaller/docker/option.go b/internal/pkg/plugininstaller/docker/option.go index bc06ed177..3735d5db0 100644 --- a/internal/pkg/plugininstaller/docker/option.go +++ b/internal/pkg/plugininstaller/docker/option.go @@ -5,7 +5,7 @@ import ( "github.com/mitchellh/mapstructure" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/docker" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/validator" @@ -25,7 +25,7 @@ type Options struct { } // NewOptions create options by raw options -func NewOptions(options plugininstaller.RawOptions) (Options, error) { +func NewOptions(options configmanager.RawOptions) (Options, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return opts, err @@ -48,7 +48,7 @@ func (opts *Options) GetRunOpts() *docker.RunOptions { RestartAlways: opts.RestartAlways, } } -func Validate(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func Validate(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/docker/state.go b/internal/pkg/plugininstaller/docker/state.go index 723cd3461..4b0da75f2 100644 --- a/internal/pkg/plugininstaller/docker/state.go +++ b/internal/pkg/plugininstaller/docker/state.go @@ -5,7 +5,7 @@ import ( "github.com/mitchellh/mapstructure" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/docker" "github.com/devstream-io/devstream/pkg/util/log" @@ -28,7 +28,7 @@ func (s *State) ToMap() (map[string]interface{}, error) { return m, nil } -func GetStaticStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func GetStaticStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { opts, err := NewOptions(options) if err != nil { return nil, err @@ -44,7 +44,7 @@ func GetStaticStatus(options plugininstaller.RawOptions) (statemanager.ResourceS return staticState.ToMap() } -func GetRunningStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func GetRunningStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/github/installer.go b/internal/pkg/plugininstaller/github/installer.go index 6415150d4..81cd8feb2 100644 --- a/internal/pkg/plugininstaller/github/installer.go +++ b/internal/pkg/plugininstaller/github/installer.go @@ -3,6 +3,7 @@ package github import ( "fmt" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/pkg/util/log" ) @@ -17,7 +18,7 @@ type action string // ProcessAction config github func ProcessAction(act action) plugininstaller.BaseOperation { - return func(options plugininstaller.RawOptions) error { + return func(options configmanager.RawOptions) error { opts, err := NewGithubActionOptions(options) if err != nil { return err diff --git a/internal/pkg/plugininstaller/github/option.go b/internal/pkg/plugininstaller/github/option.go index 9fefedbc8..5545129ec 100644 --- a/internal/pkg/plugininstaller/github/option.go +++ b/internal/pkg/plugininstaller/github/option.go @@ -5,7 +5,7 @@ import ( "github.com/mitchellh/mapstructure" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/scm/git" "github.com/devstream-io/devstream/pkg/util/scm/github" "github.com/devstream-io/devstream/pkg/util/template" @@ -40,7 +40,7 @@ type GithubActionOptions struct { Docker *Docker } -func NewGithubActionOptions(options plugininstaller.RawOptions) (*GithubActionOptions, error) { +func NewGithubActionOptions(options configmanager.RawOptions) (*GithubActionOptions, error) { var opts GithubActionOptions if err := mapstructure.Decode(options, &opts); err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/github/state.go b/internal/pkg/plugininstaller/github/state.go index 65dc3b650..d33475161 100644 --- a/internal/pkg/plugininstaller/github/state.go +++ b/internal/pkg/plugininstaller/github/state.go @@ -3,12 +3,12 @@ package github import ( "fmt" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -func GetStaticWorkFlowStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func GetStaticWorkFlowStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { opts, err := NewGithubActionOptions(options) if err != nil { return nil, err @@ -22,7 +22,7 @@ func GetStaticWorkFlowStatus(options plugininstaller.RawOptions) (statemanager.R return res, nil } -func GetActionStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func GetActionStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { opts, err := NewGithubActionOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/github/validate.go b/internal/pkg/plugininstaller/github/validate.go index 8488482a6..eb5097e3e 100644 --- a/internal/pkg/plugininstaller/github/validate.go +++ b/internal/pkg/plugininstaller/github/validate.go @@ -1,11 +1,11 @@ package github import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/validator" ) -func Validate(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func Validate(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewGithubActionOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/github/workflow.go b/internal/pkg/plugininstaller/github/workflow.go index ab95ac904..ab016d2a7 100644 --- a/internal/pkg/plugininstaller/github/workflow.go +++ b/internal/pkg/plugininstaller/github/workflow.go @@ -1,13 +1,14 @@ package github import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/pkg/util/scm/github" "github.com/devstream-io/devstream/pkg/util/types" ) func BuildWorkFlowsWrapper(workflows []*github.Workflow) plugininstaller.MutableOperation { - return func(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { + return func(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewGithubActionOptions(options) if err != nil { return options, err diff --git a/internal/pkg/plugininstaller/goclient/installer.go b/internal/pkg/plugininstaller/goclient/installer.go index 8f8e773df..23efe86e6 100644 --- a/internal/pkg/plugininstaller/goclient/installer.go +++ b/internal/pkg/plugininstaller/goclient/installer.go @@ -11,6 +11,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/pointer" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/k8s" @@ -18,7 +19,7 @@ import ( ) // Create namespace by goclient -func DealWithNsWhenInstall(options plugininstaller.RawOptions) error { +func DealWithNsWhenInstall(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err @@ -58,7 +59,7 @@ func DealWithNsWhenInstall(options plugininstaller.RawOptions) error { } // Deal with resource when errors occur during creation -func DealWithErrWhenInstall(options plugininstaller.RawOptions) error { +func DealWithErrWhenInstall(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err @@ -93,7 +94,7 @@ func DealWithErrWhenInstall(options plugininstaller.RawOptions) error { // Create persistent volume with hostpath func CreatePersistentVolumeWrapper(pvPath map[string]string) plugininstaller.BaseOperation { - return func(options plugininstaller.RawOptions) error { + return func(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err @@ -135,7 +136,7 @@ func CreatePersistentVolumeWrapper(pvPath map[string]string) plugininstaller.Bas } // Create persistent volume claim -func CreatePersistentVolumeClaim(options plugininstaller.RawOptions) error { +func CreatePersistentVolumeClaim(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { @@ -178,7 +179,7 @@ func CreatePersistentVolumeClaim(options plugininstaller.RawOptions) error { // Create deployment by goclient with label, containerPorts and name func CreateDeploymentWrapperLabelAndContainerPorts(label map[string]string, containerPorts *[]corev1.ContainerPort, name string) plugininstaller.BaseOperation { - return func(options plugininstaller.RawOptions) error { + return func(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { @@ -235,7 +236,7 @@ func CreateDeploymentWrapperLabelAndContainerPorts(label map[string]string, cont // Create service by goclient with label and servicePort func CreateServiceWrapperLabelAndPorts(label map[string]string, svcPort *corev1.ServicePort) plugininstaller.BaseOperation { - return func(options plugininstaller.RawOptions) error { + return func(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { @@ -267,7 +268,7 @@ func CreateServiceWrapperLabelAndPorts(label map[string]string, svcPort *corev1. // Check application status by goclient with retry times func WaitForReady(retry int) plugininstaller.BaseOperation { - return func(options plugininstaller.RawOptions) error { + return func(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { @@ -288,7 +289,7 @@ func WaitForReady(retry int) plugininstaller.BaseOperation { } // Delete plugin by goclient -func Delete(options plugininstaller.RawOptions) error { +func Delete(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err @@ -345,7 +346,7 @@ func Delete(options plugininstaller.RawOptions) error { } // Delete application by goclient -func DeleteApp(options plugininstaller.RawOptions) error { +func DeleteApp(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err @@ -366,7 +367,7 @@ func DeleteApp(options plugininstaller.RawOptions) error { } // GetStatus checks plugin status by goclient -func GetStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func GetStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/goclient/option.go b/internal/pkg/plugininstaller/goclient/option.go index 554b1b6cb..2ad4904da 100644 --- a/internal/pkg/plugininstaller/goclient/option.go +++ b/internal/pkg/plugininstaller/goclient/option.go @@ -3,7 +3,7 @@ package goclient import ( "github.com/mitchellh/mapstructure" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" ) // Options is the struct for parameters used by the goclient install config. @@ -45,7 +45,7 @@ type Env struct { } // NewOptions create options by raw options -func NewOptions(options plugininstaller.RawOptions) (Options, error) { +func NewOptions(options configmanager.RawOptions) (Options, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return opts, err diff --git a/internal/pkg/plugininstaller/goclient/validate.go b/internal/pkg/plugininstaller/goclient/validate.go index a796d24a5..253194274 100644 --- a/internal/pkg/plugininstaller/goclient/validate.go +++ b/internal/pkg/plugininstaller/goclient/validate.go @@ -3,13 +3,13 @@ package goclient import ( "fmt" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/validator" ) // validate validates the options provided by the core. -func Validate(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func Validate(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/helm/installer.go b/internal/pkg/plugininstaller/helm/installer.go index 291811589..1db12e734 100644 --- a/internal/pkg/plugininstaller/helm/installer.go +++ b/internal/pkg/plugininstaller/helm/installer.go @@ -1,6 +1,7 @@ package helm import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/pkg/util/helm" "github.com/devstream-io/devstream/pkg/util/k8s" @@ -24,7 +25,7 @@ var ( ) // InstallOrUpdate will install or update service by input options -func InstallOrUpdate(options plugininstaller.RawOptions) error { +func InstallOrUpdate(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err @@ -43,7 +44,7 @@ func InstallOrUpdate(options plugininstaller.RawOptions) error { } // DealWithNsWhenInstall will create namespace by input options -func DealWithNsWhenInstall(options plugininstaller.RawOptions) error { +func DealWithNsWhenInstall(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err @@ -58,7 +59,7 @@ func DealWithNsWhenInstall(options plugininstaller.RawOptions) error { } // Delete will delete service base on input options -func Delete(options plugininstaller.RawOptions) error { +func Delete(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err diff --git a/internal/pkg/plugininstaller/helm/option.go b/internal/pkg/plugininstaller/helm/option.go index 5d1e9f64b..578f4dea5 100644 --- a/internal/pkg/plugininstaller/helm/option.go +++ b/internal/pkg/plugininstaller/helm/option.go @@ -3,7 +3,7 @@ package helm import ( "github.com/mitchellh/mapstructure" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/helm" ) @@ -36,7 +36,7 @@ func (opts *Options) fillDefaultValue(defaultOpts *Options) { } // NewOptions create options by raw options -func NewOptions(options plugininstaller.RawOptions) (*Options, error) { +func NewOptions(options configmanager.RawOptions) (*Options, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/helm/option_test.go b/internal/pkg/plugininstaller/helm/option_test.go index 8017ff0ca..76defc6a9 100644 --- a/internal/pkg/plugininstaller/helm/option_test.go +++ b/internal/pkg/plugininstaller/helm/option_test.go @@ -4,7 +4,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" helmCommon "github.com/devstream-io/devstream/pkg/util/helm" ) @@ -56,7 +56,7 @@ var _ = Describe("Options struct", func() { var _ = Describe("NewOptions func", func() { var ( - inputOptions plugininstaller.RawOptions + inputOptions configmanager.RawOptions testRepoName string testChartName string ) diff --git a/internal/pkg/plugininstaller/helm/state.go b/internal/pkg/plugininstaller/helm/state.go index a26b02832..579ef2a39 100644 --- a/internal/pkg/plugininstaller/helm/state.go +++ b/internal/pkg/plugininstaller/helm/state.go @@ -1,7 +1,7 @@ package helm import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/helm" "github.com/devstream-io/devstream/pkg/util/k8s" @@ -9,7 +9,7 @@ import ( ) // GetAllResourcesStatus will get the State of k8s Deployment, DaemonSet and StatefulSet resources -func GetAllResourcesStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func GetAllResourcesStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/helm/validate.go b/internal/pkg/plugininstaller/helm/validate.go index 547e8fc6e..ca48dd468 100644 --- a/internal/pkg/plugininstaller/helm/validate.go +++ b/internal/pkg/plugininstaller/helm/validate.go @@ -3,6 +3,7 @@ package helm import ( "fmt" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/pkg/util/helm" "github.com/devstream-io/devstream/pkg/util/log" @@ -10,7 +11,7 @@ import ( ) // Validate validates the options provided by the dtm-core. -func Validate(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func Validate(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewOptions(options) if err != nil { return nil, err @@ -27,7 +28,7 @@ func Validate(options plugininstaller.RawOptions) (plugininstaller.RawOptions, e // SetDefaultConfig will update options empty values base on import options func SetDefaultConfig(defaultConfig *Options) plugininstaller.MutableOperation { - return func(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { + return func(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/helm/validate_test.go b/internal/pkg/plugininstaller/helm/validate_test.go index 0b22c2224..9f62c275d 100644 --- a/internal/pkg/plugininstaller/helm/validate_test.go +++ b/internal/pkg/plugininstaller/helm/validate_test.go @@ -4,14 +4,14 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" helmCommon "github.com/devstream-io/devstream/pkg/util/helm" "github.com/devstream-io/devstream/pkg/util/types" ) var _ = Describe("Validate func", func() { - var testOption plugininstaller.RawOptions + var testOption configmanager.RawOptions When("options is not valid", func() { BeforeEach(func() { @@ -53,7 +53,7 @@ var _ = Describe("SetDefaultConfig func", func() { testRepoName string testBool *bool defaultConfig helm.Options - testOptions plugininstaller.RawOptions + testOptions configmanager.RawOptions expectChart map[string]interface{} expectRepo map[string]interface{} ) diff --git a/internal/pkg/plugininstaller/jenkins/installer.go b/internal/pkg/plugininstaller/jenkins/installer.go index d916d270a..0abcba072 100644 --- a/internal/pkg/plugininstaller/jenkins/installer.go +++ b/internal/pkg/plugininstaller/jenkins/installer.go @@ -1,12 +1,12 @@ package jenkins import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/scm" ) -func CreateOrUpdateJob(options plugininstaller.RawOptions) error { +func CreateOrUpdateJob(options configmanager.RawOptions) error { opts, err := newJobOptions(options) if err != nil { return err @@ -21,7 +21,7 @@ func CreateOrUpdateJob(options plugininstaller.RawOptions) error { return opts.createOrUpdateJob(jenkinsClient) } -func CreateRepoWebhook(options plugininstaller.RawOptions) error { +func CreateRepoWebhook(options configmanager.RawOptions) error { opts, err := newJobOptions(options) if err != nil { return err @@ -33,7 +33,7 @@ func CreateRepoWebhook(options plugininstaller.RawOptions) error { return scmClient.AddWebhook(opts.buildWebhookInfo()) } -func DeleteJob(options plugininstaller.RawOptions) error { +func DeleteJob(options configmanager.RawOptions) error { opts, err := newJobOptions(options) if err != nil { return err @@ -57,7 +57,7 @@ func DeleteJob(options plugininstaller.RawOptions) error { } // PreInstall will download jenkins plugins and config jenkins casc -func PreInstall(options plugininstaller.RawOptions) error { +func PreInstall(options configmanager.RawOptions) error { opts, err := newJobOptions(options) if err != nil { return err diff --git a/internal/pkg/plugininstaller/jenkins/option.go b/internal/pkg/plugininstaller/jenkins/option.go index d06ae59b6..5d894ce62 100644 --- a/internal/pkg/plugininstaller/jenkins/option.go +++ b/internal/pkg/plugininstaller/jenkins/option.go @@ -6,7 +6,7 @@ import ( "github.com/mitchellh/mapstructure" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/ci" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/jenkins/plugins" "github.com/devstream-io/devstream/pkg/util/jenkins" @@ -35,7 +35,7 @@ type Jenkins struct { EnableRestart bool `mapstructure:"enableRestart"` } -func newJobOptions(options plugininstaller.RawOptions) (*JobOptions, error) { +func newJobOptions(options configmanager.RawOptions) (*JobOptions, error) { var opts JobOptions if err := mapstructure.Decode(options, &opts); err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/jenkins/state.go b/internal/pkg/plugininstaller/jenkins/state.go index 5ae76ef23..12c6ab8e4 100644 --- a/internal/pkg/plugininstaller/jenkins/state.go +++ b/internal/pkg/plugininstaller/jenkins/state.go @@ -1,12 +1,12 @@ package jenkins import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/jenkins" ) -func GetStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func GetStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { opts, err := newJobOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/jenkins/validate.go b/internal/pkg/plugininstaller/jenkins/validate.go index 06d96100b..bdb02d37e 100644 --- a/internal/pkg/plugininstaller/jenkins/validate.go +++ b/internal/pkg/plugininstaller/jenkins/validate.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/jenkins" "github.com/devstream-io/devstream/pkg/util/k8s" "github.com/devstream-io/devstream/pkg/util/log" @@ -26,7 +26,7 @@ const ( ) // SetJobDefaultConfig config default fields for usage -func SetJobDefaultConfig(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func SetJobDefaultConfig(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := newJobOptions(options) if err != nil { return nil, err @@ -75,7 +75,7 @@ func SetJobDefaultConfig(options plugininstaller.RawOptions) (plugininstaller.Ra return types.EncodeStruct(opts) } -func ValidateJobConfig(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func ValidateJobConfig(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := newJobOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/kubectl/installer.go b/internal/pkg/plugininstaller/kubectl/installer.go index 9296c17ba..fd584f4d5 100644 --- a/internal/pkg/plugininstaller/kubectl/installer.go +++ b/internal/pkg/plugininstaller/kubectl/installer.go @@ -5,13 +5,14 @@ import ( "io" "strings" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller" "github.com/devstream-io/devstream/pkg/util/kubectl" "github.com/devstream-io/devstream/pkg/util/template" ) func ProcessByContent(action, content string) plugininstaller.BaseOperation { - return func(options plugininstaller.RawOptions) error { + return func(options configmanager.RawOptions) error { reader, err := renderKubectlContent(content, options) if err != nil { return err @@ -21,7 +22,7 @@ func ProcessByContent(action, content string) plugininstaller.BaseOperation { } } -func renderKubectlContent(content string, options plugininstaller.RawOptions) (io.Reader, error) { +func renderKubectlContent(content string, options configmanager.RawOptions) (io.Reader, error) { content, err := template.New().FromContent(content).SetDefaultRender("kubectl", options).Render() if err != nil { return nil, err @@ -34,7 +35,7 @@ func renderKubectlContent(content string, options plugininstaller.RawOptions) (i } func ProcessByURL(action, url string) plugininstaller.BaseOperation { - return func(options plugininstaller.RawOptions) error { + return func(options configmanager.RawOptions) error { content, err := template.New().FromURL(url).SetDefaultRender("kubectl", options).Render() if err != nil { return err diff --git a/internal/pkg/plugininstaller/kubectl/installer_test.go b/internal/pkg/plugininstaller/kubectl/installer_test.go index 5980c8aef..3be7fd1fc 100644 --- a/internal/pkg/plugininstaller/kubectl/installer_test.go +++ b/internal/pkg/plugininstaller/kubectl/installer_test.go @@ -9,14 +9,14 @@ import ( . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" utilKubectl "github.com/devstream-io/devstream/pkg/util/kubectl" ) var _ = Describe("renderKubectlContent", func() { var ( content string - options plugininstaller.RawOptions + options configmanager.RawOptions ) BeforeEach(func() { @@ -54,7 +54,7 @@ var _ = Describe("renderKubectlContent", func() { }) var _ = Describe("ProcessByContent", Ordered, func() { - var options plugininstaller.RawOptions + var options configmanager.RawOptions var s *ghttp.Server BeforeAll(func() { diff --git a/internal/pkg/plugininstaller/plugininstaller.go b/internal/pkg/plugininstaller/plugininstaller.go index 13f1fe057..d25290ce8 100644 --- a/internal/pkg/plugininstaller/plugininstaller.go +++ b/internal/pkg/plugininstaller/plugininstaller.go @@ -1,19 +1,18 @@ package plugininstaller import ( + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" ) -type RawOptions map[string]interface{} - type ( // MutableOperation can be used to change options if it is needed - MutableOperation func(options RawOptions) (RawOptions, error) + MutableOperation func(options configmanager.RawOptions) (configmanager.RawOptions, error) // BaseOperation reads options and executes operation - BaseOperation func(options RawOptions) error + BaseOperation func(options configmanager.RawOptions) error // StatusOperation reads options and executes operation, then returns the status map - StatusOperation func(options RawOptions) (statemanager.ResourceStatus, error) + StatusOperation func(options configmanager.RawOptions) (statemanager.ResourceStatus, error) ) type ( @@ -24,7 +23,7 @@ type ( ) type Installer interface { - Execute(options RawOptions) (map[string]interface{}, error) + Execute(options configmanager.RawOptions) (statemanager.ResourceStatus, error) } // Operator knows all the operations and can execute them in order @@ -36,7 +35,7 @@ type Operator struct { } // Execute will sequentially execute all operations in Operator -func (o *Operator) Execute(options RawOptions) (map[string]interface{}, error) { +func (o *Operator) Execute(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { var err error // 1. Execute PreExecuteOperations. It may changes the options. log.Debugf("Start to execute PreExecuteOperations...") diff --git a/internal/pkg/plugininstaller/reposcaffolding/installer.go b/internal/pkg/plugininstaller/reposcaffolding/installer.go index 6ee18b73c..64ad121bd 100644 --- a/internal/pkg/plugininstaller/reposcaffolding/installer.go +++ b/internal/pkg/plugininstaller/reposcaffolding/installer.go @@ -1,13 +1,13 @@ package reposcaffolding import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/scm" "github.com/devstream-io/devstream/pkg/util/scm/git" ) // InstallRepo will install repo by opts config -func InstallRepo(options plugininstaller.RawOptions) error { +func InstallRepo(options configmanager.RawOptions) error { opts, err := NewOptions(options) if err != nil { return err @@ -36,7 +36,7 @@ func InstallRepo(options plugininstaller.RawOptions) error { } // DeleteRepo will delete repo by options -func DeleteRepo(options plugininstaller.RawOptions) error { +func DeleteRepo(options configmanager.RawOptions) error { var err error opts, err := NewOptions(options) if err != nil { diff --git a/internal/pkg/plugininstaller/reposcaffolding/option.go b/internal/pkg/plugininstaller/reposcaffolding/option.go index 393f6b994..5f21678ae 100644 --- a/internal/pkg/plugininstaller/reposcaffolding/option.go +++ b/internal/pkg/plugininstaller/reposcaffolding/option.go @@ -3,7 +3,7 @@ package reposcaffolding import ( "github.com/mitchellh/mapstructure" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/file" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/scm" @@ -16,7 +16,7 @@ type Options struct { Vars map[string]interface{} } -func NewOptions(options plugininstaller.RawOptions) (*Options, error) { +func NewOptions(options configmanager.RawOptions) (*Options, error) { var opts Options if err := mapstructure.Decode(options, &opts); err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/reposcaffolding/option_test.go b/internal/pkg/plugininstaller/reposcaffolding/option_test.go index 0f7ff8a3b..2428ddc2b 100644 --- a/internal/pkg/plugininstaller/reposcaffolding/option_test.go +++ b/internal/pkg/plugininstaller/reposcaffolding/option_test.go @@ -6,7 +6,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/scm" ) @@ -30,10 +30,10 @@ var _ = Describe("Options struct", func() { }) Context("NewOptions method", func() { var ( - rawOptions plugininstaller.RawOptions + rawOptions configmanager.RawOptions ) BeforeEach(func() { - rawOptions = plugininstaller.RawOptions{ + rawOptions = configmanager.RawOptions{ "sourceRepo": map[string]string{ "owner": "test_user", "repo": "test_repo", diff --git a/internal/pkg/plugininstaller/reposcaffolding/state.go b/internal/pkg/plugininstaller/reposcaffolding/state.go index b23371788..ff295f58e 100644 --- a/internal/pkg/plugininstaller/reposcaffolding/state.go +++ b/internal/pkg/plugininstaller/reposcaffolding/state.go @@ -1,13 +1,13 @@ package reposcaffolding import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/statemanager" "github.com/devstream-io/devstream/pkg/util/log" "github.com/devstream-io/devstream/pkg/util/scm/github" ) -func GetDynamicStatus(options plugininstaller.RawOptions) (statemanager.ResourceStatus, error) { +func GetDynamicStatus(options configmanager.RawOptions) (statemanager.ResourceStatus, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/reposcaffolding/validate.go b/internal/pkg/plugininstaller/reposcaffolding/validate.go index b2d512eeb..b25126b92 100644 --- a/internal/pkg/plugininstaller/reposcaffolding/validate.go +++ b/internal/pkg/plugininstaller/reposcaffolding/validate.go @@ -1,12 +1,12 @@ package reposcaffolding import ( - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/pkg/util/validator" ) // Validate validates the options provided by the core. -func Validate(options plugininstaller.RawOptions) (plugininstaller.RawOptions, error) { +func Validate(options configmanager.RawOptions) (configmanager.RawOptions, error) { opts, err := NewOptions(options) if err != nil { return nil, err diff --git a/internal/pkg/plugininstaller/reposcaffolding/validate_test.go b/internal/pkg/plugininstaller/reposcaffolding/validate_test.go index 4e8989a77..273ffa629 100644 --- a/internal/pkg/plugininstaller/reposcaffolding/validate_test.go +++ b/internal/pkg/plugininstaller/reposcaffolding/validate_test.go @@ -4,17 +4,17 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/devstream-io/devstream/internal/pkg/plugininstaller" + "github.com/devstream-io/devstream/internal/pkg/configmanager" "github.com/devstream-io/devstream/internal/pkg/plugininstaller/reposcaffolding" ) var _ = Describe("Validate func", func() { var ( - rawOpts plugininstaller.RawOptions + rawOpts configmanager.RawOptions ) When("reposcaffolding option is not valid", func() { BeforeEach(func() { - rawOpts = plugininstaller.RawOptions{ + rawOpts = configmanager.RawOptions{ "not_exist": true, } }) @@ -25,7 +25,7 @@ var _ = Describe("Validate func", func() { }) When("reposcaffolding option is valid", func() { BeforeEach(func() { - rawOpts = plugininstaller.RawOptions{ + rawOpts = configmanager.RawOptions{ "sourceRepo": map[string]string{ "owner": "test_user", "repo": "test_repo", diff --git a/internal/pkg/show/status/output.go b/internal/pkg/show/status/output.go index 462716e24..90276940e 100644 --- a/internal/pkg/show/status/output.go +++ b/internal/pkg/show/status/output.go @@ -4,6 +4,8 @@ import ( "bytes" "fmt" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "gopkg.in/yaml.v3" "github.com/devstream-io/devstream/internal/pkg/statemanager" @@ -27,7 +29,7 @@ type Status struct { // If the resource has drifted, status.ResourceStatusInState & status.ResourceStatusFromRead must NOT be nil and status.InlineStatus should be nil. // If the resource hasn't drifted, status.ResourceStatusInState & status.ResourceStatusFromRead should be nil and status.InlineStatus must NOT be nil. -func NewOutput(instanceID, plugin string, options map[string]interface{}, status *Status) (*Output, error) { +func NewOutput(instanceID, plugin string, options configmanager.RawOptions, status *Status) (*Output, error) { if ok, err := validateParams(instanceID, plugin, options, status); !ok { return nil, err } @@ -61,7 +63,7 @@ func (o *Output) Print() error { return nil } -func validateParams(instanceID, plugin string, options map[string]interface{}, status *Status) (bool, error) { +func validateParams(instanceID, plugin string, options configmanager.RawOptions, status *Status) (bool, error) { if instanceID == "" || plugin == "" { return false, fmt.Errorf("instanceID or plugin cannot be nil") } diff --git a/internal/pkg/statemanager/manager.go b/internal/pkg/statemanager/manager.go index 9f56ec284..8bc32f6cf 100644 --- a/internal/pkg/statemanager/manager.go +++ b/internal/pkg/statemanager/manager.go @@ -28,7 +28,7 @@ type Manager interface { AddState(key StateKey, state State) error UpdateState(key StateKey, state State) error DeleteState(key StateKey) error - GetOutputs(key StateKey) (interface{}, error) + GetOutputs(key StateKey) (ResourceOutputs, error) } // manager is the default implement with Manager @@ -117,13 +117,13 @@ func (m *manager) DeleteState(key StateKey) error { } // GetOutputs is used to get the origin outputs of a toolName_InstanceID -func (m *manager) GetOutputs(key StateKey) (interface{}, error) { +func (m *manager) GetOutputs(key StateKey) (ResourceOutputs, error) { state := m.GetState(key) if state == nil { return nil, fmt.Errorf(`key (%s) not in state, it may be failed when "Create"`, key) } - if value, ok := state.ResourceStatus["outputs"]; ok { + if value := state.ResourceStatus.GetOutputs(); value != nil { return value, nil } diff --git a/internal/pkg/statemanager/manager_test.go b/internal/pkg/statemanager/manager_test.go index 8f8b0660e..05f8dc3de 100644 --- a/internal/pkg/statemanager/manager_test.go +++ b/internal/pkg/statemanager/manager_test.go @@ -31,8 +31,8 @@ var _ = Describe("Statemanager", func() { testState = statemanager.State{ InstanceID: "name", Name: "githubactions", - Options: map[string]interface{}{"a": "value"}, - ResourceStatus: map[string]interface{}{"a": "value"}, + Options: configmanager.RawOptions{"a": "value"}, + ResourceStatus: statemanager.ResourceStatus{"a": "value"}, } }) @@ -68,8 +68,8 @@ var _ = Describe("Statemanager", func() { stateC := statemanager.State{ InstanceID: "c", Name: "githubactions", - Options: map[string]interface{}{"c": "value"}, - ResourceStatus: map[string]interface{}{"c": "value"}, + Options: configmanager.RawOptions{"c": "value"}, + ResourceStatus: statemanager.ResourceStatus{"c": "value"}, } err = smgr.AddState(key, stateC) Expect(err).NotTo(HaveOccurred()) @@ -78,8 +78,8 @@ var _ = Describe("Statemanager", func() { stateB := statemanager.State{ InstanceID: "b", Name: "githubactions", - Options: map[string]interface{}{"b": "value"}, - ResourceStatus: map[string]interface{}{"b": "value"}, + Options: configmanager.RawOptions{"b": "value"}, + ResourceStatus: statemanager.ResourceStatus{"b": "value"}, } err = smgr.AddState(key, stateB) Expect(err).NotTo(HaveOccurred()) diff --git a/internal/pkg/statemanager/state.go b/internal/pkg/statemanager/state.go index d60d2e194..64a04a845 100644 --- a/internal/pkg/statemanager/state.go +++ b/internal/pkg/statemanager/state.go @@ -5,6 +5,8 @@ import ( "fmt" "sort" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "gopkg.in/yaml.v3" "github.com/devstream-io/devstream/pkg/util/log" @@ -14,17 +16,28 @@ import ( // We call what the plugin created a ResourceStatus, and which is stored as part of the state. type ResourceStatus map[string]interface{} +type ResourceOutputs map[string]interface{} + // State is the single component's state. type State struct { - Name string `yaml:"name"` - InstanceID string `yaml:"instanceID"` - DependsOn []string `yaml:"dependsOn"` - Options map[string]interface{} `yaml:"options"` - ResourceStatus ResourceStatus `yaml:"resourceStatus"` + Name string `yaml:"name"` + InstanceID string `yaml:"instanceID"` + DependsOn []string `yaml:"dependsOn"` + Options configmanager.RawOptions `yaml:"options"` + ResourceStatus ResourceStatus `yaml:"resourceStatus"` +} + +func (rs ResourceStatus) SetOutputs(outputs ResourceOutputs) { + (rs)["outputs"] = outputs } -func (rs *ResourceStatus) SetOutputs(outputs map[string]interface{}) { - (*rs)["outputs"] = outputs +func (rs ResourceStatus) GetOutputs() ResourceOutputs { + outputs, ok := (rs)["outputs"] + if !ok { + return nil + } + + return outputs.(ResourceOutputs) } type StatesMap struct { diff --git a/pkg/util/types/struct.go b/pkg/util/types/struct.go index 586f1ff81..eea804097 100644 --- a/pkg/util/types/struct.go +++ b/pkg/util/types/struct.go @@ -3,6 +3,8 @@ package types import ( "reflect" + "github.com/devstream-io/devstream/internal/pkg/configmanager" + "github.com/mitchellh/mapstructure" ) @@ -34,8 +36,8 @@ func FillStructDefaultValue(structData, defaultStructData any) { } // EncodeStruct will get structData and encode this data to map -func EncodeStruct(structData any) (map[string]interface{}, error) { - var options map[string]interface{} +func EncodeStruct(structData any) (configmanager.RawOptions, error) { + var options configmanager.RawOptions if err := mapstructure.Decode(structData, &options); err != nil { return nil, err }