Skip to content

Commit

Permalink
Merge pull request #1196 from merico-dev/feat-helm
Browse files Browse the repository at this point in the history
Feat: Add a New Plugin `helm-installer`
  • Loading branch information
daniel-hutao authored Oct 26, 2022
2 parents 9b026d8 + 32e3181 commit b4a62f2
Show file tree
Hide file tree
Showing 42 changed files with 329 additions and 409 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ build-core: generate fmt lint vet mod-tidy ## Build dtm core only, without plugi
.PHONY: build-plugin.%
build-plugin.%: generate fmt lint vet mod-tidy ## Build one dtm plugin, like "make build-plugin.argocd".
$(eval plugin_name := $(strip $*))
@[ -d $(ROOT_DIR)/cmd/plugin/$(plugin_name) ] || { echo -e "\n${RED}✘ Plugin '$(plugin_name)' not found!${RESET} The valid plugin name is as follows (Eg. You can use ${YELLOW}make build-plugin.argocd${RESET} to build argocd plugin): \n\n$(shell ls ./cmd/plugin/)\n"; exit 1; }
@[ -d $(ROOT_DIR)/cmd/plugin/$(plugin_name) ] || { echo -e "\n${RED}✘ Plugin '$(plugin_name)' not found!${RESET} The valid plugin name is as follows (Eg. You can use ${YELLOW}make build-plugin.argocdapp${RESET} to build argocdapp plugin): \n\n$(shell ls ./cmd/plugin/)\n"; exit 1; }
@echo "$(YELLOW)Building plugin '$(plugin_name)'$(RESET)"
${GO_PLUGIN_BUILD} -o ${PLUGINS_DIR}/${plugin_name}-${PLUGIN_SUFFIX}.so ${ROOT_DIR}/cmd/plugin/${plugin_name}
@$(MAKE) md5-plugin.$(plugin_name)
Expand Down
41 changes: 0 additions & 41 deletions cmd/plugin/helm-generic/main.go

This file was deleted.

20 changes: 10 additions & 10 deletions cmd/plugin/argocd/main.go → cmd/plugin/helm-installer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@ 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/plugin/helminstaller"
"github.com/devstream-io/devstream/internal/pkg/statemanager"
"github.com/devstream-io/devstream/pkg/util/log"
)

// NAME is the name of this DevStream plugin.
const NAME = "argocd"
const NAME = "helm-installer"

// Plugin is the type used by DevStream core. It's a string.
type Plugin string

// Create implements the create of ArgoCD.
// Create implements the create of helm-installer.
func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
return argocd.Create(options)
return helminstaller.Create(options)
}

// Update implements the update of ArgoCD.
// Update implements the update of helm-installer.
func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
return argocd.Update(options)
return helminstaller.Update(options)
}

// Delete implements the delete of ArgoCD.
// Delete implements the delete of helm-installer.
func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) {
return argocd.Delete(options)
return helminstaller.Delete(options)
}

// Read implements the read of ArgoCD.
// Read implements the read of helm-installer.
func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
return argocd.Read(options)
return helminstaller.Read(options)
}

// DevStreamPlugin is the exported variable used by the DevStream core.
Expand Down
3 changes: 0 additions & 3 deletions docs/plugins/argocd.zh.md

This file was deleted.

13 changes: 0 additions & 13 deletions docs/plugins/helm-generic.md

This file was deleted.

13 changes: 0 additions & 13 deletions docs/plugins/helm-generic.zh.md

This file was deleted.

21 changes: 9 additions & 12 deletions docs/plugins/argocd.md → docs/plugins/helm-installer.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
# argocd Plugin
# helm-installer plugin

