mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #85 from opentffoundation/opentf-user-facing-internal-genconfig
Adapt user-facing usages of terraform in `internal/genconfig`
This commit is contained in:
commit
9bc0b077b8
@ -1,7 +1,7 @@
|
||||
# __generated__ by Terraform
|
||||
# __generated__ by OpenTF
|
||||
# Please review these resources and move them into your main configuration files.
|
||||
|
||||
# __generated__ by Terraform from "bar"
|
||||
# __generated__ by OpenTF from "bar"
|
||||
resource "terraform_data" "foo" {
|
||||
input = null
|
||||
triggers_replace = null
|
||||
|
@ -1,7 +1,7 @@
|
||||
# __generated__ by Terraform
|
||||
# __generated__ by OpenTF
|
||||
# Please review these resources and move them into your main configuration files.
|
||||
|
||||
# __generated__ by Terraform from "bar"
|
||||
# __generated__ by OpenTF from "bar"
|
||||
resource "terraform_data" "foo" {
|
||||
input = null
|
||||
triggers_replace = null
|
||||
|
@ -1,7 +1,7 @@
|
||||
# __generated__ by Terraform
|
||||
# __generated__ by OpenTF
|
||||
# Please review these resources and move them into your main configuration files.
|
||||
|
||||
# __generated__ by Terraform from "bar"
|
||||
# __generated__ by OpenTF from "bar"
|
||||
resource "test_instance" "foo" {
|
||||
ami = null
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ import (
|
||||
// GenerateResourceContents generates HCL configuration code for the provided
|
||||
// resource and state value.
|
||||
//
|
||||
// If you want to generate actual valid Terraform code you should follow this
|
||||
// call up with a call to WrapResourceContents, which will place a Terraform
|
||||
// If you want to generate actual valid OpenTF code you should follow this
|
||||
// call up with a call to WrapResourceContents, which will place an OpenTF
|
||||
// resource header around the attributes and blocks returned by this function.
|
||||
func GenerateResourceContents(addr addrs.AbsResourceInstance,
|
||||
schema *configschema.Block,
|
||||
|
@ -18,7 +18,7 @@ func ValidateTargetFile(out string) (diags tfdiags.Diagnostics) {
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
tfdiags.Error,
|
||||
"Target generated file already exists",
|
||||
"Terraform can only write generated config into a new file. Either choose a different target location or move all existing configuration out of the target file, delete it and try again."))
|
||||
"OpenTF can only write generated config into a new file. Either choose a different target location or move all existing configuration out of the target file, delete it and try again."))
|
||||
|
||||
}
|
||||
return diags
|
||||
@ -42,26 +42,26 @@ func (c *Change) MaybeWriteConfig(writer io.Writer, out string) (io.Writer, bool
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
tfdiags.Error,
|
||||
"Failed to create target generated file",
|
||||
fmt.Sprintf("Terraform did not have permission to create the generated file (%s) in the target directory. Please modify permissions over the target directory, and try again.", out)))
|
||||
fmt.Sprintf("OpenTF did not have permission to create the generated file (%s) in the target directory. Please modify permissions over the target directory, and try again.", out)))
|
||||
return nil, false, diags
|
||||
}
|
||||
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
tfdiags.Error,
|
||||
"Failed to create target generated file",
|
||||
fmt.Sprintf("Terraform could not create the generated file (%s) in the target directory: %v. Depending on the error message, this may be a bug in Terraform itself. If so, please report it!", out, err)))
|
||||
fmt.Sprintf("OpenTF could not create the generated file (%s) in the target directory: %v. Depending on the error message, this may be a bug in OpenTF itself. If so, please report it!", out, err)))
|
||||
return nil, false, diags
|
||||
} else {
|
||||
writer = w
|
||||
}
|
||||
|
||||
header := "# __generated__ by Terraform\n# Please review these resources and move them into your main configuration files.\n"
|
||||
header := "# __generated__ by OpenTF\n# Please review these resources and move them into your main configuration files.\n"
|
||||
// Missing the header from the file, isn't the end of the world
|
||||
// so if this did return an error, then we will just ignore it.
|
||||
_, _ = writer.Write([]byte(header))
|
||||
}
|
||||
|
||||
header := "\n# __generated__ by Terraform"
|
||||
header := "\n# __generated__ by OpenTF"
|
||||
if len(c.ImportID) > 0 {
|
||||
header += fmt.Sprintf(" from %q", c.ImportID)
|
||||
}
|
||||
@ -70,7 +70,7 @@ func (c *Change) MaybeWriteConfig(writer io.Writer, out string) (io.Writer, bool
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
tfdiags.Warning,
|
||||
"Failed to save generated config",
|
||||
fmt.Sprintf("Terraform encountered an error while writing generated config: %v. The config for %s must be created manually before applying. Depending on the error message, this may be a bug in Terraform itself. If so, please report it!", err, c.Addr)))
|
||||
fmt.Sprintf("OpenTF encountered an error while writing generated config: %v. The config for %s must be created manually before applying. Depending on the error message, this may be a bug in OpenTF itself. If so, please report it!", err, c.Addr)))
|
||||
}
|
||||
wroteConfig = true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user