Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Mongey committed May 8, 2024
2 parents 2097a51 + da0448f commit 7db3283
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 111 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3.2.0
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16.x
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v4.1.0
uses: crazy-max/ghaction-import-gpg@v5.2.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- uses: actions/cache@v2.1.7
- uses: actions/cache@v3.3.1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --rm-dist
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3.2.0
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16.x
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v4.1.0
uses: crazy-max/ghaction-import-gpg@v5.2.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- uses: actions/cache@v2.1.7
- uses: actions/cache@v3.3.1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --snapshot --rm-dist
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3.2.0
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16.x
- run: make test
Expand All @@ -24,12 +24,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3.2.0
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16.x
- uses: actions/cache@v2.1.7
- uses: actions/cache@v3.3.1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand Down
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ builds:
goarch: '386'
- goos: freebsd
goarch: 'arm64'
- goos: windows
goarch: 'arm64'
archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ resource "kafka-connect_connector" "sqlite-sink" {
| `tls_auth_crt` | String | "certificate" | `KAFKA_CONNECT_TLS_AUTH_CRT` |
| `tls_auth_key` | String | "Key" | `KAFKA_CONNECT_TLS_AUTH_KEY` |
| `tls_auth_is_insecure`| String | "Key" | `KAFKA_CONNECT_TLS_IS_INSECURE` |
| `headers` | Map[String]String | {foo = "bar"} | N/A |

## Resource Properties

Expand Down
28 changes: 23 additions & 5 deletions connect/provider.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package connect

import (
"crypto/tls"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
kc "github.com/ricardo-ch/go-kafka-connect/lib/connectors"
"context"
"crypto/tls"
"log"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

kc "github.com/ricardo-ch/go-kafka-connect/v3/lib/connectors"
)

func Provider() *schema.Provider {
Expand Down Expand Up @@ -40,9 +44,17 @@ func Provider() *schema.Provider {
Type: schema.TypeBool,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("KAFKA_CONNECT_TLS_IS_INSECURE", ""),
"headers": {
Type: schema.TypeMap,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Optional: true,
// No DefaultFunc here to read from the env on account of this issue:
// https://github.com/hashicorp/terraform-plugin-sdk/issues/142
},
},
ConfigureFunc: providerConfigure,
ConfigureContextFunc: providerConfigure,
ResourcesMap: map[string]*schema.Resource{
"kafka-connect_connector": kafkaConnectorResource(),
},
Expand All @@ -51,7 +63,7 @@ func Provider() *schema.Provider {
return &provider
}

func providerConfigure(d *schema.ResourceData) (interface{}, error) {
func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
log.Printf("[INFO] Initializing KafkaConnect client")
addr := d.Get("url").(string)
c := kc.NewClient(addr)
Expand All @@ -78,6 +90,12 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
c.SetClientCertificates(cert)
}
}
headers := d.Get("headers").(map[string]interface{})
if headers != nil {
for k, v := range headers {
c.SetHeader(k, v.(string))
}
}

return c, nil
}
2 changes: 1 addition & 1 deletion connect/resource_kafka_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
kc "github.com/ricardo-ch/go-kafka-connect/lib/connectors"
kc "github.com/ricardo-ch/go-kafka-connect/v3/lib/connectors"
)

func kafkaConnectorResource() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion connect/resource_kafka_connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

r "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
kc "github.com/ricardo-ch/go-kafka-connect/lib/connectors"
kc "github.com/ricardo-ch/go-kafka-connect/v3/lib/connectors"
)

func TestAccConnectorConfigUpdate(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.16
require (
bou.ke/monkey v1.0.2 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1
github.com/ricardo-ch/go-kafka-connect v0.0.0-20200928094249-af7817721cb5
github.com/ricardo-ch/go-kafka-connect/v3 v3.0.0-20220613085032-a69a6c33b847
)

replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999
Loading

0 comments on commit 7db3283

Please sign in to comment.