Skip to content

Commit

Permalink
Merge pull request #16 from Noahnc/refac/bug_fixes_and_improvments
Browse files Browse the repository at this point in the history
Refac/bug fixes and improvments
  • Loading branch information
Noahnc authored Aug 13, 2023
2 parents 3a1f2b2 + d7ef799 commit 2f19ffc
Show file tree
Hide file tree
Showing 25 changed files with 1,822 additions and 851 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:

jobs:
test:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

strategy:
matrix:
os:
Expand Down Expand Up @@ -87,7 +90,7 @@ jobs:
files: build/*.vsix
tag_name: "v.${{ steps.package-version.outputs.current-version}}"
generate_release_notes: true
# - name: Publish to Marketplace
# run: npx vsce publish --no-git-tag-version --packagePath $(find . -iname *.vsix)
# env:
# VSCE_PAT: ${{ secrets.VSCE_PAT }}
- name: Publish to Marketplace
run: npx vsce publish --no-git-tag-version --packagePath $(find . -iname *.vsix)
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
9 changes: 9 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}", "--extensionTestsPath=${workspaceFolder}/out/test/suite/index"],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"preLaunchTask": "tasks: watch-tests"
},
{
"name": "Launch Extension",
"type": "extensionHost",
Expand Down
21 changes: 21 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@
"problemMatcher": [],
"label": "npm: compile",
"detail": "tsc -p ./"
},
{
"label": "tasks: watch-tests",
"dependsOn": ["npm: watch"],
"problemMatcher": []
},
{
"type": "npm",
"script": "install",
"group": "clean",
"problemMatcher": [],
"label": "npm: install",
"detail": "install dependencies from package"
},
{
"type": "npm",
"script": "watch",
"group": "build",
"problemMatcher": [],
"label": "npm: watch",
"detail": "tsc -watch -p ./"
}
]
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to the terraform-toolbox extension will be documented in this file.

## [0.2.0]

- (refac) Refactoring terrraform version management (releases are now directly downloaded instead of compiled from source. GO is therefore no longer needed).
- (fix) Fix bug with file paths containing spaces.
- (fix) Fix bug with modules not containing a version attribute.
- (feat) Bundle js files with esbuild.

## [0.1.3]

- (feat) Add a setting to exclude certain files or folders while searching for terraform folders.
Expand Down
Binary file modified Images/examples/terraform_version.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ VSCode extension adding a bunch of featurees regarding Terraform and Spacelift.
- [Getting startet](#getting-startet)
- [Terraform version manager](#terraform-version-manager)
- [Spacelift](#spacelift)
- [Supported platforms](#supported-platforms)
- [Features](#features)
- [Terraform version manager](#terraform-version-manager-1)
- [Terraform workspace](#terraform-workspace)
Expand All @@ -28,11 +29,12 @@ The following features require manual configuration and installation steps:

The following requirements must be met for the terraform version manager to work:

- Since the terraform binaries are compiled from source, [GO](https://go.dev/doc/install) must be installed and available in your Path.
- All compiled binaries are stored in the following folder. This folder must be added to your Path:
- The active terraform version is stored in the following folder:
- Windows: `%USERPROFILE%\.terraform-toolbox\active`
- Mac: `$HOME/.terraform-toolbox/active`

This folder must be added to your path. Also, make sure that you have no other terraform binaries in your path.

### Spacelift

To use any spacelift feature of this extension, [spacectl](https://github.com/spacelift-io/spacectlhttps://github.com/spacect) has to be installed and available in your Path. You also have to set a userprofile in spacectl with the command:
Expand All @@ -45,11 +47,21 @@ Regarding spacelift, no authentication is required in VSCode. The extension uses

If you don't want to use any spacelift features, you can simply not install the spacectl, this will disable all spacelift features of the extension.

## Supported platforms

The extension supports all three major OS platforms:

- Windows (x64/x86/arm64)
- MacOS (x64/arm64)
- Linux (x64/x86/arm64) (not tested)

MacOS and Windows are regularly used and tested. Linux is not tested, but should work.

## Features

### Terraform version manager

This extension adds a terraform version manager, that allows you to install and switch between any terraform version available on the hashicorp/terraform Github releases page (including betas, alphas and rc). The extension downloads the source code of the selected terraform version and builds it locally. The active binary is stored in the following folder: `%USERPROFILE%\.terraform-toolbox/active` (Windows) or `$HOME/.terraform-toolbox/active` (Mac). Not active but installed versions are stored in `$HOME/.terraform-toolbox/terraform` (Mac) or `%USERPROFILE%\.terraform-toolbox\terraform` (Windows).
This extension adds a terraform version manager, that allows you to install and switch between any terraform version available on the hashicorp/terraform Github releases page (including betas, alphas and rc). The extension downloads the selected version from `https://releases.hashicorp.com/terraform`. The active binary is stored in the following folder: `%USERPROFILE%\.terraform-toolbox/active` (Windows) or `$HOME/.terraform-toolbox/active` (Mac). Not active but installed versions are stored in `$HOME/.terraform-toolbox/terraform` (Mac) or `%USERPROFILE%\.terraform-toolbox\terraform` (Windows).

- Command [`tftoolbox.setTerraformVersion`]: Select and install a specific terraform version.
![terraform-version](Images/examples/terraform_version.gif)
Expand All @@ -70,7 +82,7 @@ Tired of switching between terraform workspaces in the terminal? This extension

Since terraform init is required for many features of the official Hashicorp Terraform extension to work, this extension adds some features to make the terraform init process easier:

- Command [`tftoolbox.initCurrentProject`]: Run terraform init in the current folder. Similar to the init Command of the official Hashicorp Terraform extension, but it sets the `--upgrade` flag by default.
- Command [`tftoolbox.initCurrentProject`]: Run terraform init in the current folder. Similar to the init Command of the official Hashicorp Terraform extension, but it allows you to specify additional terraform init arguments with the setting `tftoolbox.terraform.initArg`.
- Command [`tftoolbox.initAllProjects`]: Finds all terraform folders in your open workspaces and runs terraform init in each of them asynchronically. With the setting `tftoolbox.terraform.autoInitAllProjects` you can enable to auto init all folders when opening VSCode. More information can be found here: [Terraform init all projects](docs/terraformInitAllProjects.md)
![terraform-init](Images/examples/terraform_init.gif)
- Command [`tftoolbox.initRefreshModules`]: Installs missing modules for the current folder.
Expand Down
6 changes: 4 additions & 2 deletions docs/autoSetTerraformVersion.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Auto-set terraform version

With the command `tftoolbox.autoSetTerraformVersion` you can automatically select the latest terraform version that matches the requirements of all your open workspaces. The extension evaluates the required terraform version based on the following process:
With the command `tftoolbox.autoSetTerraformVersion` you can automatically select the latest stable terraform version that matches the requirements of all your open workspaces. The extension evaluates the required terraform version based on the following process:

1. It checks each of your open workspaces for a file called `./Spacelift-Resources/main.tf`. If at least one of your workspaces contains such a file and the file contains a module `module.cmi-spacelift-stacks` with the attribute `terraform_version`, this will be used to filter the terraform versions available on the hashicorp/terraform Github releases page. The latest version that matches all the requirements will be selected. This feature is specific to our workflow at CMInformatik, since we define all spacelift terraform stacks of the Repository in this module incl. the required terraform version. If this file is not present in any of your workspaces, the extension will continue with the next step.
2. The extension searches all .tf files in your open workspaces for `terraform.required_version` attributes. All found `required_version` are then combined into a list of unique version constraints. All releases are then filtered against each of the found version constraints. The latest version that matches all the requirements will be selected. If no version matches all the requirements, the next step will be executed.
3. If the `tftoolbox.autoSetTerraformVersion` command was executed via the command palette, the extension will show you a warning and abort the process. If the command was executed by `tftoolbox.terraform.autoSelectVersion` on startup, the command will abort silently.
3. The extension will select the latest stable terraform version.

By enabling the setting `tftoolbox.terraform.autoSelectVersion` the extension will auto-select a terraform version when opening VSCode.

> **_NOTE:_** This command only selects stable versions of terraform. RC, betas or alpha versions are not considered.
Loading

0 comments on commit 2f19ffc

Please sign in to comment.