This commit is contained in:
Heng Lu 2022-02-28 13:33:37 +08:00 коммит произвёл GitHub
Родитель eae149e3ac
Коммит 024df0fd7b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 54 добавлений и 54 удалений

6
.github/ISSUE_TEMPLATE/config.yml поставляемый
Просмотреть файл

@ -1,8 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Terraform azurerm-restapi Provider Language Features / Bugs
url: https://github.com/ms-henglu/azurerm-restapi-lsp/issues
- name: Terraform AzApi Provider Language Features / Bugs
url: https://github.com/Azure/azapi-lsp/issues
about: >-
Most of the language features of the VS Code extension are supplied by the
Terraform azurerm-restapi Provider Language Server. Issues with language features
Terraform AzApi Provider Language Server. Issues with language features
in many cases may need to be filed on that repository.

Просмотреть файл

@ -1,14 +1,14 @@
# Terraform azurerm-restapi Provider Visual Studio Code Extension
# Terraform AzApi Provider Visual Studio Code Extension
The Terraform azurerm-restapi Provider Visual Studio Code (VS Code) extension adds editing features like completion/hover/diagnositics for [terraform-provider-azurerm-restapi](https://github.com/Azure/terraform-provider-azurerm-restapi) Terraform files using the [Terraform azurerm-restapi Provider Language Server](https://github.com/ms-henglu/azurerm-restapi-lsp).
The Terraform AzApi Provider Visual Studio Code (VS Code) extension adds editing features like completion/hover/diagnositics for [terraform-provider-azapi](https://github.com/Azure/terraform-provider-azapi) Terraform files using the [Terraform AzApi Provider Language Server](https://github.com/Azure/azapi-lsp).
## Features
- Manages the [Terraform azurerm-restapi Provider Language Server](https://github.com/ms-henglu/azurerm-restapi-lsp), exposing its features:
- Completion of `azurerm-restapi` resources
- Completion of allowed azure resource types when input `type` in `azurerm-restapi` resources
- Completion of allowed azure resource properties when input `body` in `azurerm-restapi` resources, limitation: it only works when use `jsonencode` function to build the JSON
- Show hint when hover on `azurerm-restapi` resources
- Manages the [Terraform AzApi Provider Language Server](https://github.com/Azure/azapi-lsp), exposing its features:
- Completion of `azapi` resources
- Completion of allowed azure resource types when input `type` in `azapi` resources
- Completion of allowed azure resource properties when input `body` in `azapi` resources, limitation: it only works when use `jsonencode` function to build the JSON
- Show hint when hover on `azapi` resources
- Diagnostics to indicate schema errors as you type
## Usage
@ -22,9 +22,9 @@ Now language server is bundled with extension, but it's still possible to use
exteral lanuage server by configuring the following:
```
"azurerm-restapi.languageServer": {
"azapi.languageServer": {
"external": true,
"pathToBinary": "C:\\Users\\henglu\\go\\bin\\azurerm-restapi-lsp.exe", //file path to language server
"pathToBinary": "C:\\Users\\henglu\\go\\bin\\azapi-lsp.exe", //file path to language server
"args": [
"serve"
],
@ -34,13 +34,13 @@ exteral lanuage server by configuring the following:
### Run in local development
0. Prerequisites: golang >1.16, node 16.X, npm 8.X
1. Clone [Terraform azurerm-restapi Provider Language Server](https://github.com/ms-henglu/azurerm-restapi-lsp) to local
1. Clone [Terraform AzApi Provider Language Server](https://github.com/Azure/azapi-lsp) to local
2. Run `go install` under project folder
3. Add the following configuration to vscode setting file.
```
"azurerm-restapi.languageServer": {
"azapi.languageServer": {
"external": true,
"pathToBinary": "C:\\Users\\henglu\\go\\bin\\azurerm-restapi-lsp.exe", //file path to language server
"pathToBinary": "C:\\Users\\henglu\\go\\bin\\azapi-lsp.exe", //file path to language server
"args": [
"serve"
],
@ -63,4 +63,4 @@ We use telemetry to send error reports to our team, so we can respond more effec
## Release History
See the [CHANGELOG](https://github.com/ms-henglu/azurerm-restapi-vscode/blob/develop/CHANGELOG.md) for more information.
See the [CHANGELOG](https://github.com/Azure/azapi-vscode/blob/develop/CHANGELOG.md) for more information.

Просмотреть файл

@ -46,7 +46,7 @@ function getArch(arch: string) {
async function getRelease(): Promise<Release> {
const response = await axios.get('https://api.github.com/repos/ms-henglu/azurerm-restapi-lsp/releases', {
const response = await axios.get('https://api.github.com/repos/Azure/azapi-lsp/releases', {
headers: {
Authorization: 'token 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',
},
@ -74,7 +74,7 @@ async function run(platform: string, architecture: string) {
const repoDir = cwd.replace(buildDir, '');
const installPath = path.join(repoDir, 'bin');
if (fs.existsSync(installPath)) {
console.log('azurerm-restapi-lsp path exists. Exiting');
console.log('azapi-lsp path exists. Exiting');
return;
}
@ -93,14 +93,14 @@ async function run(platform: string, architecture: string) {
}
if (!build) {
throw new Error(`Install error: no matching azurerm-restapi-lsp binary for ${os}/${arch}`);
throw new Error(`Install error: no matching azapi-lsp binary for ${os}/${arch}`);
}
console.log(build)
// download zip
const zipfile = path.resolve(installPath, `azurerm-restapi-lsp_${release.version}.zip`);
const zipfile = path.resolve(installPath, `azapi-lsp_${release.version}.zip`);
await axios.get(build!.downloadUrl, { responseType: 'stream' }).then(function (response) {
const fileWritePipe = fs.createWriteStream(zipfile);
response.data.pipe(fileWritePipe);
@ -112,8 +112,8 @@ async function run(platform: string, architecture: string) {
// unzip
const fileExtension = os === "windows" ? ".exe" : "";
const versionedName = path.resolve(installPath, `azurerm-restapi-lsp_${release.version}${fileExtension}`);
const unversionedName = path.resolve(installPath, `azurerm-restapi-lsp${fileExtension}`);
const versionedName = path.resolve(installPath, `azapi-lsp_${release.version}${fileExtension}`);
const unversionedName = path.resolve(installPath, `azapi-lsp${fileExtension}`);
const fileReadStream = fs.createReadStream(zipfile);
const unzipPipe = unzip.Extract({ path: installPath });
fileReadStream.pipe(unzipPipe);

8
package-lock.json сгенерированный
Просмотреть файл

@ -1,12 +1,12 @@
{
"name": "azurerm-restapi",
"version": "0.0.1",
"name": "azapi",
"version": "0.0.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "azurerm-restapi",
"version": "0.0.1",
"name": "azapi",
"version": "0.0.3",
"license": "MPL-2.0",
"dependencies": {
"@types/axios": "^0.14.0",

Просмотреть файл

@ -1,8 +1,8 @@
{
"icon": "terraform.png",
"name": "azurerm-restapi",
"displayName": "Terraform azurerm-restapi Provider",
"description": "Autocompletion for Terraform azurerm-restapi Provider",
"name": "azapi",
"displayName": "Terraform AzApi Provider",
"description": "Autocompletion for Terraform AzApi Provider",
"version": "0.0.2",
"publisher": "ms-henglu",
"appInsightsKey": "TODO",
@ -17,9 +17,9 @@
"langServer": {
"version": "0.25.2"
},
"qna": "https://github.com/ms-henglu/azurerm-restapi-vscode/issues",
"qna": "https://github.com/Azure/azapi-vscode/issues",
"bugs": {
"url": "https://github.com/ms-henglu/azurerm-restapi-vscode/issues",
"url": "https://github.com/Azure/azapi-vscode/issues",
"email": "ms-henglu@microsoft.com"
},
"categories": [
@ -36,7 +36,7 @@
],
"repository": {
"type": "git",
"url": "https://github.com/ms-henglu/azurerm-restapi-vscode.git"
"url": "https://github.com/Azure/azapi-vscode.git"
},
"activationEvents": [
"onLanguage:terraform",
@ -69,7 +69,7 @@
"type": "object",
"title": "Terraform",
"properties": {
"azurerm-restapi.languageServer": {
"azapi.languageServer": {
"type": "object",
"description": "Language Server settings",
"properties": {
@ -117,12 +117,12 @@
},
"commands": [
{
"command": "azurerm-restapi.enableLanguageServer",
"title": "Terraform azurerm-restapi Provider : Enable Language Server"
"command": "azapi.enableLanguageServer",
"title": "Terraform AzApi Provider : Enable Language Server"
},
{
"command": "azurerm-restapi.disableLanguageServer",
"title": "Terraform azurerm-restapi Provider: Disable Language Server"
"command": "azapi.disableLanguageServer",
"title": "Terraform AzApi Provider: Disable Language Server"
}
],
"menus": {},

Просмотреть файл

@ -95,7 +95,7 @@ export class ClientHandler {
private async getServerOptions(): Promise<ServerOptions> {
const cmd = await this.lsPath.resolvedPathToBinary();
const serverArgs = config('azurerm-restapi').get<string[]>('languageServer.args', []);
const serverArgs = config('azapi').get<string[]>('languageServer.args', []);
const executable: Executable = {
command: cmd,
args: serverArgs,

Просмотреть файл

@ -4,7 +4,7 @@ import { ClientHandler } from './clientHandler';
import { ServerPath } from './serverPath';
import { config } from './vscodeUtils';
const brand = `Terraform azurerm-restapi Provider`;
const brand = `Terraform AzApi Provider`;
const outputChannel = vscode.window.createOutputChannel(brand);
export let terraformStatus: vscode.StatusBarItem;
@ -22,10 +22,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
// Subscriptions
context.subscriptions.push(
vscode.commands.registerCommand('azurerm-restapi.enableLanguageServer', async () => {
vscode.commands.registerCommand('azapi.enableLanguageServer', async () => {
if (!enabled()) {
const current = config('azurerm-restapi').get('languageServer');
await config('azurerm-restapi').update(
const current = config('azapi').get('languageServer');
await config('azapi').update(
'languageServer',
Object.assign(current, { external: true }),
vscode.ConfigurationTarget.Global,
@ -33,10 +33,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
}
startLanguageServer();
}),
vscode.commands.registerCommand('azurerm-restapi.disableLanguageServer', async () => {
vscode.commands.registerCommand('azapi.disableLanguageServer', async () => {
if (enabled()) {
const current = config('azurerm-restapi').get('languageServer');
await config('azurerm-restapi').update(
const current = config('azapi').get('languageServer');
await config('azapi').update(
'languageServer',
Object.assign(current, { external: false }),
vscode.ConfigurationTarget.Global,
@ -45,7 +45,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
stopLanguageServer();
}),
vscode.workspace.onDidChangeConfiguration(async (event: vscode.ConfigurationChangeEvent) => {
if (event.affectsConfiguration('terraform') || event.affectsConfiguration('azurerm-restapi-lsp')) {
if (event.affectsConfiguration('terraform') || event.affectsConfiguration('azapi-lsp')) {
const reloadMsg = 'Reload VSCode window to apply language server changes';
const selected = await vscode.window.showInformationMessage(reloadMsg, 'Reload');
if (selected === 'Reload') {
@ -97,5 +97,5 @@ async function stopLanguageServer() {
}
function enabled(): boolean {
return config('azurerm-restapi').get('languageServer.external', false);
return config('azapi').get('languageServer.external', false);
}

Просмотреть файл

@ -9,7 +9,7 @@ export class ServerPath {
private customBinPath: string | undefined;
constructor(private context: vscode.ExtensionContext) {
this.customBinPath = vscode.workspace.getConfiguration('azurerm-restapi').get(CUSTOM_BIN_PATH_OPTION_NAME);
this.customBinPath = vscode.workspace.getConfiguration('azapi').get(CUSTOM_BIN_PATH_OPTION_NAME);
}
public installPath(): string {
@ -34,9 +34,9 @@ export class ServerPath {
}
if (process.platform === 'win32') {
return 'azurerm-restapi-lsp.exe';
return 'azapi-lsp.exe';
}
return 'azurerm-restapi-lsp';
return 'azapi-lsp';
}
public async resolvedPathToBinary(): Promise<string> {

Просмотреть файл

@ -1,12 +1,12 @@
terraform {
required_providers {
azurerm-restapi = {
source = "Azure/azurerm-restapi"
azapi = {
source = "Azure/azapi"
}
}
}
provider "azurerm-restapi" {
provider "azapi" {
}
provider "azurerm" {
@ -19,6 +19,6 @@ resource "azurerm_resource_group" "example" {
location = "West Europe"
}
resource "azurerm-restapi_resource" "test" {
resource "azapi_resource" "test" {
type = "Microsoft.Addons/supportProviders/supportPlanTypes@"
}