@@ -3,7 +3,6 @@ package connect
3
3
import (
4
4
"fmt"
5
5
"log"
6
- "time"
7
6
8
7
"github.com/hashicorp/terraform/helper/schema"
9
8
kc "github.com/ricardo-ch/go-kafka-connect/lib/connectors"
@@ -52,19 +51,11 @@ func setNameFromID(d *schema.ResourceData, meta interface{}) ([]*schema.Resource
52
51
}
53
52
54
53
func connectorCreate (d * schema.ResourceData , meta interface {}) error {
55
- c := meta .(kc.Client )
54
+ c := meta .(kc.HighLevelClient )
56
55
name := nameFromRD (d )
57
56
58
57
config , sensitiveCache := configFromRD (d )
59
- if ! kc .TryUntil (
60
- func () bool {
61
- _ , err := c .GetAll ()
62
- return err == nil
63
- },
64
- 5 * time .Minute ,
65
- ) {
66
- return fmt .Errorf ("timed out trying to connect to kafka-connect server at %s" , c .URL )
67
- }
58
+
68
59
req := kc.CreateConnectorRequest {
69
60
ConnectorRequest : kc.ConnectorRequest {
70
61
Name : name ,
@@ -87,7 +78,7 @@ func connectorCreate(d *schema.ResourceData, meta interface{}) error {
87
78
}
88
79
89
80
func connectorDelete (d * schema.ResourceData , meta interface {}) error {
90
- c := meta .(kc.Client )
81
+ c := meta .(kc.HighLevelClient )
91
82
92
83
name := nameFromRD (d )
93
84
req := kc.ConnectorRequest {
@@ -105,7 +96,7 @@ func connectorDelete(d *schema.ResourceData, meta interface{}) error {
105
96
}
106
97
107
98
func connectorUpdate (d * schema.ResourceData , meta interface {}) error {
108
- c := meta .(kc.Client )
99
+ c := meta .(kc.HighLevelClient )
109
100
110
101
name := nameFromRD (d )
111
102
@@ -135,7 +126,7 @@ func connectorUpdate(d *schema.ResourceData, meta interface{}) error {
135
126
}
136
127
137
128
func connectorRead (d * schema.ResourceData , meta interface {}) error {
138
- c := meta .(kc.Client )
129
+ c := meta .(kc.HighLevelClient )
139
130
140
131
config , sensitiveCache := configFromRD (d )
141
132
name := d .Get ("name" ).(string )
@@ -166,7 +157,7 @@ func connectorRead(d *schema.ResourceData, meta interface{}) error {
166
157
// The first is intended to be passed to CreateConnectorRequest
167
158
// The second is intended to preserve knowledge of which keys are sensitive information in the incoming
168
159
// ConnectorResponse.Config
169
- func configFromRD (d * schema.ResourceData ) (map [string ]string , map [string ]string ) {
160
+ func configFromRD (d * schema.ResourceData ) (map [string ]interface {} , map [string ]interface {} ) {
170
161
cfg := mapFromRD (d , "config" )
171
162
scfg := mapFromRD (d , "config_sensitive" )
172
163
config := combineMaps (cfg , scfg )
@@ -177,18 +168,13 @@ func nameFromRD(d *schema.ResourceData) string {
177
168
return d .Get ("name" ).(string )
178
169
}
179
170
180
- func mapFromRD (d * schema.ResourceData , key string ) map [string ]string {
181
- mapToBe := d .Get (key ).(map [string ]interface {})
182
- realMap := make (map [string ]string )
183
- for k , v := range mapToBe {
184
- realMap [k ] = v .(string )
185
- }
186
- return realMap
171
+ func mapFromRD (d * schema.ResourceData , key string ) map [string ]interface {} {
172
+ return d .Get (key ).(map [string ]interface {})
187
173
}
188
174
189
175
// if there are duplicate keys this will always take the kv from second!!!
190
- func combineMaps (first map [string ]string , second map [string ]string ) map [string ]string {
191
- union := make (map [string ]string )
176
+ func combineMaps (first map [string ]interface {} , second map [string ]interface {} ) map [string ]interface {} {
177
+ union := make (map [string ]interface {} )
192
178
for k , v := range first {
193
179
union [k ] = v
194
180
}
@@ -198,7 +184,7 @@ func combineMaps(first map[string]string, second map[string]string) map[string]s
198
184
return union
199
185
}
200
186
201
- func removeSecondKeysFromFirst (first map [string ]string , second map [string ]string ) map [string ]string {
187
+ func removeSecondKeysFromFirst (first map [string ]interface {} , second map [string ]interface {} ) map [string ]interface {} {
202
188
for k := range second {
203
189
delete (first , k )
204
190
}
0 commit comments