forked from chainguard-images/images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
68 lines (55 loc) · 1.86 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
locals {
components = toset(["admission", "background", "cleanup", "cli", "init", "reports"])
// Normally the package is named like "kyverno-{component}-controller"
// But some packages are named differently:
// - admission -> kyverno
// - cli -> kyverno-cli
// - init -> kyverno-init-container
packages = merge({
for k, v in local.components : k => "kyverno-${k}-controller"
}, {
"admission" : "kyverno",
"cli" : "kyverno-cli",
"init" : "kyverno-init-container",
})
// Normally the repository is named like "kyverno-{component}-controller"
// But some repositories are named differently:
// - admission -> kyverno
// - cli -> kyverno-cli
// - init -> kyvernopre
repositories = merge({
for k, v in local.components : k => "${var.target_repository}-${k}-controller"
}, {
"admission" : var.target_repository,
"cli" : "${var.target_repository}-cli",
"init" : "${var.target_repository}pre",
})
}
variable "target_repository" {
description = "The docker repo into which the image and attestations should be published."
}
module "latest" {
for_each = local.components
source = "../../tflib/publisher"
name = basename(path.module)
target_repository = local.repositories[each.key]
config = file("${path.module}/configs/latest.${each.key}.apko.yaml")
}
module "version-tags" {
for_each = local.components
source = "../../tflib/version-tags"
package = local.packages[each.key]
config = module.latest[each.key].config
}
module "test-latest" {
source = "./tests"
digests = { for k, v in module.latest : k => v.image_ref }
}
module "tagger" {
for_each = local.components
source = "../../tflib/tagger"
depends_on = [module.test-latest]
tags = merge(
{ for t in toset(concat(["latest"], module.version-tags[each.key].tag_list)) : t => module.latest[each.key].image_ref },
)
}