Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
feed2c1
feat: api of DingTalk notification bot
aFlyBird0 Sep 14, 2022
3344e21
feat: remove examples of dingtalk
aFlyBird0 Sep 14, 2022
c2ad862
fix: lint caused by jenkins mock client
aFlyBird0 Sep 14, 2022
e5ec95d
Merge pull request #1091 from devstream-io/release-0.9
daniel-hutao Sep 16, 2022
dd7c732
Merge pull request #1099 from devstream-io/release-0.9
IronCore864 Sep 16, 2022
4dd2a18
feat: add plugin sonar
steinliber Sep 14, 2022
50d60bd
Merge pull request #1087 from aFlyBird0/dingtalk
daniel-hutao Sep 16, 2022
e3ea5b1
feat: use `dtm init -a` to download all plugins to support use dtm of…
aFlyBird0 Sep 18, 2022
2adff3f
feat: use `dtm init --download-only` to download specify plugins from…
aFlyBird0 Sep 19, 2022
e272e45
feat: jenkins repo support private repo
steinliber Sep 19, 2022
74a7024
fix: code conflict
steinliber Sep 19, 2022
50af4c6
fix: doc error
steinliber Sep 19, 2022
cdcd43b
feat: update according to daniel-hutao's review
aFlyBird0 Sep 19, 2022
5ae6d7f
feat: jenkins plugin support version control
steinliber Sep 19, 2022
343bac5
docs: the plugins harbor and jenkins customize image repository support
daniel-hutao Sep 15, 2022
ca83d52
docs: add dtm init logic in gitlab-jenkins-harbor.zh.md
daniel-hutao Sep 19, 2022
e666f94
Merge pull request #1100 from merico-dev/feat-jenkins-plugin-install-…
daniel-hutao Sep 19, 2022
e09819a
docs: fix links according bird's review comments
daniel-hutao Sep 20, 2022
828e79e
Merge pull request #1089 from merico-dev/feat-plugin-sonar
daniel-hutao Sep 20, 2022
2e7e42f
feat: update according to steinliber's review
aFlyBird0 Sep 20, 2022
358c15d
fix: log message error
steinliber Sep 20, 2022
1887ccb
Merge pull request #1101 from merico-dev/feat-air-gapped
daniel-hutao Sep 20, 2022
ee81d99
Merge pull request #1104 from aFlyBird0/feat-dtm-init-all
daniel-hutao Sep 20, 2022
b80bd4c
doc: add flags to apply/delete/destroy/verify
aFlyBird0 Sep 20, 2022
ea1f337
doc: translate apply/init/delete/destroy/verify into Chinese
aFlyBird0 Sep 20, 2022
362de0b
ci: material for mkdocs enhancement
daniel-hutao Sep 20, 2022
952e7b2
doc: fix broken links
aFlyBird0 Sep 20, 2022
c148cc7
Merge pull request #1107 from merico-dev/feat-air-gapped
daniel-hutao Sep 21, 2022
6e77b2f
Merge pull request #1108 from aFlyBird0/bird-doc-01
daniel-hutao Sep 21, 2022
9779212
Merge pull request #1105 from merico-dev/feat-jenkins-support-private…
daniel-hutao Sep 21, 2022
27caa8a
fix: `dtm destroy` error caused by typo
aFlyBird0 Sep 21, 2022
e13f336
Merge pull request #1109 from aFlyBird0/fix-cmd-destroy
daniel-hutao Sep 21, 2022
db36d62
doc: add "show, list, upgrade" in en and zh-cn & translate "develop"
aFlyBird0 Sep 21, 2022
2b436fe
fix: exit when any command fails in auto-release script
aFlyBird0 Sep 22, 2022
7d800d0
Merge pull request #1112 from aFlyBird0/fix-auto-release
daniel-hutao Sep 22, 2022
24b9598
doc: translate autocomplete.md into Chinese
aFlyBird0 Sep 22, 2022
96eb474
docs: jenkins and harbor documents enhancement
daniel-hutao Sep 22, 2022
e987e14
Merge pull request #1111 from aFlyBird0/bird-doc-02
daniel-hutao Sep 22, 2022
13f9d5b
doc: minor changes according to daniel-hutao's review
aFlyBird0 Sep 22, 2022
8252f19
Merge pull request #1116 from merico-dev/feat-air-gapped
daniel-hutao Sep 23, 2022
f344b3e
Merge pull request #1115 from aFlyBird0/translate-autocomplete
daniel-hutao Sep 23, 2022
68fb557
feat: the plugin jenkins-pipeline-kubernetes sunset
daniel-hutao Sep 23, 2022
b9ed245
docs: gitlab-jenkins-harbor.zh.md enhancement with material advanced …
daniel-hutao Sep 23, 2022
5f15e57
Merge pull request #1117 from merico-dev/feat-air-gapped
daniel-hutao Sep 23, 2022
4de9ff4
docs: gitlab-jenkins-harbor.zh.md title fixed
daniel-hutao Sep 23, 2022
3c92b1f
Merge pull request #1118 from merico-dev/feat-air-gapped
daniel-hutao Sep 23, 2022
d23cf96
fix: minor errors in `dtm init --download-only`
aFlyBird0 Sep 23, 2022
e042b72
Merge pull request #1120 from aFlyBird0/fix-init-download-only
daniel-hutao Sep 23, 2022
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
1 change: 1 addition & 0 deletions cmd/devstream/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func destroyCMDFunc(cmd *cobra.Command, args []string) {
func init() {
destroyCMD.Flags().BoolVarP(&isForceDestroy, "force", "", false, "force destroy by config")
destroyCMD.Flags().StringVarP(&configFile, configFlagName, "f", "config.yaml", "config file")
destroyCMD.Flags().StringVarP(&pluginDir, pluginDirFlagName, "d", "", "plugins directory")
destroyCMD.Flags().BoolVarP(&continueDirectly, "yes", "y", false, "destroy directly without confirmation")

completion.FlagFilenameCompletion(destroyCMD, configFlagName)
Expand Down
5 changes: 3 additions & 2 deletions cmd/devstream/develop.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func init() {
developCMD.AddCommand(developCreatePluginCMD)
developCMD.AddCommand(developValidatePluginCMD)

developCreatePluginCMD.PersistentFlags().StringVarP(&name, "name", "n", "", "specify name with the new plugin")
developValidatePluginCMD.PersistentFlags().StringVarP(&name, "name", "n", "", "specify name with the new plugin")
developCreatePluginCMD.PersistentFlags().StringVarP(&name, "name", "n", "", "specify name of the plugin to be created")

developValidatePluginCMD.PersistentFlags().StringVarP(&name, "name", "n", "", "specify name of the plugin to be validated")
developValidatePluginCMD.PersistentFlags().BoolVarP(&all, "all", "a", false, "validate all plugins")
}
107 changes: 96 additions & 11 deletions cmd/devstream/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ package main

import (
"fmt"
"runtime"
"strings"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/devstream-io/devstream/cmd/devstream/list"
"github.com/devstream-io/devstream/internal/pkg/completion"
"github.com/devstream-io/devstream/internal/pkg/configmanager"
"github.com/devstream-io/devstream/internal/pkg/pluginmanager"
Expand All @@ -20,35 +24,116 @@ var initCMD = &cobra.Command{
Run: initCMDFunc,
}

var (
downloadOnly bool // download plugins only, from command line flags
downloadAll bool // download all plugins
pluginsToDownload []string // download specific plugins
initOS string // download plugins for specific os
initArch string // download plugins for specific arch
)

func initCMDFunc(_ *cobra.Command, _ []string) {
if version.Dev {
log.Fatalf("Dev version plugins can't be downloaded from the remote plugin repo; please run `make build-plugin.PLUGIN_NAME` to build them locally.")
}

var (
realPluginDir string
tools []configmanager.Tool
err error
)

if downloadOnly {
// download plugins from flags
tools, realPluginDir, err = GetPluginsAndPluginDirFromFlags()
} else {
// download plugins according to the config file
tools, realPluginDir, err = GetPluginsAndPluginDirFromConfig()
}

if err != nil {
log.Fatal(err)
}

if err := pluginmanager.DownloadPlugins(tools, realPluginDir, initOS, initArch); err != nil {
log.Fatal(err)
}

fmt.Println()
log.Success("Initialize finished.")
}

func GetPluginsAndPluginDirFromConfig() (tools []configmanager.Tool, pluginDir string, err error) {
cfg, err := configmanager.NewManager(configFile).LoadConfig()
if err != nil {
log.Errorf("Error: %s.", err)
return
return nil, "", err
}

// combine plugin dir from config file and flag
if err := file.SetPluginDir(cfg.PluginDir); err != nil {
log.Errorf("Error: %s.", err)
return nil, "", err
}

if version.Dev {
log.Errorf("Dev version plugins can't be downloaded from the remote plugin repo; please run `make build-plugin.PLUGIN_NAME` to build them locally.")
return
return cfg.Tools, viper.GetString(pluginDirFlagName), nil
}

func GetPluginsAndPluginDirFromFlags() (tools []configmanager.Tool, pluginDir string, err error) {
// 1. get plugins from flags
var pluginsName []string
if downloadAll {
// download all plugins
pluginsName = list.PluginsNameSlice()
} else {
// download specific plugins
for _, pluginName := range pluginsToDownload {
if p := strings.ToLower(strings.TrimSpace(pluginName)); p != "" {
pluginsName = append(pluginsName, p)
}
}
// check if plugins to download are supported by dtm
for _, plugin := range pluginsName {
if _, ok := list.PluginNamesMap()[plugin]; !ok {
return nil, "", fmt.Errorf("Plugin %s is not supported by dtm", plugin)
}
}
}

if err = pluginmanager.DownloadPlugins(cfg); err != nil {
log.Errorf("Error: %s.", err)
return
if len(pluginsName) == 0 {
log.Errorf("Please use --plugins to specify plugins to download or use --all to download all plugins.")
}
log.Debugf("plugins to download: %v", pluginsName)

fmt.Println()
log.Success("Initialize finished.")
if initOS == "" || initArch == "" {
return nil, "", fmt.Errorf("Once you use the --all flag, you must specify the --os and --arch flags")
}

log.Infof("Plugins to download: %v", pluginsName)

// build the plugin list
for _, pluginName := range pluginsName {
tools = append(tools, configmanager.Tool{Name: pluginName})
}

// 2. handle plugin dir
if err := file.SetPluginDir(""); err != nil {
return nil, "", err
}

return tools, viper.GetString(pluginDirFlagName), nil
}

func init() {
// flags for init from config file
initCMD.Flags().StringVarP(&configFile, configFlagName, "f", "config.yaml", "config file")
initCMD.Flags().StringVarP(&pluginDir, pluginDirFlagName, "d", "", "plugins directory")

// downloading specific plugins from flags
initCMD.Flags().BoolVar(&downloadOnly, "download-only", false, "download plugins only")
initCMD.Flags().StringSliceVarP(&pluginsToDownload, "plugins", "p", []string{}, "the plugins to be downloaded")
initCMD.Flags().BoolVarP(&downloadAll, "all", "a", false, "download all plugins")
initCMD.Flags().StringVar(&initOS, "os", runtime.GOOS, "download plugins for specific os")
initCMD.Flags().StringVar(&initArch, "arch", runtime.GOARCH, "download plugins for specific arch")

completion.FlagFilenameCompletion(initCMD, configFlagName)
completion.FlagDirnameCompletion(initCMD, pluginDirFlagName)
}
4 changes: 1 addition & 3 deletions cmd/devstream/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ var PluginsName string

// List all plugins name
func List(pluginFilter string) {
listPluginsName := strings.Fields(PluginsName)
r, _ := regexp.Compile(pluginFilter)
sort.Strings(listPluginsName)
for _, pluginName := range listPluginsName {
for _, pluginName := range PluginsNameSlice() {
if r.Match([]byte(pluginName)) {
fmt.Println(pluginName)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/devstream/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var template string

var showCMD = &cobra.Command{
Use: "show",
Short: "Show is used to print some useful information",
Short: "Show is used to print plugins' configuration templates or status.",
}

var showConfigCMD = &cobra.Command{
Expand All @@ -25,7 +25,8 @@ var showConfigCMD = &cobra.Command{
Long: `Show config is used for showing plugins' template configuration information.
Examples:
dtm show config --plugin=A-PLUGIN-NAME,
dtm show config --template=quickstart`,
dtm show config --template=quickstart,
dtm show config --template=gitops`,
Run: showConfigCMDFunc,
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/devstream/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ func upgradeCMDFunc(cmd *cobra.Command, args []string) {
}

func init() {
upgradeCMD.Flags().BoolVarP(&continueDirectly, "yes", "y", false, "apply directly without confirmation")
upgradeCMD.Flags().BoolVarP(&continueDirectly, "yes", "y", false, "upgrade directly without confirmation")
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package main

import (
"github.com/devstream-io/devstream/internal/pkg/plugin/jenkinspipelinekubernetes"
"github.com/devstream-io/devstream/internal/pkg/plugin/sonarqube"
"github.com/devstream-io/devstream/pkg/util/log"
)

// NAME is the name of this DevStream plugin.
const NAME = "jenkins-pipeline-kubernetes"
const NAME = "sonarqube"

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

// Create implements the create of jenkins-pipeline-kubernetes.
// Create implements the create of sonar.
func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) {
return jenkinspipelinekubernetes.Create(options)
return sonarqube.Create(options)
}

// Update implements the update of jenkins-pipeline-kubernetes.
// Update implements the update of sonar.
func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) {
return jenkinspipelinekubernetes.Update(options)
return sonarqube.Update(options)
}

// Delete implements the delete of jenkins-pipeline-kubernetes.
// Delete implements the delete of sonar.
func (p Plugin) Delete(options map[string]interface{}) (bool, error) {
return jenkinspipelinekubernetes.Delete(options)
return sonarqube.Delete(options)
}

// Read implements the read of jenkins-pipeline-kubernetes.
// Read implements the read of sonar.
func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) {
return jenkinspipelinekubernetes.Read(options)
return sonarqube.Read(options)
}

// DevStreamPlugin is the exported variable used by the DevStream core.
Expand Down
Loading