@@ -13,7 +13,7 @@ import (
1313func resourceAppdataDsource () * schema.Resource {
1414 return & schema.Resource {
1515 // This description is used by the documentation generator and the language server.
16- Description : "Resource for app data dsource creation." ,
16+ Description : "Resource for appdata dSource creation." ,
1717
1818 CreateContext : resourceAppdataDsourceCreate ,
1919 ReadContext : resourceAppdataDsourceRead ,
@@ -331,7 +331,9 @@ func toSourceOperationArray(array interface{}) []dctapi.SourceOperation {
331331 for _ , item := range array .([]interface {}) {
332332 item_map := item .(map [string ]interface {})
333333 sourceOperation := dctapi .NewSourceOperation (item_map ["name" ].(string ), item_map ["command" ].(string ))
334- sourceOperation .SetShell (item_map ["shell" ].(string ))
334+ if item_map ["shell" ].(string ) != "" {
335+ sourceOperation .SetShell (item_map ["shell" ].(string ))
336+ }
335337 sourceOperation .SetCredentialsEnvVars (toCredentialsEnvVariableArray (item_map ["credentials_env_vars" ]))
336338 items = append (items , * sourceOperation )
337339 }
@@ -342,17 +344,38 @@ func toCredentialsEnvVariableArray(array interface{}) []dctapi.CredentialsEnvVar
342344 items := []dctapi.CredentialsEnvVariable {}
343345 for _ , item := range array .([]interface {}) {
344346 item_map := item .(map [string ]interface {})
347+
345348 credentialsEnvVariable_item := dctapi .NewCredentialsEnvVariable (item_map ["base_var_name" ].(string ))
346- credentialsEnvVariable_item .SetPassword (item_map ["password" ].(string ))
347- credentialsEnvVariable_item .SetVault (item_map ["vault" ].(string ))
348- credentialsEnvVariable_item .SetHashicorpVaultEngine (item_map ["hashicorp_vault_engine" ].(string ))
349- credentialsEnvVariable_item .SetHashicorpVaultEngine (item_map ["hashicorp_vault_secret_path" ].(string ))
350- credentialsEnvVariable_item .SetHashicorpVaultEngine (item_map ["hashicorp_vault_username_key" ].(string ))
351- credentialsEnvVariable_item .SetHashicorpVaultEngine (item_map ["hashicorp_vault_secret_key" ].(string ))
352- credentialsEnvVariable_item .SetHashicorpVaultEngine (item_map ["azure_vault_name" ].(string ))
353- credentialsEnvVariable_item .SetHashicorpVaultEngine (item_map ["azure_vault_username_key" ].(string ))
354- credentialsEnvVariable_item .SetHashicorpVaultEngine (item_map ["azure_vault_secret_key" ].(string ))
355- credentialsEnvVariable_item .SetHashicorpVaultEngine (item_map ["cyberark_vault_query_string" ].(string ))
349+ if item_map ["password" ].(string ) != "" {
350+ credentialsEnvVariable_item .SetPassword (item_map ["password" ].(string ))
351+ }
352+ if item_map ["vault" ].(string ) != "" {
353+ credentialsEnvVariable_item .SetVault (item_map ["vault" ].(string ))
354+ }
355+ if item_map ["hashicorp_vault_engine" ].(string ) != "" {
356+ credentialsEnvVariable_item .SetHashicorpVaultEngine (item_map ["hashicorp_vault_engine" ].(string ))
357+ }
358+ if item_map ["hashicorp_vault_secret_path" ].(string ) != "" {
359+ credentialsEnvVariable_item .SetHashicorpVaultSecretPath (item_map ["hashicorp_vault_secret_path" ].(string ))
360+ }
361+ if item_map ["hashicorp_vault_username_key" ].(string ) != "" {
362+ credentialsEnvVariable_item .SetHashicorpVaultUsernameKey (item_map ["hashicorp_vault_username_key" ].(string ))
363+ }
364+ if item_map ["hashicorp_vault_secret_key" ].(string ) != "" {
365+ credentialsEnvVariable_item .SetHashicorpVaultSecretKey (item_map ["hashicorp_vault_secret_key" ].(string ))
366+ }
367+ if item_map ["azure_vault_name" ].(string ) != "" {
368+ credentialsEnvVariable_item .SetAzureVaultName (item_map ["azure_vault_name" ].(string ))
369+ }
370+ if item_map ["azure_vault_username_key" ].(string ) != "" {
371+ credentialsEnvVariable_item .SetAzureVaultUsernameKey (item_map ["azure_vault_username_key" ].(string ))
372+ }
373+ if item_map ["azure_vault_secret_key" ].(string ) != "" {
374+ credentialsEnvVariable_item .SetAzureVaultSecretKey (item_map ["azure_vault_secret_key" ].(string ))
375+ }
376+ if item_map ["cyberark_vault_query_string" ].(string ) != "" {
377+ credentialsEnvVariable_item .SetCyberarkVaultQueryString (item_map ["cyberark_vault_query_string" ].(string ))
378+ }
356379 items = append (items , * credentialsEnvVariable_item )
357380 }
358381 return items
@@ -470,10 +493,10 @@ func resourceAppdataDsourceRead(ctx context.Context, d *schema.ResourceData, met
470493 })
471494 // This would imply error in poll for deletion so we just log and exit.
472495 if diags != nil {
473- ErrorLog .Printf ("Error in polling of Dsource for deletion." )
496+ ErrorLog .Printf ("Error in polling of appdata dSource for deletion." )
474497 } else {
475498 // diags will be nill in case of successful poll for deletion logic aka 404
476- ErrorLog .Printf ("Error reading the Dsource %s, removing from state." , dsource_id )
499+ ErrorLog .Printf ("Error reading the appdata dSource %s, removing from state." , dsource_id )
477500 d .SetId ("" )
478501 }
479502
@@ -519,7 +542,7 @@ func resourceAppdataDsourceUpdate(ctx context.Context, d *schema.ResourceData, m
519542 d .Set (key , old )
520543 }
521544
522- return diag .Errorf ("not implemented" )
545+ return diag .Errorf ("Action update not implemented for resource : appdata dsource " )
523546}
524547
525548func resourceAppdataDsourceDelete (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
@@ -542,7 +565,7 @@ func resourceAppdataDsourceDelete(ctx context.Context, d *schema.ResourceData, m
542565 }
543566 InfoLog .Printf ("Job result is %s" , job_status )
544567 if isJobTerminalFailure (job_status ) {
545- return diag .Errorf ("[NOT OK] Dsource -Delete %s. JobId: %s / Error: %s" , job_status , * res .Id , job_err )
568+ return diag .Errorf ("[NOT OK] Appdata dSource -Delete %s. JobId: %s / Error: %s" , job_status , * res .Id , job_err )
546569 }
547570
548571 _ , diags := PollForObjectDeletion (func () (interface {}, * http.Response , error ) {
0 commit comments