Skip to content

Commit

Permalink
update aztfmigrate (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-henglu authored Oct 17, 2024
1 parent 28e3e9e commit b3cfe82
Show file tree
Hide file tree
Showing 50 changed files with 9,982 additions and 2,388 deletions.
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/Azure/azapi-lsp
go 1.22.0

require (
github.com/Azure/aztfmigrate v1.15.1-0.20241010081637-fcc6b9d0f7dc
github.com/Azure/aztfmigrate v1.15.1-0.20241017071650-067a517e275f
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0
github.com/apparentlymart/go-textseg v1.0.0
github.com/creachadair/jrpc2 v0.32.0
Expand Down Expand Up @@ -32,6 +32,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/automation/armautomation v0.9.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice v1.2.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cdn/armcdn v1.1.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices v1.6.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5 v5.7.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2 v2.1.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/datafactory/armdatafactory/v7 v7.0.0 // indirect
Expand Down Expand Up @@ -88,10 +89,10 @@ require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/magodo/armid v0.0.0-20240524082432-7ce06ae46c33 // indirect
github.com/magodo/aztft v0.3.1-0.20240802001407-2834614c6d9c // indirect
github.com/magodo/aztft v0.3.1-0.20241011060757-310738ca90dd // indirect
github.com/magodo/tfadd v0.10.1-0.20240902124619-bd18a56f410d // indirect
github.com/magodo/tfpluginschema v0.0.0-20240902090353-0525d7d8c1c2 // indirect
github.com/magodo/tfstate v0.0.0-20240829105815-03d52976fa13 // indirect
github.com/magodo/tfstate v0.0.0-20241016043929-2c95177bf0e6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
Expand Down
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ github.com/Azure/aztfmigrate v1.15.1-0.20241010074100-daaa4f34b510 h1:ncxS1gQGJW
github.com/Azure/aztfmigrate v1.15.1-0.20241010074100-daaa4f34b510/go.mod h1:bQOrvrR/2/X6rtJDGH7ARJXZT3cmTMGC6QXIDb4rMxE=
github.com/Azure/aztfmigrate v1.15.1-0.20241010081637-fcc6b9d0f7dc h1:xh3lnKKz2irii5amvw3endArzp5tylwOv2AGnjYu8os=
github.com/Azure/aztfmigrate v1.15.1-0.20241010081637-fcc6b9d0f7dc/go.mod h1:bQOrvrR/2/X6rtJDGH7ARJXZT3cmTMGC6QXIDb4rMxE=
github.com/Azure/aztfmigrate v1.15.1-0.20241017054915-54b97e908e10 h1:Yp41LLMnhRZkXRSAdbTXuAYPyCRMa8pXPJ4mahMCJfk=
github.com/Azure/aztfmigrate v1.15.1-0.20241017054915-54b97e908e10/go.mod h1:gITltwxgnRx5ByF4Xx0aJYbkE9pD8c1mH1gKFAV/nl0=
github.com/Azure/aztfmigrate v1.15.1-0.20241017064424-2fbe8d4d45ab h1:MP6GbC7MVZ2CEFV4kQnnKyNu9sn5eiXDSVoDMswUmz0=
github.com/Azure/aztfmigrate v1.15.1-0.20241017064424-2fbe8d4d45ab/go.mod h1:gITltwxgnRx5ByF4Xx0aJYbkE9pD8c1mH1gKFAV/nl0=
github.com/Azure/aztfmigrate v1.15.1-0.20241017071650-067a517e275f h1:Hm8Tf4qwQ54/cU9yrWLGNIuUUMPKAY+HMVTGnLl+oBg=
github.com/Azure/aztfmigrate v1.15.1-0.20241017071650-067a517e275f/go.mod h1:gITltwxgnRx5ByF4Xx0aJYbkE9pD8c1mH1gKFAV/nl0=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 h1:nyQWyZvwGTvunIMxi1Y9uXkcyr+I7TeNrr/foo4Kpk8=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc=
Expand All @@ -34,6 +40,8 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice v
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice v1.2.0/go.mod h1:d7OLd8MIV32CmujSnOFkT7R5N0YsV5qVI+WnKHzQujQ=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cdn/armcdn v1.1.1 h1:CtE6GCP9YEDF6DjpFxl7xQBqklqfyCC/xkBKUGa/IAc=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cdn/armcdn v1.1.1/go.mod h1:b9yk+8vyxSsBsiEjk9kzrwxgyn+7+J4HzDOYUPznES4=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices v1.6.0 h1:TiYjDq0LCNgtee1teMayYT5FjHmlunWUpthVANUXYPM=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices v1.6.0/go.mod h1:yErdzWZBzjNJCnbC1DcUcSVhjTgllT4PyOenFSeXSJI=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5 v5.7.0 h1:LkHbJbgF3YyvC53aqYGR+wWQDn2Rdp9AQdGndf9QvY4=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5 v5.7.0/go.mod h1:QyiQdW4f4/BIfB8ZutZ2s+28RAgfa/pT+zS++ZHyM1I=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2 v2.1.0 h1:8+KuY4N/1QSlGCsAFnSLs9iLcSYirbyeDDhd6MD9a9c=
Expand Down Expand Up @@ -259,12 +267,16 @@ github.com/magodo/armid v0.0.0-20240524082432-7ce06ae46c33 h1:KmQ16pNsI7DaELU+Cb
github.com/magodo/armid v0.0.0-20240524082432-7ce06ae46c33/go.mod h1:rR8E7zfGMbmfnSQvrkFiWYdhrfTqsVSltelnZB09BwA=
github.com/magodo/aztft v0.3.1-0.20240802001407-2834614c6d9c h1:6H0Rxt63ep2TlQVbevMfOId7cojsp9FzKkNDFR0rnco=
github.com/magodo/aztft v0.3.1-0.20240802001407-2834614c6d9c/go.mod h1:CHeYYR+/RTjUry+0bpkI49PvQ/1sTe7itA+9BqKE1/8=
github.com/magodo/aztft v0.3.1-0.20241011060757-310738ca90dd h1:6UcyxroC+nV2KcalwYWrkD011QXTHyEwEF2JcoYeRjU=
github.com/magodo/aztft v0.3.1-0.20241011060757-310738ca90dd/go.mod h1:KQixUbCSpXiFkjLyy0lrtZY+2doHvJ1EIdtyhmVs3KQ=
github.com/magodo/tfadd v0.10.1-0.20240902124619-bd18a56f410d h1:dmS4jSfNIfshWkh43yK4n1Qx0BsaKrfxMiqRg0fKKYw=
github.com/magodo/tfadd v0.10.1-0.20240902124619-bd18a56f410d/go.mod h1:G2Hc13YaLGHa+CPEP/HZzj9sIGyKDM5ZXInzQ8Dp86s=
github.com/magodo/tfpluginschema v0.0.0-20240902090353-0525d7d8c1c2 h1:Unxx8WLxzSxINnq7hItp4cXD7drihgfPltTd91efoBo=
github.com/magodo/tfpluginschema v0.0.0-20240902090353-0525d7d8c1c2/go.mod h1:mh3baLIzKdhegfmLrAX+mpXQBvs4sqiDRTGx5Z5FGo0=
github.com/magodo/tfstate v0.0.0-20240829105815-03d52976fa13 h1:HhTCs5IKRuJxqx3NDI5gWfAD4WCNXiYGXM1dKyPp9rA=
github.com/magodo/tfstate v0.0.0-20240829105815-03d52976fa13/go.mod h1:cm1odSE6eUeMQRjYRARg1sWLP3HPsWjwvmk/+T4eQxs=
github.com/magodo/tfstate v0.0.0-20241016043929-2c95177bf0e6 h1:Uy+WlvEHfZEVTs1Xf5N+177FTdPHx+mWUvsXHR4tGM4=
github.com/magodo/tfstate v0.0.0-20241016043929-2c95177bf0e6/go.mod h1:cm1odSE6eUeMQRjYRARg1sWLP3HPsWjwvmk/+T4eQxs=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
Expand Down
2 changes: 1 addition & 1 deletion internal/langserver/handlers/code_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (h *logHandler) textDocumentCodeAction(ctx context.Context, params lsp.Code
continue
}
address := strings.Join(block.Labels, ".")
if strings.HasPrefix(address, "azapi") {
if strings.HasPrefix(address, "azapi_resource.") {
hasAzapiResources = true
}
if strings.HasPrefix(address, "azurerm") {
Expand Down
24 changes: 5 additions & 19 deletions internal/langserver/handlers/command/aztfmigrate_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,6 @@ func (c AztfMigrateCommand) Handle(ctx context.Context, arguments []json.RawMess
resource.ResourceType = resourceTypes[0]
resources = append(resources, resource)

case *types.AzapiUpdateResource:
resourceTypes, exact, err := azurerm.GetAzureRMResourceType(resource.Id)
if err != nil {
log.Printf("failed to get resource type for %s: %v", resource.Id, err)
continue
}
if len(resourceTypes) == 0 {
log.Printf("failed to get resource type for %s", resource.Id)
continue
}
if !exact {
log.Printf("multiple resource types found for %s: %v", resource.Id, resourceTypes)
}
resource.ResourceType = resourceTypes[0]
resources = append(resources, resource)

case *types.AzurermResource:
if len(resource.Instances) == 0 {
continue
Expand Down Expand Up @@ -272,16 +256,18 @@ func (c AztfMigrateCommand) Handle(ctx context.Context, arguments []json.RawMess
for _, addr := range addresses {
r := resourcesMap[addr]
if r == nil {
emptyFile.Body().AppendBlock(writeBlockMap[addr])
emptyFile.Body().AppendNewline()
continue
}
if writeBlockMap[r.OldAddress(nil)] == nil {
continue
}
if !r.IsMigrated() {
emptyFile.Body().AppendBlock(writeBlockMap[r.OldAddress(nil)])
emptyFile.Body().AppendNewline()
continue
}
if writeBlockMap[r.OldAddress(nil)] == nil {
continue
}

emptyFile.Body().AppendUnstructuredTokens(types.CommentOutBlock(writeBlockMap[r.OldAddress(nil)]))
emptyFile.Body().AppendNewline()
Expand Down

Large diffs are not rendered by default.

33 changes: 27 additions & 6 deletions vendor/github.com/Azure/aztfmigrate/helper/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions vendor/github.com/Azure/aztfmigrate/types/azapi_resource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions vendor/github.com/Azure/aztfmigrate/types/azurerm_resource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/Azure/aztfmigrate/types/from_plan.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions vendor/github.com/Azure/aztfmigrate/types/hcl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b3cfe82

Please sign in to comment.