ModPosh.Hcl
1.1.0
dotnet add package ModPosh.Hcl --version 1.1.0
NuGet\Install-Package ModPosh.Hcl -Version 1.1.0
<PackageReference Include="ModPosh.Hcl" Version="1.1.0" />
paket add ModPosh.Hcl --version 1.1.0
#r "nuget: ModPosh.Hcl, 1.1.0"
// Install ModPosh.Hcl as a Cake Addin #addin nuget:?package=ModPosh.Hcl&version=1.1.0 // Install ModPosh.Hcl as a Cake Tool #tool nuget:?package=ModPosh.Hcl&version=1.1.0
Latest Version | Nuget.org | Issues | Testing | License | Discord |
---|---|---|---|---|---|
HCL Parser
Overview
The HCL Parser is a custom-built C# library designed to parse, manipulate, and generate HashiCorp Configuration Language (HCL) files. This parser plays a crucial role in the Terraform module update process by allowing structured modifications to variables.tf
, main.tf
, and other HCL files. The library provides an object-oriented representation of HCL, enabling easy transformations and validation before updating Terraform modules.
Features
- HCL Parsing: Converts HCL into structured objects that can be programmatically modified.
- Object-Oriented Representation: Defines HCL elements as discrete C# objects with overridable methods.
- HCL Generation: Converts modified objects back into valid HCL strings.
- PowerShell Compatibility: Can be integrated into a PowerShell module for automation in CI/CD pipelines.
Installation
The HCL Parser can be added to a .NET project via NuGet:
dotnet add package ModPosh.HclParser
Alternatively, if using an internal feed:
dotnet nuget add source <internal_feed_url>
dotnet add package ModPosh.HclParser --source <internal_feed>
Usage
Parsing HCL
using ModPosh.HclParser;
string hclText = @"variable \"instance_count\" {\n type = number\n default = 1\n}";
HclDocument doc = HclParser.Parse(hclText);
foreach (var variable in doc.Variables)
{
Console.WriteLine($"Variable: {variable.Name}, Default: {variable.Default}");
}
Modifying HCL
HclVariable variable = new HclVariable("instance_type")
{
Type = "string",
Default = "n1-standard-1"
};
HclDocument doc = new HclDocument();
doc.Add(variable);
string outputHcl = doc.ToString();
Console.WriteLine(outputHcl);
Future Enhancements
- Support for HCL2 with nested blocks and expressions.
- Integration with Azure DevOps for automated module updates.
- Additional validation rules to detect deprecated or incorrect configurations.
Contributing
Contributions are welcome! Please follow the contribution guidelines and submit a pull request.
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- Antlr4.Runtime.Standard (>= 4.13.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.