Skip to content

Commit

Permalink
debug env
Browse files Browse the repository at this point in the history
  • Loading branch information
Cedric Folliot committed Oct 14, 2021
1 parent e6ca9a0 commit aaca1d7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

dist/
aztfylogs.log
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Process",
"type": "go",
"request": "attach",
"mode": "local",
"processId": 28180 //change with your pid
}
]
}
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,32 @@ 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
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,22 @@ 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 aaca1d7

Please sign in to comment.