Skip to content

Commit

Permalink
update aztfmigrate
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-henglu committed Oct 17, 2024
1 parent 28e3e9e commit 88fd037
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.

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 88fd037

Please sign in to comment.