Add reminder configuration to opslevel_campaign resource#652
Open
jamescarr wants to merge 2 commits into
Open
Conversation
Add a `reminder` single-nested attribute to the opslevel_campaign resource for configuring recurring Slack, email, and Microsoft Teams reminders on a schedule. Includes schema validation (channel/frequency_unit/day enums, frequency >= 1, HH:MM time format, weekly cadence requires days_of_week), create/read/update wiring with clear-on-removal, and #-prefix normalization for the Slack channel to avoid perpetual diffs. Also exposes the reminder as a computed attribute on the opslevel_campaign and opslevel_campaigns data sources. Depends on OpsLevel/opslevel-go#623. The go.mod replace directive and submodule pointer are temporary for development and will be swapped for a released opslevel-go version before merge. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
Usage examplesWeekly Slack + email reminder resource "opslevel_campaign" "upgrade_rails" {
name = "Upgrade to Rails 7"
owner_id = data.opslevel_team.platform.id
filter_id = data.opslevel_filter.tier_1.id
start_date = "2026-07-01"
target_date = "2026-09-30"
reminder = {
channels = ["slack", "email"]
frequency = 1
frequency_unit = "week"
days_of_week = ["monday", "thursday"] # required for a weekly cadence
time_of_day = "09:30"
timezone = "America/Chicago"
message = "Friendly reminder to complete your Rails 7 upgrade checks."
# Fallback channel used when a team has no default Slack contact.
default_slack_channel = "#platform-eng"
}
}Every-2-days reminder (no reminder = {
channels = ["slack"]
frequency = 2
frequency_unit = "day" # daily/monthly cadences must omit days_of_week
time_of_day = "14:00"
timezone = "America/Chicago"
}Microsoft Teams reminder reminder = {
channels = ["microsoft_teams"]
frequency = 1
frequency_unit = "month"
time_of_day = "08:00"
timezone = "Europe/London"
default_microsoft_teams_channel = "Platform Eng"
}No reminder / clearing one Omit the Reading it backdata "opslevel_campaign" "upgrade_rails" {
identifier = opslevel_campaign.upgrade_rails.id
}
output "next_reminder" {
value = data.opslevel_campaign.upgrade_rails.reminder.next_occurrence
}
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #652 +/- ##
========================================
+ Coverage 0.22% 2.09% +1.86%
========================================
Files 85 103 +18
Lines 9651 12469 +2818
========================================
+ Hits 22 261 +239
- Misses 9626 12186 +2560
- Partials 3 22 +19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Cover the reminder conversion, normalization, and data-source mapping helpers with internal-package unit tests, and extract the reminder validation into a testable validateReminderConfig helper. Addresses 0% patch coverage on the reminder code paths. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
remindersingle-nested attribute to theopslevel_campaignresource for configuring recurring Slack, email, and Microsoft Teams reminders on a schedule.frequency >= 1,HH:MMtime format, andchannelsnon-empty.ValidateConfigenforces thatdays_of_weekis required for a weekly cadence and rejected otherwise.nullto clear on update when the block is removed, and normalize the#prefix ondefault_slack_channelto avoid perpetual diffs.reminderas a computed attribute on theopslevel_campaignandopslevel_campaignsdata sources.Dependency
Depends on OpsLevel/opslevel-go#623. The
go.modreplacedirective and thesubmodules/opslevel-gopointer are temporary for development (matching the prior campaign PR workflow) and will be removed in favor of a releasedopslevel-goversion bump before merge.Test plan
go build ./...,go vet ./opslevel/gofumptclean,golangci-lint run ./opslevel/(0 issues)task test— terraform mock tests + Go unit tests (107 passed, 0 failed), including new reminder assertions on theopslevel_campaignresourcetests/remote/campaign.tftest.hcl) — added create-with-reminder, update-to-daily, and clear-reminder runs; require a liveOPSLEVEL_API_TOKENand validowner_idMade with Cursor