Skip to content

Commit

Permalink
automated commit
Browse files Browse the repository at this point in the history
Signed-off-by: Public copy <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Jul 22, 2024
1 parent 47723f9 commit 14be680
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 60 deletions.
10 changes: 2 additions & 8 deletions images/loki/config/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
locals {
baseline_packages = ["loki"]
}

module "accts" {
gid = 10001
name = "loki"
Expand All @@ -17,16 +13,14 @@ terraform {
}

variable "extra_packages" {
default = ["loki"]
default = []
description = "The additional packages to install (e.g. loki)."
}

output "config" {
value = jsonencode({
"contents" : {
// TODO: remove the need for using hardcoded local.baseline_packages by plumbing
// these packages through var.extra_packages in all callers of this config module
"packages" : distinct(concat(local.baseline_packages, var.extra_packages))
"packages" : var.extra_packages
},
"entrypoint" : {
"command" : "/usr/bin/loki"
Expand Down
8 changes: 4 additions & 4 deletions images/loki/generated.tf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 28 additions & 23 deletions images/loki/main.tf
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
}
}

variable "target_repository" {
description = "The docker repo into which the image and attestations should be published."
}

module "latest-config" { source = "./config" }
module "versions" {
package = "loki"
source = "../../tflib/versions"
}

module "latest" {
source = "../../tflib/publisher"
module "config" {
extra_packages = [each.key]
for_each = module.versions.versions
source = "./config"
}

module "versioned" {
build-dev = true
config = module.config[each.key].config
for_each = module.versions.versions
main_package = each.value.main
name = basename(path.module)
source = "../../tflib/publisher"
target_repository = var.target_repository
config = module.latest-config.config
build-dev = true
update-repo = each.value.is_latest
}

module "test-latest" {
source = "./tests"
digest = module.latest.image_ref
module "test-versioned" {
digest = module.versioned[each.key].image_ref
for_each = module.versions.versions
loki_version = each.value.version
source = "./tests"
}

resource "oci_tag" "latest" {
depends_on = [module.test-latest]
digest_ref = module.latest.image_ref
tag = "latest"
module "tagger" {
depends_on = [module.test-versioned]
source = "../../tflib/tagger"
tags = merge(
[for v in module.versioned : v.latest_tag_map]...
)
}

resource "oci_tag" "latest-dev" {
depends_on = [module.test-latest]
digest_ref = module.latest.dev_ref
tag = "latest-dev"
}
1 change: 1 addition & 0 deletions images/loki/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ upstream_url: https://grafana.com/oss/loki/
keywords:
- analytics
- application
public: true
42 changes: 17 additions & 25 deletions images/loki/tests/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
imagetest = { source = "chainguard-dev/imagetest" }
oci = { source = "chainguard-dev/oci" }
}
}

Expand All @@ -10,24 +10,21 @@ variable "digest" {
}

variable "loki_version" {
description = "The version of loki to test. Defaults to version 3"
default = ""
description = "The version of loki to test. Defaults to version 3"
}

data "imagetest_inventory" "this" {}
data "imagetest_inventory" "this" {
}

resource "imagetest_harness_k3s" "this" {
name = "loki"
inventory = data.imagetest_inventory.this
name = "loki"
}

locals {
parsed = provider::oci::parse(var.digest)

// Default to loki version 3 if not specified, otherwise take the first digit
// TODO(joshrwolf): This will fail if/when we get to double digit loki major versions, but that's 2050 josh's problem.
loki_major_version = var.loki_version == "" ? "3" : substr(var.loki_version, 0, 1)

parsed = provider::oci::parse(var.digest)
values = {
// Values for loki version 3.y
"3" : {
Expand Down Expand Up @@ -166,31 +163,26 @@ locals {
}

module "helm" {
source = "../../../tflib/imagetest/helm"

namespace = "loki-system"
chart = "loki"
repo = "https://grafana.github.io/helm-charts"

// Use latest for loki major version 3, otherwise pin to last known state for 2.y
chart = "loki"
chart_version = local.loki_major_version == "3" ? "" : "5.48.0"

values = local.values[local.loki_major_version]
namespace = "loki-system"
repo = "https://grafana.github.io/helm-charts"
source = "../../../tflib/imagetest/helm"
values = local.values[local.loki_major_version]
}

resource "imagetest_feature" "basic" {
harness = imagetest_harness_k3s.this
name = "Basic"
description = "Basic functionality of the loki helm chart."

harness = imagetest_harness_k3s.this
labels = {
type = "k8s"
}
name = "Basic"
steps = [
{
name = "Helm install"
cmd = module.helm.install_cmd
},
]

labels = {
type = "k8s"
}
}

0 comments on commit 14be680

Please sign in to comment.