Skip to content

Commit

Permalink
Merge pull request #21 from tlvince/scheme
Browse files Browse the repository at this point in the history
feat: add configurable http scheme
  • Loading branch information
zaquestion authored Mar 13, 2019
2 parents c53f882 + 9484fcd commit d1cc358
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
22 changes: 12 additions & 10 deletions docs/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
```
# Configure the NiFi provider
provider "nifi" {
host = "localhost:8080"
api_path = "nifi-api"
admin_cert = "certs/nifi.crt"
admin_key = "certs/nifi.key"
host = "localhost:8080"
api_path = "nifi-api"
admin_cert = "certs/nifi.crt"
admin_key = "certs/nifi.key"
http_scheme = "http"
}
```

## Argument Reference

The following arguments are supported:

Argument | Required | Description
---------------|----------|------------
**host** | Yes | NiFi host including port, e.g. `localhost:8080`.
**api_path** | No | API path prefix, e.g. `nifi-api`. Defaults to that.
**admin_cert** | No | Path to certificate used to access admin. Provider will use HTTPS only if this is specified.
**admin_key** | No | Path to certificate's key, required if `admin_cert` is specified.
Argument | Required | Description
-----------------|----------|------------
**host** | Yes | NiFi host including port, e.g. `localhost:8080`.
**api_path** | No | API path prefix, e.g. `nifi-api`. Defaults to that.
**admin_cert** | No | Path to certificate used to access admin. Provider will use HTTPS only if this is specified.
**admin_key** | No | Path to certificate's key, required if `admin_cert` is specified.
**http_scheme** | No | Force a HTTP scheme. Useful if NiFi does not handle SSL termination. Defaults to `http`, unless `admin_cert` and `admin_key` are set, in which case `https` is used.
2 changes: 1 addition & 1 deletion nifi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Client struct {

func NewClient(config Config) *Client {
httpClient := &http.Client{}
scheme := "http"
scheme := config.HttpScheme
if config.AdminCertPath != "" && config.AdminKeyPath != "" {
cert, err := tls.LoadX509KeyPair(config.AdminCertPath, config.AdminKeyPath)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions nifi/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ type Config struct {
ApiPath string
AdminCertPath string
AdminKeyPath string
HttpScheme string
}
7 changes: 6 additions & 1 deletion nifi/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ func Provider() terraform.ResourceProvider {
Required: true,
DefaultFunc: schema.EnvDefaultFunc("NIFI_HOST", nil),
},

"http_scheme": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("NIFI_HTTP_SCHEME", "http"),
},
"api_path": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -52,6 +56,7 @@ func Provider() terraform.ResourceProvider {
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := Config{
Host: d.Get("host").(string),
HttpScheme: d.Get("http_scheme").(string),
ApiPath: d.Get("api_path").(string),
AdminCertPath: d.Get("admin_cert").(string),
AdminKeyPath: d.Get("admin_key").(string),
Expand Down

0 comments on commit d1cc358

Please sign in to comment.