resource_remote: add mirror_strategy attribute (fixes missing API field) #19
Reference in New Issue
Block a user
Delete Branch "benvin/mirror-strategy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
The provider exposed
mirrorlistbut notmirror_strategy, so the API's mirror load-balancing strategy could not be set from Terraform —least_connwas unreachable and remotes were stuck on theround_robindefault.How
mirror_strategystring on the remote resource (valuesround_robin/least_conn; only valid on rpm/deb/apk remotes).mirror_strategyon other remote types at plan time, and validates the enum value (API 400 is the backstop).mirror_strategyonly when set; empty→null on read to avoid a perpetual diff.mirror_strategy,omitemptywire field.Scoped to rpm/deb/alpine exactly like
mirrorlist; no unrelated attributes touched.go build/go test/go vet/gofmtandpre-commit run --all-filesall green.Addressed the plan-churn review finding in
24c11d2.The API stores
mirror_strategyNOT NULL DEFAULT 'round_robin' and always returns it on GET, so the original Optional-only attribute (empty→null on read) wroteround_robinto state while config was null — a perpetualround_robin -> nulldiff for every remote that didn't set it.Fix (mirrors how
descriptionhandles an API-defaulted scalar):mirror_strategyis now Optional+Computed with around_robindefault, so state can hold the API's value with no diff.apiToModelpasses the API value straight through and settles an empty create-response to theround_robindefault (no more empty→null).stringOrNullhelper.go build/test/vet/gofmtandpre-commit run --all-filesall green.