Skip to content

Commit

Permalink
fix(CLOUDDEV-414): fixed after review
Browse files Browse the repository at this point in the history
  • Loading branch information
damir.zinatullin committed Jan 16, 2024
1 parent 83f7347 commit fa90df5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 34 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ terraform.tfstate

### bin
bin/
.local.env
edgecenter/test/.env

### env
**/*.env

### other
local-files
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ PLUGIN_PATH = ~/.terraform.d/plugins/local.edgecenter.ru/repo/edgecenter/$(VERSI


create_bin:
mkdir -p bin
mkdir -p $(BIN_DIR)

install_jq:
if test "$(OS)" = "linux"; then \
curl -L -o $(BIN_DIR)/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64; \
curl -L -o $(BIN_DIR)/jq https://github.com/stedolan/jq/releases/download/jq-1.7/jq-linux64; \
elif test "$(ARCH)" = "arm64"; then \
curl -L -o $(BIN_DIR)/jq https://github.com/stedolan/jq/releases/download/jq-1.7/jq-macos-arm64; \
else \
curl -L -o $(BIN_DIR)/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64; \
curl -L -o $(BIN_DIR)/jq https://github.com/stedolan/jq/releases/download/jq-1.7/jq-osx-amd64; \
fi
chmod +x $(BIN_DIR)/jq

Expand Down
33 changes: 4 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ make test_cloud_resource
```
For testing not cloud (storage, cdn, dns) data sources and resources:
```bash
make test_not_cloud:
make test_not_cloud
```

Lint
Expand All @@ -188,7 +188,7 @@ To generate Terraform documentation, use the command `make docs`. This command u

Debugging
------------------
There are three ways to debug the provider:
There are two ways to debug the provider:
### Goland debugging
1. Add new go build configuration with field ```program arguments```:
```-debug -address=local.edgecenter.ru/repo/edgecenter```
Expand All @@ -203,15 +203,15 @@ terraform apply
```
5. Debugging.


### VSCode debugging
1. Create a `launch.json` file:
* In the Run view, click `create a launch.json file`.
* Choose Go: Launch Package from the debug configuration drop-down menu.
* VS Code will create a `launch.json` file in a `.vscode` folder in your workspace.
2. Add a new configuration to `launch.json`:
* The `address` argument must be equal to the `source` field from your `provider.tf`.
``` {
```json
{
"version": "0.2.0",
"configurations": [
{
Expand All @@ -237,29 +237,4 @@ terraform apply
5. Set a breakpoint in your code and apply the Terraform config: `terraform apply`.
6. Debugging.

### using delve
1. Install the Delve library - [installation](https://github.com/go-delve/delve/tree/master/Documentation/installation)
2. Build binary without optimization or use `make build_debug`
```shell
go build -o bin/$(BINARY_NAME) -gcflags '-N -l'
```
3. Open the first terminal:
* Run the binary with the debug option:
```shell
dlv exec bin/terraform-provider-edgecenter -- -debug
```
* Set a breakpoint for the create function with a resource that you want to debug, e.g,
```shell
break resourceFloatingIPCreate
```
* `continue`
* Copy `TF_REATTACH_PROVIDERS` with its value from output
4. Open the second terminal:
* Export `TF_REATTACH_PROVIDERS`:
```shell
export TF_REATTACH_PROVIDERS='{"local.edgecenter.ru/repo/edgecenter":{...'
```
* Launch ```terraform apply```
* Debug with the `continue` command in the first terminal via `delve`

Thank You

0 comments on commit fa90df5

Please sign in to comment.