-
Couldn't load subscription status.
- Fork 198
docs: update app-centric docs #1267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,120 +1,284 @@ | ||
| # DevStream Configuration | ||
| # Config | ||
|
|
||
| DevStream uses YAML files to describe your DevOps toolchain configuration. | ||
| Now let's have a look at some config examples. | ||
|
|
||
| ## Main Config File | ||
| TL;DR: [see the complete config file examle at the end of this doc](#7-putting-it-all-together). | ||
|
|
||
| By default, `dtm` tries to use `./config.yaml` (under your current directory) as the main config. | ||
| --- | ||
|
|
||
| The main config contains three sections: | ||
| ## 1 The Config File | ||
|
|
||
| - `varFile`: the path/to/your/variables file | ||
| - `toolFile`: the path/to/your/tools configuration file | ||
| - `pluginDir`: the path/to/your/plugins directory, default: `~/.devstream/plugins`, or use `-d` flag to specify a directory | ||
| - `state`: configuration of DevStream state. For example, | ||
| As mentioned in the overview section, the main config contains many sections, like: | ||
|
|
||
| ### Example Main Config File | ||
| - `config` | ||
| - `vars` | ||
| - `tools` | ||
| - `apps` | ||
| - `pipelineTemplates` | ||
|
|
||
| See the `config.yaml` example below: | ||
| By default, `dtm` tries to use `./config.yaml` (under your working directory) as the main config. | ||
|
|
||
| You can override the default value with `-f` or `--config-file`. Examples: | ||
|
|
||
| ```shell | ||
| dtm apply -f path/to/your/config.yaml | ||
| dtm apply --config-file path/to/your/config.yaml | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 2 State Config | ||
|
|
||
| The `config` section specifies where to store the DevStream state. | ||
|
|
||
| ### 2.1 Local | ||
|
|
||
| ```yaml | ||
| varFile: "./variables.yaml" | ||
| toolFile: "./tools.yaml" | ||
| appFile: "./apps.yaml" | ||
| templateFile: "./templates.yaml" | ||
| state: # state config, backend can be "local", "s3", or "k8s" | ||
| backend: local | ||
| options: | ||
| stateFile: devstream.state | ||
| config: | ||
| state: | ||
| backend: local | ||
| options: | ||
| stateFile: devstream.state | ||
| ``` | ||
|
|
||
| _Note: The `stateFile` under the `options` section is mandatory for the local backend._ | ||
|
|
||
| ### 2.2 Kubernetes | ||
|
|
||
| ```yaml | ||
| config: | ||
| state: | ||
| backend: k8s | ||
| options: | ||
| namespace: devstream # optional, default is "devstream", will be created if not exists | ||
| configmap: state # optional, default is "state", will be created if not exists | ||
| ``` | ||
|
|
||
| ### 2.3 S3 | ||
|
|
||
| ```yaml | ||
| config: | ||
| state: | ||
| backend: s3 | ||
| options: | ||
| bucket: devstream-remote-state | ||
| region: ap-southeast-1 | ||
| key: devstream.state | ||
| ``` | ||
|
|
||
| ### Variables File | ||
| _Note: the `bucket`, `region`, and `key` under the `options` section are all mandatory fields for the s3 backend._ | ||
|
|
||
| The var file is a YAML file containing key-value pairs. | ||
| --- | ||
|
|
||
| _At the moment, nested/composite values (for example, the value is a list/dictionary) are not supported yet._ | ||
| ## 3 Variables | ||
|
|
||
| See the `variables.yaml` example below: | ||
| 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. | ||
|
|
||
| The vars section is a YAML dict containing key-value pairs. Example: | ||
|
|
||
| Example: | ||
|
|
||
| ```yaml | ||
| githubUsername: daniel-hutao | ||
| repoName: dtm-test-go | ||
| defaultBranch: main | ||
| dockerhubUsername: exploitht | ||
| vars: | ||
| repoOwner: RepoOwner | ||
| repoTemplateBaseURL: github.com/devstream-io | ||
| imageRepoOwner: ImageRepoOwner | ||
| ``` | ||
|
|
||
| ### Tool File | ||
| To use these variables in a config file, use the following syntax: | ||
|
|
||
| Tool file contains a list of tools. | ||
| ```yaml | ||
| [[ varNameHere ]] | ||
| ``` | ||
|
|
||
| The tool file contains: | ||
| --- | ||
|
|
||
| - Only one section (at the moment), which is `tools`. | ||
| - `tools` is a list of dictionaries. | ||
| - Each dictionary defines a DevOps "tool" which is managed by a DevStream plugin | ||
| - Each dictionary (tool) has the following mandatory fields: | ||
| - `name`: the name of the tool/plugin, string, without underscore | ||
| - `instanceID`: the id of this tool instance | ||
| - 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 | ||
| - 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. | ||
| - Each directory (tool) has an optional field which is `dependsOn`. Continue reading for detail about dependencies. | ||
| ## 4 Tools | ||
|
|
||
| See the `tools.yaml` example down below: | ||
| The tools section contains a list of tools. | ||
|
|
||
| ```yaml | ||
| tools: | ||
| - name: repo-scaffolding | ||
| instanceID: golang-github | ||
| instanceID: myapp | ||
| options: | ||
| destinationRepo: | ||
| owner: [[ githubUsername ]] | ||
| org: "" | ||
| repo: [[ repoName ]] | ||
| branch: [[ defaultBranch ]] | ||
| owner: [[ githubUser ]] | ||
| repo: [[ app ]] | ||
| branch: main | ||
| repoType: github | ||
| vars: | ||
| ImageRepo: "[[ dockerhubUsername ]]/[[ repoName ]]" | ||
| sourceRepo: | ||
| org: devstream-io | ||
| repo: dtm-scaffolding-golang | ||
| repo: dtm-scaffolding-python | ||
| repoType: github | ||
| - name: jira-github-integ | ||
| vars: | ||
| imageRepo: [[ dockerUser ]]/[[ app ]] | ||
| - name: githubactions-python | ||
| instanceID: default | ||
| dependsOn: [ "repo-scaffolding.golang-github" ] | ||
| dependsOn: [ repo-scaffolding.myapp ] | ||
| options: | ||
| owner: [[ githubUsername ]] | ||
| repo: [[ repoName ]] | ||
| jiraBaseUrl: https://xxx.atlassian.net | ||
| jiraUserEmail: foo@bar.com | ||
| jiraProjectKey: zzz | ||
| owner: [[ githubUser ]] | ||
| repo: [[ app ]] | ||
| language: | ||
| name: python | ||
| branch: main | ||
| docker: | ||
| registry: | ||
| type: dockerhub | ||
| username: [[ dockerUser ]] | ||
| repository: [[ app ]] | ||
| - name: helm-installer | ||
| instanceID: argocd | ||
| - name: argocdapp | ||
| instanceID: default | ||
| dependsOn: [ "helm-installer.argocd", "githubactions-python.default" ] | ||
| options: | ||
| app: | ||
| name: [[ app ]] | ||
| namespace: argocd | ||
| destination: | ||
| server: https://kubernetes.default.svc | ||
| namespace: default | ||
| source: | ||
| valuefile: values.yaml | ||
| path: helm/[[ app ]] | ||
| repoURL: ${{repo-scaffolding.myapp.outputs.repoURL}} | ||
| ``` | ||
|
|
||
| ### State | ||
| If you want tool A to be installed before tool B, you can let tool B depend on tool A. | ||
|
|
||
| The `state` section specifies where to store DevStream state. As of now (v0.5.0), we only support local backend. | ||
| The syntax for dependency is: | ||
|
|
||
| From v0.6.0 on, we will support both "local" and "s3" backend store the DevStream state. | ||
| ```yaml | ||
| dependsOn: [ "ToolName.ToolInstanceID" ] | ||
| ``` | ||
|
|
||
| Read the section [The State Section in the Main Config](./stateconfig.md) for more details. | ||
| Since `dependsOn` is a list, a tool can have multiple dependencies: | ||
|
|
||
| ## Default Values | ||
| ``` | ||
| dependsOn: [ "ToolName1.ToolInstanceID1", "ToolName2.ToolInstanceID2", "..." ] | ||
| ``` | ||
|
|
||
| By default, `dtm` uses `config.yaml` as the main config file. | ||
| --- | ||
|
|
||
| ### Specifying a Main Config File Explicitly | ||
| ## 5 Apps | ||
|
|
||
| You can override the default value with `-f` or `--config-file`. Examples: | ||
| The Apps section looks like the following: | ||
|
|
||
| ```shell | ||
| dtm apply -f path/to/your/config.yaml | ||
| dtm apply --config-file path/to/your/config.yaml | ||
| ```yaml | ||
| apps: | ||
| - name: service-A | ||
| spec: | ||
| language: python | ||
| framework: django | ||
| repo: | ||
| scmType: github | ||
| owner: devstream-io | ||
| org: devstream-io # either owner or org must exist | ||
| name: service-A # defaults to "app.name" | ||
| url: github.com/devstream-io/repo-name # optional. if exists, no need for the scm/owner/org/name sections | ||
| apiURL: gitlab.com/some/path/to/your/api # optional, in case of self-managed git | ||
| repoTemplate: # optional. if repoTemplate isn't empty, create repo according to the template | ||
| scmType: github | ||
| owner: devstream-io | ||
| org: devstream-io # either owner or org must exist | ||
| name: dtm-scaffolding-golang | ||
| url: github.com/devstream-io/repo-name # optional. if exists, no need for the scm/owner/org/name sections | ||
| vars: # optional | ||
| foo: bar # variables used for repoTemplate specifically | ||
| ci: | ||
| - type: template # type template means it's a reference to the pipeline template. read the next section. | ||
| templateName: ci-pipeline-1 | ||
| options: # optional, used to override defaults in the template | ||
| vars: # optional, key/values to be passed to the template | ||
| key: value | ||
| cd: | ||
| - type: template # type template means it's a reference to the pipeline template. read the next section. | ||
| templateName: cd-pipeline-1 | ||
| options: # optional, used to override defaults in the template | ||
| vars: # optional, key/values to be passed to the template | ||
| key: value | ||
| ``` | ||
|
|
||
| Since many key/values have default values, it's possible to use the following minimum config for the apps section: | ||
|
|
||
| ```yaml | ||
| apps: | ||
| - name: myapp1 | ||
| spec: | ||
| language: python | ||
| framework: django | ||
| repo: | ||
| url: github.com/ironcore864/myapp1 | ||
| repoTemplate: | ||
| url: github.com/devstream-io/dtm-scaffolding-python | ||
| ci: | ||
| - type: githubactions | ||
| cd: | ||
| - type: argocdapp | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 6 Pipeline Templates | ||
|
|
||
| You can define some pipeline templates in the pipelineTemplates section: | ||
|
|
||
| ```yaml | ||
| pipelineTemplates: | ||
| - name: ci-pipeline-1 | ||
| type: githubactions # corresponds to a DevStream plugin | ||
| options: | ||
| branch: main # optional | ||
| docker: | ||
| registry: | ||
| type: dockerhub | ||
| username: [[ dockerUser ]] | ||
| repository: [[ app ]] | ||
| - name: cd-pipeline-1 | ||
| type: argocdapp | ||
| options: | ||
| app: | ||
| namespace: argocd | ||
| destination: | ||
| server: https://kubernetes.default.svc | ||
| namespace: default | ||
| source: | ||
| valuefile: values.yaml | ||
| path: helm/[[ app ]] | ||
| repoURL: ${{repo-scaffolding.myapp.outputs.repoURL}} | ||
| ``` | ||
|
|
||
| ### No Defaults for varFile and toolFile | ||
| Then, you can refer to these pipeline templates in the apps file. | ||
|
|
||
| --- | ||
|
|
||
| For `varFile` and `toolFile`, no default values are provided. | ||
| ## 7 Putting It All Together | ||
|
|
||
| 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. | ||
| Here's a complete example: | ||
|
|
||
| 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. | ||
| ```yaml | ||
| config: | ||
| state: | ||
| backend: local | ||
| options: | ||
| stateFile: devstream.state | ||
|
|
||
| tools: | ||
| - name: helm-installer | ||
| instanceID: argocd | ||
|
|
||
| apps: | ||
| - name: myapp1 | ||
| spec: | ||
| language: python | ||
| framework: django | ||
| repo: | ||
| url: github.com/ironcore864/myapp1 | ||
| repoTemplate: | ||
| url: github.com/devstream-io/dtm-scaffolding-python | ||
| ci: | ||
| - type: githubactions | ||
| cd: | ||
| - type: argocdapp | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.