Merge pull request #28230 from hashicorp/alisdair/only-rewrite-provider-locks-file-if-changed
cli: Only rewrite provider locks file if changed
This commit is contained in:
commit
4fb505631c
|
@ -798,15 +798,10 @@ Terraform has made some changes to the provider dependency selections recorded
|
||||||
in the .terraform.lock.hcl file. Review those changes and commit them to your
|
in the .terraform.lock.hcl file. Review those changes and commit them to your
|
||||||
version control system if they represent changes you intended to make.`))
|
version control system if they represent changes you intended to make.`))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Check whether newLocks is different from previousLocks and mention
|
|
||||||
// in the UI if so. We should emit a different message if previousLocks was
|
|
||||||
// empty, because that indicates we were creating a lock file for the first
|
|
||||||
// time and so we need to introduce the user to the idea of it.
|
|
||||||
|
|
||||||
moreDiags = c.replaceLockedDependencies(newLocks)
|
moreDiags = c.replaceLockedDependencies(newLocks)
|
||||||
diags = diags.Append(moreDiags)
|
diags = diags.Append(moreDiags)
|
||||||
|
}
|
||||||
|
|
||||||
return true, false, diags
|
return true, false, diags
|
||||||
}
|
}
|
||||||
|
|
|
@ -1618,6 +1618,13 @@ provider "registry.terraform.io/hashicorp/test" {
|
||||||
if diff := cmp.Diff(wantLockFile, string(buf)); diff != "" {
|
if diff := cmp.Diff(wantLockFile, string(buf)); diff != "" {
|
||||||
t.Errorf("wrong dependency lock file contents\n%s", diff)
|
t.Errorf("wrong dependency lock file contents\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make the local directory read-only, and verify that rerunning init
|
||||||
|
// succeeds, to ensure that we don't try to rewrite an unchanged lock file
|
||||||
|
os.Chmod(".", 0555)
|
||||||
|
if code := c.Run(args); code != 0 {
|
||||||
|
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInit_providerLockFileReadonly(t *testing.T) {
|
func TestInit_providerLockFileReadonly(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue