Do not diff __internal property in DiffConfig (#414)
This PR updates the implementation of DiffConfig to remove the `__internal` property when comparing provider config between old state and new input. It is observed that the `__internal` property is present when a default provider is used. This causes a provider replacement every time a user upgrades pulumi-docker-build, as the `__internal` property is always stripped from state, so Pulumi will always report a diff. Ideally, we should determine if this bug can be fixed in either upstream pulumi-go-provider or pulumi itself. For now, we will fix this locally within pulumi-docker-build to unblock our users. Changes: - Update DiffConfig implementation to strip `__internal` property from new inputs. - Add a nodejs upgrade test to test that this solution works Fixes: #404
This commit is contained in:
@@ -66,7 +66,7 @@ func (c *Config) Configure(ctx context.Context) error {
|
||||
|
||||
// NewBuildxProvider returns a new buildx provider.
|
||||
func NewBuildxProvider() provider.Provider {
|
||||
return infer.Provider(
|
||||
prov := infer.Provider(
|
||||
infer.Options{
|
||||
Metadata: pschema.Metadata{
|
||||
DisplayName: "docker-build",
|
||||
@@ -122,6 +122,27 @@ func NewBuildxProvider() provider.Provider {
|
||||
Config: infer.Config[*Config](),
|
||||
},
|
||||
)
|
||||
|
||||
prov.DiffConfig = diffConfigIgnoreInternal(prov.DiffConfig)
|
||||
|
||||
return prov
|
||||
}
|
||||
|
||||
// TODO(pulumi/pulumi-docker-build#404): Remove this function once the bug is fixed in either
|
||||
// upstream pu/pu or pulumi-go-provider.
|
||||
|
||||
// diffConfigInternalIgnore is a custom DiffConfig implementation for the buildx provider. This is required to
|
||||
// circumvent the bug identified in https://github.com/pulumi/pulumi-docker-build/issues/404.
|
||||
// Since `__internal` is currently populated in new inputs, but stripped in old state, we need to
|
||||
// ignore this field in the diff. There is no easy way to override DiffConfig to compare inputs only.
|
||||
func diffConfigIgnoreInternal(
|
||||
diffConfig func(ctx context.Context, req provider.DiffRequest) (provider.DiffResponse, error),
|
||||
) func(ctx context.Context, req provider.DiffRequest) (provider.DiffResponse, error) {
|
||||
return func(ctx context.Context, req provider.DiffRequest) (provider.DiffResponse, error) {
|
||||
delete(req.News, "__internal")
|
||||
|
||||
return diffConfig(ctx, req)
|
||||
}
|
||||
}
|
||||
|
||||
// Schema returns our package specification.
|
||||
|
||||
Reference in New Issue
Block a user