Skip to content

chore: allow pushing only inactive coderd_template versions #167

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

Merged
merged 2 commits into from
Jan 21, 2025

Conversation

ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Jan 21, 2025

Per some customer feedback, this PR relaxes some of the constraints when creating template versions via the coderd_template resource. Previously, each update of the resource required that at least one of the versions in the versions list had the active attribute set to true.

This constraint is now only required when:

  1. Creating the resource, as every template must have an active version.
  2. It's not clear what template version should be set as active.
    • This occurs when the currently active version is marked as inactive, but no changes are made to the contents of the version (and no version would be created).

Examples of these cases can be seen in the tests.

With this, a workflow that involves:

  • Marking an active version in the list as inactive
  • Pushing it a few times via the provider
  • And then finally marking it as active

is now possible with just a single item in the list.

@ethanndickson ethanndickson changed the title chore: allow only pushing inactive coderd_template versions chore: allow pushing only inactive coderd_template versions Jan 21, 2025
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ethanndickson ethanndickson force-pushed the ethan/allow-push-inactive branch from f91d9db to afe3400 Compare January 21, 2025 07:03
@ethanndickson ethanndickson self-assigned this Jan 21, 2025
}
if versionDeactivated(prevs, &planVersions[i]) {
diag.AddError("Client Error", "Plan could not determine which version should be active.\n"+
"Either specify an active version or modify the contents of the previously active version before marking it as inactive.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of returning an error and failing the plan here, we could just push a new, identical, template version and not promote it to active. Given there's no other way to push an unmodified template version, and the whole point of this resource is to avoid pushing spurious diffs, I think it's better to just fail the plan.

@ethanndickson ethanndickson marked this pull request as ready for review January 21, 2025 07:27
Copy link
Member

@deansheather deansheather left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good and the tests seem thorough. It's kinda hard to wrap your head around the one active version thing, but after I thought about it a bit your solution makes the most sense to me.

@ethanndickson ethanndickson merged commit e036857 into main Jan 21, 2025
14 checks passed
@ethanndickson ethanndickson deleted the ethan/allow-push-inactive branch January 21, 2025 09:16
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