Skip to content

Commit e9cd1ca

Browse files
committed
recovered build files
1 parent 9bc74c6 commit e9cd1ca

File tree

9 files changed

+1725
-79
lines changed

9 files changed

+1725
-79
lines changed

.gitignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
*.log
33
logs/
44

5-
# local dev
65

7-
*.ps1
8-
MAKEFILE
96
# Terraform files
107
*.tfstate
118
*.tfstate.*
@@ -25,9 +22,6 @@ override.tf.json
2522
*_override.tf.json
2623

2724
# Provider binaries and build artifacts
28-
bin/
29-
*.exe
30-
terraform-provider-*
3125
*.so
3226
*.dylib
3327
*.test

Makefile

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Terraform Provider IIS Makefile
2+
3+
# Default variables
4+
PROVIDER_NAME := terraform-provider-iis
5+
VERSION ?= 0.1.0
6+
GOOS ?= windows
7+
GOARCH ?= amd64
8+
9+
# Go build flags
10+
LDFLAGS := -ldflags "-w -s"
11+
12+
# Terraform registry paths
13+
TERRAFORM_PLUGINS_DIR := $(APPDATA)/terraform.d/plugins
14+
LOCAL_PROVIDER_PATH := terraform.local/maxjoehnk/iis/$(VERSION)/$(GOOS)_$(GOARCH)
15+
16+
.PHONY: help
17+
help: ## Display this help message
18+
@echo "Available commands:"
19+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
20+
21+
.PHONY: build
22+
build: ## Build the provider binary
23+
@echo "Building $(PROVIDER_NAME) for $(GOOS)/$(GOARCH)..."
24+
GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(LDFLAGS) -o bin/$(PROVIDER_NAME)_v$(VERSION).exe .
25+
26+
.PHONY: build-all
27+
build-all: ## Build for multiple platforms
28+
@echo "Building for multiple platforms..."
29+
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o bin/$(PROVIDER_NAME)_v$(VERSION)_windows_amd64.exe .
30+
GOOS=windows GOARCH=arm64 go build $(LDFLAGS) -o bin/$(PROVIDER_NAME)_v$(VERSION)_windows_arm64.exe .
31+
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o bin/$(PROVIDER_NAME)_v$(VERSION)_linux_amd64 .
32+
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o bin/$(PROVIDER_NAME)_v$(VERSION)_linux_arm64 .
33+
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o bin/$(PROVIDER_NAME)_v$(VERSION)_darwin_amd64 .
34+
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o bin/$(PROVIDER_NAME)_v$(VERSION)_darwin_arm64 .
35+
36+
.PHONY: install-local
37+
install-local: build ## Install the provider locally for Terraform
38+
@echo "Installing provider locally..."
39+
@if not exist "$(TERRAFORM_PLUGINS_DIR)\$(LOCAL_PROVIDER_PATH)" mkdir "$(TERRAFORM_PLUGINS_DIR)\$(LOCAL_PROVIDER_PATH)"
40+
copy "bin\$(PROVIDER_NAME)_v$(VERSION).exe" "$(TERRAFORM_PLUGINS_DIR)\$(LOCAL_PROVIDER_PATH)\$(PROVIDER_NAME)_v$(VERSION).exe"
41+
@echo "Provider installed to: $(TERRAFORM_PLUGINS_DIR)\$(LOCAL_PROVIDER_PATH)"
42+
43+
.PHONY: clean
44+
clean: ## Clean build artifacts
45+
@echo "Cleaning build artifacts..."
46+
@if exist bin rmdir /s /q bin
47+
48+
.PHONY: test
49+
test: ## Run tests
50+
go test -v ./...
51+
52+
.PHONY: fmt
53+
fmt: ## Format Go code
54+
go fmt ./...
55+
56+
.PHONY: vet
57+
vet: ## Run go vet
58+
go vet ./...
59+
60+
.PHONY: lint
61+
lint: ## Run golangci-lint (requires golangci-lint to be installed)
62+
golangci-lint run
63+
64+
.PHONY: deps
65+
deps: ## Download and tidy dependencies
66+
go mod download
67+
go mod tidy
68+
69+
.PHONY: dev-setup
70+
dev-setup: deps fmt vet ## Set up development environment
71+
72+
.PHONY: release-build
73+
release-build: clean dev-setup test build-all ## Build release artifacts
74+
75+
# Create required directories
76+
bin:
77+
@if not exist bin mkdir bin
78+
79+
# Example targets for different environments
80+
.PHONY: build-dev
81+
build-dev: VERSION := dev
82+
build-dev: build ## Build development version
83+
84+
.PHONY: install-dev
85+
install-dev: VERSION := dev
86+
install-dev: install-local ## Install development version locally

