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

refactor: import plugin default configs with go:embed #614

Merged
merged 4 commits into from
May 27, 2022
Merged
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
38 changes: 18 additions & 20 deletions internal/pkg/show/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,27 @@ import (
"fmt"

"github.com/spf13/viper"

"github.com/devstream-io/devstream/internal/pkg/show/config/plugin"
)

var pluginDefaultConfigs = map[string]string{
"argocd": plugin.ArgocdDefaultConfig,
"argocdapp": plugin.ArgocdappDefaultConfig,
"devlake": plugin.DevlakeDefaultConfig,
"github-repo-scaffolding-golang": plugin.GithubRepoScaffoldingGolangDefaultConfig,
"githubactions-golang": plugin.GithubActionsGolangDefaultConfig,
"githubactions-nodejs": plugin.GithubActionsNodejsDefaultConfig,
"githubactions-python": plugin.GithubActionsPythonDefaultConfig,
"gitlabci-generic": plugin.GitlabCIGenericDefaultConfig,
"gitlabci-golang": plugin.GitlabCIGolangDefaultConfig,
"jenkins": plugin.JenkinsDefaultConfig,
"jira-github-integ": plugin.JiraGithubDefaultConfig,
"kube-prometheus": plugin.KubePrometheusDefaultConfig,
"openldap": plugin.OpenldapDefaultConfig,
"trello-github-integ": plugin.TrelloGithubDefaultConfig,
"trello": plugin.TrelloDefaultConfig,
"helm-generic": plugin.HelmGenericDefaultConfig,
"gitlab-repo-scaffolding-golang": plugin.GitLabRepoScaffoldingGolangDefaultConfig,
"hashicorp-vault": plugin.VaultDefaultConfig,
"argocd": ArgocdDefaultConfig,
"argocdapp": ArgocdappDefaultConfig,
"devlake": DevlakeDefaultConfig,
"github-repo-scaffolding-golang": GithubRepoScaffoldingGolangDefaultConfig,
"githubactions-golang": GithubActionsGolangDefaultConfig,
"githubactions-nodejs": GithubActionsNodejsDefaultConfig,
"githubactions-python": GithubActionsPythonDefaultConfig,
"gitlabci-generic": GitlabCIGenericDefaultConfig,
"gitlabci-golang": GitlabCIGolangDefaultConfig,
"jenkins": JenkinsDefaultConfig,
"jira-github-integ": JiraGithubDefaultConfig,
"kube-prometheus": KubePrometheusDefaultConfig,
"openldap": OpenldapDefaultConfig,
"trello-github-integ": TrelloGithubDefaultConfig,
"trello": TrelloDefaultConfig,
"helm-generic": HelmGenericDefaultConfig,
"gitlab-repo-scaffolding-golang": GitLabRepoScaffoldingGolangDefaultConfig,
"hashicorp-vault": VaultDefaultConfig,
}

func Show() error {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package config

var DefaultConfig = `# config.yaml sample:
# defaultconfig.yaml sample:
# var file path, you can set it to absolute path or relative path.
varFile: variables.yaml # here is a relative path. (defaults is ./variables.yaml)
# tool file path, you can set it to absolute path or relative path.
Expand All @@ -13,13 +11,13 @@ state:

# tools.yaml sample:
tools:
- name: github-repo-scaffolding-golang
instanceID: default
options:
owner: [[ githubUsername ]]
org: ""
repo: [[ repoName ]]
- name: github-repo-scaffolding-golang
instanceID: default
options:
owner: [ [ githubUsername ] ]
org: ""
repo: [ [ repoName ] ]

# variables.yaml sample:
githubUsername: daniel-hutao
repo: go-webapp-demo`
repo: go-webapp-demo
63 changes: 63 additions & 0 deletions internal/pkg/show/config/embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package config

import _ "embed"

//go:embed default.yaml
var DefaultConfig string

// plugin default config
var (
//go:embed plugins/argocd.yaml
ArgocdDefaultConfig string

//go:embed plugins/argocdapp.yaml
ArgocdappDefaultConfig string

//go:embed plugins/devlake.yaml
DevlakeDefaultConfig string

//go:embed plugins/github-repo-scaffolding-golang.yaml
GithubRepoScaffoldingGolangDefaultConfig string

//go:embed plugins/githubactions-golang.yaml
GithubActionsGolangDefaultConfig string

//go:embed plugins/githubactions-nodejs.yaml
GithubActionsNodejsDefaultConfig string

//go:embed plugins/githubactions-python.yaml
GithubActionsPythonDefaultConfig string

//go:embed plugins/gitlabci-generic.yaml
GitlabCIGenericDefaultConfig string

//go:embed plugins/gitlabci-golang.yaml
GitlabCIGolangDefaultConfig string

//go:embed plugins/jenkins.yaml
JenkinsDefaultConfig string

//go:embed plugins/jira-github-integ.yaml
JiraGithubDefaultConfig string

//go:embed plugins/kube-prometheus.yaml
KubePrometheusDefaultConfig string

//go:embed plugins/openldap.yaml
OpenldapDefaultConfig string

//go:embed plugins/trello-github-integ.yaml
TrelloGithubDefaultConfig string

//go:embed plugins/trello.yaml
TrelloDefaultConfig string

//go:embed plugins/helm-generic.yaml
HelmGenericDefaultConfig string

//go:embed plugins/gitlab-repo-scaffolding-golang.yaml
GitLabRepoScaffoldingGolangDefaultConfig string

//go:embed plugins/hashicorp-vault.yaml
VaultDefaultConfig string
)
37 changes: 0 additions & 37 deletions internal/pkg/show/config/plugin/argocd.go

This file was deleted.

31 changes: 0 additions & 31 deletions internal/pkg/show/config/plugin/argocdapp.go

This file was deleted.

9 changes: 0 additions & 9 deletions internal/pkg/show/config/plugin/devlake.go

This file was deleted.

21 changes: 0 additions & 21 deletions internal/pkg/show/config/plugin/github-repo-scaffolding-golang.go

This file was deleted.

50 changes: 0 additions & 50 deletions internal/pkg/show/config/plugin/githubactions-golang.go

This file was deleted.

24 changes: 0 additions & 24 deletions internal/pkg/show/config/plugin/githubactions-nodejs.go

This file was deleted.

24 changes: 0 additions & 24 deletions internal/pkg/show/config/plugin/githubactions-python.go

This file was deleted.

21 changes: 0 additions & 21 deletions internal/pkg/show/config/plugin/gitlab-repo-scaffolding-golang.go

This file was deleted.

21 changes: 0 additions & 21 deletions internal/pkg/show/config/plugin/gitlabci-generic.go

This file was deleted.

Loading