Skip to content

fix: Prevent unnecessary CaC writes for Project updates#238

Open
HuyPhanNguyen wants to merge 1 commit into
mainfrom
kube89fix/project-cac
Open

fix: Prevent unnecessary CaC writes for Project updates#238
HuyPhanNguyen wants to merge 1 commit into
mainfrom
kube89fix/project-cac

Conversation

@HuyPhanNguyen

Copy link
Copy Markdown
Contributor

Original PR by @kube89 recreated here to handle GH Actions auth issues with the forked repository. Commits & contribution preserved.

Fixes #232

Summary

Fixes several Config as Code update issues affecting octopusdeploy_project. The provider previously attempted DeploymentSettings writes for every Config as Code project update, even when only database-backed project fields changed. This caused updates to fail when the default branch was protected and could also leave projects partially updated if the default branch was changed to one without valid OCL. The provider now distinguishes between Project updates and DeploymentSettings updates, and validates default branch changes before modifying the project.

Changes

  • Only updates DeploymentSettings when DeploymentSettings-owned fields have actually changed.
  • Reads the previous Terraform state to determine whether a DeploymentSettings update is required.
  • Validates target Config as Code branches before updating the project's default branch, preventing partial project updates when the target branch does not contain valid OCL.
  • Preserves API-returned Git persistence settings when the Git password is omitted from API responses.
  • Added comprehensive acceptance tests covering: protected default branches, database-backed project updates, DeploymentSettings updates, feature branch -> protected branch transitions, invalid branch transitions, atomic update behaviour.
  • Added unit tests covering DeploymentSettings change detection, Git default branch validation, and Git password preservation.

Result

Database-backed project updates no longer perform unnecessary Config as Code writes, allowing them to succeed against protected branches. Default branch changes are now validated before the project is updated, preventing partially persisted project state when the target branch does not contain valid Config as Code configuration, while preserving existing behaviour for intentional DeploymentSettings updates.

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.

octopusdeploy_project performs unnecessary Config as Code writes for database-only updates and protected default-branch changes

2 participants