Skip to content

Commit f3a4fd8

Browse files
committed
Add insecure option for TLS certificate verification skip
- Add insecure provider option to skip TLS verification - Useful for self-signed or expired BMC certificates - Support TURINGPI_INSECURE environment variable - Use shared HTTP client with configurable TLS settings - Update documentation and examples to v1.0.4
1 parent 381c724 commit f3a4fd8

File tree

10 files changed

+50
-10
lines changed

10 files changed

+50
-10
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Claude Code
22
CLAUDE.md
33

4+
# Testing directory (may contain credentials)
5+
testing/
6+
47
# Go
58
terraform-provider-turingpi
69
turingpi-terraform-provider

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.0.4] - 2025-12-22
11+
12+
### Added
13+
- `insecure` provider option to skip TLS certificate verification
14+
- Useful for self-signed or expired BMC certificates
15+
- Environment variable support via `TURINGPI_INSECURE`
16+
17+
### Changed
18+
- Shared HTTP client for all API requests with configurable TLS settings
19+
1020
## [1.0.3] - 2025-12-22
1121

1222
### Added
@@ -57,7 +67,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5767
- Release automation workflow with GoReleaser
5868
- Multi-platform binaries (linux/darwin/windows, amd64/arm64)
5969

60-
[Unreleased]: https://github.com/jfreed-dev/terraform-provider-turingpi/compare/v1.0.3...HEAD
70+
[Unreleased]: https://github.com/jfreed-dev/terraform-provider-turingpi/compare/v1.0.4...HEAD
71+
[1.0.4]: https://github.com/jfreed-dev/terraform-provider-turingpi/compare/v1.0.3...v1.0.4
6172
[1.0.3]: https://github.com/jfreed-dev/terraform-provider-turingpi/compare/v1.0.2...v1.0.3
6273
[1.0.2]: https://github.com/jfreed-dev/terraform-provider-turingpi/compare/v1.0.1...v1.0.2
6374
[1.0.1]: https://github.com/jfreed-dev/terraform-provider-turingpi/compare/v1.0.0...v1.0.1

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ terraform {
1818
required_providers {
1919
turingpi = {
2020
source = "jfreed-dev/turingpi"
21-
version = "1.0.3"
21+
version = "1.0.4"
2222
}
2323
}
2424
}
@@ -27,6 +27,7 @@ provider "turingpi" {
2727
username = "root" # or TURINGPI_USERNAME env var
2828
password = "turing" # or TURINGPI_PASSWORD env var
2929
endpoint = "https://turingpi.local" # or TURINGPI_ENDPOINT env var (optional)
30+
insecure = false # or TURINGPI_INSECURE env var (optional)
3031
}
3132
```
3233

@@ -36,6 +37,7 @@ Using environment variables:
3637
export TURINGPI_USERNAME=root
3738
export TURINGPI_PASSWORD=turing
3839
export TURINGPI_ENDPOINT=https://192.168.1.100 # optional
40+
export TURINGPI_INSECURE=true # optional, for self-signed/expired certs
3941
```
4042

4143
```hcl

docs/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ terraform {
2323
required_providers {
2424
turingpi = {
2525
source = "jfreed-dev/turingpi"
26-
version = "1.0.3"
26+
version = "1.0.4"
2727
}
2828
}
2929
}
@@ -49,13 +49,15 @@ The provider requires BMC credentials to authenticate with the Turing Pi board.
4949
- `username` - (Required) BMC username. Can also be set via `TURINGPI_USERNAME` environment variable.
5050
- `password` - (Required) BMC password. Can also be set via `TURINGPI_PASSWORD` environment variable.
5151
- `endpoint` - (Optional) BMC API endpoint URL. Defaults to `https://turingpi.local`. Can also be set via `TURINGPI_ENDPOINT` environment variable.
52+
- `insecure` - (Optional) Skip TLS certificate verification. Useful for self-signed or expired certificates. Defaults to `false`. Can also be set via `TURINGPI_INSECURE` environment variable.
5253

5354
### Using Environment Variables
5455

