Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
ms-henglu committed Jan 5, 2022
0 parents commit 1c34e41
Showing 2,143 changed files with 391,850 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.go text eol=lf
*.tf text eol=lf
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dist/
.idea/
coverage.txt
internal/schemas/.terraform/
internal/schemas/.terraform.lock.hcl
internal/schemas/*log*
internal/schemas/providers.tf
internal/schemas/schemas_gen.go
internal/schemas/data/
terraform-ls
1 change: 1 addition & 0 deletions .go-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.17
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Server",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"args": [
"serve",
"--port",
"30337"
]
}
]
}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## 0.0.0 (5 January 2022)
Initial state

FEATURES:

- Completion when input `type`
- Completion when input `body`, limitation: it only works when use `jsonencode` function to build the JSON
- Show hint when hover on `type`, `body` and properties defined inside `body`
- Show diagnostics for properties defined inside `body`
354 changes: 354 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fmt:
find . -name '*.go' | grep -v vendor | xargs gofmt -s -w
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Terraform azurerm-restapi Provider Language Server

Experimental version of [terraform-provider-azurerm-restapi](https://github.com/Azure/terraform-provider-azurerm-restapi) language server.

## What is LSP

Read more about the Language Server Protocol at https://microsoft.github.io/language-server-protocol/

## Introduction

This project only supports completion/hover/diagnostics for `terraform-provider-azurerm-restapi`,
not targeting support all language features for `HCL` or `Terraform`. To get the best user experience,
it's recommended to use it with language server for `Terraform`.

## Features

- [x] Completion when input `type`
- [x] Completion when input `body`, limitation: it only works when use `jsonencode` function to build the JSON
- [X] Show hint when hover on `type`, `body` and properties defined inside `body`
- [X] Show diagnostics for properties defined inside `body`
- [ ] Better completion for discriminated object

## Installation

1. Clone this project to local
2. Run `go install` under the project folder.

## Usage

The most reasonable way you will interact with the language server
is through a client represented by an IDE, or a plugin of an IDE.

VSCode extension: [azurerm-restapi-vscode](https://github.com/ms-henglu/azurerm-restapi-vscode)
28 changes: 28 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module github.com/ms-henglu/azurerm-restapi-lsp

go 1.16

require (
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg v1.0.0
github.com/creachadair/jrpc2 v0.32.0
github.com/google/go-cmp v0.5.6
github.com/google/uuid v1.2.0 // indirect
github.com/hashicorp/go-version v1.3.0
github.com/hashicorp/hcl-lang v0.0.0-20211123142056-191cd51dec5b
github.com/hashicorp/hcl/v2 v2.10.1
github.com/hashicorp/terraform-json v0.13.0
github.com/hashicorp/terraform-registry-address v0.0.0-20210816115301-cb2034eba045
github.com/imdario/mergo v0.3.12 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect
github.com/mitchellh/cli v1.1.2
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/spf13/afero v1.6.0
github.com/stretchr/objx v0.1.1 // indirect
github.com/stretchr/testify v1.7.0
github.com/zclconf/go-cty v1.10.0
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
183 changes: 183 additions & 0 deletions go.sum

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Essential"}},{"6":{"Value":"Standard"}},{"6":{"Value":"Advanced"}},{"5":{"Elements":[8,9,10]}},{"6":{"Value":"Microsoft.Addons/supportProviders/supportPlanTypes"}},{"6":{"Value":"2017-05-15"}},{"2":{"Name":"Microsoft.Addons/supportProviders/supportPlanTypes","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":11,"Flags":9,"Description":"The resource name"},"type":{"Type":12,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":13,"Flags":10,"Description":"The resource api version"},"properties":{"Type":15,"Flags":2,"Description":"The properties of the Canonical support plan."}}}},{"2":{"Name":"CanonicalSupportPlanProperties","Properties":{"provisioningState":{"Type":23,"Flags":2,"Description":"The provisioning state of the resource."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Cancelled"}},{"6":{"Value":"Purchasing"}},{"6":{"Value":"Downgrading"}},{"6":{"Value":"Cancelling"}},{"6":{"Value":"Upgrading"}},{"5":{"Elements":[16,17,18,19,20,21,22]}},{"4":{"Name":"Microsoft.Addons/supportProviders/supportPlanTypes@2017-05-15","ScopeType":4,"Body":14}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Essential"}},{"6":{"Value":"Standard"}},{"6":{"Value":"Advanced"}},{"5":{"Elements":[8,9,10]}},{"6":{"Value":"Microsoft.Addons/supportProviders/supportPlanTypes"}},{"6":{"Value":"2018-03-01"}},{"2":{"Name":"Microsoft.Addons/supportProviders/supportPlanTypes","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":11,"Flags":9,"Description":"The resource name"},"type":{"Type":12,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":13,"Flags":10,"Description":"The resource api version"},"properties":{"Type":15,"Flags":2,"Description":"The properties of the Canonical support plan."}}}},{"2":{"Name":"CanonicalSupportPlanProperties","Properties":{"provisioningState":{"Type":23,"Flags":2,"Description":"The provisioning state of the resource."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Cancelled"}},{"6":{"Value":"Purchasing"}},{"6":{"Value":"Downgrading"}},{"6":{"Value":"Cancelling"}},{"6":{"Value":"Upgrading"}},{"5":{"Elements":[16,17,18,19,20,21,22]}},{"4":{"Name":"Microsoft.Addons/supportProviders/supportPlanTypes@2018-03-01","ScopeType":4,"Body":14}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Microsoft.AutonomousDevelopmentPlatform/accounts"}},{"6":{"Value":"2020-07-01-preview"}},{"2":{"Name":"Microsoft.AutonomousDevelopmentPlatform/accounts","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"ADP account properties"},"systemData":{"Type":19,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."},"tags":{"Type":30,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"}}}},{"2":{"Name":"AccountProperties","Properties":{"accountId":{"Type":4,"Flags":2,"Description":"The account's data-plane ID"},"provisioningState":{"Type":18,"Flags":2,"Description":"Gets the status of the account at the time the operation was called."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Accepted"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Deleting"}},{"5":{"Elements":[12,13,14,15,16,17]}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":24,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":29,"Flags":0,"Description":"The type of identity that created the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[20,21,22,23]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[25,26,27,28]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Microsoft.AutonomousDevelopmentPlatform/accounts@2020-07-01-preview","ScopeType":8,"Body":10}},{"6":{"Value":"Microsoft.AutonomousDevelopmentPlatform/accounts/dataPools"}},{"6":{"Value":"2020-07-01-preview"}},{"2":{"Name":"Microsoft.AutonomousDevelopmentPlatform/accounts/dataPools","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":32,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":33,"Flags":10,"Description":"The resource api version"},"properties":{"Type":35,"Flags":0,"Description":"Data Pool properties"}}}},{"2":{"Name":"DataPoolProperties","Properties":{"dataPoolId":{"Type":4,"Flags":2,"Description":"The Data Pool's data-plane ID"},"provisioningState":{"Type":42,"Flags":2,"Description":"Gets the status of the account at the time the operation was called."},"locations":{"Type":44,"Flags":0,"Description":"Gets or sets the collection of locations where Data Pool resources should be created."},"systemData":{"Type":19,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Accepted"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Deleting"}},{"5":{"Elements":[36,37,38,39,40,41]}},{"2":{"Name":"DataPoolLocation","Properties":{"name":{"Type":4,"Flags":1,"Description":"The location name"}}}},{"3":{"ItemType":43}},{"4":{"Name":"Microsoft.AutonomousDevelopmentPlatform/accounts/dataPools@2020-07-01-preview","ScopeType":8,"Body":34}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Microsoft.AutonomousDevelopmentPlatform/accounts"}},{"6":{"Value":"2021-02-01-preview"}},{"2":{"Name":"Microsoft.AutonomousDevelopmentPlatform/accounts","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"ADP account properties"},"systemData":{"Type":19,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."},"tags":{"Type":30,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"}}}},{"2":{"Name":"AccountProperties","Properties":{"accountId":{"Type":4,"Flags":2,"Description":"The account's data-plane ID"},"provisioningState":{"Type":18,"Flags":2,"Description":"Gets the status of the account at the time the operation was called"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Accepted"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Deleting"}},{"5":{"Elements":[12,13,14,15,16,17]}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":24,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":29,"Flags":0,"Description":"The type of identity that created the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[20,21,22,23]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[25,26,27,28]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Microsoft.AutonomousDevelopmentPlatform/accounts@2021-02-01-preview","ScopeType":8,"Body":10}},{"6":{"Value":"Microsoft.AutonomousDevelopmentPlatform/accounts/dataPools"}},{"6":{"Value":"2021-02-01-preview"}},{"2":{"Name":"Microsoft.AutonomousDevelopmentPlatform/accounts/dataPools","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":32,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":33,"Flags":10,"Description":"The resource api version"},"properties":{"Type":35,"Flags":0,"Description":"Data Pool properties"}}}},{"2":{"Name":"DataPoolProperties","Properties":{"dataPoolId":{"Type":4,"Flags":2,"Description":"The Data Pool's data-plane ID"},"provisioningState":{"Type":42,"Flags":2,"Description":"Gets the status of the account at the time the operation was called"},"locations":{"Type":45,"Flags":0,"Description":"Gets or sets the collection of locations where Data Pool resources should be created"},"systemData":{"Type":19,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Accepted"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Deleting"}},{"5":{"Elements":[36,37,38,39,40,41]}},{"2":{"Name":"DataPoolLocation","Properties":{"name":{"Type":4,"Flags":1,"Description":"The location name"},"encryption":{"Type":44,"Flags":0,"Description":"Encryption properties of a Data Pool"}}}},{"2":{"Name":"DataPoolEncryption","Properties":{"keyVaultUri":{"Type":4,"Flags":1,"Description":"The URI of a soft delete-enabled Key Vault that is in the same location as the Data Pool location"},"keyName":{"Type":4,"Flags":1,"Description":"The name of Key Vault key"},"keyVersion":{"Type":4,"Flags":0,"Description":"The version of Key Vault key"},"userAssignedIdentity":{"Type":4,"Flags":1,"Description":"The resource ID of a user-assigned Managed Identity used to access the encryption key in the Key Vault. Requires access to the key operations get, wrap, unwrap, and recover"}}}},{"3":{"ItemType":43}},{"4":{"Name":"Microsoft.AutonomousDevelopmentPlatform/accounts/dataPools@2021-02-01-preview","ScopeType":8,"Body":34}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Microsoft.Advisor/recommendations/suppressions"}},{"6":{"Value":"2016-07-12-preview"}},{"2":{"Name":"Microsoft.Advisor/recommendations/suppressions","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"suppressionId":{"Type":4,"Flags":0,"Description":"The GUID of the suppression."},"ttl":{"Type":4,"Flags":0,"Description":"The duration for which the suppression is valid."},"location":{"Type":4,"Flags":0,"Description":"The location of the resource. This cannot be changed after the resource is created."},"tags":{"Type":11,"Flags":0,"Description":"The tags of the resource."}}}},{"2":{"Name":"ResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Microsoft.Advisor/recommendations/suppressions@2016-07-12-preview","ScopeType":0,"Body":10}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Microsoft.Advisor/recommendations/suppressions"}},{"6":{"Value":"2017-03-31"}},{"2":{"Name":"Microsoft.Advisor/recommendations/suppressions","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"The properties of the suppression."}}}},{"2":{"Name":"SuppressionProperties","Properties":{"suppressionId":{"Type":4,"Flags":0,"Description":"The GUID of the suppression."},"ttl":{"Type":4,"Flags":0,"Description":"The duration for which the suppression is valid."}}}},{"4":{"Name":"Microsoft.Advisor/recommendations/suppressions@2017-03-31","ScopeType":0,"Body":10}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Microsoft.Advisor/recommendations/suppressions"}},{"6":{"Value":"2017-04-19"}},{"2":{"Name":"Microsoft.Advisor/recommendations/suppressions","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"The properties of the suppression."}}}},{"2":{"Name":"SuppressionProperties","Properties":{"suppressionId":{"Type":4,"Flags":0,"Description":"The GUID of the suppression."},"ttl":{"Type":4,"Flags":0,"Description":"The duration for which the suppression is valid."}}}},{"4":{"Name":"Microsoft.Advisor/recommendations/suppressions@2017-04-19","ScopeType":0,"Body":10}}]
Loading

0 comments on commit 1c34e41

Please sign in to comment.