-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for state migrations in infer
#215
Conversation
f68a213
to
ed5bb88
Compare
infer
infer
This is required for pulumi/pulumi-pulumiservice#84, since pulumi-pulumiservice already maintains it's own state migrations. |
ed5bb88
to
e203a6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, let's see how it goes!
// That didn't work, so maybe we can get by decoding without state migration but by tolerating | ||
// missing fields. | ||
stateEncoder, err = ende.DecodeTolerateMissing(req.Properties, &state) | ||
if err != nil { | ||
return p.ReadResponse{}, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good fix 👍 I think I ran into this a few times
}, nil | ||
} | ||
|
||
func migrateFromV0(ctx p.Context, v0 MigrateStateV0) (infer.MigrationResult[MigrateStateV2], error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are really helpful to see how this is used in practice.
Adds support for state migrations in the
infer
provider. Resources opt into state migrations when they implement theinfer.CustomStateMigrations[O]
interface:This allows each resource to define a list of (possibly typed) migrations from old to new state. This design makes the common case of migrating from StateV1 to StateV2 fully typed, but permits an untyped to typed escape hatch.
Fixes #193