Skip to content

Commit 105e138

Browse files
authored
Merge pull request #1267 from devstream-io/docs-app-centric-docs-update
docs: update app-centric docs
2 parents 1f804a2 + 761873f commit 105e138

File tree

6 files changed

+251
-82
lines changed

6 files changed

+251
-82
lines changed

docs/core-concepts/config.md

Lines changed: 234 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,284 @@
1-
# DevStream Configuration
1+
# Config
22

3-
DevStream uses YAML files to describe your DevOps toolchain configuration.
3+
Now let's have a look at some config examples.
44

5-
## Main Config File
5+
TL;DR: [see the complete config file examle at the end of this doc](#7-putting-it-all-together).
66

7-
By default, `dtm` tries to use `./config.yaml` (under your current directory) as the main config.
7+
---
88

9-
The main config contains three sections:
9+
## 1 The Config File
1010

11-
- `varFile`: the path/to/your/variables file
12-
- `toolFile`: the path/to/your/tools configuration file
13-
- `pluginDir`: the path/to/your/plugins directory, default: `~/.devstream/plugins`, or use `-d` flag to specify a directory
14-
- `state`: configuration of DevStream state. For example,
11+
As mentioned in the overview section, the main config contains many sections, like:
1512

16-
### Example Main Config File
13+
- `config`
14+
- `vars`
15+
- `tools`
16+
- `apps`
17+
- `pipelineTemplates`
1718

18-
See the `config.yaml` example below:
19+
By default, `dtm` tries to use `./config.yaml` (under your working directory) as the main config.
20+
21+
You can override the default value with `-f` or `--config-file`. Examples:
22+
23+
```shell
24+
dtm apply -f path/to/your/config.yaml
25+
dtm apply --config-file path/to/your/config.yaml
26+
```
27+
28+
---
29+
30+
## 2 State Config
31+
32+
The `config` section specifies where to store the DevStream state.
33+
34+
### 2.1 Local
1935

2036
```yaml
21-
varFile: "./variables.yaml"
22-
toolFile: "./tools.yaml"
23-
appFile: "./apps.yaml"
24-
templateFile: "./templates.yaml"
25-
state: # state config, backend can be "local", "s3", or "k8s"
26-
backend: local
27-
options:
28-
stateFile: devstream.state
37+
config:
38+
state:
39+
backend: local
40+
options:
41+
stateFile: devstream.state
42+
```
43+
44+
_Note: The `stateFile` under the `options` section is mandatory for the local backend._
45+
46+
### 2.2 Kubernetes
47+
48+
```yaml
49+
config:
50+
state:
51+
backend: k8s
52+
options:
53+
namespace: devstream # optional, default is "devstream", will be created if not exists
54+
configmap: state # optional, default is "state", will be created if not exists
55+
```
56+
57+
### 2.3 S3
58+
59+
```yaml
60+
config:
61+
state:
62+
backend: s3
63+
options:
64+
bucket: devstream-remote-state
65+
region: ap-southeast-1
66+
key: devstream.state
2967
```
3068

31-
### Variables File
69+
_Note: the `bucket`, `region`, and `key` under the `options` section are all mandatory fields for the s3 backend._
3270

33-
The var file is a YAML file containing key-value pairs.
71+
---
3472

35-
_At the moment, nested/composite values (for example, the value is a list/dictionary) are not supported yet._
73+
## 3 Variables
3674

37-
See the `variables.yaml` example below:
75+
To not repeat yourself (Don't repeat yourself, DRY, see [here](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself),) we can define some variables in a var file and use the vars in the config file.
76+
77+
The vars section is a YAML dict containing key-value pairs. Example:
78+
79+
Example:
3880

3981
```yaml
40-
githubUsername: daniel-hutao
41-
repoName: dtm-test-go
42-
defaultBranch: main
43-
dockerhubUsername: exploitht
82+
vars:
83+
repoOwner: RepoOwner
84+
repoTemplateBaseURL: github.com/devstream-io
85+
imageRepoOwner: ImageRepoOwner
4486
```
4587

46-
### Tool File
88+
To use these variables in a config file, use the following syntax:
4789

48-
Tool file contains a list of tools.
90+
```yaml
91+
[[ varNameHere ]]
92+
```
4993

50-
The tool file contains:
94+
---
5195

52-
- Only one section (at the moment), which is `tools`.
53-
- `tools` is a list of dictionaries.
54-
- Each dictionary defines a DevOps "tool" which is managed by a DevStream plugin
55-
- Each dictionary (tool) has the following mandatory fields:
56-
- `name`: the name of the tool/plugin, string, without underscore
57-
- `instanceID`: the id of this tool instance
58-
- you can have duplicated `name` in one config file, and you can also have duplicated `instanceID` in one config file, but the `name + instanceID` combination must be unique in one config file
59-
- Each dictionary (tool) has an optional field which is `options`, which in turn is a dictionary containing parameters for that specific plugin. For plugins' parameters, see the "plugins" section of this document.
60-
- Each directory (tool) has an optional field which is `dependsOn`. Continue reading for detail about dependencies.
96+
## 4 Tools
6197

62-
See the `tools.yaml` example down below:
98+
The tools section contains a list of tools.
6399

64100
```yaml
65101
tools:
66102
- name: repo-scaffolding
67-
instanceID: golang-github
103+
instanceID: myapp
68104
options:
69105
destinationRepo:
70-
owner: [[ githubUsername ]]
71-
org: ""
72-
repo: [[ repoName ]]
73-
branch: [[ defaultBranch ]]
106+
owner: [[ githubUser ]]
107+
repo: [[ app ]]
108+
branch: main
74109
repoType: github
75-
vars:
76-
ImageRepo: "[[ dockerhubUsername ]]/[[ repoName ]]"
77110
sourceRepo:
78111
org: devstream-io
79-
repo: dtm-scaffolding-golang
112+
repo: dtm-scaffolding-python
80113
repoType: github
81-
- name: jira-github-integ
114+
vars:
115+
imageRepo: [[ dockerUser ]]/[[ app ]]
116+
- name: githubactions-python
82117
instanceID: default
83-
dependsOn: [ "repo-scaffolding.golang-github" ]
118+
dependsOn: [ repo-scaffolding.myapp ]
84119
options:
85-
owner: [[ githubUsername ]]
86-
repo: [[ repoName ]]
87-
jiraBaseUrl: https://xxx.atlassian.net
88-
jiraUserEmail: [email protected]
89-
jiraProjectKey: zzz
120+
owner: [[ githubUser ]]
121+
repo: [[ app ]]
122+
language:
123+
name: python
90124
branch: main
125+
docker:
126+
registry:
127+
type: dockerhub
128+
username: [[ dockerUser ]]
129+
repository: [[ app ]]
130+
- name: helm-installer
131+
instanceID: argocd
132+
- name: argocdapp
133+
instanceID: default
134+
dependsOn: [ "helm-installer.argocd", "githubactions-python.default" ]
135+
options:
136+
app:
137+
name: [[ app ]]
138+
namespace: argocd
139+
destination:
140+
server: https://kubernetes.default.svc
141+
namespace: default
142+
source:
143+
valuefile: values.yaml
144+
path: helm/[[ app ]]
145+
repoURL: ${{repo-scaffolding.myapp.outputs.repoURL}}
91146
```
92147

93-
### State
148+
If you want tool A to be installed before tool B, you can let tool B depend on tool A.
94149

95-
The `state` section specifies where to store DevStream state. As of now (v0.5.0), we only support local backend.
150+
The syntax for dependency is:
96151

97-
From v0.6.0 on, we will support both "local" and "s3" backend store the DevStream state.
152+
```yaml
153+
dependsOn: [ "ToolName.ToolInstanceID" ]
154+
```
98155

99-
Read the section [The State Section in the Main Config](./stateconfig.md) for more details.
156+
Since `dependsOn` is a list, a tool can have multiple dependencies:
100157

101-
## Default Values
158+
```
159+
dependsOn: [ "ToolName1.ToolInstanceID1", "ToolName2.ToolInstanceID2", "..." ]
160+
```
102161

103-
By default, `dtm` uses `config.yaml` as the main config file.
162+
---
104163

105-
### Specifying a Main Config File Explicitly
164+
## 5 Apps
106165

107-
You can override the default value with `-f` or `--config-file`. Examples:
166+
The Apps section looks like the following:
108167

109-
```shell
110-
dtm apply -f path/to/your/config.yaml
111-
dtm apply --config-file path/to/your/config.yaml
168+
```yaml
169+
apps:
170+
- name: service-A
171+
spec:
172+
language: python
173+
framework: django
174+
repo:
175+
scmType: github
176+
owner: devstream-io
177+
org: devstream-io # either owner or org must exist
178+
name: service-A # defaults to "app.name"
179+
url: github.com/devstream-io/repo-name # optional. if exists, no need for the scm/owner/org/name sections
180+
apiURL: gitlab.com/some/path/to/your/api # optional, in case of self-managed git
181+
repoTemplate: # optional. if repoTemplate isn't empty, create repo according to the template
182+
scmType: github
183+
owner: devstream-io
184+
org: devstream-io # either owner or org must exist
185+
name: dtm-scaffolding-golang
186+
url: github.com/devstream-io/repo-name # optional. if exists, no need for the scm/owner/org/name sections
187+
vars: # optional
188+
foo: bar # variables used for repoTemplate specifically
189+
ci:
190+
- type: template # type template means it's a reference to the pipeline template. read the next section.
191+
templateName: ci-pipeline-1
192+
options: # optional, used to override defaults in the template
193+
vars: # optional, key/values to be passed to the template
194+
key: value
195+
cd:
196+
- type: template # type template means it's a reference to the pipeline template. read the next section.
197+
templateName: cd-pipeline-1
198+
options: # optional, used to override defaults in the template
199+
vars: # optional, key/values to be passed to the template
200+
key: value
201+
```
202+
203+
Since many key/values have default values, it's possible to use the following minimum config for the apps section:
204+
205+
```yaml
206+
apps:
207+
- name: myapp1
208+
spec:
209+
language: python
210+
framework: django
211+
repo:
212+
url: github.com/ironcore864/myapp1
213+
repoTemplate:
214+
url: github.com/devstream-io/dtm-scaffolding-python
215+
ci:
216+
- type: githubactions
217+
cd:
218+
- type: argocdapp
219+
```
220+
221+
---
222+
223+
## 6 Pipeline Templates
224+
225+
You can define some pipeline templates in the pipelineTemplates section:
226+
227+
```yaml
228+
pipelineTemplates:
229+
- name: ci-pipeline-1
230+
type: githubactions # corresponds to a DevStream plugin
231+
options:
232+
branch: main # optional
233+
docker:
234+
registry:
235+
type: dockerhub
236+
username: [[ dockerUser ]]
237+
repository: [[ app ]]
238+
- name: cd-pipeline-1
239+
type: argocdapp
240+
options:
241+
app:
242+
namespace: argocd
243+
destination:
244+
server: https://kubernetes.default.svc
245+
namespace: default
246+
source:
247+
valuefile: values.yaml
248+
path: helm/[[ app ]]
249+
repoURL: ${{repo-scaffolding.myapp.outputs.repoURL}}
112250
```
113251

114-
### No Defaults for varFile and toolFile
252+
Then, you can refer to these pipeline templates in the apps file.
253+
254+
---
115255

116-
For `varFile` and `toolFile`, no default values are provided.
256+
## 7 Putting It All Together
117257

118-
If `varFile` isn't specified in the main config, `dtm` will not use any var files, even if there is already a file named `variables.yaml` under the current directory.
258+
Here's a complete example:
119259

120-
Similarly, if `toolFile` isn't specified in the main config, `dtm` will throw an error, even if there is a `tools.yaml` file under the current directory.
260+
```yaml
261+
config:
262+
state:
263+
backend: local
264+
options:
265+
stateFile: devstream.state
266+
267+
tools:
268+
- name: helm-installer
269+
instanceID: argocd
270+
271+
apps:
272+
- name: myapp1
273+
spec:
274+
language: python
275+
framework: django
276+
repo:
277+
url: github.com/ironcore864/myapp1
278+
repoTemplate:
279+
url: github.com/devstream-io/dtm-scaffolding-python
280+
ci:
281+
- type: githubactions
282+
cd:
283+
- type: argocdapp
284+
```

docs/core-concepts/overview.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ The main config file, which defaults to `config.yaml` in the working directory,
2929

3030
There are a few different configs, but please don't be overwhelmed because some are not mandatory, and [you can define all things within a single file](https://stackoverflow.com/questions/50788277/why-3-dashes-hyphen-in-yaml-file).
3131

32-
Configurations in the main config:
33-
34-
- `pluginDir`: the directory where DevStream plugins are stored, defaults to `~/.devstream/plugins`. You can also use the `-d' flag to specify a directory.
35-
- `state`: state-related settings. Read more [here](./state.md).
36-
- `varFile`: the location of the variable file used by DevStream. The variable file is a YAML of key/values, which can be referred to in the toolFile/appFile/templateFile.
37-
- `toolFile`: the location of the tool file used by DevStream. The tool file is a list of DevStream _Tools_, each containing its name, instanceID (unique identifier), and options. Read more [here](./tools-apps.md).
38-
- `appFile`: the location of the app file used by DevStream. The app file is a list of _Apps_, another DevStream concept, each corresponding to a microservice. Read more [here](./tools-apps.md).
39-
- `templateFile`: the location of the template file used by DevStream. The templateFile can be referred to by DevStream _Apps_. Read more [here](./tools-apps.md).
32+
Configurations in the main config contains multiple sections:
33+
34+
- `config`: basic configuration of DevStream, at the moment mainly state-related settings. Read more [here](./state.md).
35+
- `vars`: variable definitions. Key/value pairs, which can be referred to in the tools/apps/pipelineTemplates sections.
36+
- `tools`: a list of DevStream _Tools_, each containing its name, instanceID (unique identifier), and options. Read more [here](./tools-apps.md).
37+
- `apps`: a list of _Apps_, another DevStream concept, each corresponding to a microservice. Read more [here](./tools-apps.md).
38+
- `pipelineTemplates`: a list of templates which can be referred to by DevStream _Apps_. Read more [here](./tools-apps.md).
4039

4140
---
4241

docs/core-concepts/stateconfig.md

Whitespace-only changes.

0 commit comments

Comments
 (0)