bin/terraform-provider-iis.exe

18.2 MB
Binary file not shown.
18.2 MB
Binary file not shown.

build.ps1

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
# PowerShell script to build and install the Terraform IIS provider locally
2+
3+
param(
4+
[string]$Version = "0.1.0",
5+
[string]$GoOS = "windows",
6+
[string]$GoArch = "amd64",
7+
[switch]$Install,
8+
[switch]$DevSetup,
9+
[switch]$Clean,
10+
[switch]$Help
11+
)
12+
13+
$ProviderName = "terraform-provider-iis"
14+
$TerraformPluginsDir = "$env:APPDATA\terraform.d\plugins"
15+
$LocalProviderPath = "terraform.local\maxjoehnk\iis\$Version\${GoOS}_$GoArch"
16+
17+
function Show-Help {
18+
Write-Host @"
19+
Terraform IIS Provider Build Script
20+
21+
Usage: .\build.ps1 [OPTIONS]
22+
23+
Options:
24+
-Version <string> Provider version (default: 0.1.0)
25+
-GoOS <string> Target OS (default: windows)
26+
-GoArch <string> Target architecture (default: amd64)
27+
-Install Install provider locally after building
28+
-DevSetup Build and setup for local development (recommended)
29+
-Clean Clean build artifacts
30+
-Help Show this help message
31+
32+
Examples:
33+
.\build.ps1 # Build provider
34+
.\build.ps1 -DevSetup # Build and setup for development (recommended)
35+
.\build.ps1 -Install # Build and install provider locally
36+
.\build.ps1 -Version "0.2.0" # Build specific version
37+
.\build.ps1 -Clean # Clean build artifacts
38+
.\build.ps1 -GoOS linux -GoArch amd64 # Build for Linux
39+
40+
Environment Variables (for proxy testing):
41+
IIS_HOST - IIS server URL
42+
IIS_ACCESS_KEY - Access key for authentication
43+
IIS_PROXY_URL - Proxy URL (e.g., http://proxy.company.com:8080)
44+
IIS_INSECURE - Skip TLS verification (true/false)
45+
"@
46+
}
47+
48+
function Build-Provider {
49+
Write-Host "Building $ProviderName for $GoOS/$GoArch..." -ForegroundColor Green
50+
51+
# Create bin directory if it doesn't exist
52+
if (!(Test-Path "bin")) {
53+
New-Item -ItemType Directory -Name "bin" | Out-Null
54+
}
55+
56+
$env:GOOS = $GoOS
57+
$env:GOARCH = $GoArch
58+
59+
# For dev_overrides, we need the binary named exactly "terraform-provider-iis"
60+
$outputName = if ($GoOS -eq "windows") {
61+
"bin\terraform-provider-iis.exe"
62+
}
63+
else {
64+
"bin/terraform-provider-iis"
65+
}
66+
67+
$buildCmd = "go build -ldflags `"-w -s`" -o `"$outputName`" ."
68+
Write-Host "Running: $buildCmd" -ForegroundColor Yellow
69+
70+
Invoke-Expression $buildCmd
71+
72+
if ($LASTEXITCODE -eq 0) {
73+
Write-Host "Build completed successfully: $outputName" -ForegroundColor Green
74+
75+
# Also create versioned binary for registry installation
76+
$versionedName = if ($GoOS -eq "windows") {
77+
"bin\${ProviderName}_v$Version.exe"
78+
}
79+
else {
80+
"bin/${ProviderName}_v$Version"
81+
}
82+
Copy-Item $outputName $versionedName -Force
83+
Write-Host "Also created versioned binary: $versionedName" -ForegroundColor Green
84+
85+
return $outputName
86+
}
87+
else {
88+
Write-Host "Build failed!" -ForegroundColor Red
89+
exit 1
90+
}
91+
}
92+
93+
function Install-ProviderLocally {
94+
param([string]$BinaryPath)
95+
96+
Write-Host "Installing provider locally..." -ForegroundColor Green
97+
98+
$fullInstallPath = "$TerraformPluginsDir\$LocalProviderPath"
99+
100+
# Create directory structure
101+
if (!(Test-Path $fullInstallPath)) {
102+
New-Item -ItemType Directory -Path $fullInstallPath -Force | Out-Null
103+
Write-Host "Created directory: $fullInstallPath" -ForegroundColor Yellow
104+
}
105+
106+
# Copy binary
107+
$destinationFile = "$fullInstallPath\${ProviderName}_v$Version.exe"
108+
Copy-Item $BinaryPath $destinationFile -Force
109+
110+
Write-Host "Provider installed successfully!" -ForegroundColor Green
111+
Write-Host "Location: $destinationFile" -ForegroundColor Yellow
112+
113+
# Show terraform configuration hint
114+
Write-Host @"
115+
116+
To use this provider in your Terraform configuration, add:
117+
118+
terraform {
119+
required_providers {
120+
iis = {
121+
source = "terraform.local/maxjoehnk/iis"
122+
version = "~> $Version"
123+
}
124+
}
125+
}
126+
127+
provider "iis" {
128+
host = "https://your-iis-server.com:8443"
129+
access_key = "your-access-key"
130+
131+
# Optional proxy configuration
132+
proxy_url = "http://proxy.company.com:8080"
133+
insecure = false
134+
}
135+
"@ -ForegroundColor Cyan
136+
}
137+
138+
function Setup-DevEnvironment {
139+
Write-Host "Setting up development environment..." -ForegroundColor Green
140+
141+
# Get current directory and convert backslashes to forward slashes for HCL
142+
$currentDir = Get-Location
143+
$binPath = Join-Path $currentDir "bin"
144+
$binPath = $binPath -replace '\\', '/'
145+
146+
# Create terraform.rc content for dev overrides
147+
$terraformRcContent = @"
148+
provider_installation {
149+
dev_overrides {
150+
"terraform.local/maxjoehnk/iis" = "$binPath"
151+
}
152+
153+
# For all other providers, install them directly as normal.
154+
direct {}
155+
}
156+
"@
157+
158+
# Determine terraform.rc location
159+
$terraformRcPath = "$env:APPDATA\terraform.rc"
160+
161+
# Backup existing terraform.rc if it exists
162+
if (Test-Path $terraformRcPath) {
163+
$backupPath = "$terraformRcPath.backup.$(Get-Date -Format 'yyyyMMdd-HHmmss')"
164+
Copy-Item $terraformRcPath $backupPath
165+
Write-Host "Backed up existing terraform.rc to: $backupPath" -ForegroundColor Yellow
166+
}
167+
168+
# Write new terraform.rc
169+
Set-Content -Path $terraformRcPath -Value $terraformRcContent
170+
Write-Host "Created terraform.rc with dev overrides: $terraformRcPath" -ForegroundColor Green
171+
172+
Write-Host @"
173+
174+
Development environment configured!
175+
176+
The terraform.rc file has been set up to use your local provider binary.
177+
You can now run Terraform commands in the examples directory without needing
178+
to install the provider to the plugins directory.
179+
180+
Next steps:
181+
1. cd examples
182+
2. terraform init
183+
3. terraform plan
184+
185+
To restore normal provider behavior, delete or rename: $terraformRcPath
186+
"@ -ForegroundColor Cyan
187+
}
188+
189+
function Clean-BuildArtifacts {
190+
Write-Host "Cleaning build artifacts..." -ForegroundColor Green
191+
192+
if (Test-Path "bin") {
193+
Remove-Item "bin" -Recurse -Force
194+
Write-Host "Removed bin directory" -ForegroundColor Yellow
195+
}
196+
197+
Write-Host "Clean completed!" -ForegroundColor Green
198+
}
199+
200+
function Test-Environment {
201+
Write-Host "Checking environment..." -ForegroundColor Green
202+
203+
# Check if Go is installed
204+
try {
205+
$goVersion = go version
206+
Write-Host "Go: $goVersion" -ForegroundColor Yellow
207+
}
208+
catch {
209+
Write-Host "Error: Go is not installed or not in PATH" -ForegroundColor Red
210+
exit 1
211+
}
212+
213+
# Check if Terraform is installed
214+
try {
215+
$tfVersion = terraform version
216+
Write-Host "Terraform: $($tfVersion.Split("`n")[0])" -ForegroundColor Yellow
217+
}
218+
catch {
219+
Write-Host "Warning: Terraform is not installed or not in PATH" -ForegroundColor Yellow
220+
}
221+
222+
Write-Host "Environment check completed!" -ForegroundColor Green
223+
}
224+
225+
# Main script logic
226+
if ($Help) {
227+
Show-Help
228+
exit 0
229+
}
230+
231+
if ($Clean) {
232+
Clean-BuildArtifacts
233+
exit 0
234+
}
235+
236+
Test-Environment
237+
238+
$binaryPath = Build-Provider
239+
240+
if ($DevSetup) {
241+
Setup-DevEnvironment
242+
}
243+
elseif ($Install) {
244+
Install-ProviderLocally -BinaryPath $binaryPath
245+
}
246+
247+
Write-Host "Done!" -ForegroundColor Green

0 commit comments

Comments
 (0)