Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add default repo config for argo #851

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions internal/pkg/plugin/argocd/argocd.go
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
package argocd

import (
. "github.com/devstream-io/devstream/internal/pkg/plugin/common/helm"
"github.com/devstream-io/devstream/pkg/util/helm"
)

const (
defaultRepoName = "argo"
defaultRepoURL = "https://argoproj.github.io/argo-helm"
)

var DefaultDeploymentList = []string{
"argocd-applicationset-controller",
"argocd-dex-server",
"argocd-notifications-controller",
"argocd-redis",
"argocd-repo-server",
"argocd-server",
}

func GetStaticState() *helm.InstanceState {
retState := &helm.InstanceState{}
for _, dpName := range DefaultDeploymentList {
retState.Workflows.AddDeployment(dpName, true)
}
return retState
}

func defaultMissedOptions(opts *Options) error {
emptyRepo := helm.Repo{}
if opts.Repo == emptyRepo {
opts.Repo.Name = defaultRepoName
opts.Repo.URL = defaultRepoURL
} else {
if opts.Repo.URL == "" {
opts.Repo.URL = defaultRepoURL
}
if opts.Repo.Name == "" {
opts.Repo.Name = defaultRepoName
}
}
return nil
}
6 changes: 5 additions & 1 deletion internal/pkg/plugin/argocd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ import (

// Create creates ArgoCD with provided options.
func Create(options map[string]interface{}) (map[string]interface{}, error) {
// 1. decode options
// 1. decode options and fill default options if miss
var opts Options
if err := mapstructure.Decode(options, &opts); err != nil {
return nil, err
}

if err := defaultMissedOptions(&opts); err != nil {
return nil, err
}

if errs := validate(&opts); len(errs) != 0 {
for _, e := range errs {
log.Errorf("Options error: %s.", e)
Expand Down
20 changes: 0 additions & 20 deletions internal/pkg/plugin/argocd/state.go

This file was deleted.

6 changes: 5 additions & 1 deletion internal/pkg/plugin/argocd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ import (
)

func Update(options map[string]interface{}) (map[string]interface{}, error) {
// 1. decode options
// 1. decode options and fill default options if miss
var opts Options
if err := mapstructure.Decode(options, &opts); err != nil {
return nil, err
}

if err := defaultMissedOptions(&opts); err != nil {
return nil, err
}

if errs := validate(&opts); len(errs) != 0 {
for _, e := range errs {
log.Errorf("Options error: %s.", e)
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/show/config/plugins/argocd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tools:
options:
# need to create the namespace or not, default: false
create_namespace: true
# Helm repo information, this section is optional
repo:
# name of the Helm repo
name: argo
Expand All @@ -31,5 +32,5 @@ tools:
# custom configuration (Optional). You can refer to [ArgoCD values.yaml](https://github.com/argoproj/argo-helm/blob/master/charts/argo-cd/values.yaml)
values_yaml: |
controller:
service:
service:
port: 8080