Skip to content

Commit

Permalink
Merge pull request #167 from baloise/feat/gitopsconfig-v2
Browse files Browse the repository at this point in the history
feat(GitOpsConfig): release apiVersion 2
  • Loading branch information
christiansiegel authored Aug 5, 2021
2 parents b74e56d + 52583d3 commit a2cbe03
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 5 deletions.
53 changes: 50 additions & 3 deletions docs/includes/preview-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Make sure that your *app repository* contains a `.gitops.config.yaml` file. This
4. find repository and branch where the preview should be created (i.e. your *deployment config repository*)

```yaml
apiVersion: v1
apiVersion: v2
applicationName: app-xy
previewConfig:
host: '{PREVIEW_NAMESPACE}.example.tld'
Expand All @@ -40,9 +40,10 @@ previewConfig:
organisation: deployments
repository: deployment-config-repo
# branch: master # optional (defaults to repo's default branch)
namespace: '{APPLICATION_NAME}-{PREVIEW_ID_HASH}-preview' # optional (default: '{APPLICATION_NAME}-{PREVIEW_ID}-{PREVIEW_ID_HASH}-preview',
namespace: '{APPLICATION_NAME}-{PREVIEW_ID_HASH}-preview' # optional (default: '{APPLICATION_NAME}-{PREVIEW_ID}-{PREVIEW_ID_HASH_SHORT}-preview',
# Invalid characters in PREVIEW_ID will be replaced. PREVIEW_ID will be
# truncated if max namespace length exceeds 63 chars.)
# truncated if max namespace length exceeds `maxNamespaceLength` chars.)
# maxNamespaceLength: 63 # optional (default: 53)
replace:
Chart.yaml:
- path: name
Expand All @@ -54,6 +55,52 @@ previewConfig:
value: '{PREVIEW_HOST}'
```
!!! info
If you currently use the _old_ `.gitops.config.yaml` format (_v0_) you may find this [online converter](https://christiansiegel.github.io/gitopscli-config-converter/) helpful to transition to the current `apiVersion v2`.

!!! warning
The _old_ (_v0_) version and `apiVersion v1` are marked deprecated and will be removed in `gitopscli` version 6.0.0.

Equivalent example:

```yaml
# old 'v0' format
deploymentConfig:
org: deployments
repository: deployment-config-repo
applicationName: app-xy
previewConfig:
route:
host:
template: app-xy-{SHA256_8CHAR_BRANCH_HASH}.example.tld
replace:
- path: image.tag
variable: GIT_COMMIT
- path: route.host
variable: ROUTE_HOST
```

```yaml
# v2 format
apiVersion: v2
applicationName: app-xy
previewConfig:
host: ${PREVIEW_NAMESPACE}.example.tld
target:
organisation: deployments
repository: deployment-config-repo
namespace: ${APPLICATION_NAME}-${PREVIEW_ID_HASH}-preview
replace:
Chart.yaml:
- path: name
value: ${PREVIEW_NAMESPACE}
values.yaml:
- path: image.tag
value: ${GIT_HASH}
- path: route.host
value: ${PREVIEW_HOST}
```

#### Variables
- `APPLICATION_NAME`: value from `applicationName`
- `GIT_HASH`:
Expand Down
2 changes: 1 addition & 1 deletion gitopscli/gitops_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def parse(self) -> GitOpsConfig:
return self.__parse_v0()
if api_version == "v1":
return self.__parse_v1()
if api_version == "v2_beta":
if api_version == "v2":
return self.__parse_v2()
raise GitOpsException(f"GitOps config apiVersion '{api_version}' is not supported!")

Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ extra_css:
# Extensions
markdown_extensions:
- markdown.extensions.attr_list
- pymdownx.superfences
- admonition
- codehilite:
guess_lang: false
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pytest==5.4.2
mkdocs==1.0.4
mkdocs-material==4.6.3
markdown-include==0.6.0
pymdown-extensions==8.2
mypy==0.790
typeguard==2.10.0
pre-commit==2.13.0
2 changes: 1 addition & 1 deletion tests/test_gitops_config_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class GitOpsConfigV2Test(unittest.TestCase):
def setUp(self):
self.yaml = {
"apiVersion": "v2_beta",
"apiVersion": "v2",
"applicationName": "my-app",
"previewConfig": {
"host": "my-${PREVIEW_ID}-${PREVIEW_ID_HASH}-host-template",
Expand Down

0 comments on commit a2cbe03

Please sign in to comment.