Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling ssl #32

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ jobs:
name: Run linter
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v3
-
name: Set up Go
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"
cache: true

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"
cache: true
version: v1.49.0
only-new-issues: true
version: v1.53
only-new-issues: true
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/drfaust92/terraform-provider-airflow

go 1.19
go 1.20

require (
github.com/apache/airflow-client-go/airflow v0.0.0-20230210234754-8ce0b39cfbb2
Expand Down
17 changes: 16 additions & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package provider

import (
"context"
"crypto/tls"
"fmt"
"log"
"net/http"
Expand Down Expand Up @@ -54,6 +55,11 @@ func AirflowProvider() *schema.Provider {
RequiredWith: []string{"username"},
ConflictsWith: []string{"oauth2_token"},
},
"disable_ssl_verification": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
ResourcesMap: map[string]*schema.Resource{
"airflow_connection": resourceConnection(),
Expand All @@ -75,7 +81,16 @@ func AirflowProvider() *schema.Provider {
}

func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
transport := logging.NewLoggingHTTPTransport(http.DefaultTransport)
var transport http.RoundTripper

if disableSSl := d.Get("disable_ssl_verification").(bool); disableSSl {
transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
} else {
transport = logging.NewLoggingHTTPTransport(http.DefaultTransport)
}

client := &http.Client{
Transport: transport,
}
Expand Down