🩹 [Patch]: Initialize Hcl module#3
Conversation
…ertTo-Hcl functions Closes #2
There was a problem hiding this comment.
Pull request overview
Initializes the Hcl PowerShell module for an initial 0.0.1 publish by replacing template content with HCL-specific placeholders and updating docs/examples to match the intended Terraform/OpenTofu use cases.
Changes:
- Added placeholder public functions
ConvertFrom-HclandConvertTo-Hclthat throwSystem.NotImplementedException. - Added Pester tests for the placeholder functions and removed template test/boilerplate public functions.
- Updated module version to
0.0.1and replaced README/examples with HCL-focused content.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/PSModuleTest.Tests.ps1 | Removed template “Hello, World!” tests. |
| tests/Hcl.Tests.ps1 | Added Pester tests for new placeholder HCL functions. |
| src/manifest.psd1 | Bumped ModuleVersion to 0.0.1. |
| src/functions/public/completers.ps1 | Removed template argument completer. |
| src/functions/public/Test-PSModuleTest.ps1 | Removed template public function. |
| src/functions/public/SomethingElse/SomethingElse.md | Removed template docs file. |
| src/functions/public/SomethingElse/Set-PSModuleTest.ps1 | Removed template public function. |
| src/functions/public/PSModule/PSModule.md | Removed template docs file. |
| src/functions/public/PSModule/New-PSModuleTest.ps1 | Removed template public function. |
| src/functions/public/PSModule/Get-PSModuleTest.ps1 | Removed template public function. |
| src/functions/public/ConvertTo-Hcl.ps1 | Added ConvertTo-Hcl placeholder (throws). |
| src/functions/public/ConvertFrom-Hcl.ps1 | Added ConvertFrom-Hcl placeholder (throws). |
| examples/General.ps1 | Replaced template example with an HCL-focused example. |
| README.md | Replaced template README with HCL module description and examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ### Example 1: Parse a Terraform locals block | ||
|
|
||
| ```powershell | ||
| Greet-Entity -Name 'World' | ||
| Hello, World! | ||
| $hcl = @' | ||
| locals { | ||
| environment = "production" | ||
| region = "us-east-1" | ||
| tags = { | ||
| project = "myapp" | ||
| team = "platform" | ||
| } | ||
| } | ||
| '@ | ||
| $result = ConvertFrom-Hcl -InputObject $hcl | ||
| $result.locals.environment # production | ||
| $result.locals.tags.project # myapp |
| region = "us-east-1" | ||
| } | ||
| '@ | ||
| ConvertFrom-Hcl -InputObject $hcl |
| # Hcl | ||
|
|
||
| {{ DESCRIPTION }} | ||
| A PowerShell module for working with [HashiCorp Configuration Language (HCL)](https://github.com/hashicorp/hcl), as used in [Terraform](https://www.terraform.io/), [OpenTofu](https://opentofu.org/), and other infrastructure-as-code tools. Supports parsing `.tf` configuration files, `.tfvars` variable files, `locals {}` blocks, and converting PowerShell objects back to HCL format. |
| { ConvertFrom-Hcl -InputObject 'locals { }' } | Should -Throw | ||
| } | ||
| It 'Function: ConvertTo-Hcl - Throws NotImplementedException' { | ||
| { ConvertTo-Hcl -InputObject @{} } | Should -Throw |
…e/Process-PSModule/dot-github/workflows/workflow.yml-5.5.0 Bump PSModule/Process-PSModule/.github/workflows/workflow.yml from 5.4.3 to 5.5.0
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 35 out of 36 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| It 'Function: ConvertFrom-Hcl - Throws NotImplementedException' { | ||
| { ConvertFrom-Hcl -InputObject 'locals { }' } | Should -Throw | ||
| } | ||
| It 'Function: ConvertTo-Hcl - Throws NotImplementedException' { | ||
| { ConvertTo-Hcl -InputObject @{} } | Should -Throw | ||
| } |
| # Hcl | ||
|
|
||
| {{ DESCRIPTION }} | ||
| A PowerShell module for working with [HashiCorp Configuration Language (HCL)](https://github.com/hashicorp/hcl), as used in [Terraform](https://www.terraform.io/), [OpenTofu](https://opentofu.org/), and other infrastructure-as-code tools. Supports parsing `.tf` configuration files, `.tfvars` variable files, `locals {}` blocks, and converting PowerShell objects back to HCL format. |
| $result = ConvertFrom-Hcl -InputObject $hcl | ||
| $result.locals.environment # production | ||
| $result.locals.tags.project # myapp |
| region = "us-east-1" | ||
| } | ||
| '@ | ||
| ConvertFrom-Hcl -InputObject $hcl |
| [Parameter(Mandatory)] | ||
| [string] $InputObject | ||
| ) | ||
| $null = $InputObject | ||
| throw [System.NotImplementedException] 'ConvertFrom-Hcl is not yet implemented.' |
| Process-PSModule: | ||
| uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@60bdf8a5a4c92c53fcf2a8d23f7d5f5c93e6864e # v5.4.3 | ||
| uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@11117919e65242d3388727819a751f74ad24ea9e # v5.5.0 | ||
| secrets: |
|
✅ New release: PowerShell Gallery - Hcl 0.0.1 |
|
✅ New release: GitHub - Hcl v0.0.1 |
The
Hclmodule is now available on the PowerShell Gallery as version0.0.1. This initial release reserves the module name and establishes the intended API surface —ConvertFrom-HclandConvertTo-Hcl— for working with HashiCorp Configuration Language as used in Terraform, OpenTofu, and related infrastructure-as-code tooling. Both functions are placeholders that throwNotImplementedExceptionuntil the full parser and serializer are implemented.New: Hcl module on the PowerShell Gallery
The module can be installed from the PowerShell Gallery:
ConvertFrom-HclandConvertTo-Hclare available as commands but throwNotImplementedExceptionuntil the implementation is complete. Their presence reserves the intended API and allows downstream tooling to take a dependency on the module name.Technical Details
Test-PSModuleTest.ps1,completers.ps1,PSModule/andSomethingElse/subdirectories, andtests/PSModuleTest.Tests.ps1.ConvertFrom-HclandConvertTo-Hcladded as public placeholder functions, following the same pattern as PSModule/Toml#init.src/manifest.psd1set toModuleVersion = '0.0.1'to trigger the first publish pipeline run.tests/Hcl.Tests.ps1added with assertions that both placeholders throw as expected.examples/General.ps1andREADME.mdupdated with HCL-specific content (Terraform locals,.tfvarsexamples).