Skip to content

Commit

Permalink
add AZTF_MIGRATE_SKIP_COVERAGE_CHECK to skip coverage check
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-henglu committed Oct 10, 2024
1 parent 0e93aad commit f55ac28
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ yay -S aztfmigrate
2. Usage of `dynamic` can't be migrated.
3. Update resource used to manage CMK can't be migrated.

## Advanced usage

1. Adding the below environment variable will skip the coverage check when migrating the azapi resources to azurerm resources.

```
AZTF_MIGRATE_SKIP_COVERAGE_CHECK = true
```

## Credits

We wish to thank HashiCorp for the use of some MPLv2-licensed code from their open source project [terraform-plugin-sdk](https://github.com/hashicorp/terraform-plugin-sdk).
4 changes: 4 additions & 0 deletions types/azapi_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"fmt"
"os"
"strconv"
"strings"

Expand Down Expand Up @@ -151,6 +152,9 @@ func (r *AzapiResource) TargetProvider() string {
}

func (r *AzapiResource) CoverageCheck(strictMode bool) error {
if os.Getenv("AZTF_MIGRATE_SKIP_COVERAGE_CHECK") == "true" {
return nil
}
resourceId := r.Instances[0].ResourceId
idPattern, _ := GetIdPattern(resourceId)
if strictMode {
Expand Down
4 changes: 4 additions & 0 deletions types/azapi_update_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"fmt"
"os"
"strings"

"github.com/Azure/aztfmigrate/azurerm/coverage"
Expand Down Expand Up @@ -80,6 +81,9 @@ func (r *AzapiUpdateResource) TargetProvider() string {
}

func (r *AzapiUpdateResource) CoverageCheck(strictMode bool) error {
if os.Getenv("AZTF_MIGRATE_SKIP_COVERAGE_CHECK") == "true" {
return nil
}
idPattern, _ := GetIdPattern(r.Id)
if strictMode {
azurermApiVersion := coverage.GetApiVersion(idPattern)
Expand Down

0 comments on commit f55ac28

Please sign in to comment.