Skip to content

Commit

Permalink
feat(debug): add extension output channel log
Browse files Browse the repository at this point in the history
- Add vscode extension output channel for debugging
- Update demo.gif with tested examples
- Add examples main.tf used in demo.gif
- Add .tool-versions for nodejs version
  • Loading branch information
tdharris committed Aug 16, 2024
1 parent 8b0e0bd commit 73fff17
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 2 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs v20.12.2
Binary file modified assets/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions examples/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

resource "aws_s3_bucket" "example" {
bucket = "my-bucket"
}

data "aws_s3_bucket" "example" {
bucket = aws_s3_bucket.example.bucket
}

module "consul" {
source = "hashicorp/consul/aws"
}

module "k8s_cluster" {
source = "app.terraform.io/example-corp/k8s-cluster/azurerm"
}

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
}

module "iam_assumable_role" {
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-role"
}

module "example_github" {
source = "github.com/hashicorp/example"
}

module "example_git_ssh" {
source = "git@github.com:hashicorp/example.git"
}

module "example_bitbucket" {
source = "bitbucket.org/hashicorp/terraform-consul-aws"
}

module "storage_git_ssh" {
source = "git::ssh://username@example.com/repo/storage.git"
}

module "storage_git_username" {
source = "git::username@example.com:repo/storage.git"
}

module "example_git_ref" {
source = "git::git@github.com:owner/repo.git//modules/name?ref=v0.0.1"
}

module "example_git_commit" {
source = "git::git@github.com:owner/repo.git//modules/name?ref=51d462976d84fdea54b47d80dcabbf680badcdb8"
}

module "example_git_no_ref" {
source = "git::git@github.com:owner/repo.git//modules/name"
}

module "example_git_tag" {
source = "git@github.com:owner/repo.git?ref=v0.0.1"
}













7 changes: 5 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const linkProvider: vscode.DocumentLinkProvider = {
const line = document.lineAt(ln);
const lineMatchResult = moduleLineMatcher(line) || resourceLineMatcher(line);
if (lineMatchResult) {
console.log(logPrefix, "LMR", lineMatchResult);
outputChannel.appendLine(`${logPrefix} LMR ${JSON.stringify(lineMatchResult)}`);
res.push(lineMatchResult);
}
}
Expand All @@ -37,7 +37,7 @@ const linkProvider: vscode.DocumentLinkProvider = {
if (!uri) { return; }

const link = uri.toString();
console.log(logPrefix, `${lmr.type} link`, link);
outputChannel.appendLine(`${logPrefix} ${lmr.type} link ${link}`);
const ln = new vscode.DocumentLink(
lmr.range, uri
);
Expand All @@ -47,9 +47,12 @@ const linkProvider: vscode.DocumentLinkProvider = {
}
};

const outputChannel = vscode.window.createOutputChannel("Terraform Link Docs");

export function activate(context: vscode.ExtensionContext) {
const disposeTerraformLinkProvider = vscode.languages.registerDocumentLinkProvider('terraform', linkProvider);
const disposeHclLinkProvider = vscode.languages.registerDocumentLinkProvider('hcl', linkProvider);

context.subscriptions.push(disposeTerraformLinkProvider, disposeHclLinkProvider);
outputChannel.appendLine("Extension activated");
}

0 comments on commit 73fff17

Please sign in to comment.