in custom-targets/terraform/terraform-deployer/render.go [340:370]
func createReleaseInspectorArtifact(autoTFVarsPath string, planData []byte, dstPath string) error {
dstFile, err := os.Create(dstPath)
if err != nil {
return fmt.Errorf("error creating file %s: %v", dstPath, err)
}
defer dstFile.Close()
autoVarsFile, err := os.Open(autoTFVarsPath)
if err != nil {
return fmt.Errorf("unable to open generated variable file %s: %v", autoTFVarsPath, err)
}
defer autoVarsFile.Close()
if _, err := io.Copy(dstFile, autoVarsFile); err != nil {
return fmt.Errorf("unable to copy contents from %s to %s: %v", autoTFVarsPath, dstPath, err)
}
// No plan was generated.
if len(planData) == 0 {
return nil
}
tBytes, err := time.Now().MarshalText()
if err != nil {
return fmt.Errorf("unable to marshal currrent time: %v", err)
}
dstFile.Write([]byte(fmt.Sprintf("---\n# Speculative Terraform plan generated at %s for informational purposes.\n# This plan is not used when applying the Terraform configuration.\n", string(tBytes))))
dstFile.Write(planData)
return nil
}