Skip to content

Commit

Permalink
feat: add updatecli autodiscovery policy
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Vernin <[email protected]>
  • Loading branch information
olblak committed Mar 23, 2024
1 parent d81b961 commit 67a2fb6
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 0 deletions.
12 changes: 12 additions & 0 deletions updatecli/policies/autodiscovery/updatecli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## 0.2.0

* Set default groupby to "all"
* Set pipelineid
* Update pipeline name
* Swap default order for scm configuration to use environment variable if nothing else is defined

## 0.1.0

* Init policy
14 changes: 14 additions & 0 deletions updatecli/policies/autodiscovery/updatecli/Policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
authors:
- Olblak <[email protected]>

url: "https://github.com/updatecli/policies/"
documentation: "https://github.com/updatecli/policies/tree/main/updatecli/policies/autodiscovery/updatecli/README.md"
source: "https://github.com/updatecli/policies/tree/main/updatecli/policies/autodiscovery/updatecli/"
version: 0.2.0
vendor: Updatecli Project

licenses:
- "Apache-2.0 license"

description: |
Updatecli Autodiscovery
3 changes: 3 additions & 0 deletions updatecli/policies/autodiscovery/updatecli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# README

This Updatecli policy tries to detected available Updatecli policies update in file `update-compose.yaml`
10 changes: 10 additions & 0 deletions updatecli/policies/autodiscovery/updatecli/testdata/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
scm:
enabled: true
user: updatecli-bot
email: [email protected]
owner: updatecli
repository: website
#token: "xxx"
username: "updatecli-bot"
branch: master

45 changes: 45 additions & 0 deletions updatecli/policies/autodiscovery/updatecli/updatecli.d/default.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
# Helpers
# {{ $GitHubUser := env ""}}
# {{ $GitHubRepositoryList := env "GITHUB_REPOSITORY" | split "/"}}
# {{ $GitHubPAT := env "GITHUB_TOKEN"}}
# {{ $GitHubUsername := env "GITHUB_ACTOR"}}

name: "deps(updatecli): bump all policies"
pipelineid: {{ .pipelineid }}

autodiscovery:
groupby: {{ .groupby }}
#{{ if or (.scm.enabled) (env "GITHUB_REPOSITORY") }}
scmid: default
actionid: default
# {{ end }}

crawlers:
updatecli:
{{ .spec | toYaml | indent 6 }}

{{ if or (.scm.enabled) (env "GITHUB_REPOSITORY") }}
scms:
default:
kind: "github"
spec:
# Priority set to the environment variable
user: '{{ default $GitHubUser .scm.user }}'
email: '{{ .scm.email }}'
owner: '{{ default $GitHubRepositoryList._0 .scm.owner }}'
repository: '{{ default $GitHubRepositoryList._1 .scm.repository }}'
token: '{{ default $GitHubPAT .scm.token }}'
username: '{{ default $GitHubUsername .scm.username }}'
branch: '{{ .scm.branch }}'

actions:
default:
kind: "github/pullrequest"
scmid: "default"
spec:
automerge: {{ .automerge }}
labels:
- dependencies
{{ end }}

16 changes: 16 additions & 0 deletions updatecli/policies/autodiscovery/updatecli/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pipelineid: updatecli_policies
automerge: false

scm:
enabled: false
user: updatecli-bot
#email: [email protected]
#owner: updatecli
#repository: "repository"
#token: "xxx"
username: "updatecli-bot"
branch: main

# spec:
groupby: all

0 comments on commit 67a2fb6

Please sign in to comment.