-
Notifications
You must be signed in to change notification settings - Fork 22
docs: clarify cron attribute format for coder_script resource #409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
All contributors have signed the CLA ✍️ ✅ |
- Update cron description to specify 6-field format (seconds minutes hours day month day-of-week) - Fix misleading example that used 5-field Unix format - Add additional cron examples with proper 6-field format - Include inline comments explaining the schedule Fixes #353
- Detect when users provide Unix 5-field cron format - Provide helpful warning with suggested 6-field conversion - Maintain backwards compatibility - expressions still work - Add comprehensive tests for validation function This helps users avoid confusion where '*/5 * * * *' (intended for every 5 minutes) actually runs every 5 seconds due to the missing seconds field.
- Added the missing every_5_minutes cron script example to examples/resources/coder_script/resource.tf - This example demonstrates the 6-field cron format with a health check that runs every 5 minutes - Ensures examples directory matches the documentation examples
- Updated the cron field description in provider/script.go to include detailed 6-field format explanation - Fixed formatting issues in documentation (removed extra spaces before comments) - Regenerated documentation to ensure consistency between schema and docs - This ensures the documentation generation preserves the detailed cron description instead of reverting to generic text
e998cb2
to
e810230
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR clarifies the cron attribute format used by the coder_script resource, addressing issue #353 by updating documentation and examples to reflect the usage of a 6-field cron format.
- Updated cron description in resource schema and docs
- Fixed misleading example by converting a 5-field expression to a correct 6-field expression
- Added tests to validate cron expressions and introduced a new example for an every 5 minutes schedule
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
provider/script_test.go | Added tests for various cron expression scenarios |
provider/script.go | Introduced ValidateCronExpression and updated the resource's validation logic |
examples/resources/coder_script/resource.tf | Updated resource examples to use the correct 6-field cron format |
docs/resources/script.md | Updated documentation for the cron attribute to clarify the 6-field format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description looks good to me! I tested out the 6-field format too and it works per what example describes.
I'm not sure about the new function though. I don't know how to test this myself, but it looks like the runner was able to verify it: https://github.com/coder/terraform-provider-coder/actions/runs/15445849660
Would be good to get someone to test out the resource change, but overall this looks great to me!
This PR addresses issue #353 by clarifying the cron format documentation for the
coder_script
resource.Changes Made
seconds minutes hours day-of-month month day-of-week
) instead of the standard Unix 5-field format"0 22 * * *"
to"0 0 22 * * *"
to show proper 6-field formatProblem Solved
The original issue was that users expected the standard Unix cron format (
minutes hours day month day-of-week
) but the provider actually uses a 6-field format that includes seconds as the first field. This caused confusion where a user's"*/5 * * * *"
(intended for every 5 minutes) was actually running every 5 seconds.Testing
The documentation changes have been tested by verifying the cron parser configuration in
provider/script.go
which shows:This confirms the 6-field format is correct.
Fixes #353