Skip to content
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

Catch case where state from older version could be unexpected #396

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion fastly/base_fastly_service_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,14 @@ func resourceServiceRead(ctx context.Context, d *schema.ResourceData, meta inter
// the latest version supplied via the get service version details call.
// This is to ensure we still read all of the state below. Then set the
// cloned_version to this version.
if isImport {
// In addition to this, we need to do the same thing if cloned_version is
// not yet set to anything. This could happen if the current state was from
// v0.28.0 of the provider or lower, i.e. the user has upgraded from an
// earlier version. This prevents us from getting into the state where the
// attribute has never been set and gets passed into CloneVersion in the
// Update function and fails.
clonedVersionNotSet := d.Get("cloned_version") == 0
if isImport || clonedVersionNotSet {
if s.ActiveVersion.Number == 0 {
s.ActiveVersion.Number = s.Version.Number
}
Expand Down