Documentation
¶
Index ¶
- Constants
- Variables
- func BuildUpdateInput(serviceID string, version int, m NestedModel) (*fastly.UpdateImageOptimizerDefaultSettingsInput, error)
- func CommonAttributes() map[string]schema.Attribute
- func Equal(a, b []NestedModel) bool
- func NestedBlockSchema() schema.ListNestedBlock
- func Reconcile(ctx context.Context, client *fastly.Client, serviceID string, version int, ...) error
- type NestedModel
Constants ¶
const ( DefaultAllowVideo = false DefaultJpegQuality = 85 DefaultJpegType = "auto" DefaultResizeFilter = "lanczos3" DefaultUpscale = false DefaultWebp = false DefaultWebpQuality = 85 )
Variables ¶
var ( JpegTypes = []string{"auto", "baseline", "progressive"} ResizeFilters = []string{"lanczos3", "lanczos2", "bicubic", "bilinear", "nearest"} )
Functions ¶
func BuildUpdateInput ¶
func BuildUpdateInput(serviceID string, version int, m NestedModel) (*fastly.UpdateImageOptimizerDefaultSettingsInput, error)
BuildUpdateInput builds the API input to fully replace Image Optimizer default settings for a service version. All fields are always populated so that boolean fields (which cannot be represented as "unset" in Go) are never accidentally dropped from an update.
func CommonAttributes ¶
func Equal ¶
func Equal(a, b []NestedModel) bool
func NestedBlockSchema ¶
func NestedBlockSchema() schema.ListNestedBlock
NestedBlockSchema returns the image_optimizer_default_settings block for use inside _auto aggregate resources. At most one block is supported per service, since Image Optimizer default settings are a singleton per service version.
func Reconcile ¶
func Reconcile(ctx context.Context, client *fastly.Client, serviceID string, version int, previous, desired []NestedModel) error
Reconcile ensures the Image Optimizer default settings for a service version match desired.
Image Optimizer default settings always exist server-side once Image Optimizer has been enabled, so create and update are the same operation: a full replace of all fields. Removing the block from configuration resets the settings back to their API defaults, but only when previous shows the block was actually configured before - otherwise there is nothing to reset, since the block was never under this resource's management.
Types ¶
type NestedModel ¶
type NestedModel struct {
AllowVideo types.Bool `tfsdk:"allow_video"`
JpegQuality types.Int64 `tfsdk:"jpeg_quality"`
JpegType types.String `tfsdk:"jpeg_type"`
ResizeFilter types.String `tfsdk:"resize_filter"`
Upscale types.Bool `tfsdk:"upscale"`
Webp types.Bool `tfsdk:"webp"`
WebpQuality types.Int64 `tfsdk:"webp_quality"`
}
func FlattenToNestedModel ¶
func FlattenToNestedModel(s *fastly.ImageOptimizerDefaultSettings) NestedModel
func ReadForVersion ¶
func ReadForVersion(ctx context.Context, client *fastly.Client, serviceID string, version int, current []NestedModel, forceRefresh bool) ([]NestedModel, error)
ReadForVersion reads Image Optimizer default settings for a service version.
Because a service always has *some* default settings once Image Optimizer has ever been enabled (regardless of whether this block is configured in Terraform), the remote API is only queried when current is non-empty. This avoids surfacing settings as configuration drift for users who never declared this block. forceRefresh bypasses that check - callers must set it on the first Read following an import, since the incoming state has no prior current value to gate on even when the block is actually configured remotely.
func (NestedModel) ModelsEqual ¶
func (n NestedModel) ModelsEqual(other NestedModel) bool