-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tmc): add --cloud-sync-terraform-plan-file option. (#1171)
This new flag must be used with `--cloud-sync-drift-status` to enable the sending of the rendered plan output to the Terramate Cloud.
- Loading branch information
Showing
17 changed files
with
357 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2023 Terramate GmbH | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/terramate-io/terramate/errors" | ||
) | ||
|
||
func main() { | ||
if len(os.Args) < 2 { | ||
log.Fatalf("%s requires at least one subcommand argument", os.Args[0]) | ||
} | ||
|
||
ownPath, err := os.Executable() | ||
if err != nil { | ||
panic(errors.E(err, "cannot detect own path")) | ||
} | ||
|
||
name := filepath.Base(ownPath) | ||
if name == "terraform" || name == "terraform.exe" { | ||
terraform() | ||
} else { | ||
helper() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2023 Terramate GmbH | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/terramate-io/terramate/errors" | ||
) | ||
|
||
const envNameShowASCII = "TM_TEST_TERRAFORM_SHOW_ASCII_OUTPUT" | ||
|
||
func terraform() { | ||
switch os.Args[1] { | ||
case "show": | ||
fs := flag.NewFlagSet("terraform show", flag.ExitOnError) | ||
_ = fs.Bool("no-color", false, "-no-color (ignored)") | ||
err := fs.Parse(os.Args[2:]) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "error: %v\n", err) | ||
os.Exit(1) | ||
} | ||
if fs.NArg() != 1 { | ||
fmt.Fprintf(os.Stderr, "given args: %v\n", fs.Args()) | ||
fmt.Fprintf(os.Stderr, "usage: %s show <file>\n", os.Args[0]) | ||
os.Exit(1) | ||
} | ||
file := fs.Arg(0) | ||
st, err := os.Lstat(file) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "file not found: %s\n", file) | ||
os.Exit(1) | ||
} | ||
if !st.Mode().IsRegular() { | ||
fmt.Fprintf(os.Stderr, "not a regular file: %s\n", file) | ||
os.Exit(1) | ||
} | ||
|
||
// file exists but ignore it | ||
|
||
output := os.Getenv(envNameShowASCII) | ||
if output == "" { | ||
panic(errors.E("please set %s", envNameShowASCII)) | ||
} | ||
fmt.Print(output) | ||
default: | ||
panic(errors.E("unsupported command: %s", os.Args[1])) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.