command/013upgrade: detect builtin terraform provider (#25215)

* command/013upgrade: detect builtin terraform provider
This commit is contained in:
Kristin Laemmert 2020-06-11 14:10:47 -04:00 committed by GitHub
parent 9303b9f8fc
commit 5450e8515d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 8 deletions

View File

@ -240,6 +240,11 @@ command and dealing with them before running this command again.
for _, file := range files {
// Step 2: add missing provider requirements from provider blocks
for _, p := range file.ProviderConfigs {
// Skip internal providers
if p.Name == "terraform" {
continue
}
// If no explicit provider configuration exists for the
// provider configuration's local name, add one with a legacy
// provider address.
@ -266,6 +271,11 @@ command and dealing with them before running this command again.
localName = r.Addr().ImpliedProvider()
}
// Skip internal providers
if localName == "terraform" {
continue
}
// If no explicit provider configuration exists for this local
// name, add one with a legacy provider address.
if _, exist := requiredProviders[localName]; !exist {

View File

@ -1,4 +1,4 @@
provider foo {
provider "foo" {
version = "1.2.3"
}
@ -17,3 +17,5 @@ terraform {
}
}
}
provider "terraform" {}

View File

@ -1,4 +1,4 @@
provider foo {
provider "foo" {
version = "1.2.3"
}
@ -10,3 +10,5 @@ terraform {
}
}
}
provider "terraform" { }

View File

@ -1,5 +1,6 @@
resource foo_resource b {}
resource bar_resource c {}
resource bar_resource ab {
resource "foo_resource" "b" {}
resource "bar_resource" "c" {}
resource "bar_resource" "ab" {
provider = baz
}
resource "terraform_remote_state" "production" {}

View File

@ -1,5 +1,6 @@
resource foo_resource b {}
resource bar_resource c {}
resource bar_resource ab {
resource "foo_resource" "b" {}
resource "bar_resource" "c" {}
resource "bar_resource" "ab" {
provider = baz
}
resource "terraform_remote_state" "production" {}