fix: include all optional fields in schema for all resource types

This commit is contained in:
2026-06-07 16:47:03 +10:00
parent 1405675e8f
commit 31057182aa
+15 -31
View File
@@ -131,25 +131,19 @@ func (r *remoteResource) Schema(_ context.Context, _ resource.SchemaRequest, res
Description: "Serve stale cached content when upstream is unreachable.", Description: "Serve stale cached content when upstream is unreachable.",
Optional: true, Computed: true, Default: booldefault.StaticBool(true), Optional: true, Computed: true, Default: booldefault.StaticBool(true),
}, },
} "ban_tags_enabled": schema.BoolAttribute{
Description: "Enable tag banning (docker only).",
if r.packageType == "docker" {
attrs["ban_tags_enabled"] = schema.BoolAttribute{
Description: "Enable tag banning.",
Optional: true, Computed: true, Default: booldefault.StaticBool(false), Optional: true, Computed: true, Default: booldefault.StaticBool(false),
} },
attrs["ban_tags"] = schema.ListAttribute{ "ban_tags": schema.ListAttribute{
Description: "Tags to ban (e.g. latest, edge).", Description: "Tags to ban (docker only).",
Optional: true, Optional: true,
ElementType: types.StringType, ElementType: types.StringType,
} },
} "releases_remote": schema.StringAttribute{
Description: "Name of the CDN remote for download URL rewriting (terraform only).",
if r.packageType == "terraform" {
attrs["releases_remote"] = schema.StringAttribute{
Description: "Name of the CDN remote for download URL rewriting.",
Optional: true, Computed: true, Default: stringdefault.StaticString(""), Optional: true, Computed: true, Default: stringdefault.StaticString(""),
} },
} }
resp.Schema = schema.Schema{ resp.Schema = schema.Schema{
@@ -268,14 +262,9 @@ func (r *remoteResource) modelToAPI(ctx context.Context, m remoteResourceModel)
api.Blocklist = listToStrings(ctx, m.Blocklist) api.Blocklist = listToStrings(ctx, m.Blocklist)
api.MutablePatterns = listToStrings(ctx, m.MutablePatterns) api.MutablePatterns = listToStrings(ctx, m.MutablePatterns)
api.ImmutablePatterns = listToStrings(ctx, m.ImmutablePatterns) api.ImmutablePatterns = listToStrings(ctx, m.ImmutablePatterns)
api.BanTagsEnabled = m.BanTagsEnabled.ValueBool()
if r.packageType == "docker" { api.BanTags = listToStrings(ctx, m.BanTags)
api.BanTagsEnabled = m.BanTagsEnabled.ValueBool() api.ReleasesRemote = m.ReleasesRemote.ValueString()
api.BanTags = listToStrings(ctx, m.BanTags)
}
if r.packageType == "terraform" {
api.ReleasesRemote = m.ReleasesRemote.ValueString()
}
return api return api
} }
@@ -296,14 +285,9 @@ func (r *remoteResource) apiToModel(ctx context.Context, api remoteAPI) remoteRe
QuarantineEnabled: types.BoolValue(api.QuarantineEnabled), QuarantineEnabled: types.BoolValue(api.QuarantineEnabled),
QuarantineDays: types.Int64Value(api.QuarantineDays), QuarantineDays: types.Int64Value(api.QuarantineDays),
StaleOnError: types.BoolValue(api.StaleOnError), StaleOnError: types.BoolValue(api.StaleOnError),
} BanTagsEnabled: types.BoolValue(api.BanTagsEnabled),
BanTags: stringsToList(ctx, api.BanTags),
if r.packageType == "docker" { ReleasesRemote: types.StringValue(api.ReleasesRemote),
m.BanTagsEnabled = types.BoolValue(api.BanTagsEnabled)
m.BanTags = stringsToList(ctx, api.BanTags)
}
if r.packageType == "terraform" {
m.ReleasesRemote = types.StringValue(api.ReleasesRemote)
} }
return m return m
} }