resource_remote: add mirror_strategy attribute
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful

The provider exposed mirrorlist but not mirror_strategy, so the API's
mirror load-balancing strategy (round_robin/least_conn) was unreachable
via Terraform. Add mirror_strategy the same way mirrorlist was added,
scoped to rpm/deb/alpine remotes.

- schema: optional string mirror_strategy on the remote resource
- ValidateConfig: reject on non-rpm/deb/alpine types and validate the
  round_robin/least_conn enum at plan time
- wire model + modelToAPI/apiToModel (empty->null to avoid perpetual diff)
- datasource (computed) + README + rpm example
- unit tests: modelToAPI/apiToModel round-trip and ValidateConfig matrix
This commit is contained in:
2026-08-13 17:50:52 +10:00
parent bc13e7372d
commit c69c3d9f74
7 changed files with 182 additions and 9 deletions
+3
View File
@@ -31,6 +31,7 @@ func (d *remoteDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
"package_type": schema.StringAttribute{Computed: true},
"base_url": schema.StringAttribute{Computed: true},
"mirrorlist": schema.ListAttribute{Computed: true, ElementType: types.StringType},
"mirror_strategy": schema.StringAttribute{Computed: true},
"description": schema.StringAttribute{Computed: true},
"immutable_ttl": schema.Int64Attribute{Computed: true},
"mutable_ttl": schema.Int64Attribute{Computed: true},
@@ -59,6 +60,7 @@ type remoteDataSourceModel struct {
PackageType types.String `tfsdk:"package_type"`
BaseURL types.String `tfsdk:"base_url"`
Mirrorlist types.List `tfsdk:"mirrorlist"`
MirrorStrategy types.String `tfsdk:"mirror_strategy"`
Description types.String `tfsdk:"description"`
ImmutableTTL types.Int64 `tfsdk:"immutable_ttl"`
MutableTTL types.Int64 `tfsdk:"mutable_ttl"`
@@ -110,6 +112,7 @@ func (d *remoteDataSource) Read(ctx context.Context, req datasource.ReadRequest,
PackageType: types.StringValue(remote.PackageType),
BaseURL: types.StringValue(remote.BaseURL),
Mirrorlist: stringsToList(ctx, remote.Mirrorlist),
MirrorStrategy: stringOrNull(remote.MirrorStrategy),
Description: types.StringValue(remote.Description),
ImmutableTTL: types.Int64Value(remote.ImmutableTTL),
MutableTTL: types.Int64Value(remote.MutableTTL),