This plugin installs [ArgoCD](https://argoproj.github.io/cd/) in an existing Kubernetes cluster using the Helm chart.
TODO(daniel-hutao): I'll update this the document after code refactoring finished.

## Usage

The following content is an example of the "tool file".

For more information on the main config, the tool file and the var file of DevStream, see [Core Concepts Overview](../core-concepts/core-concepts.md#1-config) and [DevStream Configuration](../core-concepts/config.md).

```yaml
--8<-- "argocd.yaml"
``` yaml
--8<-- "helm-installer.yaml"
```

### Default Configs
### Argo CD

#### Default Configs

| key | default value | description |
| ---------------- | ------------------------------------ | ------------------------------------------------ |
| chart.chartPath | "" | local chart path |
| chart.chartName | argo/argo-cd | chart name |
| chart.timeout | 5m | this config will wait 5 minutes to deploy argocd |
| chart.version | "" | chart version
| chart.timeout | 5m | this config will wait 5 minutes to deploy Argo CD |
| chart.upgradeCRDs | true | default update CRD config |
| chart.releaseName | argocd | helm release name |
| chart.namespace | argocd | namespace where helm to deploy |
| chart.wait | true | whether to wait until installation is complete |
| repo.url | https://argoproj.github.io/argo-helm | helm official repo address |
| repo.name | argo | helm repo name |

Currently, except for `valuesYaml` and default configs, all the parameters in the example above are mandatory.
8 changes: 8 additions & 0 deletions docs/plugins/helm-installer.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# helm-installer 插件

TODO(daniel-hutao): I'll update this the document after code refactoring finished.
## 用例

``` yaml
--8<-- "helm-installer.yaml"
```
4 changes: 1 addition & 3 deletions docs/plugins/plugins-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
| CI | ci-generic | Generic CI plugin | [doc](ci-generic.md) |
| CI | tekton | Tekton CI installation | [doc](tekton.md) |
| Code Quality/Security | sonarqube | SonarQube | [doc](sonarqube.md)
| CD/GitOps | argocd | ArgoCD installation | [doc](argocd.md) |
| CD/GitOps | argocdapp | ArgoCD Application creation | [doc](argocdapp.md) |
| Image Repository | artifactory | Artifactory installation | [doc](artifactory.md) |
| Image Repository | harbor | Harbor helm installation | [doc](harbor.md) |
| Image Repository | harbor-docker | Harbor Docker compose install | [doc](harbor-docker.md) |
| Deployment | helm-generic | Helm chart install | [doc](helm-generic.md) |
| Deployment | helm-installer | Helm chart install | [doc](helm-installer.md) |
| Monitoring | kube-prometheus | Prometheus/Grafana K8s install | [doc](kube-prometheus.md) |
| Observability | devlake | DevLake installation | [doc](devlake.md) |
| LDAP | openldap | OpenLDAP installation | [doc](openldap.md) |
Expand All @@ -34,7 +33,6 @@ Or, to get a list of plugins, run:

```shell
$ dtm list plugins
argocd
argocdapp
artifactory
ci-generic
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/develop/plugin/template/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var createGoDirTpl = "internal/pkg/plugin/[[ .Name | dirFormat ]]/"
var createGoContentTpl = `package [[ .Name | format ]]
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"
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/develop/plugin/template/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var optionsGoContentTpl = `package [[ .Name | format ]]
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 configurations of the [[ .Name ]] plugin.
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/develop/plugin/template/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var readGoDirTpl = "internal/pkg/plugin/[[ .Name | dirFormat ]]/"
var readGoContentTpl = `package [[ .Name | format ]]
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"
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/develop/plugin/template/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var updateGoDirTpl = "internal/pkg/plugin/[[ .Name | dirFormat ]]/"
var updateGoContentTpl = `package [[ .Name | format ]]
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"
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/develop/plugin/template/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var validateGoContentTpl = `package [[ .Name | format ]]
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"
)
Expand Down
25 changes: 0 additions & 25 deletions internal/pkg/plugin/argocd/delete.go

This file was deleted.

29 changes: 0 additions & 29 deletions internal/pkg/plugin/argocd/update.go

This file was deleted.

30 changes: 0 additions & 30 deletions internal/pkg/plugin/helmgeneric/create.go

This file was deleted.

1 change: 0 additions & 1 deletion internal/pkg/plugin/helmgeneric/helmgeneric.go

This file was deleted.

27 changes: 0 additions & 27 deletions internal/pkg/plugin/helmgeneric/read.go

This file was deleted.

12 changes: 0 additions & 12 deletions internal/pkg/plugin/helmgeneric/state.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package argocd
package helminstaller

import (
"github.com/devstream-io/devstream/internal/pkg/configmanager"
Expand All @@ -8,13 +8,13 @@ import (
"github.com/devstream-io/devstream/pkg/util/log"
)

// Create creates ArgoCD with provided options.
func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
// Initialize Operator with Operations
operator := &plugininstaller.Operator{
PreExecuteOperations: plugininstaller.PreExecuteOperations{
helm.SetDefaultConfig(&defaultHelmConfig),
helm.Validate,
SetDefaultConfig,
RenderValuesYaml,
validate,
},
ExecuteOperations: helm.DefaultCreateOperations,
TerminateOperations: helm.DefaultTerminateOperations,
Expand Down
Loading

0 comments on commit b4a62f2

Please sign in to comment.