Skip to content

Commit c35d1b2

Browse files
authored
feat(opentofu): support opentofu versions (#137)
* feat(opentofu): support opentofu versions * fix * Revert "fix" This reverts commit a3d921c.
1 parent efac3e6 commit c35d1b2

File tree

9 files changed

+138
-0
lines changed

9 files changed

+138
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.87.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
opentofu 0.87.0

updatecli-compose.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ policies:
3939
values:
4040
- updatecli/policies/opa/version/testdata/values.yaml
4141

42+
- name: Handle opentofu update (e2e tests)
43+
policy: ghcr.io/elastic/oblt-updatecli-policies/opentofu/version:latest
44+
values:
45+
- updatecli/policies/opentofu/version/testdata/values.yaml
46+
4247
- name: Handle terraform update (e2e tests)
4348
policy: ghcr.io/elastic/oblt-updatecli-policies/terraform/version:latest
4449
values:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 0.1.0
4+
5+
- Initial release
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
authors:
2+
- Victor Martinez <[email protected]>
3+
4+
url: "https://github.com/elastic/oblt-updatecli-policies/"
5+
changelog: "https://github.com/elastic/oblt-updatecli-policies/tree/main/updatecli/policies/opentofu/version/CHANGELOG.md"
6+
documentation: "https://github.com/elastic/oblt-updatecli-policies/tree/main/updatecli/policies/opentofu/version/README.md"
7+
source: "https://github.com/elastic/oblt-updatecli-policies/tree/main/updatecli/policies/opentofu/version/"
8+
version: 0.1.0
9+
vendor: Elastic
10+
11+
licenses:
12+
- "Apache-2.0 license"
13+
14+
description: |
15+
opentofu Version update policy
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# README
2+
3+
This policy will update the version of the [opentofu](https://github.com/opentofu/opentofu/releases/)
4+
defined in a file. Also supports .tool-versions file (asdf-vm).
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
scm:
2+
enabled: true
3+
user: obltmachine
4+
owner: elastic
5+
repository: oblt-updatecli-policies
6+
username: obltmachine
7+
branch: main
8+
commitusingapi: true
9+
10+
path: tests/opentofu/version/.opentofu-version
11+
12+
pull_request:
13+
labels:
14+
- dependencies
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
# Copyright Elasticsearch B.V. and contributors
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# Helpers
6+
# {{ $GitHubUser := env ""}}
7+
# {{ $GitHubRepositoryList := env "GITHUB_REPOSITORY" | split "/"}}
8+
# {{ $GitHubPAT := env "GITHUB_TOKEN"}}
9+
# {{ $GitHubUsername := env "GITHUB_ACTOR"}}
10+
11+
name: '{{ .name }}'
12+
pipelineid: '{{ .pipelineid }}'
13+
14+
sources:
15+
version:
16+
name: Get latest opentofu version from opentofu/opentofu
17+
kind: githubrelease
18+
spec:
19+
owner: opentofu
20+
repository: opentofu
21+
token: "{{ default $GitHubPAT .scm.token }}"
22+
username: "{{ default $GitHubUsername .scm.username }}"
23+
versionFilter:
24+
kind: latest
25+
transformers:
26+
- trimprefix: "v"
27+
28+
targets:
29+
version-file:
30+
name: 'deps(opentofu): Bump opentofu version to {{ source "version" }}'
31+
kind: file
32+
# {{ if or (.scm.enabled) (env "GITHUB_REPOSITORY") }}
33+
scmid: default
34+
# {{ end }}
35+
sourceid: version
36+
spec:
37+
file: '{{ .path }}'
38+
# {{ if hasSuffix ".tool-versions" .path }}
39+
matchpattern: '^opentofu\s+v\d+\.\d+\.\d+'
40+
content: 'opentofu {{ source `version` }}'
41+
# {{ else }}
42+
# |+ adds newline to the end of the file
43+
content: |+
44+
{{ source `version` }}
45+
# {{ end }}
46+
47+
# {{ if or (.scm.enabled) (env "GITHUB_REPOSITORY") }}
48+
scms:
49+
default:
50+
kind: "github"
51+
spec:
52+
# Priority set to the environment variable
53+
user: '{{ default $GitHubUser .scm.user}}'
54+
owner: '{{ default $GitHubRepositoryList._0 .scm.owner }}'
55+
repository: '{{ default $GitHubRepositoryList._1 .scm.repository}}'
56+
token: '{{ default $GitHubPAT .scm.token }}'
57+
username: '{{ default $GitHubUsername .scm.username }}'
58+
branch: '{{ .scm.branch }}'
59+
#{{ if .scm.commitusingapi }}
60+
commitusingapi: {{ .scm.commitusingapi }}
61+
# {{ end }}
62+
63+
actions:
64+
default:
65+
title: 'deps: Bump opentofu version to {{ source "version" }}'
66+
kind: "github/pullrequest"
67+
spec:
68+
automerge: {{ .automerge }}
69+
labels:
70+
# {{ range .pull_request.labels }}
71+
- {{ . }}
72+
# {{ end }}
73+
scmid: "default"
74+
{{ end }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'deps: Bump opentofu version'
2+
pipelineid: opentofu/version
3+
automerge: false
4+
5+
path: .opentofu-version
6+
7+
scm:
8+
enabled: false
9+
# user: v1v-bot
10+
# owner: v1v
11+
# repository: updatecli-demo
12+
# token: "xxx"
13+
# username: "v1v-bot"
14+
# branch: main
15+
# commitusingapi: false
16+
17+
pull_request:
18+
labels:
19+
- dependencies

0 commit comments

Comments
 (0)