Skip to content

Commit

Permalink
delete on resources ignores 404 error as resource is already in desir…
Browse files Browse the repository at this point in the history
…ed state.
  • Loading branch information
Robert Wafle authored and Robert Wafle committed Oct 22, 2022
1 parent d8218f2 commit feee4b9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HOSTNAME=registry.terraform.io
NAMESPACE=robwafle
NAME=tsm
BINARY=terraform-provider-${NAME}
VERSION=0.0.83
VERSION=0.0.84
OS_ARCH=linux_amd64

default: install
Expand Down
16 changes: 8 additions & 8 deletions client/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,16 @@ func (c *Client) DeleteCluster(ctx context.Context, id string, authToken *string
return nil, err
}

body, err := c.doRequest(req, authToken)
if err != nil {
_, err = c.doRequest(req, authToken)
if err != nil && err.Error() != "404" {
return nil, err
}

newCluster := Cluster{}
err = json.Unmarshal(body, &newCluster)
if err != nil {
return nil, err
}
// newCluster := Cluster{}
// err = json.Unmarshal(body, &newCluster)
// if err != nil {
// return nil, err
// }

return &newCluster, nil
return nil, nil
}
2 changes: 1 addition & 1 deletion client/globalnamespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (c *Client) DeleteGlobalNamespace(ctx context.Context, id string, authToken
}

_, err = c.doRequest(req, authToken)
if err != nil {
if err != nil && err.Error() != "404" {
return nil, err
}

Expand Down
13 changes: 1 addition & 12 deletions examples/aks_cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,9 @@ TSM_APIKEY: <its-a-secret>

# command to rebuild, install and test
```
pushd ../../terraform-provider-tsm ; make install && popd; rm .terraform.lock.hcl ; terraform init -upgrade ; terraform plan
pushd ../.. ; if make build; then echo "built!"; else popd; fi && popd && rm tflog.json ; terraform plan -out=tfplan
```

# clean up if it all goes wrong
```
rm terraform.tfstate.backup; rm terraform.tfstate; rm tfplan; rm tfplan.txt ; export TF_LOG=TRACE; rm .terraform.lock.hcl ;
```

# plan, if you get a checksum error you didn't update the version in Makefile.
```
rm terraform.tfstate.backup; rm terraform.tfstate; rm tfplan ; export TF_LOG=TRACE; rm .terraform.lock.hcl ; terraform init -upgrade ; terraform plan -out=tfplan; terraform show tfplan | tee tfplan.txt;
```


# apply
```
terraform apply -input=false tfplan
Expand Down
7 changes: 3 additions & 4 deletions examples/aks_cluster/tsm-globalnamespace.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "tsm_globalnamespace" "default" {
depends_on = [tsm_cluster.aks]

name = "global-default"
display_name = "global-default"
domain_name = "global-default.gns"
name = "global-default-aks"
display_name = "global-default-aks"
domain_name = "global-default-aks.gns"
use_shared_gateway = true
mtls_enforced = true
api_discovery_enabled = true
Expand All @@ -27,7 +27,6 @@ data "tsm_globalnamespace" "default" {
}

output "tsm_globalnamespace" {

value = data.tsm_globalnamespace.default
}

0 comments on commit feee4b9

Please sign in to comment.