Skip to content

feat: Tests for product module channel input#202

Merged
MichaelThamm merged 2 commits intomainfrom
feat/tf-channel-validation
Mar 10, 2026
Merged

feat: Tests for product module channel input#202
MichaelThamm merged 2 commits intomainfrom
feat/tf-channel-validation

Conversation

@MichaelThamm
Copy link
Contributor

@MichaelThamm MichaelThamm commented Mar 10, 2026

Issue

If a user specifies the TF COS (or COS Lite) modules

  1. without a ref "git::.../observability-stack//terraform/cos-lite then they must use track dev
  2. with a ref "git::.../observability-stack//terraform/cos-lite?ref=track/2 then they must use track 2

I noticed some users make this mistake (and I) where you try out a different track, e.g. dev, but leave the module source as ?ref=track/2 and notice a failure to deploy.

Solution

Same PR as this one into track/2, but for main:

Usage

module "cos-lite" {
  source                          = "../../cos-lite"
  model_uuid                      = juju_model.cos-lite.uuid
  channel                         = "3/stable"
}
│ Error: Invalid value for variable
│ 
│   on root.tf line 19, in module "cos-lite":
│   19:   channel                         = "3/stable"
│     ├────────────────
│     │ var.channel is "3/stable"
│ 
│ The track of the channel must be 'dev/'. e.g. 'dev/edge'.
│ 
│ This was checked by the validation rule at ../../cos-lite/variables.tf:18,3-13.

Checklist

  • I have added or updated relevant documentation.
  • PR title makes an appropriate release note and follows conventional commits syntax.
  • Merge target is the correct branch, and relevant tandem backport PRs opened.

Context

This has a few side-effects:

  • When someone navigates to the repo, they will be on the main branch, which will show that the default channel is dev/edge. This is fine, because the README is not the official stack documentation, which defaults to our latest (non-dev track) e.g., track/2.

Testing Instructions

Running Terraform tests:

  • tf -chdir=terraform/cos test
  • tf -chdir=terraform/cos-lite test

will result in running unit tests for channel validation

tests/channel_validation.tftest.hcl... in progress
  run "valid_channel_stable"... pass
  run "valid_channel_candidate"... pass
  run "valid_channel_beta"... pass
  run "valid_channel_edge"... pass
  run "invalid_channel_track_2"... pass
tests/channel_validation.tftest.hcl... tearing down
tests/channel_validation.tftest.hcl... pass

Upgrade Notes

@MichaelThamm MichaelThamm marked this pull request as ready for review March 10, 2026 15:29
@MichaelThamm MichaelThamm merged commit 95680d5 into main Mar 10, 2026
12 of 16 checks passed
@MichaelThamm MichaelThamm deleted the feat/tf-channel-validation branch March 10, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants