Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/0zyt/devstream into dev3
Browse files Browse the repository at this point in the history
  • Loading branch information
0zyt committed Oct 16, 2022
2 parents 134306a + ed469dc commit 84c801b
Show file tree
Hide file tree
Showing 143 changed files with 2,330 additions and 1,348 deletions.
1 change: 1 addition & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ https://fonts.gstatic.com/
.*foo.*
.*bar.*
.*xxx.*
.*changeme.*
.*example.*
.*YOUR_.*
https://id.atlassian.net
Expand Down
9 changes: 8 additions & 1 deletion cmd/devstream/develop.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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"
)

Expand All @@ -12,6 +13,11 @@ var (
all bool
)

var validatePluginFlagNames = []string{
"name",
"all",
}

var developCMD = &cobra.Command{
Use: "develop",
Short: "Develop is used for develop a new plugin",
Expand All @@ -33,7 +39,8 @@ var developValidatePluginCMD = &cobra.Command{
Examples:
dtm develop validate-plugin --name=YOUR-PLUGIN-NAME,
dtm develop validate-plugin --all`,
Run: developValidateCMDFunc,
Run: developValidateCMDFunc,
PreRun: cli.BindPFlags(validatePluginFlagNames),
}

func developCreateCMDFunc(cmd *cobra.Command, args []string) {
Expand Down
39 changes: 39 additions & 0 deletions cmd/plugin/devlake-config/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"github.com/devstream-io/devstream/internal/pkg/plugin/devlakeconfig"
"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 map[string]interface{}) (map[string]interface{}, error) {
return devlakeconfig.Create(options)
}

// Update implements the update of devlake-config.
func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) {
return devlakeconfig.Update(options)
}

// Delete implements the delete of devlake-config.
func (p Plugin) Delete(options map[string]interface{}) (bool, error) {
return devlakeconfig.Delete(options)
}

// Read implements the read of devlake-config.
func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, 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)
}
18 changes: 12 additions & 6 deletions docs/best-practices/gitops.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,24 @@ Note: These dependencies are optional; you can use dependency to make sure a cer

## 1 Download DevStream (`dtm`)

Download the appropriate `dtm` version for your platform from [DevStream Releases](https://github.com/devstream-io/devstream/releases).
In your working directory, run:

> Remember to rename the binary file to `dtm` so that it's easier to use. For example: `mv dtm-darwin-arm64 dtm`.
```shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/devstream-io/devstream/main/hack/install/download.sh)"
```

This will download the corresponding `dtm` binary to your working directory according to your OS and chip architecture, and grant the binary execution permission.

> Once downloaded, you can run the binary from anywhere. Ideally, you want to put it in a place that is in your PATH (e.g., `/usr/local/bin`).
> Optional: you can then move `dtm` to a place which is in your PATH. For example: `mv dtm /usr/local/bin/`.
_For more details on how to install, see [install dtm](../install.md)._

## 2 Prepare the Config File

Download the `gitops.yaml` to your working directory:
Run the following command to generate a template configuration file for gitops `gitops.yaml`.

```bash
curl -o gitops.yaml https://raw.githubusercontent.com/devstream-io/devstream/main/examples/gitops.yaml
```shell
./dtm show config -t gitops > gitops.yaml
```

Then modify the `gitops.yaml` file accordingly.
Expand Down
30 changes: 18 additions & 12 deletions docs/best-practices/gitops.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

## 所需插件

1. [repo-scaffolding](../plugins/repo-scaffolding.md)
2. [jira-github](../plugins/jira-github-integ.md)
3. [githubactions-golang](../plugins/githubactions-golang.md)
4. [argocd](../plugins/argocd.md)
5. [argocdapp](../plugins/argocdapp.md)
1. [repo-scaffolding](../plugins/repo-scaffolding.zh.md)
2. [jira-github](../plugins/jira-github-integ.zh.md)
3. [githubactions-golang](../plugins/githubactions-golang.zh.md)
4. [argocd](../plugins/argocd.zh.md)
5. [argocdapp](../plugins/argocdapp.zh.md)

这些插件的依赖关系如下(`a -> b`意味着`a依赖b`):

Expand All @@ -22,23 +22,29 @@

**注意**:依赖并不是必须指定的,我们可以用依赖确保某个工具可以先于另外一个工具安装。我们应该根据实际的使用场景来使用`dependsOn`

## 1 下载DevStream`dtm`
## 1 下载 DevStream`dtm`

[DevStream Releases](https://github.com/devstream-io/devstream/releases)页面下载适合你操作系统和CPU架构的`dtm`
进入你的工作目录,运行:

> 将二进制文件改名为`dtm`,以便易于使用。例如,执行:`mv dtm-drawin-arm64 dtm`
```shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/devstream-io/devstream/main/hack/install/download.sh)"
```

这个命令会根据你的操作系统和芯片架构下载对应的 `dtm` 二进制文件到你的工作目录中,并赋予二进制文件执行权限。

> 可选:建议你将 dtm 移动到包含于 PATH 的目录下,比如 `mv dtm /usr/local/bin/`
> 下载之后,你可以在任意地方执行这个二进制文件。你可以将它加入到你的PATH中(例如`/usr/local/bin`)。
_更多安装方式详见[安装dtm](../install.zh.md)_

## 2 准备配置文件

`gitops.yaml`下载到你的工作目录下:
运行以下命令来生成 gitops 的模板配置文件 `gitops.yaml`

```shell
curl -o gitops.yaml https://raw.githubusercontent.com/devstream-io/devstream/main/examples/gitops.yaml
./dtm show config -t gitops > gitops.yaml
```

然后对`gitops.yaml`文件做相应的修改。
然后对 `gitops.yaml` 文件做相应的修改。

配置文件中用到的变量的解释和示例值如下:

Expand Down
28 changes: 0 additions & 28 deletions docs/commands/install.md

This file was deleted.

28 changes: 0 additions & 28 deletions docs/commands/install.zh.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/development/commit-messages.zh.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Commit 信息
我们尽最大的努力遵守[conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary)规范。
我们尽最大的努力遵守[conventional commits](https://www.conventionalcommits.org/zh-hans/v1.0.0/#概述)规范。

TL;DR:提交信息应当结构如下:

Expand Down
2 changes: 1 addition & 1 deletion docs/development/creating-a-plugin.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
请在这里编写插件的主要逻辑。

可以查看我们的[Standard Go Project Layout](project-layout.md)文件,了解关于项目布局的详细说明。
可以查看我们的[Standard Go Project Layout](project-layout.zh.md)文件,了解关于项目布局的详细说明。

## 2 接口

Expand Down
2 changes: 1 addition & 1 deletion docs/development/project-layout.zh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 项目组织结构

参见 [`标准 Go 项目布局`](https://github.com/golang-standards/project-layout) 以了解更多背景信息。
参见 [`标准 Go 项目布局`](https://github.com/golang-standards/project-layout/blob/master/README_zh.md) 以了解更多背景信息。

更多关于命名、包的组织,以及其他代码结构的建议如下:

Expand Down
51 changes: 51 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Installation

## 0 Currently supported operating systems and chip architectures

* Darwin/arm64
* Darwin/amd64
* Linux/amd64

## 1 Install dtm binary with script

In your working directory, run:

```shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/devstream-io/devstream/main/hack/install/download.sh)"
```

This will download the corresponding `dtm` binary to your working directory according to your OS and chip architecture, and grant the binary execution permission.

> Optional: you can then move `dtm` to a place which is in your PATH. For example: `mv dtm /usr/local/bin/`.
## 2 Install with [asdf](https://asdf-vm.com/)

```shell
# Plugin
asdf plugin add dtm
# Show all installable versions
asdf list-all dtm
# Install specific version
asdf install dtm latest
# Set a version globally (on your ~/.tool-versions file)
asdf global dtm latest
# Now dtm commands are available
dtm --help
```

## 3 Download manually from the Release page

You could find the latest version of `dtm` on the [Release](https://github.com/devstream-io/devstream/releases/) page and click Download.
Note that there are multiple versions of `dtm` available, so you will need to choose the correct version for your operating system and chip architecture. Once downloaded locally, you can choose to rename it, move it to the directory containing `$PATH` and give it executable permissions, for example, on Linux you can do this by running the following command.

```shell
mv dtm-linux-amd64 /usr/local/bin/dtm
chmod +x dtm
```

Then you can verify that the permissions and version of dtm are correct with the following command.

```shell
$ dtm version
0.9.1
```
51 changes: 51 additions & 0 deletions docs/install.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 安装

## 0 当前支持的操作系统与芯片架构

* Darwin/arm64
* Darwin/amd64
* Linux/amd64

## 1 用脚本安装

进入你的工作目录,运行:

```shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/devstream-io/devstream/main/hack/install/download.sh)"
```

这个命令会根据你的操作系统和芯片架构下载对应的 `dtm` 二进制文件到你的工作目录中,并赋予二进制文件执行权限。

> 可选:建议你将 dtm 移动到包含于 PATH 的目录下,比如 `mv dtm /usr/local/bin/`
## 2 用 [asdf](https://asdf-vm.com/) 安装

```shell
# Plugin
asdf plugin add dtm
# Show all installable versions
asdf list-all dtm
# Install specific version
asdf install dtm latest
# Set a version globally (on your ~/.tool-versions file)
asdf global dtm latest
# Now dtm commands are available
dtm --help
```

## 3 从 Release 页面手动下载

[Release](https://github.com/devstream-io/devstream/releases/) 页面找到当前最新版本 `dtm`,然后点击下载。
需要注意的是当前 `dtm` 提供了多个版本,你需要根据操作系统和芯片架构选择自己需要的正确版本。下载到本地后,你可以选择将其重命名,移入包含在"$PATH"的目录里并赋予其可执行权限,比如在 Linux 上你可以执行如下命令完成这些操作:

```shell
mv dtm-linux-amd64 /usr/local/bin/dtm
chmod +x dtm
```

接着你可以通过如下命令验证 dtm 的权限以及版本等是否正确:

```shell
$ dtm version
0.9.1
```
4 changes: 4 additions & 0 deletions docs/plugins/argocd.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This plugin installs [ArgoCD](https://argoproj.github.io/cd/) in an existing Kub

## Usage

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

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

```yaml
--8<-- "argocd.yaml"
```
Expand Down
4 changes: 4 additions & 0 deletions docs/plugins/argocdapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ This plugin creates an [ArgoCD Application](https://argo-cd.readthedocs.io/en/st

## Usage

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

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

```yaml
--8<-- "argocdapp.yaml"
```
Expand Down
4 changes: 4 additions & 0 deletions docs/plugins/artifactory.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ This plugin support`Ingress`, `ClusterIP`, `NodePort` and `LoadBalancer` , You c

### Config

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

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

```yaml
--8<-- "artifactory.yaml"
```
Expand Down
4 changes: 4 additions & 0 deletions docs/plugins/artifactory.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ valuesYaml: |

### 配置

下面的配置文件展示的是"tool file"的内容。

关于更多关于DevStream的主配置、tool file、var file的信息,请阅读[核心概念概览](../core-concepts/core-concepts.zh.md)和[DevStream配置](../core-concepts/config.zh.md).

```yaml
--8<-- "artifactory.yaml"
```
Expand Down
Loading

0 comments on commit 84c801b

Please sign in to comment.