@@ -82,22 +82,28 @@ func (r *sourceResource) getSourceConfig(data *resource_source.SourceModel) (uns
8282 }
8383
8484 if ! data .S3 .Anonymous .IsNull () && ! data .S3 .Anonymous .IsUnknown () {
85- config .Anonymous = & []bool {data .S3 .Anonymous .ValueBool ()}[0 ]
85+ anonymous := data .S3 .Anonymous .ValueBool ()
86+ config .Anonymous = & anonymous
8687 }
8788 if ! data .S3 .Key .IsNull () && ! data .S3 .Key .IsUnknown () {
88- config .Key = & []string {data .S3 .Key .ValueString ()}[0 ]
89+ key := data .S3 .Key .ValueString ()
90+ config .Key = & key
8991 }
9092 if ! data .S3 .Secret .IsNull () && ! data .S3 .Secret .IsUnknown () {
91- config .Secret = & []string {data .S3 .Secret .ValueString ()}[0 ]
93+ secret := data .S3 .Secret .ValueString ()
94+ config .Secret = & secret
9295 }
9396 if ! data .S3 .Token .IsNull () && ! data .S3 .Token .IsUnknown () {
94- config .Token = & []string {data .S3 .Token .ValueString ()}[0 ]
97+ token := data .S3 .Token .ValueString ()
98+ config .Token = & token
9599 }
96100 if ! data .S3 .EndpointUrl .IsNull () && ! data .S3 .EndpointUrl .IsUnknown () {
97- config .EndpointURL = & []string {data .S3 .EndpointUrl .ValueString ()}[0 ]
101+ endpointUrl := data .S3 .EndpointUrl .ValueString ()
102+ config .EndpointURL = & endpointUrl
98103 }
99104 if ! data .S3 .Recursive .IsNull () && ! data .S3 .Recursive .IsUnknown () {
100- config .Recursive = & []bool {data .S3 .Recursive .ValueBool ()}[0 ]
105+ recursive := data .S3 .Recursive .ValueBool ()
106+ config .Recursive = & recursive
101107 }
102108
103109 return config , nil
@@ -112,7 +118,10 @@ func (r *sourceResource) getSourceConfig(data *resource_source.SourceModel) (uns
112118 Password : data .Postgres .Password .ValueString (),
113119 TableName : data .Postgres .TableName .ValueString (),
114120 BatchSize : int (data .Postgres .BatchSize .ValueInt64 ()),
115- IDColumn : & []string {data .Postgres .IdColumn .ValueString ()}[0 ],
121+ }
122+ if ! data .Postgres .IdColumn .IsNull () && ! data .Postgres .IdColumn .IsUnknown () {
123+ idColumn := data .Postgres .IdColumn .ValueString ()
124+ config .IDColumn = & idColumn
116125 }
117126
118127 // Convert fields list
@@ -127,16 +136,22 @@ func (r *sourceResource) getSourceConfig(data *resource_source.SourceModel) (uns
127136
128137 if ! data .Azure .IsNull () {
129138 config := & unstructured.AzureSourceConnectorConfigInput {
130- RemoteURL : data .Azure .RemoteUrl .ValueString (),
131- ConnectionString : & []string {data .Azure .ConnectionString .ValueString ()}[0 ],
139+ RemoteURL : data .Azure .RemoteUrl .ValueString (),
140+ }
141+ if ! data .Azure .ConnectionString .IsNull () && ! data .Azure .ConnectionString .IsUnknown () {
142+ connectionString := data .Azure .ConnectionString .ValueString ()
143+ config .ConnectionString = & connectionString
132144 }
133145 return config , nil
134146 }
135147
136148 if ! data .GoogleDrive .IsNull () {
137149 config := & unstructured.GoogleDriveSourceConnectorConfigInput {
138- DriveID : data .GoogleDrive .DriveId .ValueString (),
139- ServiceAccountKey : & []string {data .GoogleDrive .ServiceAccountKey .ValueString ()}[0 ],
150+ DriveID : data .GoogleDrive .DriveId .ValueString (),
151+ }
152+ if ! data .GoogleDrive .ServiceAccountKey .IsNull () && ! data .GoogleDrive .ServiceAccountKey .IsUnknown () {
153+ serviceAccountKey := data .GoogleDrive .ServiceAccountKey .ValueString ()
154+ config .ServiceAccountKey = & serviceAccountKey
140155 }
141156
142157 if ! data .GoogleDrive .Extensions .IsNull () && ! data .GoogleDrive .Extensions .IsUnknown () {
@@ -145,7 +160,8 @@ func (r *sourceResource) getSourceConfig(data *resource_source.SourceModel) (uns
145160 config .Extensions = extensions
146161 }
147162 if ! data .GoogleDrive .Recursive .IsNull () && ! data .GoogleDrive .Recursive .IsUnknown () {
148- config .Recursive = & []bool {data .GoogleDrive .Recursive .ValueBool ()}[0 ]
163+ recursive := data .GoogleDrive .Recursive .ValueBool ()
164+ config .Recursive = & recursive
149165 }
150166
151167 return config , nil
@@ -195,9 +211,8 @@ func (r *sourceResource) Create(ctx context.Context, req resource.CreateRequest,
195211
196212 // Create the source
197213 source , err := r .client .CreateSource (ctx , unstructured.CreateSourceRequest {
198- Name : data .Name .ValueString (),
199- Description : "Created by Terraform" ,
200- Config : config ,
214+ Name : data .Name .ValueString (),
215+ Config : config ,
201216 })
202217 if err != nil {
203218 resp .Diagnostics .AddError ("Error creating source" , err .Error ())
@@ -262,7 +277,7 @@ func (r *sourceResource) Update(ctx context.Context, req resource.UpdateRequest,
262277 }
263278
264279 // Update the source
265- source , err := r .client .UpdateSource (ctx , state . Id . ValueString (), unstructured.UpdateSourceRequest {
280+ source , err := r .client .UpdateSource (ctx , unstructured.UpdateSourceRequest {
266281 Config : config ,
267282 })
268283 if err != nil {
0 commit comments