From 31057182aa37fcd008c90414f684e637e5e06133 Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sun, 7 Jun 2026 16:47:03 +1000 Subject: [PATCH] fix: include all optional fields in schema for all resource types --- internal/provider/resource_remote.go | 46 +++++++++------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/internal/provider/resource_remote.go b/internal/provider/resource_remote.go index 0caf216..edfbcc7 100644 --- a/internal/provider/resource_remote.go +++ b/internal/provider/resource_remote.go @@ -131,25 +131,19 @@ func (r *remoteResource) Schema(_ context.Context, _ resource.SchemaRequest, res Description: "Serve stale cached content when upstream is unreachable.", Optional: true, Computed: true, Default: booldefault.StaticBool(true), }, - } - - if r.packageType == "docker" { - attrs["ban_tags_enabled"] = schema.BoolAttribute{ - Description: "Enable tag banning.", + "ban_tags_enabled": schema.BoolAttribute{ + Description: "Enable tag banning (docker only).", Optional: true, Computed: true, Default: booldefault.StaticBool(false), - } - attrs["ban_tags"] = schema.ListAttribute{ - Description: "Tags to ban (e.g. latest, edge).", + }, + "ban_tags": schema.ListAttribute{ + Description: "Tags to ban (docker only).", Optional: true, ElementType: types.StringType, - } - } - - if r.packageType == "terraform" { - attrs["releases_remote"] = schema.StringAttribute{ - Description: "Name of the CDN remote for download URL rewriting.", + }, + "releases_remote": schema.StringAttribute{ + Description: "Name of the CDN remote for download URL rewriting (terraform only).", Optional: true, Computed: true, Default: stringdefault.StaticString(""), - } + }, } resp.Schema = schema.Schema{ @@ -268,14 +262,9 @@ func (r *remoteResource) modelToAPI(ctx context.Context, m remoteResourceModel) api.Blocklist = listToStrings(ctx, m.Blocklist) api.MutablePatterns = listToStrings(ctx, m.MutablePatterns) api.ImmutablePatterns = listToStrings(ctx, m.ImmutablePatterns) - - if r.packageType == "docker" { - api.BanTagsEnabled = m.BanTagsEnabled.ValueBool() - api.BanTags = listToStrings(ctx, m.BanTags) - } - if r.packageType == "terraform" { - api.ReleasesRemote = m.ReleasesRemote.ValueString() - } + api.BanTagsEnabled = m.BanTagsEnabled.ValueBool() + api.BanTags = listToStrings(ctx, m.BanTags) + api.ReleasesRemote = m.ReleasesRemote.ValueString() return api } @@ -296,14 +285,9 @@ func (r *remoteResource) apiToModel(ctx context.Context, api remoteAPI) remoteRe QuarantineEnabled: types.BoolValue(api.QuarantineEnabled), QuarantineDays: types.Int64Value(api.QuarantineDays), StaleOnError: types.BoolValue(api.StaleOnError), - } - - if r.packageType == "docker" { - m.BanTagsEnabled = types.BoolValue(api.BanTagsEnabled) - m.BanTags = stringsToList(ctx, api.BanTags) - } - if r.packageType == "terraform" { - m.ReleasesRemote = types.StringValue(api.ReleasesRemote) + BanTagsEnabled: types.BoolValue(api.BanTagsEnabled), + BanTags: stringsToList(ctx, api.BanTags), + ReleasesRemote: types.StringValue(api.ReleasesRemote), } return m }