Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
magodo committed Oct 15, 2021
1 parent 3cfe24d commit aa0f0a7
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 69 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

dist/
aztfylogs.log
15 changes: 0 additions & 15 deletions .vscode/launch.json

This file was deleted.

29 changes: 0 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,3 @@ For example, the `azurerm_lb_backend_address_pool_address` is actually a propert
Another popular case is that in the AzureRM provider, there are a bunch of "association" resources, e.g. the `azurerm_network_interface_security_group_association`. These "association" resources represent the association relationship between two Terraform resources (in this case they are `azurerm_network_interface` and `azurerm_network_security_group`). They also have some synthetic resource ID, e.g. `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.network/networkInterfaces/example|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/networkSecurityGroups/group1`.

Currently, this tool only works on the assumption that there is 1:1 mapping between Azure resources and the Terraform resources.

## Development: How to debug using vscode

### requirement
install vs code and go extension

In vscode
> Ctrl + Shift + P
>
> Go: Install/Update Tools

### Debug
0. Uncoment line in the main.go

1. go build -gcflags=all="-N -l"

2. run the program
./aztfy rg-my-demo

4. Get pid
- Linux : pgrep aztfy
- Windows : Task manager / tab detail

5. Update launch.json processId with aztfy pid

6. launch debug session

7. Press enter
14 changes: 2 additions & 12 deletions internal/meta/tfinstall_find.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package meta
import (
"context"
"fmt"
"log"
"os"
"path/filepath"
"strconv"
Expand All @@ -17,19 +16,10 @@ import (
// FindTerraform finds the path to the terraform executable whose version meets the min version constraint.
// It first tries to find from the local OS PATH. If there is no match, it will then download the release of the minVersion from hashicorp to the tfDir.
func FindTerraform(ctx context.Context, tfDir string, minVersion *version.Version) (string, error) {
var terraformPath, terraformExe string

log.Println("FindTerraform loaded")

if os.PathSeparator == '\\' { // windows
terraformExe = "terraform.exe"
} else {
terraformExe = "terraform"
}

var terraformPath string
opts := []tfinstall.ExecPathFinder{
tfinstall.LookPath(),
tfinstall.ExactPath(filepath.Join(tfDir, terraformExe)),
tfinstall.ExactPath(filepath.Join(tfDir, terraformBinary)),
tfinstall.ExactVersion(minVersion.String(), tfDir),
}

Expand Down
5 changes: 5 additions & 0 deletions internal/meta/tfinstall_find_fallback.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build !windows

package meta

const terraformBinary = "terraform"
3 changes: 3 additions & 0 deletions internal/meta/tfinstall_find_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package meta

const terraformBinary = "terraform.exe"
12 changes: 0 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,10 @@ func init() {
flagVersion = flag.Bool("v", false, "Print version")
}

// var reader = bufio.NewReader(os.Stdin)

const usage = `aztfy [option] <resource group name>
`

func main() {
// os.Setenv("AZTFY_DEBUG", "true")
// os.Setenv("AZTFY_MOCK_CLIENT", "false")
// os.Setenv("AZTFY_LOGFILE", "aztfylogs.log")

// log.Println("Main hitted")

// input, _ := reader.ReadString('\n')
// value := strings.TrimSpace(input)
// fmt.Printf("input: %v", value)

flag.Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(), "%s\n", usage)
flag.PrintDefaults()
Expand Down

0 comments on commit aa0f0a7

Please sign in to comment.