-
-
-

-
# DevStream
-[](https://makeapullrequest.com)
-
-[](https://goreportcard.com/report/github.com/devstream-io/devstream)
-[](https://github.com/devstream-io/devstream/releases)
-[](https://bestpractices.coreinfrastructure.org/projects/6202)
-[](https://cloud-native.slack.com/archives/C03LA2B8K0A)
-
-| English | [中文](README_zh.md) |
-| --- | --- |
-
-
-
-## DevStream, What Is It Anyway?
-
-TL;DR: DevStream (CLI tool named `dtm`) is an open-source DevOps toolchain manager.
-
-[v0.6.0 Demo](https://www.youtube.com/watch?v=q7TK3vFr1kg)
-
-Imagine you are starting a new project or ramping up a new team. Before writing the first line of code, you have to figure out the tools to run an effective SDLC process and from development to deployment.
-
-Typically, you'd need the following pieces in place to work effectively:
-
-- Project management software or issue tracking tools (JIRA, etc.)
-- Source code management (GitHub, Bitbucket, etc.)
-- Continuous integration tools (Jenkins, CircleCI, Travis CI, etc.)
-- Continuous delivery/deployment tools (Flux CD/Flux2, Argo CD, etc.)
-- A single source of truth for secrets and credentials (secrets manager, e.g., Vault by HashiCorp)
-- Some tools for centralized logging and monitoring (for example, ELK, Prometheus/Grafana);
-
-The list could go on for quite a bit, but you get the idea!
-
-There are many challenges in creating an effective and personalized workflow:
-
-- There are too many choices. Which is best? There is no "one-size-fits-all" answer because it totally depends on your needs and preferences.
-- Integration between different pieces is challenging, creating silos and fragmentation.
-- The software world evolves fast. What's best today might not make sense tomorrow. If you want to switch parts or tools out, it can be challenging and resource intensive to manage.
-
-To be fair, there are a few integrated products out there that may contain everything you might need, but they might not suit your specific requirements perfectly. So, the chances are, you will still want to go out and do your research, find the best pieces, and integrate them yourself. That being said, to choose, launch, connect, and manage all these pieces take a lot of time and energy.
-
-You might be seeing where we are going with this...
-
-We wanted to make it easy to set up these personalized and flexible toolchains, so we built DevStream, an open-source DevOps toolchain manager.
-
-Think of the Linux kernel V.S. different distributions. Different distros offer different packages so that you can always choose the best for your need.
-
-Or, think of `yum`, `apt`, or `apk`. You can easily set it up with your favorite packages for any new environment using these package managers.
-
-DevStream aims to be the package manager for DevOps tools.
-
-To be more ambitious, DevStream wants to be the Linux kernel, around which different distros can be created with various components so that you can always have the best components for each part of your SDLC workflow.
-
-## Why `dtm`?
-
-Q: The CLI tool is named `dtm`, while the tool itself is called DevStream. What the heck?! Where is the consistency?
-
-A: Inspired by [`git`](https://github.com/git/git#readme), the name is (depending on your mood):
-
-- a symmetric, scientific acronym of **d**evs**t**rea**m**.
-- "devops toolchain manager": you're in a good mood, and it actually works for you.
-- "dead to me": when it breaks.
-
-## Why Use DevStream?
-
-No more manual curl/wget download, apt install, helm install; no more local experiments and playing around just to get a piece of tool installed correctly.
-
-Define your desired DevOps tools in a single human-readable YAML config file, and at the press of a button (one single command), you will have your whole DevOps toolchain and SDLC workflow set up. Five Minutes. One Command.
-
-Want to install another different tool for a try? No problem.
-
-Want to remove or reinstall a specific piece in the workflow? DevStream has got your back!
-
-## Quick Start
-
-If you want to get a quick start, follow our [quick start](https://docs.devstream.io/en/latest/quickstart/) doc now.
-
-## Best Practices Toolchain Integration
-
-DevStream supports the management of many tools. You can flexibly combine some tools to meet the DevOps toolchain your need.
-
-And yes, if you ask me if any recommended practices that can be used out of the box,
-
-I am happy to tell you that we have, and we are constantly adding more possible combinations,
-
-so you are more than welcome to tell us what combinations you expect.
-
-- [GitOps Toolchain](https://docs.devstream.io/en/latest/best-practices/gitops/)
-- [GitLab, Jenkins and Harbor On Premise Toolchain (Chinese only for now)](https://docs.devstream.io/en/latest/best-practices/gitlab-jenkins-harbor-java-springboot.zh/)
-
-## Supported DevOps Tools
-
-DevStream already supports many tools and it's still growing. For a complete list of supported tools, check out our [list of plugins](https://docs.devstream.io/en/latest/plugins/plugins-list/) document.
-
-Alternatively, run `dtm list plugins` and it will show you all the available plugins.
-
-## Dev Info
-
-### Pre-requisites
-
-- Git
-- Go (1.18+)
-
-### Development Guide
-
-- [Development Environment Setup](https://docs.devstream.io/en/latest/development/dev/dev-env-setup)
-- [Code linter](https://docs.devstream.io/en/latest/development/dev/lint)
-- [Build the source code](https://docs.devstream.io/en/latest/development/dev/build)
-- [Test the source code: unit test, e2e test](https://docs.devstream.io/en/latest/development/dev/test)
-- [Create a plugin](https://docs.devstream.io/en/latest/development/dev/creating-a-plugin)
-
-## Contribute
-
-First of all, thanks for wanting to contribute to DevStream! For more details on how to contribute, contributor growth program, style guide and more, please check out our [CONTRIBUTING](./CONTRIBUTING.md) document.
-
-## Community
-
-We will regularly organize `DevStream Community Meeting`, please visit the [wiki](https://github.com/devstream-io/devstream/wiki) page for details.
-
-Please join our Slack channel. Here's how:
-
-1. [Invite yourself to CNCF's Slack if you haven't done so](https://slack.cncf.io).
- - Input your email address, and click "get my invite."
- - Open your inbox, find the invitation email, and click "join now."
- - You can join by Email or with your Google account; follow the instructions.
-2. Join DevStream channel, there are two ways to do so:
- - Use [this link](https://cloud-native.slack.com/messages/devstream) to join the channel.
- - In your Slack app, on the left side navigation bar, move your mouse to the "Channels" section, and there should emerge a "plus" sign on the right. Click, and select "browse channels." Input "devstream", and join.
-3. For Mandarin-speaking users and contributors, you are also encouraged to join the [devstream-mandarin](https://cloud-native.slack.com/messages/devstream-mandarin) channel, where all discussions will be in Mandarin.
-
-For WeChat users, you can also join our WeChat group:
-
-
-
-## Code of Conduct
-
-[DevStream code of conduct](./CODE_OF_CONDUCT.md)
-
-As of Jun 2022, we joined CNCF sandbox. We also need to follow the [CNCF Community Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md).
+to be updated
diff --git a/README_zh.md b/README_zh.md
deleted file mode 100644
index 9e112c151..000000000
--- a/README_zh.md
+++ /dev/null
@@ -1,147 +0,0 @@
-
-
-
-

-
-# DevStream
-
-[](https://makeapullrequest.com)
-
-[](https://goreportcard.com/report/github.com/devstream-io/devstream)
-[](https://bestpractices.coreinfrastructure.org/projects/6202)
-[](https://github.com/devstream-io/devstream/releases)
-[](https://cloud-native.slack.com/archives/C03LA2B8K0A)
-
-| [English](README.md) | 中文 |
-| --- | --- |
-
-
-
-## DevStream 是什么?
-TL;DR: DevStream(CLI工具名为`dtm`)是一个开源的DevOps工具链管理器。
-
-[v0.6.0 Demo](https://www.bilibili.com/video/BV1W3411P7oW/)
-
-想象你正在开始一个新的项目或组建一个新的团队。在写第一行代码之前,你需要一个能够高效运转SDLC(软件开发生命周期)和承载开发至部署全过程的工具。
-
-通常情况下,你需要以下几个部分来高效地工作。
-
-- 项目管理软件或 `issue` 追溯工具(JIRA等)
-- 源代码管理(GitHub、Bitbucket等)
-- 持续集成(Jenkins、CircleCI、Travis CI等)
-- 持续交付/部署(Flux CD/Flux2、Argo CD等)
-- 密钥和证书的单一事实来源(A single source of truth)(密钥管理器,如HashiCorp的Vault)
-- 集成化的日志和监控工具(例如,ELK、Prometheus/Grafana)
-- ......
-
-具体内容远远不止这些,不过你应该已经明白意思了。
-
-在创建一个高效、定制化的工作流上,当前有许多挑战。
-
-- 我们有很多选择。哪个是最好的?没有"放之四海而皆准"的答案,因为这完全取决于你的需求和喜好。
-- 不同部分之间的整合是非常具有挑战性的,否则将导致项目孤岛化、碎片化。
-- 软件领域演进很快。今天最好的东西可能明天就毫无意义。如果你想换掉一些组件或工具,管理起来会很困难,也很耗费资源。
-
-说实话,有一些产品可能包含你需要的一切,但它们可能并不完全适合你的具体要求。因此,你仍然需要自己去搜寻,找到最好的组件,并自己将它们整合起来。也就是说,选择、启动、连接和管理所有这些组件需要大量的时间和精力。
-
-你可能已经看到了我们想要做的事情......
-
-我们想简化整合组件的过程,所以我们建立了DevStream,一个开源的DevOps工具链管理器。
-
-想一想Linux内核与不同发行版的关系。不同的发行版提供不同的软件包,这样你就可以随时选择你最需要的。
-
-或者,想想`yum`、`apt`或`apk`。你可以使用这些包管理器为任何新环境轻松设置你最喜欢的软件包。
-
-**DevStream的目标是成为DevOps工具的软件包管理器。**
-
-**更具野心的是,DevStream想成为Linux内核,你可以用各种组件创建不同的发行版,为SDLC工作流的每个部分选择最适合的组件。**
-
-## 为什么是 `dtm` ?
-Q:CLI被命名为 `dtm`,而工具本身被称为 `DevStream`。这是怎么回事!?一致性在哪里?
-
-A:受 [`git`](https://github.com/git/git#readme) 的启发,这个名字可以是(取决于你的心情):
-
-- "**d**evs**t**rea**m**": 一个对称缩写。
-- "**D**evops **T**oolchain **M**anager":当它对你有用的时候。
-- "**d**ead **t**o **m**e":当它崩溃的时候。
-
-## 为什么使用DevStream?
-
-不再需要手动的 `curl/wget` 下载、`apt` 安装、`helm` 安装;不再需要预先的本地试验以保证组件能正确安装。
-
-在一个人类可读的 `YAML` 配置文件中定义你所需要的DevOps工具,只需按一个按钮(或一个命令),你就能建立起整个DevOps工具链和SDLC工作流。
-
-五分钟,一个命令。
-
-想安装另一个不同的工具来试一试?没问题。
-
-想删除或重新安装工作流中的某个特定部分?DevStream已经帮你解决了!
-
-## 快速入门
-
-现在就跟随我们的[快速入门](https://docs.devstream.io/en/latest/quickstart.zh/)文档开始使用 DevStream
-
-## 最佳实践
-
-DevStream支持许多工具的管理。你可以灵活地结合一些工具来满足你所需要的DevOps工具链。
-
-是的,如果你问我是否有可以开箱即用的推荐实践。
-
-我很高兴地告诉你,我们有,而且我们正在不断增加更多可能的组合。
-
-我们非常欢迎你告诉我们你期望的组合。
-
-- [GitOps工具链](https://docs.devstream.io/en/latest/best-practices/gitops.zh/)
-- [用 DevStream 搭建 GitLab + Jenkins + Harbor 工具链,管理 Java Spring Boot 项目开发生命周期全流程](https://docs.devstream.io/en/latest/best-practices/gitlab-jenkins-harbor-java-springboot.zh/)
-
-## 支持的DevOps工具
-
-DevStream已经支持许多工具,而且还在不断增加。关于支持的工具的完整列表,请查看我们的 [插件列表](https://docs.devstream.io/en/latest/plugins/plugins-list) 文档。
-
-或者,运行 `dtm list plugins`,它将显示所有可用的插件。
-
-## 开发指南
-
-### 前提条件
-
-- Git
-- Go (1.18版本以上)
-
-### 开发指南
-
-- [开发环境搭建](https://docs.devstream.io/en/latest/development/dev/dev-env-setup.zh)
-- [代码格式检查](https://docs.devstream.io/en/latest/development/dev/lint.zh)
-- [源码构建](https://docs.devstream.io/en/latest/development/dev/build.zh)
-- [代码测试:单元测试(unit test)、端到端测试(e2e test)](https://docs.devstream.io/en/latest/development/dev/test.zh)
-- [开发新插件](https://docs.devstream.io/en/latest/development/dev/creating-a-plugin.zh)
-
-## 贡献
-
-首先,感谢你愿意为DevStream做贡献!
-
-关于如何贡献、贡献者成长计划、风格指南等更多细节,请查看我们的 [CONTRIBUTING](CONTRIBUTING.md) 文档。
-
-## 社区
-
-我们将定期组织 "DevStream Community Meeting",请访问 [WIKI](https://github.com/devstream-io/devstream/wiki) 页面了解详情。
-
-另外,请加入我们的Slack channel,请参见如下步骤:
-
-1. [给自己发送进入CNCF的Slack的邀请](https://slack.cncf.io)。
- - 输入邮箱地址,点击"get my invite"。
- - 打开收件箱,找到邀请邮件,点击邮件中的"join now"。
- - 你可以用邮箱地址或者Google账号等方式加入,跟随屏幕提示即可。
-2. 对于会说英文的用户:加入DevStream的英语频道。以下两种方式均可:
- - [点击这里](https://cloud-native.slack.com/messages/devstream)。
- - 在Slack app里,在左侧的导航栏,找到“频道”区域,将鼠标移动到上面,这时“频道”的右侧会出现一个加号。点击加号,然后选择“浏览频道”。输入"devstream",找到频道然后加入。
-3. 对于只说中文的用户,可以加入[devstream-mandarin](https://cloud-native.slack.com/messages/devstream-mandarin)频道,这里的讨论都是用中文进行的。
-
-对于使用微信的用户,请扫描二维码进群:
-
-
-
-## 行为守则
-
-[DevStream行为守则](/CODE_OF_CONDUCT.md)
-
-DevStream于2022年6月加入CNCF沙盒。我们也需要遵循[云原生计算基金会(CNCF)社区行为准则](https://github.com/cncf/foundation/blob/main/code-of-conduct-languages/zh.md).
diff --git a/ROADMAP.md b/ROADMAP.md
index eb9f5d745..258cd5725 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -1,109 +1 @@
-# Roadmap
-
-## 1 New Tools to Support (Plugins)
-
-- artifactory: https://github.com/devstream-io/devstream/issues/607
-- Jenkins pipeline plugin: https://github.com/devstream-io/devstream/issues/582
-- Cloudflare IP List Monitor: https://github.com/devstream-io/devstream/issues/560
-- Use Validator for Config Validation: https://github.com/devstream-io/devstream/issues/558
-- GitLab CE: https://github.com/devstream-io/devstream/issues/509
-- zendao: https://github.com/devstream-io/devstream/issues/508
-- Tekton
-- Jira-GitHub, Jira-GitLab integration
-- Jenkins-GitHub, Jenkins-GitLab integration
-- ArgoCD-GitHub SSO integration
-- Repository bootstrapping for Python/Nodejs for GitHub, Golang/Python/Nodejs for GitLab
-- GitLab CI workflows for Python/Nodejs
-- FluxCD plugin
-- Trello-GitLab Integration
-
-## 2 Core Features
-
-General:
-
-- single config profile support: https://github.com/devstream-io/devstream/issues/596
-- make sure people who don't have optimum internet connections (e.g., users behind firewall or proxy) can still use DevStream smoothly.
-
-### `dtm show config`
-
-This is already supported, but we will improve the features of it, for example:
-
-- show the default configs of multiple plugins that are used together
-- interactive: user select plugin then show the default config
-
-## 3 Quality of Life Improvements for Developers
-
-### Automated End-to-End Testing in a Staging Environment
-
-- AWS EC2 (linux-amd64) creation with Terraform/Ansible
-- Push notification to Slack/Lark when the testing environment is occupied or released
-
-### Misc
-
-- Integrate the golangci-lint command in the makefile https://github.com/devstream-io/devstream/issues/632
-- Push notification when CI failed: https://github.com/devstream-io/devstream/issues/636
-- Shorter CI time: for example, adding packages into a base image
-- More end-to-end tests coverage, to test more typical usecases and plugins
-- Push notification to core committers when there is a new PR ready for review
-
-## 4 Already Done
-
-Core:
-- local state support: https://github.com/devstream-io/devstream/issues/16
-- pluginmanager module: https://github.com/devstream-io/devstream/issues/17
-- statemanager supports concurrent map: https://github.com/devstream-io/devstream/issues/71
-- pluginmanager download status bar: https://github.com/devstream-io/devstream/issues/88, https://github.com/devstream-io/devstream/issues/98
-- multi-plugin instance support: https://github.com/devstream-io/devstream/issues/136
-- force delete feature: https://github.com/devstream-io/devstream/issues/177, https://github.com/devstream-io/devstream/issues/278
-- `verify` command: https://github.com/devstream-io/devstream/issues/252, https://github.com/devstream-io/devstream/issues/253
-- output support: https://github.com/devstream-io/devstream/issues/324
-- Homebrew support: https://github.com/devstream-io/devstream/issues/351, https://github.com/devstream-io/devstream/issues/372
-- remote state: https://github.com/devstream-io/devstream/issues/378, https://github.com/devstream-io/devstream/issues/485
-- autocomplete: https://github.com/devstream-io/devstream/issues/380
-- generate default config: https://github.com/devstream-io/devstream/issues/383
-- list all plugins: https://github.com/devstream-io/devstream/issues/384
-- config supports global variables: https://github.com/devstream-io/devstream/issues/393
-- plugin status: https://github.com/devstream-io/devstream/issues/401
-- parallel download: https://github.com/devstream-io/devstream/issues/579
-- plugins released to AWS S3 instead of GitHub releases page
-
-Plugins:
-- Jenkins plugin: https://github.com/devstream-io/devstream/issues/11
-- GitLab CI plugin: https://github.com/devstream-io/devstream/issues/12
-- GitHub Actions plugin for Nodejs and Python: https://github.com/devstream-io/devstream/issues/14
-- GitHub Actions plugin supports test coverage: https://github.com/devstream-io/devstream/issues/133
-- GitHub repo scaffolding for Golang plugin: https://github.com/devstream-io/devstream/issues/191, https://github.com/devstream-io/devstream/issues/520
-- Prometheus/grafana plugin: https://github.com/devstream-io/devstream/issues/231
-- Helm type plugins support values: https://github.com/devstream-io/devstream/issues/272
-- openldap plugin: https://github.com/devstream-io/devstream/issues/284
-- trello plugin: https://github.com/devstream-io/devstream/issues/307, https://github.com/devstream-io/devstream/issues/314
-- GitLab CI generic plugin: https://github.com/devstream-io/devstream/issues/377
-- Helm generic plugin: https://github.com/devstream-io/devstream/issues/424
-
-Develop:
-- cross-platform build: https://github.com/devstream-io/devstream/issues/21, https://github.com/devstream-io/devstream/issues/170
-- end to end test: https://github.com/devstream-io/devstream/issues/50, https://github.com/devstream-io/devstream/issues/118
-- logging level: https://github.com/devstream-io/devstream/issues/176
-- parallel build: https://github.com/devstream-io/devstream/issues/361
-- automated release: https://github.com/devstream-io/devstream/issues/364
-- command to help contributors to generate scaffolding code: https://github.com/devstream-io/devstream/issues/454, https://github.com/devstream-io/devstream/issues/443, https://github.com/devstream-io/devstream/issues/436
-- params validation improvement: https://github.com/devstream-io/devstream/issues/511
-- editor config: https://github.com/devstream-io/devstream/issues/629
-
-By versions:
-
-v0.3.1:
-- automated release: when a new tag is generated, build binaries for different platforms/OS and distribute the binaries to the plugin storage.
-
-v0.3.0:
-- "Destroy" and "force delete": everything can be cleared up without any residue or side effects.
-- "Output": all plugin's output is printed for users to review.
-- Plugin dependency management: a common way to handle plugin dependencies and execution order using graph/topology sort.
-- Automated e2e testing: AWS EKS cluster with Terraform.
-- Trello plugin that creates boards.
-
-v0.4.0-v0.5.0:
-- generic GitLab CI plugin
-- define variables and use it in the config file.
-- auto-complete support for `dtm` commands
-- HashiCorp Vault
+todo
diff --git a/SECURITY.md b/SECURITY.md
index cb7c3d3ed..ab70a6ddd 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -1,6 +1,6 @@
# DevStream Security Policy
-Version: **v0.1 (2022-02-28)**
+Version: **v0.12 (2023-04-24)**
## Overview
@@ -20,7 +20,6 @@ In some cases, where a security fix needs complex re-design of a feature or is o
Please report vulnerabilities by e-mail to the following address:
-- tiexin.guo@merico.dev
- tao.hu@merico.dev
If you find a security-related bug in DevStream, we kindly ask you to disclose responsibly and give us appropriate time to react to mitigate the vulnerability.
diff --git a/cmd/commit.go b/cmd/commit.go
new file mode 100644
index 000000000..6bf840e6d
--- /dev/null
+++ b/cmd/commit.go
@@ -0,0 +1,49 @@
+package cmd
+
+import (
+ "os"
+
+ "github.com/spf13/cobra"
+
+ "github.com/devstream-io/devstream/internal/log"
+ "github.com/devstream-io/devstream/internal/pkg/commit"
+ "github.com/devstream-io/devstream/internal/response"
+)
+
+// commit message got from the command line by -m flag
+var message string
+
+// commitCmd represents the commit command
+var commitCmd = &cobra.Command{
+ Use: "commit",
+ Short: "commit is used to execute git commit operations",
+ Long: `commit is used to execute git commit operations
+
+e.g.
+
+1. dtm commit -m "commit message"
+`,
+ Run: func(cmd *cobra.Command, args []string) {
+ if message == "" {
+ errStr := "message is required"
+ log.Error(errStr)
+ r := response.New(response.StatusError, response.MessageError, errStr)
+ r.Print(OutputFormat)
+ os.Exit(1)
+ }
+ err := commit.Commit(message)
+ if err != nil {
+ log.Errorf("commit error: %v", err)
+ r := response.New(response.StatusError, response.MessageError, err.Error())
+ r.Print(OutputFormat)
+ } else {
+ r := response.New(response.StatusOK, response.MessageOK, "")
+ r.Print(OutputFormat)
+ }
+ },
+}
+
+func init() {
+ rootCmd.AddCommand(commitCmd)
+ commitCmd.Flags().StringVarP(&message, "message", "m", "", "commit message")
+}
diff --git a/cmd/devstream/apply.go b/cmd/devstream/apply.go
deleted file mode 100644
index c1abf3694..000000000
--- a/cmd/devstream/apply.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package main
-
-import (
- "os"
- "strings"
-
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/internal/pkg/pluginengine"
- "github.com/devstream-io/devstream/pkg/util/log"
-)
-
-var applyCMD = &cobra.Command{
- Use: "apply",
- Short: "Create or update DevOps tools according to DevStream configuration file",
- Long: `Create or update DevOps tools according to DevStream configuration file.
-DevStream will generate and execute a new plan based on the config file and the state file by default.`,
- Run: applyCMDFunc,
- SuggestFor: []string{"install"},
-}
-
-func applyCMDFunc(cmd *cobra.Command, args []string) {
- checkConfigFile()
- log.Info("Apply started.")
- if err := pluginengine.Apply(configFilePath, continueDirectly); err != nil {
- log.Errorf("Apply failed => %s.", err)
- if strings.Contains(err.Error(), "config not valid") {
- log.Info("It seems your config file is not valid. Please check the official documentation https://docs.devstream.io, or use the \"dtm show config\" command to get an example.")
- }
- os.Exit(1)
- }
- log.Success("Apply finished.")
-}
-
-func init() {
- addFlagConfigFile(applyCMD)
- addFlagPluginDir(applyCMD)
- addFlagContinueDirectly(applyCMD)
-}
diff --git a/cmd/devstream/common.go b/cmd/devstream/common.go
deleted file mode 100644
index c6944d415..000000000
--- a/cmd/devstream/common.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package main
-
-import (
- "os"
- "strings"
-
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/internal/pkg/completion"
- "github.com/devstream-io/devstream/pkg/util/log"
-)
-
-var (
- configFilePath string
- pluginDir string
- continueDirectly bool
-)
-
-const (
- configFlagName = "config-file"
- pluginDirFlagName = "plugin-dir"
- defaultPluginDir = "~/.devstream/plugins"
-)
-
-func checkConfigFile() {
- if strings.TrimSpace(configFilePath) == "" {
- log.Errorf(`Config file is required. You could use "-f filename" or "-f directory" to specify it.`)
- os.Exit(1)
- }
-}
-
-func addFlagConfigFile(cmd *cobra.Command) {
- cmd.Flags().StringVarP(&configFilePath, configFlagName, "f", "", "config file or directory")
- completion.FlagFilenameCompletion(cmd, configFlagName)
-}
-
-func addFlagPluginDir(cmd *cobra.Command) {
- cmd.Flags().StringVarP(&pluginDir, pluginDirFlagName, "d", defaultPluginDir, "plugins directory")
- completion.FlagDirnameCompletion(cmd, pluginDirFlagName)
-}
-
-func addFlagContinueDirectly(cmd *cobra.Command) {
- cmd.Flags().BoolVarP(&continueDirectly, "yes", "y", false, "continue directly without confirmation")
-}
diff --git a/cmd/devstream/completion.go b/cmd/devstream/completion.go
deleted file mode 100644
index c7ea6a49e..000000000
--- a/cmd/devstream/completion.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package main
-
-import (
- "io"
- "os"
- "path/filepath"
-
- "github.com/spf13/cobra"
-
- cobracompletefig "github.com/withfig/autocomplete-tools/integrations/cobra"
-
- "github.com/devstream-io/devstream/internal/pkg/completion"
-)
-
-func completionCMD(out io.Writer) *cobra.Command {
- cmd := &cobra.Command{
- Use: "completion",
- Short: "Generate the autocompletion script for dtm for the specified shell",
- Long: "See each sub-command's help for details on how to use the generated script.",
- DisableFlagsInUseLine: true,
- Args: cobra.ExactValidArgs(1),
- }
-
- binaryName := filepath.Base(os.Args[0])
- bash := &cobra.Command{
- Use: "bash",
- Short: "generate autocompletion script for bash",
- Example: completion.BashExample(binaryName),
- RunE: func(cmd *cobra.Command, args []string) error {
- return completion.CompletionBash(out, cmd)
- },
- }
-
- zsh := &cobra.Command{
- Use: "zsh",
- Short: "generate autocompletion script for zsh",
- Example: completion.ZshExample(binaryName),
- RunE: func(cmd *cobra.Command, args []string) error {
- return completion.CompletionZsh(out, cmd)
- },
- }
-
- fish := &cobra.Command{
- Use: "fish",
- Short: "generate autocompletion script for fish",
- Example: completion.FishExample(binaryName),
- RunE: func(cmd *cobra.Command, args []string) error {
- return cmd.Root().GenFishCompletion(out, true)
- },
- }
-
- powershell := &cobra.Command{
- Use: "powershell",
- Short: "generate autocompletion script for powershell",
- Example: completion.PowershellExample(binaryName),
- RunE: func(cmd *cobra.Command, args []string) error {
- return cmd.Root().GenPowerShellCompletionWithDesc(out)
- },
- }
-
- cmd.AddCommand(bash, zsh, fish, powershell, cobracompletefig.CreateCompletionSpecCommand(cobracompletefig.Opts{Use: "fig"}))
-
- return cmd
-}
diff --git a/cmd/devstream/create.go b/cmd/devstream/create.go
deleted file mode 100644
index 18fc7b5a9..000000000
--- a/cmd/devstream/create.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package main
-
-import (
- "fmt"
-
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/internal/pkg/create"
-)
-
-var createCMD = &cobra.Command{
- Use: "create",
- Short: "create",
- Long: `create.`,
- Run: createCMDFunc,
-}
-
-func createCMDFunc(cmd *cobra.Command, args []string) {
- err := create.Create()
- if err != nil && err.Error() != "^C" {
- fmt.Printf("Failed with error: %s", err)
- }
-}
diff --git a/cmd/devstream/delete.go b/cmd/devstream/delete.go
deleted file mode 100644
index b2cd65a1c..000000000
--- a/cmd/devstream/delete.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package main
-
-import (
- "os"
-
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/internal/pkg/pluginengine"
- "github.com/devstream-io/devstream/pkg/util/log"
-)
-
-var isForceDelete bool
-
-var deleteCMD = &cobra.Command{
- Use: "delete",
- Short: "Delete DevOps tools according to DevStream configuration file",
- Long: `Delete DevOps tools according to DevStream configuration file.
-DevStream will delete everything defined in the config file, regardless of the state.`,
- Run: deleteCMDFunc,
-}
-
-func deleteCMDFunc(cmd *cobra.Command, args []string) {
- checkConfigFile()
- log.Info("Delete started.")
- if err := pluginengine.Remove(configFilePath, continueDirectly, isForceDelete); err != nil {
- log.Errorf("Delete error: %s.", err)
- os.Exit(1)
- }
-
- log.Success("Delete finished.")
-}
-
-func init() {
- addFlagConfigFile(deleteCMD)
- addFlagPluginDir(deleteCMD)
- addFlagContinueDirectly(deleteCMD)
-
- deleteCMD.Flags().BoolVarP(&isForceDelete, "force", "", false, "force delete by config")
-}
diff --git a/cmd/devstream/destroy.go b/cmd/devstream/destroy.go
deleted file mode 100644
index f5f5afeb8..000000000
--- a/cmd/devstream/destroy.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package main
-
-import (
- "os"
-
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/internal/pkg/pluginengine"
- "github.com/devstream-io/devstream/pkg/util/log"
-)
-
-var isForceDestroy bool
-
-var destroyCMD = &cobra.Command{
- Use: "destroy",
- Short: "Destroy DevOps tools deployment according to DevStream configuration file & state file",
- Long: `Destroy DevOps tools deployment according to DevStream configuration file & state file.`,
- Run: destroyCMDFunc,
-}
-
-func destroyCMDFunc(cmd *cobra.Command, args []string) {
- checkConfigFile()
- log.Info("Destroy started.")
- if err := pluginengine.Destroy(configFilePath, continueDirectly, isForceDestroy); err != nil {
- log.Errorf("Destroy failed => %s.", err)
- os.Exit(1)
- }
- log.Success("Destroy finished.")
-}
-
-func init() {
- addFlagConfigFile(destroyCMD)
- addFlagPluginDir(destroyCMD)
- addFlagContinueDirectly(destroyCMD)
-
- destroyCMD.Flags().BoolVarP(&isForceDestroy, "force", "", false, "force destroy by config")
-}
diff --git a/cmd/devstream/develop.go b/cmd/devstream/develop.go
deleted file mode 100644
index 95aeaa5be..000000000
--- a/cmd/devstream/develop.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package main
-
-import (
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/internal/pkg/develop"
- "github.com/devstream-io/devstream/pkg/util/cli"
- "github.com/devstream-io/devstream/pkg/util/log"
-)
-
-var (
- name string
- all bool
-)
-
-var validatePluginFlagNames = []string{
- "name",
- "all",
-}
-
-var developCMD = &cobra.Command{
- Use: "develop",
- Short: "Develop is used for develop a new plugin",
-}
-
-var developCreatePluginCMD = &cobra.Command{
- Use: "create-plugin",
- Short: "Create a new plugin",
- Long: `Create-plugin is used for creating a new plugin.
-Examples:
- dtm develop create-plugin --name=YOUR-PLUGIN-NAME`,
- Run: developCreateCMDFunc,
-}
-
-var developValidatePluginCMD = &cobra.Command{
- Use: "validate-plugin",
- Short: "Validate a plugin",
- Long: `Validate-plugin is used for validating an existing plugin or all plugins.
-Examples:
- dtm develop validate-plugin --name=YOUR-PLUGIN-NAME,
- dtm develop validate-plugin --all`,
- Run: developValidateCMDFunc,
- PreRun: cli.BindPFlags(validatePluginFlagNames),
-}
-
-func developCreateCMDFunc(cmd *cobra.Command, args []string) {
- if err := develop.CreatePlugin(); err != nil {
- log.Fatal(err)
- }
-}
-
-func developValidateCMDFunc(cmd *cobra.Command, args []string) {
- if err := develop.ValidatePlugin(); err != nil {
- log.Fatal(err)
- }
-}
-
-func init() {
- developCMD.AddCommand(developCreatePluginCMD)
- developCMD.AddCommand(developValidatePluginCMD)
-
- 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")
-}
diff --git a/cmd/devstream/init.go b/cmd/devstream/init.go
deleted file mode 100644
index d5a466f43..000000000
--- a/cmd/devstream/init.go
+++ /dev/null
@@ -1,128 +0,0 @@
-package main
-
-import (
- "errors"
- "fmt"
- "runtime"
- "strings"
-
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/cmd/devstream/list"
- "github.com/devstream-io/devstream/internal/pkg/configmanager"
- "github.com/devstream-io/devstream/internal/pkg/pluginmanager"
- "github.com/devstream-io/devstream/internal/pkg/version"
- "github.com/devstream-io/devstream/pkg/util/log"
-)
-
-var initCMD = &cobra.Command{
- Use: "init",
- Short: "Download needed plugins according to the config file",
- Long: `Download needed plugins according to the config file`,
- 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 (
- tools configmanager.Tools
- err error
- )
-
- if downloadOnly {
- // download plugins from flags
- tools, err = GetPluginsFromFlags()
- } else {
- // download plugins according to the config file
- tools, err = GetPluginsFromConfig()
- }
-
- if err != nil {
- log.Fatal(err)
- }
-
- pluginDir, err = pluginmanager.GetPluginDir()
- if err != nil {
- log.Fatal(err)
- }
- log.Debugf("Plugin directory: %s.", pluginDir)
-
- if err = pluginmanager.DownloadPlugins(tools, pluginDir, initOS, initArch); err != nil {
- log.Fatal(err)
- }
-
- fmt.Println()
- log.Success("Initialize finished.")
-}
-
-func GetPluginsFromConfig() (tools configmanager.Tools, err error) {
- cfg, err := configmanager.NewManager(configFilePath).LoadConfig()
- if err != nil {
- return nil, err
- }
-
- return cfg.Tools, nil
-}
-
-func GetPluginsFromFlags() (tools configmanager.Tools, 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 len(pluginsName) == 0 {
- return nil, errors.New("please use --plugins to specify plugins to download or use --all to download all plugins")
- }
- log.Debugf("plugins to download: %v", pluginsName)
-
- 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})
- }
-
- return tools, nil
-}
-
-func init() {
- addFlagConfigFile(initCMD)
- addFlagPluginDir(initCMD)
-
- // 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")
-}
diff --git a/cmd/devstream/list.go b/cmd/devstream/list.go
deleted file mode 100644
index ca0b92145..000000000
--- a/cmd/devstream/list.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package main
-
-import (
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/cmd/devstream/list"
-)
-
-var (
- pluginFilter string
-)
-
-var listCMD = &cobra.Command{
- Use: "list",
- Short: "This command only supports listing plugins now",
-}
-
-var listPluginsCMD = &cobra.Command{
- Use: "plugins",
- Short: "List all plugins",
- Long: `This command lists all of the plugins.
-Examples:
- dtm list plugins
- dtm list plugins --filter=argo.*
- dtm list plugins -r ^argo
-`,
- Run: listPluginsCMDFunc,
-}
-
-func listPluginsCMDFunc(_ *cobra.Command, _ []string) {
- list.List(pluginFilter)
-}
-
-// TODO Use `--group=somegroup` to filter the specified groups on feature
-func init() {
- listCMD.AddCommand(listPluginsCMD)
-
- listPluginsCMD.PersistentFlags().StringVarP(&pluginFilter, "filter", "r", "", "filter plugin by regex")
-}
diff --git a/cmd/devstream/list/list.go b/cmd/devstream/list/list.go
deleted file mode 100644
index c75a999c2..000000000
--- a/cmd/devstream/list/list.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package list
-
-import (
- "fmt"
- "regexp"
- "sort"
- "strings"
-)
-
-// list is the version of DevStream.
-// Assign the value when building with the -X parameter. Example:
-// -X github.com/devstream-io/devstream/cmd/devstream/list.PluginsName=${PLUGINS_NAME}
-// See the Makefile for more info.
-
-var PluginsName string
-
-// List all plugins name
-func List(pluginFilter string) {
- r, _ := regexp.Compile(pluginFilter)
- for _, pluginName := range PluginsNameSlice() {
- if r.Match([]byte(pluginName)) {
- fmt.Println(pluginName)
- }
- }
-}
-
-// PluginsNameSlice Gets plugins name in slice
-func PluginsNameSlice() []string {
- listPluginsName := strings.Fields(PluginsName)
- sort.Strings(listPluginsName)
- return listPluginsName
-}
-
-// PluginNamesMap Gets plugins name in map
-func PluginNamesMap() map[string]struct{} {
- mp := make(map[string]struct{})
-
- listPluginsName := strings.Fields(PluginsName)
-
- for _, pluginName := range listPluginsName {
- mp[pluginName] = struct{}{}
- }
-
- return mp
-}
diff --git a/cmd/devstream/main.go b/cmd/devstream/main.go
deleted file mode 100644
index ffea2e158..000000000
--- a/cmd/devstream/main.go
+++ /dev/null
@@ -1,108 +0,0 @@
-package main
-
-import (
- "os"
-
- "github.com/sirupsen/logrus"
- "github.com/spf13/cobra"
- "github.com/spf13/viper"
-
- "github.com/devstream-io/devstream/pkg/util/log"
-)
-
-var (
- isDebug bool
- rootCMD = &cobra.Command{
- Use: "dtm",
- Short: `DevStream is an open-source DevOps toolchain manager`,
- Long: `DevStream is an open-source DevOps toolchain manager
-
-###### #####
-# # ###### # # # # ##### ##### ###### ## # #
-# # # # # # # # # # # # ## ##
-# # ##### # # ##### # # # ##### # # # ## #
-# # # # # # # ##### # ###### # #
-# # # # # # # # # # # # # # #
-###### ###### ## ##### # # # ###### # # # #
-`,
- PersistentPreRun: func(cmd *cobra.Command, args []string) {
- initLog()
- },
- }
-)
-
-func init() {
- cobra.OnInitialize(initConfig)
- rootCMD.PersistentFlags().BoolVarP(&isDebug, "debug", "", false, "debug level log")
- rootCMD.AddCommand(completionCMD(os.Stdout))
- rootCMD.AddCommand(versionCMD)
- rootCMD.AddCommand(initCMD)
- rootCMD.AddCommand(applyCMD)
- rootCMD.AddCommand(deleteCMD)
- rootCMD.AddCommand(destroyCMD)
- rootCMD.AddCommand(verifyCMD)
- rootCMD.AddCommand(developCMD)
- rootCMD.AddCommand(listCMD)
- rootCMD.AddCommand(showCMD)
- rootCMD.AddCommand(upgradeCMD)
-
- rootCMD.AddCommand(startCMD)
- rootCMD.AddCommand(createCMD)
-}
-
-func initConfig() {
- viper.AutomaticEnv()
- if err := viper.BindEnv("github_token"); err != nil {
- log.Fatal(err)
- }
- if err := viper.BindEnv("kubeconfig"); err != nil {
- log.Fatal(err)
- }
- if err := viper.BindEnv("dockerhub_username"); err != nil {
- log.Fatal(err)
- }
- if err := viper.BindEnv("dockerhub_token"); err != nil {
- log.Fatal(err)
- }
- if err := viper.BindEnv("trello_api_key"); err != nil {
- log.Fatal(err)
- }
- if err := viper.BindEnv("trello_token"); err != nil {
- log.Fatal(err)
- }
- if err := viper.BindPFlags(rootCMD.Flags()); err != nil {
- log.Fatal(err)
- }
- if err := viper.BindPFlags(developCreatePluginCMD.Flags()); err != nil {
- log.Fatal(err)
- }
- if err := viper.BindPFlags(developValidatePluginCMD.Flags()); err != nil {
- log.Fatal(err)
- }
- if err := viper.BindPFlags(showConfigCMD.Flags()); err != nil {
- log.Fatal(err)
- }
- if err := viper.BindPFlags(showStatusCMD.Flags()); err != nil {
- log.Fatal(err)
- }
- if err := viper.BindPFlags(initCMD.Flags()); err != nil {
- log.Fatal(err)
- }
-}
-
-func initLog() {
- if isDebug {
- logrus.SetLevel(logrus.DebugLevel)
- log.Infof("Log level is: %s.", logrus.GetLevel())
- } else {
- logrus.SetLevel(logrus.InfoLevel)
- }
-}
-
-func main() {
-
- err := rootCMD.Execute()
- if err != nil {
- os.Exit(1)
- }
-}
diff --git a/cmd/devstream/show.go b/cmd/devstream/show.go
deleted file mode 100644
index 0ef7e4851..000000000
--- a/cmd/devstream/show.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package main
-
-import (
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/internal/pkg/completion"
- "github.com/devstream-io/devstream/internal/pkg/show/config"
- "github.com/devstream-io/devstream/internal/pkg/show/status"
- "github.com/devstream-io/devstream/pkg/util/log"
-)
-
-var plugin string
-var instanceID string
-var statusAllFlag bool
-var template string
-
-var showCMD = &cobra.Command{
- Use: "show",
- Short: "Show is used to print plugins' configuration templates or status",
-}
-
-var showConfigCMD = &cobra.Command{
- Use: "config",
- Short: "Show configuration information",
- 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=gitops,
- dtm show config --template=apps`,
- Run: showConfigCMDFunc,
-}
-
-var showStatusCMD = &cobra.Command{
- Use: "status",
- Short: "Show status information",
- Long: `Show status is used for showing plugins' status information.
-Examples:
- dtm show status --plugin=A-PLUGIN-NAME --id=A-PLUGIN-INSTANCE-ID
- dtm show status -p=A-PLUGIN-NAME -i=INSTANCE-ID
- dtm show status --all
- dtm show status -a`,
- Run: showStatusCMDFunc,
-}
-
-func showConfigCMDFunc(_ *cobra.Command, _ []string) {
- log.Debug("Show configuration information.")
- if err := config.Show(); err != nil {
- log.Fatal(err)
- }
-}
-
-func showStatusCMDFunc(_ *cobra.Command, _ []string) {
- log.Debug("Show status information.")
- if err := status.Show(configFilePath); err != nil {
- log.Fatal(err)
- }
-}
-
-func init() {
- showCMD.AddCommand(showConfigCMD)
- showCMD.AddCommand(showStatusCMD)
-
- addFlagConfigFile(showConfigCMD)
- addFlagPluginDir(showConfigCMD)
-
- showConfigCMD.Flags().StringVarP(&plugin, "plugin", "p", "", "specify name with the plugin")
- showConfigCMD.Flags().StringVarP(&template, "template", "t", "", "print a template config, e.g. quickstart/gitops/...")
- completion.FlagPluginsCompletion(showConfigCMD, "plugin")
-
- showStatusCMD.Flags().StringVarP(&plugin, "plugin", "p", "", "specify name with the plugin")
- showStatusCMD.Flags().StringVarP(&instanceID, "id", "i", "", "specify id with the plugin instance")
- showStatusCMD.Flags().BoolVarP(&statusAllFlag, "all", "a", false, "show all instances of all plugins status")
-}
diff --git a/cmd/devstream/start.go b/cmd/devstream/start.go
deleted file mode 100644
index ab2213967..000000000
--- a/cmd/devstream/start.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package main
-
-import (
- "fmt"
-
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/internal/pkg/start"
-)
-
-var startCMD = &cobra.Command{
- Use: "start",
- Short: "start",
- Long: `start.`,
- Run: startCMDFunc,
-}
-
-func startCMDFunc(_ *cobra.Command, _ []string) {
- err := start.Start()
- if err != nil && err.Error() != "^C" {
- fmt.Printf("Failed with error: %s", err)
- }
-}
diff --git a/cmd/devstream/upgrade.go b/cmd/devstream/upgrade.go
deleted file mode 100644
index 2302ffdd3..000000000
--- a/cmd/devstream/upgrade.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package main
-
-import (
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/internal/pkg/upgrade"
- "github.com/devstream-io/devstream/pkg/util/log"
-)
-
-var upgradeCMD = &cobra.Command{
- Use: "upgrade",
- Short: "Upgrade dtm to the latest release version",
- Long: `Upgrade dtm to the latest release version.`,
- Run: upgradeCMDFunc,
-}
-
-func upgradeCMDFunc(cmd *cobra.Command, args []string) {
- if err := upgrade.Upgrade(continueDirectly); err != nil {
- log.Fatal(err)
- }
-}
-
-func init() {
- addFlagContinueDirectly(upgradeCMD)
-}
diff --git a/cmd/devstream/verify.go b/cmd/devstream/verify.go
deleted file mode 100644
index e86e67756..000000000
--- a/cmd/devstream/verify.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package main
-
-import (
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/internal/pkg/pluginengine"
- "github.com/devstream-io/devstream/pkg/util/log"
-)
-
-var verifyCMD = &cobra.Command{
- Use: "verify",
- Short: "Verify DevOps tools according to DevStream config file and state",
- Long: `Verify DevOps tools according to DevStream config file and state.`,
- Run: verifyCMDFunc,
-}
-
-func verifyCMDFunc(cmd *cobra.Command, args []string) {
- log.Info("Verify started.")
- if pluginengine.Verify(configFilePath) {
- log.Success("Verify succeeded.")
- } else {
- log.Info("Verify finished.")
- }
-}
-
-func init() {
- addFlagConfigFile(verifyCMD)
- addFlagPluginDir(verifyCMD)
-}
diff --git a/cmd/devstream/version.go b/cmd/devstream/version.go
deleted file mode 100644
index ecdaf99c6..000000000
--- a/cmd/devstream/version.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package main
-
-import (
- "fmt"
-
- "github.com/spf13/cobra"
-
- "github.com/devstream-io/devstream/internal/pkg/version"
-)
-
-var versionCMD = &cobra.Command{
- Use: "version",
- Short: "Print the version number of DevStream",
- Long: `All software has versions. This is DevStream's`,
- Run: versionCMDFunc,
-}
-
-func versionCMDFunc(cmd *cobra.Command, args []string) {
- fmt.Println(version.Version)
-}
diff --git a/cmd/github.go b/cmd/github.go
new file mode 100644
index 000000000..4c1c64d52
--- /dev/null
+++ b/cmd/github.go
@@ -0,0 +1,22 @@
+package cmd
+
+import (
+ "github.com/spf13/cobra"
+
+ "github.com/devstream-io/devstream/internal/pkg/github"
+)
+
+// githubCmd represents the github command
+var githubCmd = &cobra.Command{
+ Use: "github",
+ Short: "github is used to execute github operations",
+ Long: `github is used to execute github operations
+ 参考 gh`,
+ Run: func(cmd *cobra.Command, args []string) {
+ github.Run()
+ },
+}
+
+func init() {
+ rootCmd.AddCommand(githubCmd)
+}
diff --git a/cmd/patch.go b/cmd/patch.go
new file mode 100644
index 000000000..d03ebd325
--- /dev/null
+++ b/cmd/patch.go
@@ -0,0 +1,49 @@
+package cmd
+
+import (
+ "os"
+
+ "github.com/devstream-io/devstream/internal/response"
+
+ "github.com/devstream-io/devstream/internal/log"
+ "github.com/devstream-io/devstream/internal/pkg/patch"
+
+ "github.com/spf13/cobra"
+)
+
+// patchCmd represents the patch command
+var patchCmd = &cobra.Command{
+ Use: "patch",
+ Short: "apply a diff file to an original",
+ Long: `patch will take a patch file containing any of the four forms of difference listing
+produced by the diff program and apply those differences to an original file,
+producing a patched version. If patchfile is omitted, or is a hyphen,
+the patch will be read from the standard input.
+
+e.g.
+- dtm patch file.patch
+- dtm patch file.patch -ojson
+`,
+ Run: func(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ errMsg := "Incorrect number of arguments"
+ log.Error(errMsg)
+ r := response.New(response.StatusError, response.MessageError, errMsg)
+ r.Print(OutputFormat)
+ os.Exit(1)
+ }
+ err := patch.Patch(args[0])
+ if err != nil {
+ log.Errorf("patch error: %v", err)
+ r := response.New(response.StatusError, response.MessageError, err.Error())
+ r.Print(OutputFormat)
+ } else {
+ r := response.New(response.StatusOK, response.MessageOK, "")
+ r.Print(OutputFormat)
+ }
+ },
+}
+
+func init() {
+ rootCmd.AddCommand(patchCmd)
+}
diff --git a/cmd/plugin/argocdapp/main.go b/cmd/plugin/argocdapp/main.go
deleted file mode 100644
index 29653e2cb..000000000
--- a/cmd/plugin/argocdapp/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-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"
-)
-
-// NAME is the name of this DevStream plugin.
-const NAME = "argocdapp"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the create of an argocdapp.
-func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return argocdapp.Create(options)
-}
-
-// Update implements the update of an argocdapp.
-func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return argocdapp.Update(options)
-}
-
-// Read implements the read of argocdapp.
-func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return argocdapp.Read(options)
-}
-
-// Delete implements the delete of argocdapp.
-func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) {
- return argocdapp.Delete(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/plugin/ci-generic/main.go b/cmd/plugin/ci-generic/main.go
deleted file mode 100644
index 5632f8ab2..000000000
--- a/cmd/plugin/ci-generic/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-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"
-)
-
-// NAME is the name of this DevStream plugin.
-const NAME = "ci-generic"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the create of ci-generic.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return cigeneric.Update(options)
-}
-
-// Delete implements the delete of ci-generic.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return cigeneric.Read(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/plugin/devlake-config/main.go b/cmd/plugin/devlake-config/main.go
deleted file mode 100644
index 0ca594263..000000000
--- a/cmd/plugin/devlake-config/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-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"
-)
-
-// NAME is the name of this DevStream plugin.
-const NAME = "devlake-config"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the create of devlake-config.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return devlakeconfig.Update(options)
-}
-
-// Delete implements the delete of devlake-config.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return devlakeconfig.Read(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/plugin/github-actions/main.go b/cmd/plugin/github-actions/main.go
deleted file mode 100644
index e3cfda802..000000000
--- a/cmd/plugin/github-actions/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package main
-
-import (
- "github.com/devstream-io/devstream/internal/pkg/configmanager"
- general "github.com/devstream-io/devstream/internal/pkg/plugin/githubactions"
- "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 = "github-actions"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the create of github-actions.
-func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return general.Create(options)
-}
-
-// Update implements the update of github-actions.
-func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return general.Update(options)
-}
-
-// Read implements the read of github-actions.
-func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return general.Read(options)
-}
-
-// Delete implements the delete of github-actions.
-func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) {
- return general.Delete(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/plugin/gitlab-ce-docker/main.go b/cmd/plugin/gitlab-ce-docker/main.go
deleted file mode 100644
index db1e7318d..000000000
--- a/cmd/plugin/gitlab-ce-docker/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-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"
-)
-
-// NAME is the name of this DevStream plugin.
-const NAME = "gitlab-ce-docker"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the create of gitlab-ce-docker.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return gitlabcedocker.Update(options)
-}
-
-// Delete implements the delete of gitlab-ce-docker.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return gitlabcedocker.Read(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/plugin/gitlab-ci/main.go b/cmd/plugin/gitlab-ci/main.go
deleted file mode 100644
index 5b25d7806..000000000
--- a/cmd/plugin/gitlab-ci/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package main
-
-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/statemanager"
- "github.com/devstream-io/devstream/pkg/util/log"
-)
-
-// NAME is the name of this DevStream plugin.
-const NAME = "gitlab-ci"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the create of gitlab-ci.
-func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return gitlabci.Create(options)
-}
-
-// Update implements the update of gitlab-ci.
-func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return gitlabci.Update(options)
-}
-
-// Delete implements the delete of gitlab-ci.
-func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) {
- return gitlabci.Delete(options)
-}
-
-// Read implements the read of gitlab-ci.
-func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return gitlabci.Read(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/plugin/harbor-docker/main.go b/cmd/plugin/harbor-docker/main.go
deleted file mode 100644
index 319e5468e..000000000
--- a/cmd/plugin/harbor-docker/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-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"
-)
-
-// NAME is the name of this DevStream plugin.
-const NAME = "harbor-docker"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the create of harbor-docker.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return harbordocker.Update(options)
-}
-
-// Delete implements the delete of harbor-docker.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return harbordocker.Read(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/plugin/helm-installer/main.go b/cmd/plugin/helm-installer/main.go
deleted file mode 100644
index c7d41e354..000000000
--- a/cmd/plugin/helm-installer/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package main
-
-import (
- "github.com/devstream-io/devstream/internal/pkg/configmanager"
- "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 = "helm-installer"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the create of helm-installer.
-func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return helminstaller.Create(options)
-}
-
-// Update implements the update of helm-installer.
-func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return helminstaller.Update(options)
-}
-
-// Delete implements the delete of helm-installer.
-func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) {
- return helminstaller.Delete(options)
-}
-
-// Read implements the read of helm-installer.
-func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return helminstaller.Read(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/plugin/jenkins-pipeline/main.go b/cmd/plugin/jenkins-pipeline/main.go
deleted file mode 100644
index 370fb9f09..000000000
--- a/cmd/plugin/jenkins-pipeline/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-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"
-)
-
-// NAME is the name of this DevStream plugin.
-const NAME = "jenkins-pipeline"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the create of jenkins-pipeline.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return jenkinspipeline.Update(options)
-}
-
-// Delete implements the delete of jenkins-pipeline.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return jenkinspipeline.Read(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/plugin/jira/main.go b/cmd/plugin/jira/main.go
deleted file mode 100644
index 3e4e1e5d4..000000000
--- a/cmd/plugin/jira/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package main
-
-import (
- "github.com/devstream-io/devstream/internal/pkg/configmanager"
- "github.com/devstream-io/devstream/internal/pkg/plugin/jira"
- "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 = "jira"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the installation of some jira-github-integ workflows.
-func (p Plugin) Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return jira.Create(options)
-}
-
-// Update implements the installation of some jira-github-integ workflows.
-func (p Plugin) Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return jira.Update(options)
-}
-
-// Read implements the healthy check of jira-github-integ workflows.
-func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return jira.Read(options)
-}
-
-// Delete implements the installation of some jira-github-integ workflows.
-func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) {
- return jira.Delete(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/plugin/repo-scaffolding/main.go b/cmd/plugin/repo-scaffolding/main.go
deleted file mode 100644
index 865a2067b..000000000
--- a/cmd/plugin/repo-scaffolding/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-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"
-)
-
-// NAME is the name of this DevStream plugin.
-const NAME = "repo-scaffolding"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the create of repo-scaffolding.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return reposcaffolding.Update(options)
-}
-
-// Delete implements the delete of repo-scaffolding.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return reposcaffolding.Read(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/plugin/trello/main.go b/cmd/plugin/trello/main.go
deleted file mode 100644
index 85b446202..000000000
--- a/cmd/plugin/trello/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-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"
-)
-
-// NAME is the name of this DevStream plugin.
-const NAME = "trello"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the creation of trello board.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return trello.Update(options)
-}
-
-// Read implements the healthy check of trello board.
-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 configmanager.RawOptions) (bool, error) {
- return trello.Delete(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/plugin/zentao/main.go b/cmd/plugin/zentao/main.go
deleted file mode 100644
index 4ce8aa1ba..000000000
--- a/cmd/plugin/zentao/main.go
+++ /dev/null
@@ -1,41 +0,0 @@
-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"
-)
-
-// NAME is the name of this DevStream plugin.
-const NAME = "zentao"
-
-// Plugin is the type used by DevStream core. It's a string.
-type Plugin string
-
-// Create implements the create of zentao.
-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 configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return zentao.Update(options)
-}
-
-// Delete implements the delete of zentao.
-func (p Plugin) Delete(options configmanager.RawOptions) (bool, error) {
- return zentao.Delete(options)
-}
-
-// Read implements the read of zentao.
-func (p Plugin) Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
- return zentao.Read(options)
-}
-
-// DevStreamPlugin is the exported variable used by the DevStream core.
-var DevStreamPlugin Plugin
-
-func main() {
- log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME)
-}
diff --git a/cmd/root.go b/cmd/root.go
new file mode 100644
index 000000000..5f01a3954
--- /dev/null
+++ b/cmd/root.go
@@ -0,0 +1,90 @@
+package cmd
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/sirupsen/logrus"
+ "github.com/spf13/cobra"
+ "github.com/spf13/viper"
+
+ "github.com/devstream-io/devstream/internal/log"
+ "github.com/devstream-io/devstream/internal/option"
+)
+
+var cfgFile string
+
+// isDebug is a flag to enable debug level log
+var isDebug bool
+
+// OutputFormat is the output format for the command. One of: json|yaml|raw
+// Default value is "raw"
+var OutputFormat string
+
+// rootCmd represents the base command when called without any subcommands
+var rootCmd = &cobra.Command{
+ Use: "dtm",
+ Short: "dtm is a tool to manage variaties of development platforms",
+ Long: `dtm is a tool to manage variaties of development platforms.`,
+ PersistentPreRun: func(cmd *cobra.Command, args []string) {
+ initLog()
+ },
+}
+
+// Execute adds all child commands to the root command and sets flags appropriately.
+// This is called by main.main(). It only needs to happen once to the rootCmd.
+func Execute() {
+ err := rootCmd.Execute()
+ if err != nil {
+ os.Exit(1)
+ }
+}
+
+func init() {
+ cobra.OnInitialize(initConfig)
+
+ rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.devstream.yaml)")
+ rootCmd.PersistentFlags().StringVarP(&OutputFormat, "output", "o", "raw", "Output format. One of: json|yaml|raw")
+ rootCmd.PersistentFlags().BoolVarP(&isDebug, "debug", "", false, "debug level log")
+ rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
+}
+
+// initConfig reads in config file and ENV variables if set.
+func initConfig() {
+ if cfgFile != "" {
+ // Use config file from the flag.
+ viper.SetConfigFile(cfgFile)
+ } else {
+ // Find home directory.
+ home, err := os.UserHomeDir()
+ cobra.CheckErr(err)
+
+ // Search config in home directory with name ".devstream" (without extension).
+ viper.AddConfigPath(home)
+ viper.SetConfigType("yaml")
+ viper.SetConfigName(".devstream")
+ }
+
+ viper.AutomaticEnv() // read in environment variables that match
+
+ // If a config file is found, read it in.
+ if err := viper.ReadInConfig(); err == nil {
+ fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
+ }
+
+ if OutputFormat != "raw" {
+ option.Silence = true
+ }
+}
+
+func initLog() {
+ // if OutputFormat is not "raw", set log level to PanicLevel to disable log
+ if OutputFormat != "raw" {
+ logrus.SetLevel(logrus.PanicLevel)
+ } else if isDebug {
+ logrus.SetLevel(logrus.DebugLevel)
+ log.Infof("Log level is: %s.", logrus.GetLevel())
+ } else {
+ logrus.SetLevel(logrus.InfoLevel)
+ }
+}
diff --git a/cmd/scaffold.go b/cmd/scaffold.go
new file mode 100644
index 000000000..462ebe2e9
--- /dev/null
+++ b/cmd/scaffold.go
@@ -0,0 +1,45 @@
+package cmd
+
+import (
+ "os"
+
+ "github.com/spf13/cobra"
+
+ "github.com/devstream-io/devstream/internal/log"
+ "github.com/devstream-io/devstream/internal/pkg/scaffold"
+)
+
+var structure string
+
+// scaffoldCmd represents the scaffold command
+var scaffoldCmd = &cobra.Command{
+ Use: "scaffold",
+ Short: "scaffold is used to generate folder and file structure",
+ Long: `
+dtm scaffold "
+project/
+├── src/
+│ ├── main.go
+│ └── utils/
+│ ├── file1.go
+│ └── file2.go
+└── README.md
+"
+ `,
+ Run: func(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ log.Error("Incorrect number of arguments")
+ os.Exit(1)
+ }
+ if err := scaffold.Scaffold(args[0]); err != nil {
+ log.Error(err)
+ os.Exit(1)
+ }
+ },
+}
+
+func init() {
+ rootCmd.AddCommand(scaffoldCmd)
+
+ scaffoldCmd.Flags().StringVarP(&structure, "structure", "s", "", "structure specify the folder and file structure")
+}
diff --git a/docs/assets/versions.css b/docs/assets/versions.css
deleted file mode 100644
index 0f51d07dd..000000000
--- a/docs/assets/versions.css
+++ /dev/null
@@ -1,180 +0,0 @@
-.md-header__title {
- display: flex;
-}
-
-.dropdown-caret {
- display: inline-block !important;
- position: absolute;
- right: 4px;
-}
-
-.fa .fa-caret-down {
- display: none !important;
-}
-
-.rst-other-versions {
- text-align: left;
-}
-
-.rst-other-versions > dl, .rst-other-versions dt, .rst-other-versions small {
- display: none;
-}
-
-.rst-other-versions > dl:first-child {
- display: flex !important;
- flex-direction: column;
- line-height: 0px !important;
-}
-
-.rst-versions.shift-up .rst-other-versions {
- display: flex !important;
-}
-
-.rst-versions .rst-other-versions {
- display: none;
-}
-
-/* Version Warning */
-div[data-md-component=announce] {
- background-color: rgb(248, 243, 236);
- position: sticky;
- top: 0;
- z-index: 2;
-}
-div[data-md-component=announce]>div#announce-msg{
- color:green;
- font-size: .8rem;
- text-align: center;
- margin: 15px;
-}
-div[data-md-component=announce]>div#announce-msg>a{
- color: var(--md-typeset-a-color);
- text-decoration: underline;
-}
-
-/* from https://assets.readthedocs.org/static/css/badge_only.css,
-most styles have to be overriden here */
-.rst-versions{
- position: relative !important;
- bottom: 0;
- left: 0;
- width: 100px !important;
- /* background: hsla(173, 100%, 24%, 1) !important; */
- background: #4051b5 !important;
- font-family: inherit !important;
- z-index: 0 !important;
-}
-.rst-versions a{
- color:#2980B9;
- text-decoration:none
-}
-.rst-versions .rst-badge-small{
- display:none
-}
-.rst-versions .rst-current-version{
- padding:12px;
- /* background: hsla(173, 100%, 24%, 1) !important; */
- background: #4051b5 !important;
- display:block;
- text-align:right;
- font-size:90%;
- cursor:pointer;
- color: white !important;
- *zoom:1
-}
-.rst-versions .rst-current-version:before,.rst-versions .rst-current-version:after{
- display:table;content:""
-}
-.rst-versions .rst-current-version:after{
- clear:both
-}
-.rst-versions .rst-current-version .fa{
- color:#fcfcfc
-}
-.rst-versions .rst-current-version .fa-caret-down{
- display: none;
-}
-.rst-versions.shift-up .rst-other-versions{
- display:block
-}
-.rst-versions .rst-other-versions{
- font-size:90%;
- padding-left:12px;
- padding-right:12px;
- padding-top:0px;
- padding-bottom:0px;
- color:gray;
- display:none
-}
-.rst-versions .rst-other-versions hr{
- display: none !important;
- height: 0px !important;
- border: 0px;
- margin: 0px !important;
- padding: 0px;
- border-top: none !important;
-}
-.rst-versions .rst-other-versions dd{
- display:inline-block;
- margin:0
-}
-.rst-versions .rst-other-versions dd a{
- display:inline-block;
- padding: 1em 0em !important;
- color:#fcfcfc;
- font-size: .6rem !important;
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- width: 80px;
-}
-.rst-versions .rst-other-versions dd a:hover{
- font-size: .7rem !important;
- font-weight: bold;
-}
-.rst-versions.rst-badge{
- display: block !important;
- width: 100px !important;
- bottom: 0px !important;
- right: 0px !important;
- left:auto;
- border:none;
- text-align: center !important;
- line-height: 0;
-}
-.rst-versions.rst-badge .icon-book{
- display: none;
-}
-.rst-versions.rst-badge .fa-book{
- display: none !important;
-}
-.rst-versions.rst-badge.shift-up .rst-current-version{
- text-align: left !important;
-}
-.rst-versions.rst-badge.shift-up .rst-current-version .fa-book{
- display: none !important;
-}
-.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{
- display: none !important;
-}
-.rst-versions.rst-badge .rst-current-version{
- width: 70px !important;
- height: 2.4rem !important;
- line-height:2.4rem !important;
- padding: 0px 5px !important;
- display: inline-block !important;
- font-size: .6rem !important;
- overflow: hidden !important;
- text-overflow: ellipsis !important;
- white-space: nowrap !important;
- text-align: left !important;
-}
-@media screen and (max-width: 768px){
- .rst-versions{
- width:85%;
- display:none
- }
- .rst-versions.shift{
- display:block
- }
-}
diff --git a/docs/assets/versions.js b/docs/assets/versions.js
deleted file mode 100644
index 60777dc6f..000000000
--- a/docs/assets/versions.js
+++ /dev/null
@@ -1,59 +0,0 @@
-setTimeout(function () {
- const callbackName = 'callback_' + new Date().getTime();
- window[callbackName] = function (response) {
- const div = document.createElement('div');
- div.innerHTML = response.html;
- document.querySelector(".md-header__inner > .md-header__title").appendChild(div);
- const container = div.querySelector('.rst-versions');
- var caret = document.createElement('div');
- caret.innerHTML = "You are viewing the latest of DevStream docs. Maybe you want to choose a specific version.
"
- var bannerHeight = document.getElementById('announce-msg').offsetHeight + margin
- document.querySelector("header.md-header").style.top = bannerHeight + "px";
- document.querySelector('style').textContent +=
- "@media screen and (min-width: 76.25em){ .md-sidebar { height: 0; top:" + (bannerHeight + headerHeight) + "px !important; }}"
- document.querySelector('style').textContent +=
- "@media screen and (min-width: 60em){ .md-sidebar--secondary { height: 0; top:" + (bannerHeight + headerHeight) + "px !important; }}"
- }
- // at the moment we do not have stable version; keep the following code for future reference
- // else if (rtdData.version !== "stable") {
- // document.querySelector("div[data-md-component=announce]").innerHTML = "