5556
```bash
5657
export TURINGPI_USERNAME=root
5758
export TURINGPI_PASSWORD=turing
5859
export TURINGPI_ENDPOINT=https://192.168.1.100
60+
export TURINGPI_INSECURE=true # optional, for self-signed/expired certs
5961
```
6062

6163
```hcl

examples/basic/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
turingpi = {
44
source = "jfreed-dev/turingpi"
5-
version = "1.0.3"
5+
version = "1.0.4"
66
}
77
}
88
}

examples/flash-firmware/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
turingpi = {
44
source = "jfreed-dev/turingpi"
5-
version = "1.0.3"
5+
version = "1.0.4"
66
}
77
}
88
}

examples/full-provisioning/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
turingpi = {
44
source = "jfreed-dev/turingpi"
5-
version = "1.0.3"
5+
version = "1.0.4"
66
}
77
}
88
}

provider/auth.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"net/http"
87
)
98

109
func authenticate(endpoint, username, password string) (string, error) {
1110
url := fmt.Sprintf("%s/api/bmc/authenticate", endpoint)
1211
data := map[string]string{"username": username, "password": password}
1312
jsonData, _ := json.Marshal(data)
1413

15-
resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData))
14+
resp, err := HTTPClient.Post(url, "application/json", bytes.NewBuffer(jsonData))
1615
if err != nil {
1716
return "", err
1817
}

provider/helpers.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"time"
99
)
1010

11+
// Note: Uses HTTPClient from provider.go for TLS configuration
12+
1113
func checkPowerStatus(node int) string {
1214
// Simulate checking power status
1315
fmt.Printf("Checking power status for node %d\n", node)
@@ -32,7 +34,6 @@ func flashNode(node int, firmware string) {
3234

3335
func checkBootStatus(endpoint string, node int, timeout int, token string) (bool, error) {
3436
url := fmt.Sprintf("%s/api/bmc?opt=get&type=uart&node=%d", endpoint, node)
35-
client := &http.Client{}
3637

3738
deadline := time.Now().Add(time.Duration(timeout) * time.Second)
3839

@@ -43,7 +44,7 @@ func checkBootStatus(endpoint string, node int, timeout int, token string) (bool
4344
}
4445

4546
req.Header.Set("Authorization", "Bearer "+token)
46-
resp, err := client.Do(req)
47+
resp, err := HTTPClient.Do(req)
4748
if err != nil {
4849
return false, fmt.Errorf("UART request failed: %v", err)
4950
}

provider/provider.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
package provider
22

33
import (
4+
"crypto/tls"
5+
"net/http"
6+
47
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
58
)
69

710
const defaultEndpoint = "https://turingpi.local"
811

12+
// HTTPClient is the shared HTTP client for all API requests
13+
var HTTPClient = &http.Client{}
14+
915
// ProviderConfig holds the configuration for the provider
1016
type ProviderConfig struct {
1117
Token string
@@ -34,6 +40,12 @@ func Provider() *schema.Provider {
3440
DefaultFunc: schema.EnvDefaultFunc("TURINGPI_ENDPOINT", defaultEndpoint),
3541
Description: "The BMC API endpoint URL (e.g., https://turingpi.local or https://192.168.1.100)",
3642
},
43+
"insecure": {
44+
Type: schema.TypeBool,
45+
Optional: true,
46+
DefaultFunc: schema.EnvDefaultFunc("TURINGPI_INSECURE", false),
47+
Description: "Skip TLS certificate verification (useful for self-signed or expired certificates)",
48+
},
3749
},
3850
ResourcesMap: map[string]*schema.Resource{
3951
"turingpi_power": resourcePower(),
@@ -48,6 +60,16 @@ func configureProvider(d *schema.ResourceData) (interface{}, error) {
4860
username := d.Get("username").(string)
4961
password := d.Get("password").(string)
5062
endpoint := d.Get("endpoint").(string)
63+
insecure := d.Get("insecure").(bool)
64+
65+
// Configure HTTP client with TLS settings
66+
if insecure {
67+
HTTPClient = &http.Client{
68+
Transport: &http.Transport{
69+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
70+
},
71+
}
72+
}
5173

5274
token, err := authenticate(endpoint, username, password)
5375
if err != nil {

0 commit comments

Comments
 (0)