From 390b5b4b9a235822a989754e554f709cc70f9227 Mon Sep 17 00:00:00 2001 From: VaishnaviGopal Date: Wed, 9 Oct 2024 11:36:34 +0530 Subject: [PATCH 1/7] Removed debug log statements with err and response in schematics --- .../data_source_ibm_schematics_action.go | 3 +-- .../data_source_ibm_schematics_agent.go | 3 +-- .../data_source_ibm_schematics_agent_deploy.go | 3 +-- .../data_source_ibm_schematics_agent_health.go | 3 +-- .../data_source_ibm_schematics_agent_prs.go | 3 +-- .../data_source_ibm_schematics_agents.go | 5 ++--- .../data_source_ibm_schematics_inventory.go | 3 +-- .../data_source_ibm_schematics_job.go | 3 +-- .../data_source_ibm_schematics_output.go | 3 +-- .../data_source_ibm_schematics_policies.go | 5 ++--- .../data_source_ibm_schematics_policy.go | 3 +-- ...ata_source_ibm_schematics_resource_query.go | 3 +-- .../data_source_ibm_schematics_state.go | 3 +-- .../data_source_ibm_schematics_workspace.go | 5 ++--- .../resource_ibm_schematics_action.go | 9 ++++----- .../resource_ibm_schematics_agent.go | 18 +++++++++--------- .../resource_ibm_schematics_agent_deploy.go | 6 +++--- .../resource_ibm_schematics_agent_health.go | 7 +++---- .../resource_ibm_schematics_agent_prs.go | 7 +++---- .../resource_ibm_schematics_inventory.go | 9 ++++----- .../schematics/resource_ibm_schematics_job.go | 9 ++++----- .../resource_ibm_schematics_policy.go | 9 ++++----- .../resource_ibm_schematics_resource_query.go | 9 ++++----- .../resource_ibm_schematics_workspace.go | 13 ++++++------- 24 files changed, 61 insertions(+), 83 deletions(-) diff --git a/ibm/service/schematics/data_source_ibm_schematics_action.go b/ibm/service/schematics/data_source_ibm_schematics_action.go index ad97052fa1..ee8ef9c81b 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_action.go +++ b/ibm/service/schematics/data_source_ibm_schematics_action.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" @@ -962,7 +961,7 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour action, response, err := schematicsClient.GetActionWithContext(context, getActionOptions) if err != nil { - log.Printf("[DEBUG] GetActionWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetActionWithContext failed %s\n%s", err, response)) } diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent.go b/ibm/service/schematics/data_source_ibm_schematics_agent.go index f11932e05f..9014edeed2 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -548,7 +547,7 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc agentData, response, err := schematicsClient.GetAgentDataWithContext(context, getAgentDataOptions) if err != nil { - log.Printf("[DEBUG] GetAgentDataWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) } diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go b/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go index ebc1cafde8..13a9eff0b3 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -89,7 +88,7 @@ func dataSourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.R d.SetId(DataSourceIBMSchematicsAgentID(d)) return nil } - log.Printf("[DEBUG] GetAgentDataWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) } d.SetId(DataSourceIBMSchematicsAgentID(d)) diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_health.go b/ibm/service/schematics/data_source_ibm_schematics_agent_health.go index 637d819706..c934b6b767 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_health.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_health.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -84,7 +83,7 @@ func dataSourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.R d.SetId(DataSourceIBMSchematicsAgentID(d)) return nil } - log.Printf("[DEBUG] GetAgentDataWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) } d.SetId(DataSourceIBMSchematicsAgentID(d)) diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go b/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go index d54b38d38c..78ae8a04ce 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -84,7 +83,7 @@ func dataSourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.Reso d.SetId(DataSourceIBMSchematicsAgentID(d)) return nil } - log.Printf("[DEBUG] GetAgentDataWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) } d.SetId(DataSourceIBMSchematicsAgentID(d)) diff --git a/ibm/service/schematics/data_source_ibm_schematics_agents.go b/ibm/service/schematics/data_source_ibm_schematics_agents.go index 2b37171461..fa28b4266d 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agents.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agents.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -195,7 +194,7 @@ func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.Resour agentList, response, err := schematicsClient.ListAgentWithContext(context, listAgentOptions) if err != nil { - log.Printf("[DEBUG] ListAgentWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("ListAgentWithContext failed %s\n%s", err, response)) } @@ -219,7 +218,7 @@ func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.Resour if suppliedFilter { if len(agentList.Agents) == 0 { - log.Printf("[DEBUG] no Agents found with name %s\n", name) + // return diag.FromErr(fmt.Errorf("no Agents found with name %s", name)) } d.SetId(name) diff --git a/ibm/service/schematics/data_source_ibm_schematics_inventory.go b/ibm/service/schematics/data_source_ibm_schematics_inventory.go index bbd7746e25..dbf8dac007 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_inventory.go +++ b/ibm/service/schematics/data_source_ibm_schematics_inventory.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" @@ -108,7 +107,7 @@ func dataSourceIBMSchematicsInventoryRead(context context.Context, d *schema.Res inventoryResourceRecord, response, err := schematicsClient.GetInventoryWithContext(context, getInventoryOptions) if err != nil { - log.Printf("[DEBUG] GetInventoryWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetInventoryWithContext failed %s\n%s", err, response)) } diff --git a/ibm/service/schematics/data_source_ibm_schematics_job.go b/ibm/service/schematics/data_source_ibm_schematics_job.go index 64f35170d5..a841baf911 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_job.go +++ b/ibm/service/schematics/data_source_ibm_schematics_job.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" @@ -2831,7 +2830,7 @@ func dataSourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceD job, response, err := schematicsClient.GetJobWithContext(context, getJobOptions) if err != nil { - log.Printf("[DEBUG] GetJobWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetJobWithContext failed %s\n%s", err, response)) } diff --git a/ibm/service/schematics/data_source_ibm_schematics_output.go b/ibm/service/schematics/data_source_ibm_schematics_output.go index 0e46b0c9c9..4cc417d8e2 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_output.go +++ b/ibm/service/schematics/data_source_ibm_schematics_output.go @@ -6,7 +6,6 @@ package schematics import ( "encoding/json" "fmt" - "log" "time" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -76,7 +75,7 @@ func dataSourceIBMSchematicsOutputRead(d *schema.ResourceData, meta interface{}) outputValuesList, response, err := schematicsClient.GetWorkspaceOutputs(getWorkspaceOutputsOptions) if err != nil { - log.Printf("[DEBUG] GetWorkspaceOutputs failed %s\n%s", err, response) + return err } diff --git a/ibm/service/schematics/data_source_ibm_schematics_policies.go b/ibm/service/schematics/data_source_ibm_schematics_policies.go index 7cfe407d0e..05434ee9e7 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_policies.go +++ b/ibm/service/schematics/data_source_ibm_schematics_policies.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -152,7 +151,7 @@ func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.Reso policyList, response, err := schematicsClient.ListPolicyWithContext(context, listPolicyOptions) if err != nil { - log.Printf("[DEBUG] ListPolicyWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("ListPolicyWithContext failed %s\n%s", err, response)) } @@ -178,7 +177,7 @@ func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.Reso if suppliedFilter { if len(policyList.Policies) == 0 { - log.Printf("[DEBUG] no Policies found with policyKind %s\n", policyKind) + // return diag.FromErr(fmt.Errorf("no Policies found with policyKind %s", policyKind)) } d.SetId(policyKind) diff --git a/ibm/service/schematics/data_source_ibm_schematics_policy.go b/ibm/service/schematics/data_source_ibm_schematics_policy.go index 5bab24dfe2..cde67bc38c 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_policy.go +++ b/ibm/service/schematics/data_source_ibm_schematics_policy.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -277,7 +276,7 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour policy, response, err := schematicsClient.GetPolicyWithContext(context, getPolicyOptions) if err != nil { - log.Printf("[DEBUG] GetPolicyWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetPolicyWithContext failed %s\n%s", err, response)) } diff --git a/ibm/service/schematics/data_source_ibm_schematics_resource_query.go b/ibm/service/schematics/data_source_ibm_schematics_resource_query.go index d9625ba981..ba87c73356 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_resource_query.go +++ b/ibm/service/schematics/data_source_ibm_schematics_resource_query.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" @@ -133,7 +132,7 @@ func dataSourceIBMSchematicsResourceQueryRead(context context.Context, d *schema resourceQueryRecord, response, err := schematicsClient.GetResourcesQueryWithContext(context, getResourcesQueryOptions) if err != nil { - log.Printf("[DEBUG] GetResourcesQueryWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetResourcesQueryWithContext failed %s\n%s", err, response)) } diff --git a/ibm/service/schematics/data_source_ibm_schematics_state.go b/ibm/service/schematics/data_source_ibm_schematics_state.go index c66d1145ce..a8eb19de1f 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_state.go +++ b/ibm/service/schematics/data_source_ibm_schematics_state.go @@ -8,7 +8,6 @@ import ( "context" "encoding/json" "fmt" - "log" "time" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -76,7 +75,7 @@ func dataSourceIBMSchematicsStateRead(context context.Context, d *schema.Resourc _, response, _ := schematicsClient.GetWorkspaceTemplateStateWithContext(context, getWorkspaceTemplateStateOptions) if response.StatusCode != 200 { - log.Printf("[DEBUG] GetWorkspaceTemplateStateWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetWorkspaceTemplateStateWithContext failed %s\n%s", err, response)) } diff --git a/ibm/service/schematics/data_source_ibm_schematics_workspace.go b/ibm/service/schematics/data_source_ibm_schematics_workspace.go index 7e59232d2f..c190aa40b8 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_workspace.go +++ b/ibm/service/schematics/data_source_ibm_schematics_workspace.go @@ -7,7 +7,6 @@ import ( "context" "encoding/json" "fmt" - "log" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" @@ -654,7 +653,7 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res workspaceResponse, response, err := schematicsClient.GetWorkspaceWithContext(context, getWorkspaceOptions) if err != nil { - log.Printf("[DEBUG] GetWorkspaceWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetWorkspaceWithContext failed %s\n%s", err, response)) } @@ -863,7 +862,7 @@ func dataSourceWorkspaceResponseCatalogRefToMap(catalogRefItem schematicsv1.Cata if catalogRefItem.ServiceExtensions != nil { serviceExtensionsByte, err := json.MarshalIndent(catalogRefItem.ServiceExtensions, "", "") if err != nil { - log.Printf("[DEBUG] Marshelling of service extensions failed %s", err) + } serviceExtensionsJSON := string(serviceExtensionsByte[:]) catalogRefMap["service_extensions"] = serviceExtensionsJSON diff --git a/ibm/service/schematics/resource_ibm_schematics_action.go b/ibm/service/schematics/resource_ibm_schematics_action.go index cf291e7807..ea3537eed2 100644 --- a/ibm/service/schematics/resource_ibm_schematics_action.go +++ b/ibm/service/schematics/resource_ibm_schematics_action.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "strings" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -1077,7 +1076,7 @@ func resourceIBMSchematicsActionCreate(context context.Context, d *schema.Resour action, response, err := schematicsClient.CreateActionWithContext(context, createActionOptions) if err != nil { - log.Printf("[DEBUG] CreateActionWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreateActionWithContext failed %s\n%s", err, response)) } @@ -1352,7 +1351,7 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource d.SetId("") return nil } - log.Printf("[DEBUG] GetActionWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetActionWithContext failed %s\n%s", err, response)) } if err = d.Set("name", action.Name); err != nil { @@ -1907,7 +1906,7 @@ func resourceIBMSchematicsActionUpdate(context context.Context, d *schema.Resour if hasChange { _, response, err := schematicsClient.UpdateActionWithContext(context, updateActionOptions) if err != nil { - log.Printf("[DEBUG] UpdateActionWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("UpdateActionWithContext failed %s\n%s", err, response)) } } @@ -1932,7 +1931,7 @@ func resourceIBMSchematicsActionDelete(context context.Context, d *schema.Resour response, err := schematicsClient.DeleteActionWithContext(context, deleteActionOptions) if err != nil { - log.Printf("[DEBUG] DeleteActionWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeleteActionWithContext failed %s\n%s", err, response)) } diff --git a/ibm/service/schematics/resource_ibm_schematics_agent.go b/ibm/service/schematics/resource_ibm_schematics_agent.go index 5dd0150fe9..d1db6270ed 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent.go @@ -613,7 +613,7 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc agentData, response, err := schematicsClient.CreateAgentDataWithContext(context, createAgentDataOptions) if err != nil { - log.Printf("[DEBUG] CreateAgentDataWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreateAgentDataWithContext failed %s\n%s", err, response)) } @@ -640,7 +640,7 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD d.SetId("") return nil } - log.Printf("[DEBUG] GetAgentDataWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) } @@ -836,7 +836,7 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc d.SetId("") return nil } - log.Printf("[DEBUG] GetAgentDataWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) } if agentData.Name != nil { @@ -927,18 +927,18 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc response, err := schematicsClient.DeleteAgentResourcesWithContext(context, deleteAgentResourcesOptions) if err != nil { - log.Printf("[DEBUG] DeleteAgentResourcesWithContext failed %s\n%s", err, response) + } else { _, err = isWaitForAgentDestroyResources(context, schematicsClient, *deleteAgentResourcesOptions.AgentID, d.Timeout(schema.TimeoutUpdate)) if err != nil { - log.Printf("[DEBUG] waiting for agent deploy resources to be destroyed has failed %s", err) + } } } if hasChange { _, response, err := schematicsClient.UpdateAgentDataWithContext(context, updateAgentDataOptions) if err != nil { - log.Printf("[DEBUG] UpdateAgentDataWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("UpdateAgentDataWithContext failed %s\n%s", err, response)) } } @@ -979,11 +979,11 @@ func resourceIbmSchematicsAgentDelete(context context.Context, d *schema.Resourc response, err := schematicsClient.DeleteAgentResourcesWithContext(context, deleteAgentResourcesOptions) if err != nil { - log.Printf("[DEBUG] DeleteAgentResourcesWithContext failed %s\n%s", err, response) + } else { _, err = isWaitForAgentDestroyResources(context, schematicsClient, *deleteAgentResourcesOptions.AgentID, d.Timeout(schema.TimeoutDelete)) if err != nil { - log.Printf("[DEBUG] waiting for agent deploy resources to be destroyed has failed %s", err) + } } @@ -991,7 +991,7 @@ func resourceIbmSchematicsAgentDelete(context context.Context, d *schema.Resourc deleteresponse, err := schematicsClient.DeleteAgentDataWithContext(context, deleteAgentDataOptions) if err != nil { - log.Printf("[DEBUG] DeleteAgentDataWithContext failed %s\n%s", err, deleteresponse) + return diag.FromErr(fmt.Errorf("DeleteAgentDataWithContext failed %s\n%s", err, deleteresponse)) } diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go b/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go index 5610a01ef6..31e43a4b1b 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go @@ -113,7 +113,7 @@ func resourceIbmSchematicsAgentDeployCreate(context context.Context, d *schema.R agentDeployJob, response, err := schematicsClient.DeployAgentJobWithContext(context, deployAgentJobOptions) if err != nil { - log.Printf("[DEBUG] DeployAgentJobWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeployAgentJobWithContext failed %s\n%s", err, response)) } @@ -191,7 +191,7 @@ func resourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.Res d.SetId("") return nil } - log.Printf("[DEBUG] GetAgentDataWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) } if agentData.RecentDeployJob != nil { @@ -264,7 +264,7 @@ func resourceIbmSchematicsAgentDeployUpdate(context context.Context, d *schema.R if hasChange { agentDeployJob, response, err := schematicsClient.DeployAgentJobWithContext(context, deployAgentJobOptions) if err != nil { - log.Printf("[DEBUG] DeployAgentJobWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeployAgentJobWithContext failed %s\n%s", err, response)) } d.SetId(fmt.Sprintf("%s/%s", *deployAgentJobOptions.AgentID, *agentDeployJob.JobID)) diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_health.go b/ibm/service/schematics/resource_ibm_schematics_agent_health.go index a0765c75d9..a4c147081d 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_health.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_health.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -102,7 +101,7 @@ func resourceIbmSchematicsAgentHealthCreate(context context.Context, d *schema.R agentHealthJob, response, err := schematicsClient.HealthCheckAgentJobWithContext(context, healthCheckAgentJobOptions) if err != nil { - log.Printf("[DEBUG] HealthCheckAgentJobWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("HealthCheckAgentJobWithContext failed %s\n%s", err, response)) } @@ -134,7 +133,7 @@ func resourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.Res d.SetId("") return nil } - log.Printf("[DEBUG] GetAgentDataWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) } @@ -210,7 +209,7 @@ func resourceIbmSchematicsAgentHealthUpdate(context context.Context, d *schema.R if hasChange { agentHealthJob, response, err := schematicsClient.HealthCheckAgentJobWithContext(context, healthCheckAgentJobOptions) if err != nil { - log.Printf("[DEBUG] HealthCheckAgentJobWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("HealthCheckAgentJobWithContext failed %s\n%s", err, response)) } d.SetId(fmt.Sprintf("%s/%s", *healthCheckAgentJobOptions.AgentID, *agentHealthJob.JobID)) diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_prs.go b/ibm/service/schematics/resource_ibm_schematics_agent_prs.go index 73032e4bc3..1ef6768155 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_prs.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_prs.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -101,7 +100,7 @@ func resourceIbmSchematicsAgentPrsCreate(context context.Context, d *schema.Reso agentPrsJob, response, err := schematicsClient.PrsAgentJobWithContext(context, prsAgentJobOptions) if err != nil { - log.Printf("[DEBUG] PrsAgentJobWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("PrsAgentJobWithContext failed %s\n%s", err, response)) } @@ -133,7 +132,7 @@ func resourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.Resour d.SetId("") return nil } - log.Printf("[DEBUG] GetAgentDataWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) } if agentData.RecentPrsJob != nil { @@ -207,7 +206,7 @@ func resourceIbmSchematicsAgentPrsUpdate(context context.Context, d *schema.Reso if hasChange { agentPrsJob, response, err := schematicsClient.PrsAgentJobWithContext(context, prsAgentJobOptions) if err != nil { - log.Printf("[DEBUG] PrsAgentJobWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("PrsAgentJobWithContext failed %s\n%s", err, response)) } d.SetId(fmt.Sprintf("%s/%s", *prsAgentJobOptions.AgentID, *agentPrsJob.JobID)) diff --git a/ibm/service/schematics/resource_ibm_schematics_inventory.go b/ibm/service/schematics/resource_ibm_schematics_inventory.go index 77b7e70630..64910b9694 100644 --- a/ibm/service/schematics/resource_ibm_schematics_inventory.go +++ b/ibm/service/schematics/resource_ibm_schematics_inventory.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "strings" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -144,7 +143,7 @@ func resourceIBMSchematicsInventoryCreate(context context.Context, d *schema.Res inventoryResourceRecord, response, err := schematicsClient.CreateInventoryWithContext(context, createInventoryOptions) if err != nil { - log.Printf("[DEBUG] CreateInventoryWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreateInventoryWithContext failed %s\n%s", err, response)) } @@ -175,7 +174,7 @@ func resourceIBMSchematicsInventoryRead(context context.Context, d *schema.Resou d.SetId("") return nil } - log.Printf("[DEBUG] GetInventoryWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetInventoryWithContext failed %s\n%s", err, response)) } if err = d.Set("name", inventoryResourceRecord.Name); err != nil { @@ -265,7 +264,7 @@ func resourceIBMSchematicsInventoryUpdate(context context.Context, d *schema.Res if hasChange { _, response, err := schematicsClient.ReplaceInventoryWithContext(context, updateInventoryOptions) if err != nil { - log.Printf("[DEBUG] UpdateInventoryWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("UpdateInventoryWithContext failed %s\n%s", err, response)) } } @@ -290,7 +289,7 @@ func resourceIBMSchematicsInventoryDelete(context context.Context, d *schema.Res response, err := schematicsClient.DeleteInventoryWithContext(context, deleteInventoryOptions) if err != nil { - log.Printf("[DEBUG] DeleteInventoryWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeleteInventoryWithContext failed %s\n%s", err, response)) } diff --git a/ibm/service/schematics/resource_ibm_schematics_job.go b/ibm/service/schematics/resource_ibm_schematics_job.go index 4893b8b7ae..9f9a08f2a6 100644 --- a/ibm/service/schematics/resource_ibm_schematics_job.go +++ b/ibm/service/schematics/resource_ibm_schematics_job.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "strings" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -2938,7 +2937,7 @@ func resourceIBMSchematicsJobCreate(context context.Context, d *schema.ResourceD job, response, err := schematicsClient.CreateJobWithContext(context, createJobOptions) if err != nil { - log.Printf("[DEBUG] CreateJobWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreateJobWithContext failed %s\n%s", err, response)) } @@ -3921,7 +3920,7 @@ func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceDat d.SetId("") return nil } - log.Printf("[DEBUG] GetJobWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetJobWithContext failed %s\n%s", err, response)) } if err = d.Set("command_object", job.CommandObject); err != nil { @@ -5061,7 +5060,7 @@ func resourceIBMSchematicsJobUpdate(context context.Context, d *schema.ResourceD _, response, err := schematicsClient.UpdateJobWithContext(context, updateJobOptions) if err != nil { - log.Printf("[DEBUG] UpdateJobWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("UpdateJobWithContext failed %s\n%s", err, response)) } @@ -5094,7 +5093,7 @@ func resourceIBMSchematicsJobDelete(context context.Context, d *schema.ResourceD response, err := schematicsClient.DeleteJobWithContext(context, deleteJobOptions) if err != nil { - log.Printf("[DEBUG] DeleteJobWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeleteJobWithContext failed %s\n%s", err, response)) } diff --git a/ibm/service/schematics/resource_ibm_schematics_policy.go b/ibm/service/schematics/resource_ibm_schematics_policy.go index 6d065fcfab..949e911ff5 100644 --- a/ibm/service/schematics/resource_ibm_schematics_policy.go +++ b/ibm/service/schematics/resource_ibm_schematics_policy.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -349,7 +348,7 @@ func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.Resour policy, response, err := schematicsClient.CreatePolicyWithContext(context, createPolicyOptions) if err != nil { - log.Printf("[DEBUG] CreatePolicyWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreatePolicyWithContext failed %s\n%s", err, response)) } @@ -374,7 +373,7 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource d.SetId("") return nil } - log.Printf("[DEBUG] GetPolicyWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetPolicyWithContext failed %s\n%s", err, response)) } @@ -521,7 +520,7 @@ func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.Resour if hasChange { _, response, err := schematicsClient.UpdatePolicyWithContext(context, updatePolicyOptions) if err != nil { - log.Printf("[DEBUG] UpdatePolicyWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("UpdatePolicyWithContext failed %s\n%s", err, response)) } } @@ -541,7 +540,7 @@ func resourceIbmSchematicsPolicyDelete(context context.Context, d *schema.Resour response, err := schematicsClient.DeletePolicyWithContext(context, deletePolicyOptions) if err != nil { - log.Printf("[DEBUG] DeletePolicyWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeletePolicyWithContext failed %s\n%s", err, response)) } diff --git a/ibm/service/schematics/resource_ibm_schematics_resource_query.go b/ibm/service/schematics/resource_ibm_schematics_resource_query.go index ab9817a1be..4b450fd0ea 100644 --- a/ibm/service/schematics/resource_ibm_schematics_resource_query.go +++ b/ibm/service/schematics/resource_ibm_schematics_resource_query.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "strings" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -166,7 +165,7 @@ func resourceIBMSchematicsResourceQueryCreate(context context.Context, d *schema resourceQueryRecord, response, err := schematicsClient.CreateResourceQueryWithContext(context, createResourceQueryOptions) if err != nil { - log.Printf("[DEBUG] CreateResourceQueryWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreateResourceQueryWithContext failed %s\n%s", err, response)) } @@ -237,7 +236,7 @@ func resourceIBMSchematicsResourceQueryRead(context context.Context, d *schema.R d.SetId("") return nil } - log.Printf("[DEBUG] GetResourcesQueryWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetResourcesQueryWithContext failed %s\n%s", err, response)) } if err = d.Set("type", resourceQueryRecord.Type); err != nil { @@ -342,7 +341,7 @@ func resourceIBMSchematicsResourceQueryUpdate(context context.Context, d *schema _, response, err := schematicsClient.ReplaceResourcesQueryWithContext(context, replaceResourcesQueryOptions) if err != nil { - log.Printf("[DEBUG] ReplaceResourcesQueryWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("ReplaceResourcesQueryWithContext failed %s\n%s", err, response)) } @@ -366,7 +365,7 @@ func resourceIBMSchematicsResourceQueryDelete(context context.Context, d *schema response, err := schematicsClient.DeleteResourcesQueryWithContext(context, deleteResourcesQueryOptions) if err != nil { - log.Printf("[DEBUG] DeleteResourcesQueryWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeleteResourcesQueryWithContext failed %s\n%s", err, response)) } diff --git a/ibm/service/schematics/resource_ibm_schematics_workspace.go b/ibm/service/schematics/resource_ibm_schematics_workspace.go index bbd89ddf2f..abea785fca 100644 --- a/ibm/service/schematics/resource_ibm_schematics_workspace.go +++ b/ibm/service/schematics/resource_ibm_schematics_workspace.go @@ -6,7 +6,6 @@ package schematics import ( "context" "fmt" - "log" "strings" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -753,7 +752,7 @@ func resourceIBMSchematicsWorkspaceCreate(context context.Context, d *schema.Res workspaceResponse, response, err := schematicsClient.CreateWorkspaceWithContext(context, createWorkspaceOptions) if err != nil { - log.Printf("[DEBUG] CreateWorkspaceWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreateWorkspaceWithContext failed %s\n%s", err, response)) } @@ -1095,7 +1094,7 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou d.SetId("") return nil } - log.Printf("[DEBUG] GetWorkspaceWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetWorkspaceWithContext failed %s\n%s", err, response)) } if workspaceResponse.AppliedShareddataIds != nil { @@ -1814,7 +1813,7 @@ func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.Res changed = true _, response, err := schematicsClient.ReplaceWorkspaceWithContext(context, replaceWorkspaceOptions) if err != nil { - log.Printf("[DEBUG] ReplaceWorkspaceWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("ReplaceWorkspaceWithContext failed %s\n%s", err, response)) } } @@ -1822,7 +1821,7 @@ func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.Res if !changed && metadataChange { _, response, err := schematicsClient.UpdateWorkspaceWithContext(context, updateWorkspaceOptions) if err != nil { - log.Printf("[DEBUG] UpdateWorkspaceWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("UpdateWorkspaceWithContext failed %s\n%s", err, response)) } } @@ -1849,7 +1848,7 @@ func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.Res _, response, err := schematicsClient.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptions) if err != nil { - log.Printf("[DEBUG] ReplaceWorkspaceInputs failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("ReplaceWorkspaceInputs failed %s\n%s", err, response)) } } @@ -1885,7 +1884,7 @@ func resourceIBMSchematicsWorkspaceDelete(context context.Context, d *schema.Res _, response, err := schematicsClient.DeleteWorkspaceWithContext(context, deleteWorkspaceOptions) if err != nil { - log.Printf("[DEBUG] DeleteWorkspaceWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeleteWorkspaceWithContext failed %s\n%s", err, response)) } From aa972928cfee9a07e99479296af0f58a00905243 Mon Sep 17 00:00:00 2001 From: VaishnaviGopal Date: Wed, 9 Oct 2024 11:53:30 +0530 Subject: [PATCH 2/7] updated diag.FromErr(err) return statements --- .../data_source_ibm_schematics_action.go | 5 +- .../data_source_ibm_schematics_agent.go | 41 ++++++--- ...data_source_ibm_schematics_agent_deploy.go | 5 +- ...data_source_ibm_schematics_agent_health.go | 5 +- .../data_source_ibm_schematics_agent_prs.go | 5 +- .../data_source_ibm_schematics_agents.go | 9 +- .../data_source_ibm_schematics_inventory.go | 5 +- .../data_source_ibm_schematics_job.go | 5 +- .../data_source_ibm_schematics_policies.go | 9 +- .../data_source_ibm_schematics_policy.go | 21 +++-- ...ta_source_ibm_schematics_resource_query.go | 5 +- .../data_source_ibm_schematics_state.go | 13 ++- .../data_source_ibm_schematics_workspace.go | 9 +- .../resource_ibm_schematics_action.go | 17 +++- .../resource_ibm_schematics_agent.go | 84 ++++++++++++++----- .../resource_ibm_schematics_agent_deploy.go | 28 +++++-- .../resource_ibm_schematics_agent_health.go | 29 +++++-- .../resource_ibm_schematics_agent_prs.go | 29 +++++-- .../resource_ibm_schematics_inventory.go | 17 +++- .../schematics/resource_ibm_schematics_job.go | 29 +++++-- .../resource_ibm_schematics_policy.go | 61 ++++++++++---- .../resource_ibm_schematics_resource_query.go | 17 +++- .../resource_ibm_schematics_workspace.go | 21 +++-- 23 files changed, 357 insertions(+), 112 deletions(-) diff --git a/ibm/service/schematics/data_source_ibm_schematics_action.go b/ibm/service/schematics/data_source_ibm_schematics_action.go index ee8ef9c81b..137ed060e1 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_action.go +++ b/ibm/service/schematics/data_source_ibm_schematics_action.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" @@ -946,7 +947,9 @@ func DataSourceIBMSchematicsAction() *schema.Resource { func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if r, ok := d.GetOk("location"); ok { region := r.(string) diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent.go b/ibm/service/schematics/data_source_ibm_schematics_agent.go index 9014edeed2..7aacb89642 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -536,7 +537,9 @@ func DataSourceIbmSchematicsAgent() *schema.Resource { func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getAgentDataOptions := &schematicsv1.GetAgentDataOptions{ @@ -585,7 +588,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.AgentInfrastructure != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentInfrastructureToMap(agentData.AgentInfrastructure) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentInfrastructure = append(agentInfrastructure, modelMap) } @@ -598,7 +603,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc for _, modelItem := range agentData.AgentMetadata { modelMap, err := dataSourceIbmSchematicsAgentAgentMetadataInfoToMap(&modelItem) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentMetadata = append(agentMetadata, modelMap) } @@ -612,7 +619,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc for _, modelItem := range agentData.AgentInputs { modelMap, err := dataSourceIbmSchematicsAgentVariableDataToMap(&modelItem) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentInputs = append(agentInputs, modelMap) } @@ -625,7 +634,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.UserState != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentUserStateToMap(agentData.UserState) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } userState = append(userState, modelMap) } @@ -661,7 +672,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.SystemState != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentSystemStatusToMap(agentData.SystemState) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } systemState = append(systemState, modelMap) } @@ -673,7 +686,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.AgentKpi != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentKPIDataToMap(agentData.AgentKpi) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentKpi = append(agentKpi, modelMap) } @@ -685,7 +700,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.RecentPrsJob != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentDataRecentPrsJobToMap(agentData.RecentPrsJob) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } recentPrsJob = append(recentPrsJob, modelMap) } @@ -697,7 +714,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.RecentDeployJob != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentDataRecentDeployJobToMap(agentData.RecentDeployJob) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } recentDeployJob = append(recentDeployJob, modelMap) } @@ -709,7 +728,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.RecentHealthJob != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentDataRecentHealthJobToMap(agentData.RecentHealthJob) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } recentHealthJob = append(recentHealthJob, modelMap) } diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go b/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go index 13a9eff0b3..a5613ffd09 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -74,7 +75,9 @@ func dataSourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.R schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getAgentDataOptions := &schematicsv1.GetAgentDataOptions{ diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_health.go b/ibm/service/schematics/data_source_ibm_schematics_agent_health.go index c934b6b767..20b45589ac 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_health.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_health.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -69,7 +70,9 @@ func dataSourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.R schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getAgentDataOptions := &schematicsv1.GetAgentDataOptions{ diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go b/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go index 78ae8a04ce..950312a5bb 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -69,7 +70,9 @@ func DataSourceIbmSchematicsAgentPrs() *schema.Resource { func dataSourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getAgentDataOptions := &schematicsv1.GetAgentDataOptions{ diff --git a/ibm/service/schematics/data_source_ibm_schematics_agents.go b/ibm/service/schematics/data_source_ibm_schematics_agents.go index fa28b4266d..f1ca157284 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agents.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agents.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -187,7 +188,9 @@ func DataSourceIbmSchematicsAgents() *schema.Resource { func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } listAgentOptions := &schematicsv1.ListAgentOptions{} @@ -243,7 +246,9 @@ func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.Resour for _, modelItem := range agentList.Agents { modelMap, err := dataSourceIbmSchematicsAgentsAgentToMap(&modelItem) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agents = append(agents, modelMap) } diff --git a/ibm/service/schematics/data_source_ibm_schematics_inventory.go b/ibm/service/schematics/data_source_ibm_schematics_inventory.go index dbf8dac007..73e211db9e 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_inventory.go +++ b/ibm/service/schematics/data_source_ibm_schematics_inventory.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" @@ -91,7 +92,9 @@ func DataSourceIBMSchematicsInventory() *schema.Resource { func dataSourceIBMSchematicsInventoryRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if r, ok := d.GetOk("location"); ok { region := r.(string) diff --git a/ibm/service/schematics/data_source_ibm_schematics_job.go b/ibm/service/schematics/data_source_ibm_schematics_job.go index a841baf911..a4aef5f7a6 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_job.go +++ b/ibm/service/schematics/data_source_ibm_schematics_job.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" @@ -2815,7 +2816,9 @@ func DataSourceIBMSchematicsJob() *schema.Resource { func dataSourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if r, ok := d.GetOk("location"); ok { region := r.(string) diff --git a/ibm/service/schematics/data_source_ibm_schematics_policies.go b/ibm/service/schematics/data_source_ibm_schematics_policies.go index 05434ee9e7..81bd750d06 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_policies.go +++ b/ibm/service/schematics/data_source_ibm_schematics_policies.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -144,7 +145,9 @@ func DataSourceIbmSchematicsPolicies() *schema.Resource { func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } listPolicyOptions := &schematicsv1.ListPolicyOptions{} @@ -202,7 +205,9 @@ func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.Reso for _, modelItem := range policyList.Policies { modelMap, err := dataSourceIbmSchematicsPoliciesPolicyLiteToMap(&modelItem) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } policies = append(policies, modelMap) } diff --git a/ibm/service/schematics/data_source_ibm_schematics_policy.go b/ibm/service/schematics/data_source_ibm_schematics_policy.go index cde67bc38c..2f6dd54e84 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_policy.go +++ b/ibm/service/schematics/data_source_ibm_schematics_policy.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -267,7 +268,9 @@ func DataSourceIbmSchematicsPolicy() *schema.Resource { func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getPolicyOptions := &schematicsv1.GetPolicyOptions{} @@ -302,7 +305,9 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour if policy.State != nil { modelMap, err := dataSourceIbmSchematicsPolicyUserStateToMap(policy.State) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } state = append(state, modelMap) } @@ -323,7 +328,9 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour if policy.Target != nil { modelMap, err := dataSourceIbmSchematicsPolicyPolicyObjectsToMap(policy.Target) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } target = append(target, modelMap) } @@ -335,7 +342,9 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour if policy.Parameter != nil { modelMap, err := dataSourceIbmSchematicsPolicyPolicyParameterToMap(policy.Parameter) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } parameter = append(parameter, modelMap) } @@ -360,7 +369,9 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour for _, modelItem := range policy.ScopedResources { modelMap, err := dataSourceIbmSchematicsPolicyScopedResourceToMap(&modelItem) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } scopedResources = append(scopedResources, modelMap) } diff --git a/ibm/service/schematics/data_source_ibm_schematics_resource_query.go b/ibm/service/schematics/data_source_ibm_schematics_resource_query.go index ba87c73356..ddada4e4e1 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_resource_query.go +++ b/ibm/service/schematics/data_source_ibm_schematics_resource_query.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" @@ -116,7 +117,9 @@ func DataSourceIBMSchematicsResourceQuery() *schema.Resource { func dataSourceIBMSchematicsResourceQueryRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if r, ok := d.GetOk("location"); ok { diff --git a/ibm/service/schematics/data_source_ibm_schematics_state.go b/ibm/service/schematics/data_source_ibm_schematics_state.go index a8eb19de1f..7bdc0c7880 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_state.go +++ b/ibm/service/schematics/data_source_ibm_schematics_state.go @@ -8,6 +8,7 @@ import ( "context" "encoding/json" "fmt" + "log" "time" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -58,7 +59,9 @@ func DataSourceIBMSchematicsState() *schema.Resource { func dataSourceIBMSchematicsStateRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if r, ok := d.GetOk("location"); ok { region := r.(string) @@ -95,7 +98,9 @@ func dataSourceIBMSchematicsStateRead(context context.Context, d *schema.Resourc stateByte, err := json.MarshalIndent(stateStore, "", "") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } stateStoreJSON := string(stateByte[:]) @@ -103,7 +108,9 @@ func dataSourceIBMSchematicsStateRead(context context.Context, d *schema.Resourc controller, err := flex.GetBaseController(meta) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.Set(flex.ResourceControllerURL, controller+"/schematics") diff --git a/ibm/service/schematics/data_source_ibm_schematics_workspace.go b/ibm/service/schematics/data_source_ibm_schematics_workspace.go index c190aa40b8..690e633c41 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_workspace.go +++ b/ibm/service/schematics/data_source_ibm_schematics_workspace.go @@ -7,6 +7,7 @@ import ( "context" "encoding/json" "fmt" + "log" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" @@ -637,7 +638,9 @@ func SchematicsEndpointURL(region, meta interface{}) (string, bool, error) { func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if r, ok := d.GetOk("location"); ok { region := r.(string) @@ -814,7 +817,9 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res controller, err := flex.GetBaseController(meta) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.Set(flex.ResourceControllerURL, controller+"/schematics") diff --git a/ibm/service/schematics/resource_ibm_schematics_action.go b/ibm/service/schematics/resource_ibm_schematics_action.go index ea3537eed2..1feb149116 100644 --- a/ibm/service/schematics/resource_ibm_schematics_action.go +++ b/ibm/service/schematics/resource_ibm_schematics_action.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "strings" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -977,7 +978,9 @@ func ResourceIBMSchematicsActionValidator() *validate.ResourceValidator { func resourceIBMSchematicsActionCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if r, ok := d.GetOk("location"); ok { region := r.(string) @@ -1333,7 +1336,9 @@ func resourceIBMSchematicsActionMapToSystemLock(systemLockMap map[string]interfa func resourceIBMSchematicsActionRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } actionIDSplit := strings.Split(d.Id(), ".") region := actionIDSplit[0] @@ -1781,7 +1786,9 @@ func resourceIBMSchematicsActionSystemLockToMap(systemLock schematicsv1.SystemLo func resourceIBMSchematicsActionUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } actionIDSplit := strings.Split(d.Id(), ".") region := actionIDSplit[0] @@ -1917,7 +1924,9 @@ func resourceIBMSchematicsActionUpdate(context context.Context, d *schema.Resour func resourceIBMSchematicsActionDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } actionIDSplit := strings.Split(d.Id(), ".") region := actionIDSplit[0] diff --git a/ibm/service/schematics/resource_ibm_schematics_agent.go b/ibm/service/schematics/resource_ibm_schematics_agent.go index d1db6270ed..452d5a8488 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent.go @@ -558,7 +558,9 @@ func ResourceIbmSchematicsAgent() *schema.Resource { func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createAgentDataOptions := &schematicsv1.CreateAgentDataOptions{} @@ -570,7 +572,9 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc createAgentDataOptions.SetAgentLocation(d.Get("agent_location").(string)) agentInfrastructureModel, err := resourceIbmSchematicsAgentMapToAgentInfrastructure(d.Get("agent_infrastructure.0").(map[string]interface{})) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createAgentDataOptions.SetAgentInfrastructure(agentInfrastructureModel) if _, ok := d.GetOk("description"); ok { @@ -585,7 +589,9 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc value := e.(map[string]interface{}) agentMetadataItem, err := resourceIbmSchematicsAgentMapToAgentMetadataInfo(value) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentMetadata = append(agentMetadata, *agentMetadataItem) } @@ -597,7 +603,9 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc value := e.(map[string]interface{}) agentInputsItem, err := resourceIbmSchematicsAgentMapToVariableData(value) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentInputs = append(agentInputs, *agentInputsItem) } @@ -606,7 +614,9 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc if _, ok := d.GetOk("user_state"); ok { userStateModel, err := resourceIbmSchematicsAgentMapToAgentUserState(d.Get("user_state.0").(map[string]interface{})) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createAgentDataOptions.SetUserState(userStateModel) } @@ -625,7 +635,9 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getAgentDataOptions := &schematicsv1.GetAgentDataOptions{ @@ -661,7 +673,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD } agentInfrastructureMap, err := resourceIbmSchematicsAgentAgentInfrastructureToMap(agentData.AgentInfrastructure) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("agent_infrastructure", []map[string]interface{}{agentInfrastructureMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting agent_infrastructure: %s", err)) @@ -679,7 +693,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD for _, agentMetadataItem := range agentData.AgentMetadata { agentMetadataItemMap, err := resourceIbmSchematicsAgentAgentMetadataInfoToMap(&agentMetadataItem) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentMetadata = append(agentMetadata, agentMetadataItemMap) } @@ -692,7 +708,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD for _, agentInputsItem := range agentData.AgentInputs { agentInputsItemMap, err := resourceIbmSchematicsAgentVariableDataToMap(&agentInputsItem) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentInputs = append(agentInputs, agentInputsItemMap) } @@ -703,7 +721,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD if agentData.UserState != nil { userStateMap, err := resourceIbmSchematicsAgentAgentUserStateToMap(agentData.UserState) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("user_state", []map[string]interface{}{userStateMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting user_state: %s", err)) @@ -712,7 +732,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD if agentData.AgentKpi != nil { agentKpiMap, err := resourceIbmSchematicsAgentAgentKPIDataToMap(agentData.AgentKpi) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("agent_kpi", []map[string]interface{}{agentKpiMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting agent_kpi: %s", err)) @@ -736,7 +758,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD if agentData.SystemState != nil { systemStateMap, err := resourceIbmSchematicsAgentAgentSystemStatusToMap(agentData.SystemState) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("system_state", []map[string]interface{}{systemStateMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting system_state: %s", err)) @@ -745,7 +769,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD if agentData.RecentPrsJob != nil { recentPrsJobMap, err := resourceIbmSchematicsAgentAgentDataRecentPrsJobToMap(agentData.RecentPrsJob) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("recent_prs_job", []map[string]interface{}{recentPrsJobMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting recent_prs_job: %s", err)) @@ -754,7 +780,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD if agentData.RecentDeployJob != nil { recentDeployJobMap, err := resourceIbmSchematicsAgentAgentDataRecentDeployJobToMap(agentData.RecentDeployJob) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("recent_deploy_job", []map[string]interface{}{recentDeployJobMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting recent_deploy_job: %s", err)) @@ -763,7 +791,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD if agentData.RecentHealthJob != nil { recentHealthJobMap, err := resourceIbmSchematicsAgentAgentDataRecentHealthJobToMap(agentData.RecentHealthJob) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("recent_health_job", []map[string]interface{}{recentHealthJobMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting recent_health_job: %s", err)) @@ -804,13 +834,17 @@ func agentDestroyRefreshFunc(schematicsClient *schematicsv1.SchematicsV1, id str func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } updateAgentDataOptions := &schematicsv1.UpdateAgentDataOptions{} session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } iamAccessToken := session.Config.IAMAccessToken iamRefreshToken := session.Config.IAMRefreshToken @@ -892,7 +926,9 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc if d.HasChange("agent_infrastructure") { agentInfrastructure, err := resourceIbmSchematicsAgentMapToAgentInfrastructure(d.Get("agent_infrastructure.0").(map[string]interface{})) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } updateAgentDataOptions.SetAgentInfrastructure(agentInfrastructure) hasChange = true @@ -911,7 +947,9 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc value := e.(map[string]interface{}) agentMetadataItem, err := resourceIbmSchematicsAgentMapToAgentMetadataInfo(value) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentMetadata = append(agentMetadata, *agentMetadataItem) } @@ -949,7 +987,9 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc func resourceIbmSchematicsAgentDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } deleteAgentDataOptions := &schematicsv1.DeleteAgentDataOptions{ @@ -957,7 +997,9 @@ func resourceIbmSchematicsAgentDelete(context context.Context, d *schema.Resourc } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } iamAccessToken := session.Config.IAMAccessToken iamRefreshToken := session.Config.IAMRefreshToken diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go b/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go index 31e43a4b1b..9af6ba3406 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go @@ -91,11 +91,15 @@ func ResourceIbmSchematicsAgentDeploy() *schema.Resource { func resourceIbmSchematicsAgentDeployCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } iamAccessToken := session.Config.IAMAccessToken iamRefreshToken := session.Config.IAMRefreshToken @@ -172,12 +176,16 @@ func agentRefreshFunc(schematicsClient *schematicsv1.SchematicsV1, id string) re func resourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getAgentDataOptions := &schematicsv1.GetAgentDataOptions{ @@ -228,11 +236,15 @@ func resourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.Res func resourceIbmSchematicsAgentDeployUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } iamAccessToken := session.Config.IAMAccessToken iamRefreshToken := session.Config.IAMRefreshToken @@ -245,7 +257,9 @@ func resourceIbmSchematicsAgentDeployUpdate(context context.Context, d *schema.R parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } deployAgentJobOptions.SetAgentID(parts[0]) diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_health.go b/ibm/service/schematics/resource_ibm_schematics_agent_health.go index a4c147081d..bd8ab75b8c 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_health.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_health.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -78,11 +79,15 @@ func ResourceIbmSchematicsAgentHealth() *schema.Resource { func resourceIbmSchematicsAgentHealthCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } iamAccessToken := session.Config.IAMAccessToken iamRefreshToken := session.Config.IAMRefreshToken @@ -113,12 +118,16 @@ func resourceIbmSchematicsAgentHealthCreate(context context.Context, d *schema.R func resourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getAgentDataOptions := &schematicsv1.GetAgentDataOptions{ @@ -172,11 +181,15 @@ func resourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.Res func resourceIbmSchematicsAgentHealthUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } iamAccessToken := session.Config.IAMAccessToken iamRefreshToken := session.Config.IAMRefreshToken @@ -190,7 +203,9 @@ func resourceIbmSchematicsAgentHealthUpdate(context context.Context, d *schema.R parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } healthCheckAgentJobOptions.SetAgentID(parts[0]) diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_prs.go b/ibm/service/schematics/resource_ibm_schematics_agent_prs.go index 1ef6768155..908c4cdce3 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_prs.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_prs.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -78,11 +79,15 @@ func ResourceIbmSchematicsAgentPrs() *schema.Resource { func resourceIbmSchematicsAgentPrsCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } iamAccessToken := session.Config.IAMAccessToken iamRefreshToken := session.Config.IAMRefreshToken @@ -112,12 +117,16 @@ func resourceIbmSchematicsAgentPrsCreate(context context.Context, d *schema.Reso func resourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getAgentDataOptions := &schematicsv1.GetAgentDataOptions{ @@ -169,11 +178,15 @@ func resourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.Resour func resourceIbmSchematicsAgentPrsUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } iamAccessToken := session.Config.IAMAccessToken iamRefreshToken := session.Config.IAMRefreshToken @@ -187,7 +200,9 @@ func resourceIbmSchematicsAgentPrsUpdate(context context.Context, d *schema.Reso parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } prsAgentJobOptions.SetAgentID(parts[0]) diff --git a/ibm/service/schematics/resource_ibm_schematics_inventory.go b/ibm/service/schematics/resource_ibm_schematics_inventory.go index 64910b9694..3d71df934e 100644 --- a/ibm/service/schematics/resource_ibm_schematics_inventory.go +++ b/ibm/service/schematics/resource_ibm_schematics_inventory.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "strings" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -111,7 +112,9 @@ func ResourceIBMSchematicsInventoryValidator() *validate.ResourceValidator { func resourceIBMSchematicsInventoryCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if r, ok := d.GetOk("location"); ok { region := r.(string) @@ -155,7 +158,9 @@ func resourceIBMSchematicsInventoryCreate(context context.Context, d *schema.Res func resourceIBMSchematicsInventoryRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } inventoryIDSplit := strings.Split(d.Id(), ".") region := inventoryIDSplit[0] @@ -216,7 +221,9 @@ func resourceIBMSchematicsInventoryRead(context context.Context, d *schema.Resou func resourceIBMSchematicsInventoryUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } inventoryIDSplit := strings.Split(d.Id(), ".") @@ -275,7 +282,9 @@ func resourceIBMSchematicsInventoryUpdate(context context.Context, d *schema.Res func resourceIBMSchematicsInventoryDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } inventoryIDSplit := strings.Split(d.Id(), ".") region := inventoryIDSplit[0] diff --git a/ibm/service/schematics/resource_ibm_schematics_job.go b/ibm/service/schematics/resource_ibm_schematics_job.go index 9f9a08f2a6..50cb78f8b6 100644 --- a/ibm/service/schematics/resource_ibm_schematics_job.go +++ b/ibm/service/schematics/resource_ibm_schematics_job.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "strings" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -2847,12 +2848,16 @@ func ResourceIBMSchematicsJobValidator() *validate.ResourceValidator { func resourceIBMSchematicsJobCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } iamRefreshToken := session.Config.IAMRefreshToken @@ -3902,7 +3907,9 @@ func resourceIBMSchematicsJobMapToJobLogSummarySystemJob(jobLogSummarySystemJobM func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } jobIDSplit := strings.Split(d.Id(), ".") region := jobIDSplit[0] @@ -4970,12 +4977,16 @@ func resourceIBMSchematicsJobJobLogSummarySystemJobToMap(jobLogSummarySystemJob func resourceIBMSchematicsJobUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } iamRefreshToken := session.Config.IAMRefreshToken @@ -5071,12 +5082,16 @@ func resourceIBMSchematicsJobDelete(context context.Context, d *schema.ResourceD session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } jobIDSplit := strings.Split(d.Id(), ".") region := jobIDSplit[0] diff --git a/ibm/service/schematics/resource_ibm_schematics_policy.go b/ibm/service/schematics/resource_ibm_schematics_policy.go index 949e911ff5..5ecffee628 100644 --- a/ibm/service/schematics/resource_ibm_schematics_policy.go +++ b/ibm/service/schematics/resource_ibm_schematics_policy.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -289,7 +290,9 @@ func ResourceIbmSchematicsPolicyValidator() *validate.ResourceValidator { func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createPolicyOptions := &schematicsv1.CreatePolicyOptions{} @@ -312,7 +315,9 @@ func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.Resour if _, ok := d.GetOk("state"); ok { stateModel, err := resourceIbmSchematicsPolicyMapToUserState(d.Get("state.0").(map[string]interface{})) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createPolicyOptions.SetState(stateModel) } @@ -322,14 +327,18 @@ func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.Resour if _, ok := d.GetOk("target"); ok { targetModel, err := resourceIbmSchematicsPolicyMapToPolicyObjects(d.Get("target.0").(map[string]interface{})) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createPolicyOptions.SetTarget(targetModel) } if _, ok := d.GetOk("parameter"); ok { parameterModel, err := resourceIbmSchematicsPolicyMapToPolicyParameter(d.Get("parameter.0").(map[string]interface{})) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createPolicyOptions.SetParameter(parameterModel) } @@ -339,7 +348,9 @@ func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.Resour value := e.(map[string]interface{}) scopedResourcesItem, err := resourceIbmSchematicsPolicyMapToScopedResource(value) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } scopedResources = append(scopedResources, *scopedResourcesItem) } @@ -360,7 +371,9 @@ func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.Resour func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getPolicyOptions := &schematicsv1.GetPolicyOptions{} @@ -397,7 +410,9 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource if policy.State != nil { stateMap, err := resourceIbmSchematicsPolicyUserStateToMap(policy.State) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("state", []map[string]interface{}{stateMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) @@ -409,7 +424,9 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource if policy.Target != nil { targetMap, err := resourceIbmSchematicsPolicyPolicyObjectsToMap(policy.Target) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("target", []map[string]interface{}{targetMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting target: %s", err)) @@ -418,7 +435,9 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource if policy.Parameter != nil { parameterMap, err := resourceIbmSchematicsPolicyPolicyParameterToMap(policy.Parameter) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("parameter", []map[string]interface{}{parameterMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting parameter: %s", err)) @@ -429,7 +448,9 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource for _, scopedResourcesItem := range policy.ScopedResources { scopedResourcesItemMap, err := resourceIbmSchematicsPolicyScopedResourceToMap(&scopedResourcesItem) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } scopedResources = append(scopedResources, scopedResourcesItemMap) } @@ -459,7 +480,9 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } updatePolicyOptions := &schematicsv1.UpdatePolicyOptions{} @@ -487,7 +510,9 @@ func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.Resour if d.HasChange("state") { state, err := resourceIbmSchematicsPolicyMapToUserState(d.Get("state.0").(map[string]interface{})) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } updatePolicyOptions.SetState(state) hasChange = true @@ -499,7 +524,9 @@ func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.Resour if d.HasChange("target") { target, err := resourceIbmSchematicsPolicyMapToPolicyObjects(d.Get("target.0").(map[string]interface{})) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } updatePolicyOptions.SetTarget(target) hasChange = true @@ -507,7 +534,9 @@ func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.Resour if d.HasChange("parameter") { parameter, err := resourceIbmSchematicsPolicyMapToPolicyParameter(d.Get("parameter.0").(map[string]interface{})) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } updatePolicyOptions.SetParameter(parameter) hasChange = true @@ -531,7 +560,9 @@ func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.Resour func resourceIbmSchematicsPolicyDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } deletePolicyOptions := &schematicsv1.DeletePolicyOptions{} diff --git a/ibm/service/schematics/resource_ibm_schematics_resource_query.go b/ibm/service/schematics/resource_ibm_schematics_resource_query.go index 4b450fd0ea..07da0415c4 100644 --- a/ibm/service/schematics/resource_ibm_schematics_resource_query.go +++ b/ibm/service/schematics/resource_ibm_schematics_resource_query.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "strings" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -136,7 +137,9 @@ func ResourceIBMSchematicsResourceQueryValidator() *validate.ResourceValidator { func resourceIBMSchematicsResourceQueryCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if r, ok := d.GetOk("location"); ok { region := r.(string) @@ -218,7 +221,9 @@ func resourceIBMSchematicsResourceQueryMapToResourceQueryParam(resourceQueryPara func resourceIBMSchematicsResourceQueryRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } actionIDSplit := strings.Split(d.Id(), ".") region := actionIDSplit[0] @@ -312,7 +317,9 @@ func resourceIBMSchematicsResourceQueryResourceQueryParamToMap(resourceQueryPara func resourceIBMSchematicsResourceQueryUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } actionIDSplit := strings.Split(d.Id(), ".") region := actionIDSplit[0] @@ -351,7 +358,9 @@ func resourceIBMSchematicsResourceQueryUpdate(context context.Context, d *schema func resourceIBMSchematicsResourceQueryDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } actionIDSplit := strings.Split(d.Id(), ".") region := actionIDSplit[0] diff --git a/ibm/service/schematics/resource_ibm_schematics_workspace.go b/ibm/service/schematics/resource_ibm_schematics_workspace.go index abea785fca..726939d160 100644 --- a/ibm/service/schematics/resource_ibm_schematics_workspace.go +++ b/ibm/service/schematics/resource_ibm_schematics_workspace.go @@ -6,6 +6,7 @@ package schematics import ( "context" "fmt" + "log" "strings" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -591,7 +592,9 @@ func ResourceIBMSchematicsWorkspaceValidator() *validate.ResourceValidator { func resourceIBMSchematicsWorkspaceCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if r, ok := d.GetOk("location"); ok { region := r.(string) @@ -1076,7 +1079,9 @@ func resourceIBMSchematicsWorkspaceMapToWorkspaceStatusUpdateRequest(workspaceSt func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } actionIDSplit := strings.Split(d.Id(), ".") region := actionIDSplit[0] @@ -1623,7 +1628,9 @@ func resourceIBMSchematicsWorkspaceWorkspaceStatusMessageToMap(workspaceStatusMe func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } actionIDSplit := strings.Split(d.Id(), ".") region := actionIDSplit[0] @@ -1862,12 +1869,16 @@ func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.Res func resourceIBMSchematicsWorkspaceDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } actionIDSplit := strings.Split(d.Id(), ".") region := actionIDSplit[0] From 65f4e695d7785835a204dd5ca40bef2f7297a7a9 Mon Sep 17 00:00:00 2001 From: VaishnaviGopal Date: Wed, 9 Oct 2024 12:02:50 +0530 Subject: [PATCH 3/7] updated diag.FromErr(fmt.Errorf) kind return statements in schematics --- .../data_source_ibm_schematics_action.go | 4 +++- .../data_source_ibm_schematics_agent.go | 4 +++- ...data_source_ibm_schematics_agent_deploy.go | 4 +++- ...data_source_ibm_schematics_agent_health.go | 4 +++- .../data_source_ibm_schematics_agent_prs.go | 4 +++- .../data_source_ibm_schematics_agents.go | 4 +++- .../data_source_ibm_schematics_inventory.go | 4 +++- .../data_source_ibm_schematics_job.go | 4 +++- .../data_source_ibm_schematics_policies.go | 4 +++- .../data_source_ibm_schematics_policy.go | 4 +++- ...ta_source_ibm_schematics_resource_query.go | 4 +++- .../data_source_ibm_schematics_state.go | 4 +++- .../data_source_ibm_schematics_workspace.go | 4 +++- .../resource_ibm_schematics_action.go | 16 +++++++++---- .../resource_ibm_schematics_agent.go | 16 +++++++++---- .../resource_ibm_schematics_agent_deploy.go | 12 +++++++--- .../resource_ibm_schematics_agent_health.go | 12 +++++++--- .../resource_ibm_schematics_agent_prs.go | 12 +++++++--- .../resource_ibm_schematics_inventory.go | 16 +++++++++---- .../schematics/resource_ibm_schematics_job.go | 16 +++++++++---- .../resource_ibm_schematics_policy.go | 16 +++++++++---- .../resource_ibm_schematics_resource_query.go | 16 +++++++++---- .../resource_ibm_schematics_workspace.go | 24 ++++++++++++++----- 23 files changed, 156 insertions(+), 52 deletions(-) diff --git a/ibm/service/schematics/data_source_ibm_schematics_action.go b/ibm/service/schematics/data_source_ibm_schematics_action.go index 137ed060e1..f7f41cf23f 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_action.go +++ b/ibm/service/schematics/data_source_ibm_schematics_action.go @@ -965,7 +965,9 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour action, response, err := schematicsClient.GetActionWithContext(context, getActionOptions) if err != nil { - return diag.FromErr(fmt.Errorf("GetActionWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*getActionOptions.ActionID) diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent.go b/ibm/service/schematics/data_source_ibm_schematics_agent.go index 7aacb89642..d40dad1ee4 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent.go @@ -551,7 +551,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc agentData, response, err := schematicsClient.GetAgentDataWithContext(context, getAgentDataOptions) if err != nil { - return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s", *getAgentDataOptions.AgentID)) diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go b/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go index a5613ffd09..d021a54129 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go @@ -92,7 +92,9 @@ func dataSourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.R return nil } - return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(DataSourceIBMSchematicsAgentID(d)) diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_health.go b/ibm/service/schematics/data_source_ibm_schematics_agent_health.go index 20b45589ac..dd575d7106 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_health.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_health.go @@ -87,7 +87,9 @@ func dataSourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.R return nil } - return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(DataSourceIBMSchematicsAgentID(d)) diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go b/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go index 950312a5bb..e97acdc071 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go @@ -87,7 +87,9 @@ func dataSourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.Reso return nil } - return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(DataSourceIBMSchematicsAgentID(d)) diff --git a/ibm/service/schematics/data_source_ibm_schematics_agents.go b/ibm/service/schematics/data_source_ibm_schematics_agents.go index f1ca157284..0cec697c2d 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agents.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agents.go @@ -198,7 +198,9 @@ func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.Resour agentList, response, err := schematicsClient.ListAgentWithContext(context, listAgentOptions) if err != nil { - return diag.FromErr(fmt.Errorf("ListAgentWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } // Use the provided filter argument and construct a new list with only the requested resource(s) diff --git a/ibm/service/schematics/data_source_ibm_schematics_inventory.go b/ibm/service/schematics/data_source_ibm_schematics_inventory.go index 73e211db9e..09215af81c 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_inventory.go +++ b/ibm/service/schematics/data_source_ibm_schematics_inventory.go @@ -111,7 +111,9 @@ func dataSourceIBMSchematicsInventoryRead(context context.Context, d *schema.Res inventoryResourceRecord, response, err := schematicsClient.GetInventoryWithContext(context, getInventoryOptions) if err != nil { - return diag.FromErr(fmt.Errorf("GetInventoryWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*getInventoryOptions.InventoryID) diff --git a/ibm/service/schematics/data_source_ibm_schematics_job.go b/ibm/service/schematics/data_source_ibm_schematics_job.go index a4aef5f7a6..f17754f70c 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_job.go +++ b/ibm/service/schematics/data_source_ibm_schematics_job.go @@ -2834,7 +2834,9 @@ func dataSourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceD job, response, err := schematicsClient.GetJobWithContext(context, getJobOptions) if err != nil { - return diag.FromErr(fmt.Errorf("GetJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*getJobOptions.JobID) diff --git a/ibm/service/schematics/data_source_ibm_schematics_policies.go b/ibm/service/schematics/data_source_ibm_schematics_policies.go index 81bd750d06..b78fe6e880 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_policies.go +++ b/ibm/service/schematics/data_source_ibm_schematics_policies.go @@ -155,7 +155,9 @@ func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.Reso policyList, response, err := schematicsClient.ListPolicyWithContext(context, listPolicyOptions) if err != nil { - return diag.FromErr(fmt.Errorf("ListPolicyWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } // Use the provided filter argument and construct a new list with only the requested resource(s) diff --git a/ibm/service/schematics/data_source_ibm_schematics_policy.go b/ibm/service/schematics/data_source_ibm_schematics_policy.go index 2f6dd54e84..1a3469be22 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_policy.go +++ b/ibm/service/schematics/data_source_ibm_schematics_policy.go @@ -280,7 +280,9 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour policy, response, err := schematicsClient.GetPolicyWithContext(context, getPolicyOptions) if err != nil { - return diag.FromErr(fmt.Errorf("GetPolicyWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s", *getPolicyOptions.PolicyID)) diff --git a/ibm/service/schematics/data_source_ibm_schematics_resource_query.go b/ibm/service/schematics/data_source_ibm_schematics_resource_query.go index ddada4e4e1..5869dfdf4d 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_resource_query.go +++ b/ibm/service/schematics/data_source_ibm_schematics_resource_query.go @@ -136,7 +136,9 @@ func dataSourceIBMSchematicsResourceQueryRead(context context.Context, d *schema resourceQueryRecord, response, err := schematicsClient.GetResourcesQueryWithContext(context, getResourcesQueryOptions) if err != nil { - return diag.FromErr(fmt.Errorf("GetResourcesQueryWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*getResourcesQueryOptions.QueryID) diff --git a/ibm/service/schematics/data_source_ibm_schematics_state.go b/ibm/service/schematics/data_source_ibm_schematics_state.go index 7bdc0c7880..a8ecfe1c0c 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_state.go +++ b/ibm/service/schematics/data_source_ibm_schematics_state.go @@ -79,7 +79,9 @@ func dataSourceIBMSchematicsStateRead(context context.Context, d *schema.Resourc _, response, _ := schematicsClient.GetWorkspaceTemplateStateWithContext(context, getWorkspaceTemplateStateOptions) if response.StatusCode != 200 { - return diag.FromErr(fmt.Errorf("GetWorkspaceTemplateStateWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(dataSourceIBMSchematicsStateID(d)) diff --git a/ibm/service/schematics/data_source_ibm_schematics_workspace.go b/ibm/service/schematics/data_source_ibm_schematics_workspace.go index 690e633c41..47cc4d7384 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_workspace.go +++ b/ibm/service/schematics/data_source_ibm_schematics_workspace.go @@ -657,7 +657,9 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res workspaceResponse, response, err := schematicsClient.GetWorkspaceWithContext(context, getWorkspaceOptions) if err != nil { - return diag.FromErr(fmt.Errorf("GetWorkspaceWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*getWorkspaceOptions.WID) diff --git a/ibm/service/schematics/resource_ibm_schematics_action.go b/ibm/service/schematics/resource_ibm_schematics_action.go index 1feb149116..6f27f0a13f 100644 --- a/ibm/service/schematics/resource_ibm_schematics_action.go +++ b/ibm/service/schematics/resource_ibm_schematics_action.go @@ -1080,7 +1080,9 @@ func resourceIBMSchematicsActionCreate(context context.Context, d *schema.Resour action, response, err := schematicsClient.CreateActionWithContext(context, createActionOptions) if err != nil { - return diag.FromErr(fmt.Errorf("CreateActionWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*action.ID) @@ -1357,7 +1359,9 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource return nil } - return diag.FromErr(fmt.Errorf("GetActionWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("name", action.Name); err != nil { return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) @@ -1914,7 +1918,9 @@ func resourceIBMSchematicsActionUpdate(context context.Context, d *schema.Resour _, response, err := schematicsClient.UpdateActionWithContext(context, updateActionOptions) if err != nil { - return diag.FromErr(fmt.Errorf("UpdateActionWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -1941,7 +1947,9 @@ func resourceIBMSchematicsActionDelete(context context.Context, d *schema.Resour response, err := schematicsClient.DeleteActionWithContext(context, deleteActionOptions) if err != nil { - return diag.FromErr(fmt.Errorf("DeleteActionWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") diff --git a/ibm/service/schematics/resource_ibm_schematics_agent.go b/ibm/service/schematics/resource_ibm_schematics_agent.go index 452d5a8488..7c5afd7cc2 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent.go @@ -624,7 +624,9 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc agentData, response, err := schematicsClient.CreateAgentDataWithContext(context, createAgentDataOptions) if err != nil { - return diag.FromErr(fmt.Errorf("CreateAgentDataWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*agentData.ID) @@ -653,7 +655,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD return nil } - return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("name", agentData.Name); err != nil { @@ -871,7 +875,9 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc return nil } - return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if agentData.Name != nil { updateAgentDataOptions.Name = agentData.Name @@ -977,7 +983,9 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc _, response, err := schematicsClient.UpdateAgentDataWithContext(context, updateAgentDataOptions) if err != nil { - return diag.FromErr(fmt.Errorf("UpdateAgentDataWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go b/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go index 9af6ba3406..4935cf68d4 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go @@ -118,7 +118,9 @@ func resourceIbmSchematicsAgentDeployCreate(context context.Context, d *schema.R agentDeployJob, response, err := schematicsClient.DeployAgentJobWithContext(context, deployAgentJobOptions) if err != nil { - return diag.FromErr(fmt.Errorf("DeployAgentJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *deployAgentJobOptions.AgentID, *agentDeployJob.JobID)) @@ -200,7 +202,9 @@ func resourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.Res return nil } - return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if agentData.RecentDeployJob != nil { @@ -279,7 +283,9 @@ func resourceIbmSchematicsAgentDeployUpdate(context context.Context, d *schema.R agentDeployJob, response, err := schematicsClient.DeployAgentJobWithContext(context, deployAgentJobOptions) if err != nil { - return diag.FromErr(fmt.Errorf("DeployAgentJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *deployAgentJobOptions.AgentID, *agentDeployJob.JobID)) diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_health.go b/ibm/service/schematics/resource_ibm_schematics_agent_health.go index bd8ab75b8c..01bfb71f8a 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_health.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_health.go @@ -107,7 +107,9 @@ func resourceIbmSchematicsAgentHealthCreate(context context.Context, d *schema.R agentHealthJob, response, err := schematicsClient.HealthCheckAgentJobWithContext(context, healthCheckAgentJobOptions) if err != nil { - return diag.FromErr(fmt.Errorf("HealthCheckAgentJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *healthCheckAgentJobOptions.AgentID, *agentHealthJob.JobID)) @@ -143,7 +145,9 @@ func resourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.Res return nil } - return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if agentData.RecentHealthJob != nil { @@ -225,7 +229,9 @@ func resourceIbmSchematicsAgentHealthUpdate(context context.Context, d *schema.R agentHealthJob, response, err := schematicsClient.HealthCheckAgentJobWithContext(context, healthCheckAgentJobOptions) if err != nil { - return diag.FromErr(fmt.Errorf("HealthCheckAgentJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *healthCheckAgentJobOptions.AgentID, *agentHealthJob.JobID)) } diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_prs.go b/ibm/service/schematics/resource_ibm_schematics_agent_prs.go index 908c4cdce3..53f998fca2 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_prs.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_prs.go @@ -106,7 +106,9 @@ func resourceIbmSchematicsAgentPrsCreate(context context.Context, d *schema.Reso agentPrsJob, response, err := schematicsClient.PrsAgentJobWithContext(context, prsAgentJobOptions) if err != nil { - return diag.FromErr(fmt.Errorf("PrsAgentJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *prsAgentJobOptions.AgentID, *agentPrsJob.JobID)) @@ -142,7 +144,9 @@ func resourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.Resour return nil } - return diag.FromErr(fmt.Errorf("GetAgentDataWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if agentData.RecentPrsJob != nil { @@ -222,7 +226,9 @@ func resourceIbmSchematicsAgentPrsUpdate(context context.Context, d *schema.Reso agentPrsJob, response, err := schematicsClient.PrsAgentJobWithContext(context, prsAgentJobOptions) if err != nil { - return diag.FromErr(fmt.Errorf("PrsAgentJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *prsAgentJobOptions.AgentID, *agentPrsJob.JobID)) } diff --git a/ibm/service/schematics/resource_ibm_schematics_inventory.go b/ibm/service/schematics/resource_ibm_schematics_inventory.go index 3d71df934e..78080fe7a9 100644 --- a/ibm/service/schematics/resource_ibm_schematics_inventory.go +++ b/ibm/service/schematics/resource_ibm_schematics_inventory.go @@ -147,7 +147,9 @@ func resourceIBMSchematicsInventoryCreate(context context.Context, d *schema.Res inventoryResourceRecord, response, err := schematicsClient.CreateInventoryWithContext(context, createInventoryOptions) if err != nil { - return diag.FromErr(fmt.Errorf("CreateInventoryWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*inventoryResourceRecord.ID) @@ -180,7 +182,9 @@ func resourceIBMSchematicsInventoryRead(context context.Context, d *schema.Resou return nil } - return diag.FromErr(fmt.Errorf("GetInventoryWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("name", inventoryResourceRecord.Name); err != nil { return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) @@ -272,7 +276,9 @@ func resourceIBMSchematicsInventoryUpdate(context context.Context, d *schema.Res _, response, err := schematicsClient.ReplaceInventoryWithContext(context, updateInventoryOptions) if err != nil { - return diag.FromErr(fmt.Errorf("UpdateInventoryWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -299,7 +305,9 @@ func resourceIBMSchematicsInventoryDelete(context context.Context, d *schema.Res response, err := schematicsClient.DeleteInventoryWithContext(context, deleteInventoryOptions) if err != nil { - return diag.FromErr(fmt.Errorf("DeleteInventoryWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") diff --git a/ibm/service/schematics/resource_ibm_schematics_job.go b/ibm/service/schematics/resource_ibm_schematics_job.go index 50cb78f8b6..f9430eb230 100644 --- a/ibm/service/schematics/resource_ibm_schematics_job.go +++ b/ibm/service/schematics/resource_ibm_schematics_job.go @@ -2943,7 +2943,9 @@ func resourceIBMSchematicsJobCreate(context context.Context, d *schema.ResourceD job, response, err := schematicsClient.CreateJobWithContext(context, createJobOptions) if err != nil { - return diag.FromErr(fmt.Errorf("CreateJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*job.ID) @@ -3928,7 +3930,9 @@ func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceDat return nil } - return diag.FromErr(fmt.Errorf("GetJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("command_object", job.CommandObject); err != nil { return diag.FromErr(fmt.Errorf("[ERROR] Error setting command_object: %s", err)) @@ -5072,7 +5076,9 @@ func resourceIBMSchematicsJobUpdate(context context.Context, d *schema.ResourceD _, response, err := schematicsClient.UpdateJobWithContext(context, updateJobOptions) if err != nil { - return diag.FromErr(fmt.Errorf("UpdateJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return resourceIBMSchematicsJobRead(context, d, meta) @@ -5109,7 +5115,9 @@ func resourceIBMSchematicsJobDelete(context context.Context, d *schema.ResourceD response, err := schematicsClient.DeleteJobWithContext(context, deleteJobOptions) if err != nil { - return diag.FromErr(fmt.Errorf("DeleteJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") diff --git a/ibm/service/schematics/resource_ibm_schematics_policy.go b/ibm/service/schematics/resource_ibm_schematics_policy.go index 5ecffee628..2744f299f1 100644 --- a/ibm/service/schematics/resource_ibm_schematics_policy.go +++ b/ibm/service/schematics/resource_ibm_schematics_policy.go @@ -360,7 +360,9 @@ func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.Resour policy, response, err := schematicsClient.CreatePolicyWithContext(context, createPolicyOptions) if err != nil { - return diag.FromErr(fmt.Errorf("CreatePolicyWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*policy.ID) @@ -387,7 +389,9 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource return nil } - return diag.FromErr(fmt.Errorf("GetPolicyWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("name", policy.Name); err != nil { @@ -550,7 +554,9 @@ func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.Resour _, response, err := schematicsClient.UpdatePolicyWithContext(context, updatePolicyOptions) if err != nil { - return diag.FromErr(fmt.Errorf("UpdatePolicyWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -572,7 +578,9 @@ func resourceIbmSchematicsPolicyDelete(context context.Context, d *schema.Resour response, err := schematicsClient.DeletePolicyWithContext(context, deletePolicyOptions) if err != nil { - return diag.FromErr(fmt.Errorf("DeletePolicyWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") diff --git a/ibm/service/schematics/resource_ibm_schematics_resource_query.go b/ibm/service/schematics/resource_ibm_schematics_resource_query.go index 07da0415c4..97dc2ec75e 100644 --- a/ibm/service/schematics/resource_ibm_schematics_resource_query.go +++ b/ibm/service/schematics/resource_ibm_schematics_resource_query.go @@ -169,7 +169,9 @@ func resourceIBMSchematicsResourceQueryCreate(context context.Context, d *schema resourceQueryRecord, response, err := schematicsClient.CreateResourceQueryWithContext(context, createResourceQueryOptions) if err != nil { - return diag.FromErr(fmt.Errorf("CreateResourceQueryWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*resourceQueryRecord.ID) @@ -242,7 +244,9 @@ func resourceIBMSchematicsResourceQueryRead(context context.Context, d *schema.R return nil } - return diag.FromErr(fmt.Errorf("GetResourcesQueryWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("type", resourceQueryRecord.Type); err != nil { return diag.FromErr(fmt.Errorf("[ERROR] Error setting type: %s", err)) @@ -349,7 +353,9 @@ func resourceIBMSchematicsResourceQueryUpdate(context context.Context, d *schema _, response, err := schematicsClient.ReplaceResourcesQueryWithContext(context, replaceResourcesQueryOptions) if err != nil { - return diag.FromErr(fmt.Errorf("ReplaceResourcesQueryWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return resourceIBMSchematicsResourceQueryRead(context, d, meta) @@ -375,7 +381,9 @@ func resourceIBMSchematicsResourceQueryDelete(context context.Context, d *schema response, err := schematicsClient.DeleteResourcesQueryWithContext(context, deleteResourcesQueryOptions) if err != nil { - return diag.FromErr(fmt.Errorf("DeleteResourcesQueryWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") diff --git a/ibm/service/schematics/resource_ibm_schematics_workspace.go b/ibm/service/schematics/resource_ibm_schematics_workspace.go index 726939d160..7e6afdfd5f 100644 --- a/ibm/service/schematics/resource_ibm_schematics_workspace.go +++ b/ibm/service/schematics/resource_ibm_schematics_workspace.go @@ -756,7 +756,9 @@ func resourceIBMSchematicsWorkspaceCreate(context context.Context, d *schema.Res workspaceResponse, response, err := schematicsClient.CreateWorkspaceWithContext(context, createWorkspaceOptions) if err != nil { - return diag.FromErr(fmt.Errorf("CreateWorkspaceWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*workspaceResponse.ID) @@ -1100,7 +1102,9 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou return nil } - return diag.FromErr(fmt.Errorf("GetWorkspaceWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if workspaceResponse.AppliedShareddataIds != nil { if err = d.Set("applied_shareddata_ids", workspaceResponse.AppliedShareddataIds); err != nil { @@ -1821,7 +1825,9 @@ func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.Res _, response, err := schematicsClient.ReplaceWorkspaceWithContext(context, replaceWorkspaceOptions) if err != nil { - return diag.FromErr(fmt.Errorf("ReplaceWorkspaceWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -1829,7 +1835,9 @@ func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.Res _, response, err := schematicsClient.UpdateWorkspaceWithContext(context, updateWorkspaceOptions) if err != nil { - return diag.FromErr(fmt.Errorf("UpdateWorkspaceWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -1856,7 +1864,9 @@ func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.Res _, response, err := schematicsClient.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptions) if err != nil { - return diag.FromErr(fmt.Errorf("ReplaceWorkspaceInputs failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } } @@ -1896,7 +1906,9 @@ func resourceIBMSchematicsWorkspaceDelete(context context.Context, d *schema.Res _, response, err := schematicsClient.DeleteWorkspaceWithContext(context, deleteWorkspaceOptions) if err != nil { - return diag.FromErr(fmt.Errorf("DeleteWorkspaceWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") From f178824f7548aeed9b7d5186d676d9e99e577122 Mon Sep 17 00:00:00 2001 From: VaishnaviGopal Date: Wed, 9 Oct 2024 12:04:47 +0530 Subject: [PATCH 4/7] updated return diag.FromErr(fmt.Errorf) kind of return statements with only err in schematics --- .../data_source_ibm_schematics_action.go | 120 ++++++++++---- .../data_source_ibm_schematics_agent.go | 88 +++++++--- ...data_source_ibm_schematics_agent_deploy.go | 36 +++- ...data_source_ibm_schematics_agent_health.go | 32 +++- .../data_source_ibm_schematics_agent_prs.go | 32 +++- .../data_source_ibm_schematics_agents.go | 20 ++- .../data_source_ibm_schematics_inventory.go | 40 +++-- .../data_source_ibm_schematics_job.go | 96 ++++++++--- .../data_source_ibm_schematics_policies.go | 20 ++- .../data_source_ibm_schematics_policy.go | 64 +++++-- ...ta_source_ibm_schematics_resource_query.go | 32 +++- .../data_source_ibm_schematics_workspace.go | 152 ++++++++++++----- .../resource_ibm_schematics_action.go | 124 ++++++++++---- .../resource_ibm_schematics_agent.go | 88 +++++++--- .../resource_ibm_schematics_agent_deploy.go | 44 +++-- .../resource_ibm_schematics_agent_health.go | 36 +++- .../resource_ibm_schematics_agent_prs.go | 36 +++- .../resource_ibm_schematics_inventory.go | 40 +++-- .../schematics/resource_ibm_schematics_job.go | 100 ++++++++--- .../resource_ibm_schematics_policy.go | 60 +++++-- .../resource_ibm_schematics_resource_query.go | 28 +++- .../resource_ibm_schematics_workspace.go | 156 +++++++++++++----- 22 files changed, 1083 insertions(+), 361 deletions(-) diff --git a/ibm/service/schematics/data_source_ibm_schematics_action.go b/ibm/service/schematics/data_source_ibm_schematics_action.go index f7f41cf23f..23d93c7f21 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_action.go +++ b/ibm/service/schematics/data_source_ibm_schematics_action.go @@ -972,133 +972,193 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour d.SetId(*getActionOptions.ActionID) if err = d.Set("name", action.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("description", action.Description); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting description: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("location", action.Location); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("resource_group", action.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_group: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if action.UserState != nil { err = d.Set("user_state", dataSourceActionFlattenUserState(*action.UserState)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting user_state %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("source_readme_url", action.SourceReadmeURL); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source_readme_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if action.Source != nil { err = d.Set("source", dataSourceActionFlattenSource(*action.Source)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("source_type", action.SourceType); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source_type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("command_parameter", action.CommandParameter); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting command_parameter: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("inventory", action.Inventory); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting inventory: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if action.Credentials != nil { err = d.Set("credentials", dataSourceActionFlattenCredentials(action.Credentials)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting credentials %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if action.Bastion != nil { err = d.Set("bastion", dataSourceActionFlattenBastion(*action.Bastion)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting bastion %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if action.BastionCredential != nil { err = d.Set("bastion_credential", dataSourceActionFlattenBastionCredential(*action.BastionCredential)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting bastion_credential %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("targets_ini", action.TargetsIni); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting targets_ini: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if action.Inputs != nil { err = d.Set("action_inputs", dataSourceActionFlattenInputs(action.Inputs)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting action_inputs %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if action.Outputs != nil { err = d.Set("action_outputs", dataSourceActionFlattenOutputs(action.Outputs)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting action_outputs %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if action.Settings != nil { err = d.Set("settings", dataSourceActionFlattenSettings(action.Settings)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting settings %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("id", action.ID); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("crn", action.Crn); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting crn: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("account", action.Account); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting account: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("source_created_at", flex.DateTimeToString(action.SourceCreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source_created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("source_created_by", action.SourceCreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source_created_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("source_updated_at", flex.DateTimeToString(action.SourceUpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source_updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("source_updated_by", action.SourceUpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source_updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(action.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_by", action.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(action.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", action.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if action.State != nil { err = d.Set("state", dataSourceActionFlattenState(*action.State)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting state %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if action.SysLock != nil { err = d.Set("sys_lock", dataSourceActionFlattenSysLock(*action.SysLock)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting sys_lock %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent.go b/ibm/service/schematics/data_source_ibm_schematics_agent.go index d40dad1ee4..2235b9c106 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent.go @@ -559,31 +559,45 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc d.SetId(fmt.Sprintf("%s", *getAgentDataOptions.AgentID)) if err = d.Set("name", agentData.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("description", agentData.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("resource_group", agentData.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("version", agentData.Version); err != nil { - return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("schematics_location", agentData.SchematicsLocation); err != nil { - return diag.FromErr(fmt.Errorf("Error setting schematics_location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("agent_location", agentData.AgentLocation); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if agentData.Tags != nil { if err = d.Set("tags", agentData.Tags); err != nil { - return diag.FromErr(fmt.Errorf("Error setting tags: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } agentInfrastructure := []map[string]interface{}{} @@ -597,7 +611,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc agentInfrastructure = append(agentInfrastructure, modelMap) } if err = d.Set("agent_infrastructure", agentInfrastructure); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_infrastructure %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentMetadata := []map[string]interface{}{} @@ -613,7 +629,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc } } if err = d.Set("agent_metadata", agentMetadata); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_metadata %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentInputs := []map[string]interface{}{} @@ -629,7 +647,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc } } if err = d.Set("agent_inputs", agentInputs); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_inputs %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } userState := []map[string]interface{}{} @@ -643,31 +663,45 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc userState = append(userState, modelMap) } if err = d.Set("user_state", userState); err != nil { - return diag.FromErr(fmt.Errorf("Error setting user_state %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("agent_crn", agentData.AgentCrn); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_crn: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("id", agentData.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(agentData.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("creation_by", agentData.CreationBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting creation_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } systemState := []map[string]interface{}{} @@ -681,7 +715,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc systemState = append(systemState, modelMap) } if err = d.Set("system_state", systemState); err != nil { - return diag.FromErr(fmt.Errorf("Error setting system_state %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentKpi := []map[string]interface{}{} @@ -695,7 +731,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc agentKpi = append(agentKpi, modelMap) } if err = d.Set("agent_kpi", agentKpi); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_kpi %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } recentPrsJob := []map[string]interface{}{} @@ -709,7 +747,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc recentPrsJob = append(recentPrsJob, modelMap) } if err = d.Set("recent_prs_job", recentPrsJob); err != nil { - return diag.FromErr(fmt.Errorf("Error setting recent_prs_job %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } recentDeployJob := []map[string]interface{}{} @@ -723,7 +763,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc recentDeployJob = append(recentDeployJob, modelMap) } if err = d.Set("recent_deploy_job", recentDeployJob); err != nil { - return diag.FromErr(fmt.Errorf("Error setting recent_deploy_job %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } recentHealthJob := []map[string]interface{}{} @@ -737,7 +779,9 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc recentHealthJob = append(recentHealthJob, modelMap) } if err = d.Set("recent_health_job", recentHealthJob); err != nil { - return diag.FromErr(fmt.Errorf("Error setting recent_health_job %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return nil diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go b/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go index d021a54129..8caa3f2528 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go @@ -101,33 +101,51 @@ func dataSourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.R if agentData.RecentDeployJob != nil { if err = d.Set("agent_id", getAgentDataOptions.AgentID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentDeployJob.JobID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting job_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } else if agentData.RecentDeployJob.JobID != nil { d.SetId(fmt.Sprintf("%s", *agentData.RecentDeployJob.JobID)) } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentDeployJob.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentDeployJob.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("is_redeployed", agentData.RecentDeployJob.IsRedeployed); err != nil { - return diag.FromErr(fmt.Errorf("Error setting is_redeployed: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_version: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentDeployJob.StatusCode); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_code: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentDeployJob.StatusMessage); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_message: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentDeployJob.LogURL); err != nil { - return diag.FromErr(fmt.Errorf("Error setting log_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_health.go b/ibm/service/schematics/data_source_ibm_schematics_agent_health.go index dd575d7106..85d3685386 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_health.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_health.go @@ -96,30 +96,46 @@ func dataSourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.R if agentData.RecentHealthJob != nil { if err = d.Set("agent_id", getAgentDataOptions.AgentID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentHealthJob.JobID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting job_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } else if agentData.RecentHealthJob.JobID != nil { d.SetId(fmt.Sprintf("%s", *agentData.RecentHealthJob.JobID)) } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentHealthJob.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentHealthJob.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_version: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentHealthJob.StatusCode); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_code: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentHealthJob.StatusMessage); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_message: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentHealthJob.LogURL); err != nil { - return diag.FromErr(fmt.Errorf("Error setting log_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go b/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go index e97acdc071..7e4a3a858f 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go @@ -96,30 +96,46 @@ func dataSourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.Reso if agentData.RecentPrsJob != nil { if err = d.Set("agent_id", getAgentDataOptions.AgentID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentPrsJob.JobID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting job_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } else if agentData.RecentPrsJob.JobID != nil { d.SetId(fmt.Sprintf("%s", *agentData.RecentPrsJob.JobID)) } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentPrsJob.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentPrsJob.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_version: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentPrsJob.StatusCode); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_code: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentPrsJob.StatusMessage); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_message: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentPrsJob.LogURL); err != nil { - return diag.FromErr(fmt.Errorf("Error setting log_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } diff --git a/ibm/service/schematics/data_source_ibm_schematics_agents.go b/ibm/service/schematics/data_source_ibm_schematics_agents.go index 0cec697c2d..f21d1c341f 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agents.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agents.go @@ -224,7 +224,9 @@ func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.Resour if suppliedFilter { if len(agentList.Agents) == 0 { - // return diag.FromErr(fmt.Errorf("no Agents found with name %s", name)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(name) } else { @@ -232,15 +234,21 @@ func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.Resour } if err = d.Set("total_count", flex.IntValue(agentList.TotalCount)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting total_count: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("limit", flex.IntValue(agentList.Limit)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting limit: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("offset", flex.IntValue(agentList.Offset)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting offset: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agents := []map[string]interface{}{} @@ -256,7 +264,9 @@ func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.Resour } } if err = d.Set("agents", agents); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agents %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return nil diff --git a/ibm/service/schematics/data_source_ibm_schematics_inventory.go b/ibm/service/schematics/data_source_ibm_schematics_inventory.go index 09215af81c..830e6a8059 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_inventory.go +++ b/ibm/service/schematics/data_source_ibm_schematics_inventory.go @@ -118,34 +118,54 @@ func dataSourceIBMSchematicsInventoryRead(context context.Context, d *schema.Res d.SetId(*getInventoryOptions.InventoryID) if err = d.Set("name", inventoryResourceRecord.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("id", inventoryResourceRecord.ID); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("description", inventoryResourceRecord.Description); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting description: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("location", inventoryResourceRecord.Location); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("resource_group", inventoryResourceRecord.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_group: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(inventoryResourceRecord.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_by", inventoryResourceRecord.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(inventoryResourceRecord.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", inventoryResourceRecord.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("inventories_ini", inventoryResourceRecord.InventoriesIni); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting inventories_ini: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return nil diff --git a/ibm/service/schematics/data_source_ibm_schematics_job.go b/ibm/service/schematics/data_source_ibm_schematics_job.go index f17754f70c..5ba36bee12 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_job.go +++ b/ibm/service/schematics/data_source_ibm_schematics_job.go @@ -2841,100 +2841,148 @@ func dataSourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceD d.SetId(*getJobOptions.JobID) if err = d.Set("command_object", job.CommandObject); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting command_object: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("command_object_id", job.CommandObjectID); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting command_object_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("command_name", job.CommandName); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting command_name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("command_parameter", job.CommandParameter); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting command_parameter: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if job.Inputs != nil { err = d.Set("job_inputs", dataSourceJobFlattenInputs(job.Inputs)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting job_inputs %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if job.Settings != nil { err = d.Set("job_env_settings", dataSourceJobFlattenSettings(job.Settings)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting job_env_settings %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("id", job.ID); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("name", job.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("description", job.Description); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting description: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("location", job.Location); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("resource_group", job.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_group: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("submitted_at", flex.DateTimeToString(job.SubmittedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting submitted_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("submitted_by", job.SubmittedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting submitted_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("start_at", flex.DateTimeToString(job.StartAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting start_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("end_at", flex.DateTimeToString(job.EndAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting end_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("duration", job.Duration); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting duration: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if job.Status != nil { err = d.Set("status", dataSourceJobFlattenStatus(*job.Status)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting status %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if job.Data != nil { err = d.Set("data", dataSourceJobFlattenData(*job.Data)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting data %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if job.Bastion != nil { err = d.Set("bastion", dataSourceJobFlattenBastion(*job.Bastion)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting bastion %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if job.LogSummary != nil { err = d.Set("log_summary", dataSourceJobFlattenLogSummary(*job.LogSummary)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting log_summary %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("log_store_url", job.LogStoreURL); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting log_store_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("state_store_url", job.StateStoreURL); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting state_store_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("results_url", job.ResultsURL); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting results_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(job.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return nil diff --git a/ibm/service/schematics/data_source_ibm_schematics_policies.go b/ibm/service/schematics/data_source_ibm_schematics_policies.go index b78fe6e880..d4173d5fe7 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_policies.go +++ b/ibm/service/schematics/data_source_ibm_schematics_policies.go @@ -183,7 +183,9 @@ func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.Reso if suppliedFilter { if len(policyList.Policies) == 0 { - // return diag.FromErr(fmt.Errorf("no Policies found with policyKind %s", policyKind)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(policyKind) } else { @@ -191,15 +193,21 @@ func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.Reso } if err = d.Set("total_count", flex.IntValue(policyList.TotalCount)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting total_count: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("limit", flex.IntValue(policyList.Limit)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting limit: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("offset", flex.IntValue(policyList.Offset)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting offset: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } policies := []map[string]interface{}{} @@ -215,7 +223,9 @@ func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.Reso } } if err = d.Set("policies", policies); err != nil { - return diag.FromErr(fmt.Errorf("Error setting policies %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return nil diff --git a/ibm/service/schematics/data_source_ibm_schematics_policy.go b/ibm/service/schematics/data_source_ibm_schematics_policy.go index 1a3469be22..51ec47635e 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_policy.go +++ b/ibm/service/schematics/data_source_ibm_schematics_policy.go @@ -288,19 +288,27 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour d.SetId(fmt.Sprintf("%s", *getPolicyOptions.PolicyID)) if err = d.Set("name", policy.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("description", policy.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("resource_group", policy.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("location", policy.Location); err != nil { - return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } state := []map[string]interface{}{} @@ -314,16 +322,22 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour state = append(state, modelMap) } if err = d.Set("state", state); err != nil { - return diag.FromErr(fmt.Errorf("Error setting state %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("kind", policy.Kind); err != nil { - return diag.FromErr(fmt.Errorf("Error setting kind: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if policy.Tags != nil { if err = d.Set("tags", policy.Tags); err != nil { - return diag.FromErr(fmt.Errorf("Error setting tags: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } target := []map[string]interface{}{} @@ -337,7 +351,9 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour target = append(target, modelMap) } if err = d.Set("target", target); err != nil { - return diag.FromErr(fmt.Errorf("Error setting target %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } parameter := []map[string]interface{}{} @@ -351,19 +367,27 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour parameter = append(parameter, modelMap) } if err = d.Set("parameter", parameter); err != nil { - return diag.FromErr(fmt.Errorf("Error setting parameter %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("id", policy.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("crn", policy.Crn); err != nil { - return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("account", policy.Account); err != nil { - return diag.FromErr(fmt.Errorf("Error setting account: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } scopedResources := []map[string]interface{}{} @@ -379,19 +403,27 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour } } if err = d.Set("scoped_resources", scopedResources); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scoped_resources %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(policy.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_by", policy.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(policy.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return nil diff --git a/ibm/service/schematics/data_source_ibm_schematics_resource_query.go b/ibm/service/schematics/data_source_ibm_schematics_resource_query.go index 5869dfdf4d..ee057b3a84 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_resource_query.go +++ b/ibm/service/schematics/data_source_ibm_schematics_resource_query.go @@ -143,31 +143,47 @@ func dataSourceIBMSchematicsResourceQueryRead(context context.Context, d *schema d.SetId(*getResourcesQueryOptions.QueryID) if err = d.Set("type", resourceQueryRecord.Type); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("name", resourceQueryRecord.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("id", resourceQueryRecord.ID); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(resourceQueryRecord.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_by", resourceQueryRecord.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(resourceQueryRecord.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", resourceQueryRecord.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if resourceQueryRecord.Queries != nil { err = d.Set("queries", dataSourceResourceQueryRecordFlattenQueries(resourceQueryRecord.Queries)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting queries %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } diff --git a/ibm/service/schematics/data_source_ibm_schematics_workspace.go b/ibm/service/schematics/data_source_ibm_schematics_workspace.go index 47cc4d7384..9c404e9d11 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_workspace.go +++ b/ibm/service/schematics/data_source_ibm_schematics_workspace.go @@ -667,104 +667,156 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res if workspaceResponse.CatalogRef != nil { err = d.Set("catalog_ref", dataSourceWorkspaceResponseFlattenCatalogRef(*workspaceResponse.CatalogRef)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting catalog_ref %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("created_at", flex.DateTimeToString(workspaceResponse.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_by", workspaceResponse.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("crn", workspaceResponse.Crn); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting crn: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("description", workspaceResponse.Description); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting description: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("last_health_check_at", flex.DateTimeToString(workspaceResponse.LastHealthCheckAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting last_health_check_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("location", workspaceResponse.Location); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("name", workspaceResponse.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("resource_group", workspaceResponse.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_group: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if workspaceResponse.RuntimeData != nil { err = d.Set("runtime_data", dataSourceWorkspaceResponseFlattenRuntimeData(workspaceResponse.RuntimeData)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting runtime_data %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if workspaceResponse.SharedData != nil { err = d.Set("shared_data", dataSourceWorkspaceResponseFlattenSharedData(*workspaceResponse.SharedData)) if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting shared_data %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("status", workspaceResponse.Status); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting status: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if workspaceResponse.TemplateData != nil { templateData := dataSourceWorkspaceResponseFlattenTemplateData(workspaceResponse.TemplateData) if err = d.Set("template_env_settings", templateData[0]["env_values"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading env_values: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_git_folder", templateData[0]["folder"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading folder: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_init_state_file", templateData[0]["init_state_file"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading init_state_file: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_type", templateData[0]["type"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_uninstall_script_name", templateData[0]["uninstall_script_name"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading uninstall_script_name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_values", templateData[0]["values"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading values: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } err = d.Set("template_values_metadata", dataSourceWorkspaceResponseFlattenValuesMetadata(templateData[0]["values_metadata"])) if err != nil { fmt.Println(fmt.Errorf("[ERROR] Error reading template_values_metadata %s", err)) } if err = d.Set("template_inputs", templateData[0]["variablestore"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading variablestore: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("template_ref", workspaceResponse.TemplateRef); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting template_ref: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if workspaceResponse.TemplateRepo != nil { templateRepoMap := dataSourceWorkspaceResponseFlattenTemplateRepo(*workspaceResponse.TemplateRepo) if err = d.Set("template_git_branch", templateRepoMap[0]["branch"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading branch: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_git_release", templateRepoMap[0]["release"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading release: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_git_repo_sha_value", templateRepoMap[0]["repo_sha_value"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading repo_sha_value: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_git_repo_url", templateRepoMap[0]["repo_url"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading repo_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_git_url", templateRepoMap[0]["url"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_git_has_uploadedgitrepotar", templateRepoMap[0]["has_uploadedgitrepotar"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading has_uploadedgitrepotar: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } /*if err = d.Set("type", workspaceResponse.Type); err != nil { @@ -772,48 +824,72 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res }*/ if workspaceResponse.UpdatedAt != nil { if err = d.Set("updated_at", workspaceResponse.UpdatedAt.String()); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("updated_by", workspaceResponse.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if workspaceResponse.WorkspaceStatus != nil { workspaceStatusMap := dataSourceWorkspaceResponseFlattenWorkspaceStatus(*workspaceResponse.WorkspaceStatus) if err = d.Set("is_frozen", workspaceStatusMap[0]["frozen"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading frozen: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("frozen", workspaceStatusMap[0]["frozen"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading frozen: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("frozen_at", workspaceStatusMap[0]["frozen_at"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading frozen_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("frozen_by", workspaceStatusMap[0]["frozen_by"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading frozen_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("is_locked", workspaceStatusMap[0]["locked"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading locked: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("locked", workspaceStatusMap[0]["locked"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading locked: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("locked_by", workspaceStatusMap[0]["locked_by"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading locked_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("locked_time", workspaceStatusMap[0]["locked_time"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading locked_time: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if workspaceResponse.WorkspaceStatusMsg != nil { workspaceStatusMsgMap := dataSourceWorkspaceResponseFlattenWorkspaceStatusMsg(*workspaceResponse.WorkspaceStatusMsg) if err = d.Set("status_code", workspaceStatusMsgMap[0]["status_code"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading status_code: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_msg", workspaceStatusMsgMap[0]["status_msg"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading status_msg: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } diff --git a/ibm/service/schematics/resource_ibm_schematics_action.go b/ibm/service/schematics/resource_ibm_schematics_action.go index 6f27f0a13f..dc633ce4a9 100644 --- a/ibm/service/schematics/resource_ibm_schematics_action.go +++ b/ibm/service/schematics/resource_ibm_schematics_action.go @@ -1364,47 +1364,69 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource return tfErr.GetDiag() } if err = d.Set("name", action.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("description", action.Description); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting description: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("location", action.Location); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("resource_group", action.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_group: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if action.Tags != nil { if err = d.Set("tags", action.Tags); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting tags: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if action.UserState != nil { userStateMap := resourceIBMSchematicsActionUserStateToMap(*action.UserState) if err = d.Set("user_state", []map[string]interface{}{userStateMap}); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting user_state: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("source_readme_url", action.SourceReadmeURL); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source_readme_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if _, ok := d.GetOk("source"); ok { if action.Source != nil { sourceMap := resourceIBMSchematicsActionExternalSourceToMap(*action.Source) if err = d.Set("source", []map[string]interface{}{sourceMap}); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } } if err = d.Set("source_type", action.SourceType); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source_type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("command_parameter", action.CommandParameter); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting command_parameter: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("inventory", action.Inventory); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting inventory: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if action.Credentials != nil { credentials := []map[string]interface{}{} @@ -1413,25 +1435,33 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource credentials = append(credentials, credentialsItemMap) } if err = d.Set("credentials", credentials); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting credentials: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if _, ok := d.GetOk("bastion"); ok { if action.Bastion != nil { bastionMap := resourceIBMSchematicsActionBastionResourceDefinitionToMap(*action.Bastion) if err = d.Set("bastion", []map[string]interface{}{bastionMap}); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting bastion: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } } if action.BastionCredential != nil { bastionCredentialMap := resourceIBMSchematicsActionCredentialVariableDataToMap(*action.BastionCredential) if err = d.Set("bastion_credential", []map[string]interface{}{bastionCredentialMap}); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting bastion_credential: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("targets_ini", action.TargetsIni); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting targets_ini: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if action.Inputs != nil { actionInputs := []map[string]interface{}{} @@ -1440,7 +1470,9 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource actionInputs = append(actionInputs, actionInputsItemMap) } if err = d.Set("action_inputs", actionInputs); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting action_inputs: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if action.Outputs != nil { @@ -1450,7 +1482,9 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource actionOutputs = append(actionOutputs, actionOutputsItemMap) } if err = d.Set("action_outputs", actionOutputs); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting action_outputs: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if action.Settings != nil { @@ -1460,54 +1494,82 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource settings = append(settings, settingsItemMap) } if err = d.Set("settings", settings); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting settings: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if action.State != nil { stateMap := resourceIBMSchematicsActionActionStateToMap(*action.State) if err = d.Set("state", []map[string]interface{}{stateMap}); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting state: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if action.SysLock != nil { sysLockMap := resourceIBMSchematicsActionSystemLockToMap(*action.SysLock) if err = d.Set("sys_lock", []map[string]interface{}{sysLockMap}); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting sys_lock: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("crn", action.Crn); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting crn: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("account", action.Account); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting account: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("source_created_at", flex.DateTimeToString(action.SourceCreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source_created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("source_created_by", action.SourceCreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source_created_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("source_updated_at", flex.DateTimeToString(action.SourceUpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source_updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("source_updated_by", action.SourceUpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting source_updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(action.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_by", action.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(action.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", action.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if action.PlaybookNames != nil && len(action.PlaybookNames) > 0 { if err = d.Set("playbook_names", action.PlaybookNames); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting playbook_names: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } else { d.Set("playbook_names", []string{}) diff --git a/ibm/service/schematics/resource_ibm_schematics_agent.go b/ibm/service/schematics/resource_ibm_schematics_agent.go index 7c5afd7cc2..8ffd6c08a6 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent.go @@ -661,19 +661,29 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD } if err = d.Set("name", agentData.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("resource_group", agentData.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("version", agentData.Version); err != nil { - return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("schematics_location", agentData.SchematicsLocation); err != nil { - return diag.FromErr(fmt.Errorf("Error setting schematics_location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("agent_location", agentData.AgentLocation); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentInfrastructureMap, err := resourceIbmSchematicsAgentAgentInfrastructureToMap(agentData.AgentInfrastructure) if err != nil { @@ -682,14 +692,20 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD return tfErr.GetDiag() } if err = d.Set("agent_infrastructure", []map[string]interface{}{agentInfrastructureMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_infrastructure: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("description", agentData.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if agentData.Tags != nil { if err = d.Set("tags", agentData.Tags); err != nil { - return diag.FromErr(fmt.Errorf("Error setting tags: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } agentMetadata := []map[string]interface{}{} @@ -705,7 +721,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD } } if err = d.Set("agent_metadata", agentMetadata); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_metadata: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } agentInputs := []map[string]interface{}{} if agentData.AgentInputs != nil { @@ -720,7 +738,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD } } if err = d.Set("agent_inputs", agentInputs); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_inputs: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if agentData.UserState != nil { userStateMap, err := resourceIbmSchematicsAgentAgentUserStateToMap(agentData.UserState) @@ -730,7 +750,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD return tfErr.GetDiag() } if err = d.Set("user_state", []map[string]interface{}{userStateMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting user_state: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if agentData.AgentKpi != nil { @@ -741,23 +763,35 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD return tfErr.GetDiag() } if err = d.Set("agent_kpi", []map[string]interface{}{agentKpiMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_kpi: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("agent_crn", agentData.AgentCrn); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_crn: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(agentData.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("creation_by", agentData.CreationBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting creation_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if agentData.SystemState != nil { systemStateMap, err := resourceIbmSchematicsAgentAgentSystemStatusToMap(agentData.SystemState) @@ -767,7 +801,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD return tfErr.GetDiag() } if err = d.Set("system_state", []map[string]interface{}{systemStateMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting system_state: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if agentData.RecentPrsJob != nil { @@ -778,7 +814,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD return tfErr.GetDiag() } if err = d.Set("recent_prs_job", []map[string]interface{}{recentPrsJobMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting recent_prs_job: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if agentData.RecentDeployJob != nil { @@ -789,7 +827,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD return tfErr.GetDiag() } if err = d.Set("recent_deploy_job", []map[string]interface{}{recentDeployJobMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting recent_deploy_job: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if agentData.RecentHealthJob != nil { @@ -800,7 +840,9 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD return tfErr.GetDiag() } if err = d.Set("recent_health_job", []map[string]interface{}{recentHealthJobMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting recent_health_job: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -1042,7 +1084,9 @@ func resourceIbmSchematicsAgentDelete(context context.Context, d *schema.Resourc deleteresponse, err := schematicsClient.DeleteAgentDataWithContext(context, deleteAgentDataOptions) if err != nil { - return diag.FromErr(fmt.Errorf("DeleteAgentDataWithContext failed %s\n%s", err, deleteresponse)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go b/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go index 4935cf68d4..2553f5a10d 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go @@ -128,7 +128,9 @@ func resourceIbmSchematicsAgentDeployCreate(context context.Context, d *schema.R _, err = isWaitForAgentAvailable(context, schematicsClient, *deployAgentJobOptions.AgentID, d.Timeout(schema.TimeoutCreate)) if err != nil { - return diag.FromErr(fmt.Errorf("Waiting for agent to be available failed %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } return resourceIbmSchematicsAgentDeployRead(context, d, meta) @@ -209,28 +211,44 @@ func resourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.Res if agentData.RecentDeployJob != nil { if err = d.Set("agent_id", parts[0]); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_id: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentDeployJob.JobID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting job_id: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentDeployJob.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentDeployJob.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_by: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_version: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentDeployJob.StatusCode); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_code: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentDeployJob.StatusMessage); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_message: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentDeployJob.LogURL); err != nil { - return diag.FromErr(fmt.Errorf("Error setting log_url: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } } @@ -271,7 +289,9 @@ func resourceIbmSchematicsAgentDeployUpdate(context context.Context, d *schema.R hasChange := false if d.HasChange("agent_id") { - return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() " The resource must be re-created to update this property.", "agent_id")) } if d.HasChange("force") { @@ -291,7 +311,9 @@ func resourceIbmSchematicsAgentDeployUpdate(context context.Context, d *schema.R _, err = isWaitForAgentAvailable(context, schematicsClient, parts[0], d.Timeout(schema.TimeoutUpdate)) if err != nil { - return diag.FromErr(fmt.Errorf("Waiting for agent to be available failed %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } } diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_health.go b/ibm/service/schematics/resource_ibm_schematics_agent_health.go index 01bfb71f8a..87032fb9de 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_health.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_health.go @@ -153,28 +153,44 @@ func resourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.Res if agentData.RecentHealthJob != nil { if err = d.Set("agent_id", parts[0]); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_id: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentHealthJob.JobID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting job_id: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentHealthJob.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentHealthJob.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_by: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_version: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentHealthJob.StatusCode); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_code: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentHealthJob.StatusMessage); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_message: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentHealthJob.LogURL); err != nil { - return diag.FromErr(fmt.Errorf("Error setting log_url: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } } @@ -217,7 +233,9 @@ func resourceIbmSchematicsAgentHealthUpdate(context context.Context, d *schema.R hasChange := false if d.HasChange("agent_id") { - return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() " The resource must be re-created to update this property.", "agent_id")) } if d.HasChange("force") { diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_prs.go b/ibm/service/schematics/resource_ibm_schematics_agent_prs.go index 53f998fca2..5064426621 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_prs.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_prs.go @@ -151,28 +151,44 @@ func resourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.Resour if agentData.RecentPrsJob != nil { if err = d.Set("agent_id", parts[0]); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_id: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentPrsJob.JobID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting job_id: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentPrsJob.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentPrsJob.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_by: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { - return diag.FromErr(fmt.Errorf("Error setting agent_version: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentPrsJob.StatusCode); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_code: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentPrsJob.StatusMessage); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_message: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentPrsJob.LogURL); err != nil { - return diag.FromErr(fmt.Errorf("Error setting log_url: %s", err)) +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() } } @@ -214,7 +230,9 @@ func resourceIbmSchematicsAgentPrsUpdate(context context.Context, d *schema.Reso hasChange := false if d.HasChange("agent_id") { - return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ +tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") +log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) +return tfErr.GetDiag() " The resource must be re-created to update this property.", "agent_id")) } if d.HasChange("force") { diff --git a/ibm/service/schematics/resource_ibm_schematics_inventory.go b/ibm/service/schematics/resource_ibm_schematics_inventory.go index 78080fe7a9..e0783e315d 100644 --- a/ibm/service/schematics/resource_ibm_schematics_inventory.go +++ b/ibm/service/schematics/resource_ibm_schematics_inventory.go @@ -187,36 +187,56 @@ func resourceIBMSchematicsInventoryRead(context context.Context, d *schema.Resou return tfErr.GetDiag() } if err = d.Set("name", inventoryResourceRecord.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("description", inventoryResourceRecord.Description); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting description: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("location", inventoryResourceRecord.Location); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("resource_group", inventoryResourceRecord.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_group: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("inventories_ini", inventoryResourceRecord.InventoriesIni); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting inventories_ini: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if inventoryResourceRecord.ResourceQueries != nil { if err = d.Set("resource_queries", inventoryResourceRecord.ResourceQueries); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_queries: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("created_at", flex.DateTimeToString(inventoryResourceRecord.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_by", inventoryResourceRecord.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(inventoryResourceRecord.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", inventoryResourceRecord.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return nil diff --git a/ibm/service/schematics/resource_ibm_schematics_job.go b/ibm/service/schematics/resource_ibm_schematics_job.go index f9430eb230..b8a96b060d 100644 --- a/ibm/service/schematics/resource_ibm_schematics_job.go +++ b/ibm/service/schematics/resource_ibm_schematics_job.go @@ -3935,22 +3935,32 @@ func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceDat return tfErr.GetDiag() } if err = d.Set("command_object", job.CommandObject); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting command_object: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("command_object_id", job.CommandObjectID); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting command_object_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("command_name", job.CommandName); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting command_name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if _, ok := d.GetOk("command_parameter"); ok { if err = d.Set("command_parameter", d.Get("command_parameter").(string)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting command_parameter: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if job.CommandOptions != nil { if err = d.Set("command_options", job.CommandOptions); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting command_options: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if job.Inputs != nil { @@ -3960,7 +3970,9 @@ func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceDat jobInputs = append(jobInputs, jobInputsItemMap) } if err = d.Set("job_inputs", jobInputs); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting job_inputs: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if job.Settings != nil { @@ -3970,76 +3982,114 @@ func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceDat jobEnvSettings = append(jobEnvSettings, jobEnvSettingsItemMap) } if err = d.Set("job_env_settings", jobEnvSettings); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting job_env_settings: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if job.Tags != nil { if err = d.Set("tags", job.Tags); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting tags: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("location", job.Location); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if job.Status != nil { statusMap := resourceIBMSchematicsJobJobStatusToMap(*job.Status) if err = d.Set("status", []map[string]interface{}{statusMap}); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting status: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if job.Data != nil { dataMap := resourceIBMSchematicsJobJobDataToMap(*job.Data) if err = d.Set("data", []map[string]interface{}{dataMap}); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting data: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if job.Bastion != nil { bastionMap := resourceIBMSchematicsJobBastionResourceDefinitionToMap(*job.Bastion) if err = d.Set("bastion", []map[string]interface{}{bastionMap}); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting bastion: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if job.LogSummary != nil { logSummaryMap := resourceIBMSchematicsJobJobLogSummaryToMap(*job.LogSummary) if err = d.Set("log_summary", []map[string]interface{}{logSummaryMap}); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting log_summary: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("name", job.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("description", job.Description); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting description: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("resource_group", job.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_group: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("submitted_at", flex.DateTimeToString(job.SubmittedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting submitted_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("submitted_by", job.SubmittedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting submitted_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("start_at", flex.DateTimeToString(job.StartAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting start_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("end_at", flex.DateTimeToString(job.EndAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting end_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("duration", job.Duration); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting duration: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("log_store_url", job.LogStoreURL); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting log_store_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("state_store_url", job.StateStoreURL); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting state_store_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("results_url", job.ResultsURL); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting results_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(job.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return nil diff --git a/ibm/service/schematics/resource_ibm_schematics_policy.go b/ibm/service/schematics/resource_ibm_schematics_policy.go index 2744f299f1..1419326423 100644 --- a/ibm/service/schematics/resource_ibm_schematics_policy.go +++ b/ibm/service/schematics/resource_ibm_schematics_policy.go @@ -395,21 +395,31 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource } if err = d.Set("name", policy.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("description", policy.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("resource_group", policy.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if policy.Tags != nil { if err = d.Set("tags", policy.Tags); err != nil { - return diag.FromErr(fmt.Errorf("Error setting tags: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("location", policy.Location); err != nil { - return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if policy.State != nil { stateMap, err := resourceIbmSchematicsPolicyUserStateToMap(policy.State) @@ -419,11 +429,15 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource return tfErr.GetDiag() } if err = d.Set("state", []map[string]interface{}{stateMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("kind", policy.Kind); err != nil { - return diag.FromErr(fmt.Errorf("Error setting kind: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if policy.Target != nil { targetMap, err := resourceIbmSchematicsPolicyPolicyObjectsToMap(policy.Target) @@ -433,7 +447,9 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource return tfErr.GetDiag() } if err = d.Set("target", []map[string]interface{}{targetMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting target: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if policy.Parameter != nil { @@ -444,7 +460,9 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource return tfErr.GetDiag() } if err = d.Set("parameter", []map[string]interface{}{parameterMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting parameter: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } scopedResources := []map[string]interface{}{} @@ -460,22 +478,34 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource } } if err = d.Set("scoped_resources", scopedResources); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scoped_resources: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("crn", policy.Crn); err != nil { - return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("account", policy.Account); err != nil { - return diag.FromErr(fmt.Errorf("Error setting account: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(policy.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_by", policy.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(policy.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return nil diff --git a/ibm/service/schematics/resource_ibm_schematics_resource_query.go b/ibm/service/schematics/resource_ibm_schematics_resource_query.go index 97dc2ec75e..a9c9cb0032 100644 --- a/ibm/service/schematics/resource_ibm_schematics_resource_query.go +++ b/ibm/service/schematics/resource_ibm_schematics_resource_query.go @@ -249,10 +249,14 @@ func resourceIBMSchematicsResourceQueryRead(context context.Context, d *schema.R return tfErr.GetDiag() } if err = d.Set("type", resourceQueryRecord.Type); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("name", resourceQueryRecord.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if resourceQueryRecord.Queries != nil { queries := []map[string]interface{}{} @@ -261,20 +265,30 @@ func resourceIBMSchematicsResourceQueryRead(context context.Context, d *schema.R queries = append(queries, queriesItemMap) } if err = d.Set("queries", queries); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting queries: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("created_at", flex.DateTimeToString(resourceQueryRecord.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("created_by", resourceQueryRecord.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(resourceQueryRecord.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", resourceQueryRecord.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return nil diff --git a/ibm/service/schematics/resource_ibm_schematics_workspace.go b/ibm/service/schematics/resource_ibm_schematics_workspace.go index 7e6afdfd5f..9b0d628760 100644 --- a/ibm/service/schematics/resource_ibm_schematics_workspace.go +++ b/ibm/service/schematics/resource_ibm_schematics_workspace.go @@ -1108,38 +1108,54 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou } if workspaceResponse.AppliedShareddataIds != nil { if err = d.Set("applied_shareddata_ids", workspaceResponse.AppliedShareddataIds); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting applied_shareddata_ids: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if workspaceResponse.CatalogRef != nil { catalogRefMap := resourceIBMSchematicsWorkspaceCatalogRefToMap(*workspaceResponse.CatalogRef) if err = d.Set("catalog_ref", []map[string]interface{}{catalogRefMap}); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting catalog_ref: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("description", workspaceResponse.Description); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting description: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("location", workspaceResponse.Location); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting location: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("name", workspaceResponse.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("resource_group", workspaceResponse.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_group: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if _, ok := d.GetOk("shared_data"); ok { if workspaceResponse.SharedData != nil { sharedDataMap := resourceIBMSchematicsWorkspaceSharedTargetDataResponseToMap(*workspaceResponse.SharedData) if err = d.Set("shared_data", []map[string]interface{}{sharedDataMap}); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading shared_data: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } } if workspaceResponse.Tags != nil { if err = d.Set("tags", workspaceResponse.Tags); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting tags: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if workspaceResponse.TemplateData != nil { @@ -1149,53 +1165,83 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou templateData = append(templateData, templateDataItemMap) } if err = d.Set("template_env_settings", templateData[0]["env_values"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading env_values: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_git_folder", templateData[0]["folder"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading folder: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_init_state_file", templateData[0]["init_state_file"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading init_state_file: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_type", templateData[0]["type"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_uninstall_script_name", templateData[0]["uninstall_script_name"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading uninstall_script_name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_values", templateData[0]["values"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading values: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_values_metadata", templateData[0]["values_metadata"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading values_metadata: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_inputs", templateData[0]["variablestore"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading variablestore: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("template_ref", workspaceResponse.TemplateRef); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting template_ref: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if workspaceResponse.TemplateRepo != nil { templateRepoMap := resourceIBMSchematicsWorkspaceTemplateRepoResponseToMap(*workspaceResponse.TemplateRepo) if err = d.Set("template_git_branch", templateRepoMap["branch"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading branch: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_git_release", templateRepoMap["release"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading release: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_git_repo_sha_value", templateRepoMap["repo_sha_value"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading repo_sha_value: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_git_repo_url", templateRepoMap["repo_url"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading repo_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_git_url", templateRepoMap["url"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("template_git_has_uploadedgitrepotar", templateRepoMap["has_uploadedgitrepotar"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading has_uploadedgitrepotar: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } /*if workspaceResponse.Type != nil { @@ -1206,38 +1252,58 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou if workspaceResponse.WorkspaceStatus != nil { workspaceStatusMap := resourceIBMSchematicsWorkspaceWorkspaceStatusResponseToMap(*workspaceResponse.WorkspaceStatus) if err = d.Set("frozen", workspaceStatusMap["frozen"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading frozen: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("frozen_at", workspaceStatusMap["frozen_at"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading frozen_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("frozen_by", workspaceStatusMap["frozen_by"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading frozen_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("locked", workspaceStatusMap["locked"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading locked: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("locked_by", workspaceStatusMap["locked_by"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading locked_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("locked_time", workspaceStatusMap["locked_time"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading locked_time: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if workspaceResponse.CreatedAt != nil { if err = d.Set("created_at", workspaceResponse.CreatedAt.String()); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("created_by", workspaceResponse.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("crn", workspaceResponse.Crn); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading crn: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if workspaceResponse.LastHealthCheckAt != nil { if err = d.Set("last_health_check_at", workspaceResponse.LastHealthCheckAt.String()); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading last_health_check_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if workspaceResponse.RuntimeData != nil { @@ -1247,27 +1313,39 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou runtimeData = append(runtimeData, runtimeDataItemMap) } if err = d.Set("runtime_data", runtimeData); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting runtime_data: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("status", workspaceResponse.Status); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting status: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if workspaceResponse.UpdatedAt != nil { if err = d.Set("updated_at", workspaceResponse.UpdatedAt.String()); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading updated_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } if err = d.Set("updated_by", workspaceResponse.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_by: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if workspaceResponse.WorkspaceStatusMsg != nil { workspaceStatusMsgMap := resourceIBMSchematicsWorkspaceWorkspaceStatusMessageToMap(*workspaceResponse.WorkspaceStatusMsg) if err = d.Set("status_code", workspaceStatusMsgMap["status_code"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading status_code: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_msg", workspaceStatusMsgMap["status_msg"]); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error reading status_msg: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } From d8ad0ba24a0e315dee4ea50ddead7abc7c55b562 Mon Sep 17 00:00:00 2001 From: VaishnaviGopal Date: Wed, 9 Oct 2024 12:46:40 +0530 Subject: [PATCH 5/7] some hand-edit changes on err diag before making func name changes in sch --- .../data_source_ibm_schematics_output.go | 4 +- .../resource_ibm_schematics_agent.go | 9 +-- .../resource_ibm_schematics_agent_deploy.go | 67 +++++++++---------- .../resource_ibm_schematics_agent_health.go | 55 ++++++++------- .../resource_ibm_schematics_agent_prs.go | 55 ++++++++------- 5 files changed, 95 insertions(+), 95 deletions(-) diff --git a/ibm/service/schematics/data_source_ibm_schematics_output.go b/ibm/service/schematics/data_source_ibm_schematics_output.go index 4cc417d8e2..f7a883a11c 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_output.go +++ b/ibm/service/schematics/data_source_ibm_schematics_output.go @@ -6,6 +6,7 @@ package schematics import ( "encoding/json" "fmt" + "log" "time" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -75,7 +76,8 @@ func dataSourceIBMSchematicsOutputRead(d *schema.ResourceData, meta interface{}) outputValuesList, response, err := schematicsClient.GetWorkspaceOutputs(getWorkspaceOutputsOptions) if err != nil { - + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return err } diff --git a/ibm/service/schematics/resource_ibm_schematics_agent.go b/ibm/service/schematics/resource_ibm_schematics_agent.go index 8ffd6c08a6..5c095e3578 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent.go @@ -1013,7 +1013,8 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc response, err := schematicsClient.DeleteAgentResourcesWithContext(context, deleteAgentResourcesOptions) if err != nil { - + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) } else { _, err = isWaitForAgentDestroyResources(context, schematicsClient, *deleteAgentResourcesOptions.AgentID, d.Timeout(schema.TimeoutUpdate)) if err != nil { @@ -1071,7 +1072,8 @@ func resourceIbmSchematicsAgentDelete(context context.Context, d *schema.Resourc response, err := schematicsClient.DeleteAgentResourcesWithContext(context, deleteAgentResourcesOptions) if err != nil { - + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) } else { _, err = isWaitForAgentDestroyResources(context, schematicsClient, *deleteAgentResourcesOptions.AgentID, d.Timeout(schema.TimeoutDelete)) if err != nil { @@ -1083,8 +1085,7 @@ func resourceIbmSchematicsAgentDelete(context context.Context, d *schema.Resourc deleteresponse, err := schematicsClient.DeleteAgentDataWithContext(context, deleteAgentDataOptions) if err != nil { - - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, deleteresponse), "ibm_cloud", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go b/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go index 2553f5a10d..d3f59ce8af 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go @@ -128,9 +128,9 @@ func resourceIbmSchematicsAgentDeployCreate(context context.Context, d *schema.R _, err = isWaitForAgentAvailable(context, schematicsClient, *deployAgentJobOptions.AgentID, d.Timeout(schema.TimeoutCreate)) if err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } return resourceIbmSchematicsAgentDeployRead(context, d, meta) @@ -211,44 +211,44 @@ func resourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.Res if agentData.RecentDeployJob != nil { if err = d.Set("agent_id", parts[0]); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentDeployJob.JobID); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentDeployJob.UpdatedAt)); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentDeployJob.UpdatedBy); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentDeployJob.StatusCode); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentDeployJob.StatusMessage); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentDeployJob.LogURL); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -289,10 +289,9 @@ func resourceIbmSchematicsAgentDeployUpdate(context context.Context, d *schema.R hasChange := false if d.HasChange("agent_id") { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() - " The resource must be re-created to update this property.", "agent_id")) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if d.HasChange("force") { deployAgentJobOptions.SetForce(d.Get("force").(bool)) @@ -311,9 +310,9 @@ return tfErr.GetDiag() _, err = isWaitForAgentAvailable(context, schematicsClient, parts[0], d.Timeout(schema.TimeoutUpdate)) if err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_health.go b/ibm/service/schematics/resource_ibm_schematics_agent_health.go index 87032fb9de..195a51edf0 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_health.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_health.go @@ -153,44 +153,44 @@ func resourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.Res if agentData.RecentHealthJob != nil { if err = d.Set("agent_id", parts[0]); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentHealthJob.JobID); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentHealthJob.UpdatedAt)); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentHealthJob.UpdatedBy); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentHealthJob.StatusCode); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentHealthJob.StatusMessage); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentHealthJob.LogURL); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -233,10 +233,9 @@ func resourceIbmSchematicsAgentHealthUpdate(context context.Context, d *schema.R hasChange := false if d.HasChange("agent_id") { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() - " The resource must be re-created to update this property.", "agent_id")) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if d.HasChange("force") { healthCheckAgentJobOptions.SetForce(d.Get("force").(bool)) diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_prs.go b/ibm/service/schematics/resource_ibm_schematics_agent_prs.go index 5064426621..d82ab74e15 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_prs.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_prs.go @@ -151,44 +151,44 @@ func resourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.Resour if agentData.RecentPrsJob != nil { if err = d.Set("agent_id", parts[0]); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentPrsJob.JobID); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentPrsJob.UpdatedAt)); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentPrsJob.UpdatedBy); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentPrsJob.StatusCode); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentPrsJob.StatusMessage); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentPrsJob.LogURL); err != nil { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -230,10 +230,9 @@ func resourceIbmSchematicsAgentPrsUpdate(context context.Context, d *schema.Reso hasChange := false if d.HasChange("agent_id") { -tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") -log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) -return tfErr.GetDiag() - " The resource must be re-created to update this property.", "agent_id")) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if d.HasChange("force") { prsAgentJobOptions.SetForce(d.Get("force").(bool)) From b65c3731cd9c2bfa3c6078657f0247906c74d325 Mon Sep 17 00:00:00 2001 From: VaishnaviGopal Date: Thu, 5 Dec 2024 15:42:22 +0530 Subject: [PATCH 6/7] all ds specific changes for new way of logging --- .../data_source_ibm_schematics_action.go | 64 +++++++-------- .../data_source_ibm_schematics_agent.go | 66 +++++++-------- ...data_source_ibm_schematics_agent_deploy.go | 22 ++--- ...data_source_ibm_schematics_agent_health.go | 20 ++--- .../data_source_ibm_schematics_agent_prs.go | 20 ++--- .../data_source_ibm_schematics_agents.go | 16 ++-- .../data_source_ibm_schematics_inventory.go | 24 +++--- .../data_source_ibm_schematics_job.go | 52 ++++++------ .../data_source_ibm_schematics_output.go | 2 +- .../data_source_ibm_schematics_policies.go | 16 ++-- .../data_source_ibm_schematics_policy.go | 44 +++++----- ...ta_source_ibm_schematics_resource_query.go | 20 ++--- .../data_source_ibm_schematics_state.go | 8 +- .../data_source_ibm_schematics_workspace.go | 82 +++++++++---------- 14 files changed, 228 insertions(+), 228 deletions(-) diff --git a/ibm/service/schematics/data_source_ibm_schematics_action.go b/ibm/service/schematics/data_source_ibm_schematics_action.go index 23d93c7f21..3c00f993cb 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_action.go +++ b/ibm/service/schematics/data_source_ibm_schematics_action.go @@ -947,7 +947,7 @@ func DataSourceIBMSchematicsAction() *schema.Resource { func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -965,29 +965,29 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour action, response, err := schematicsClient.GetActionWithContext(context, getActionOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead GetActionWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } d.SetId(*getActionOptions.ActionID) if err = d.Set("name", action.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("description", action.Description); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("location", action.Location); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("resource_group", action.ResourceGroup); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -995,13 +995,13 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour if action.UserState != nil { err = d.Set("user_state", dataSourceActionFlattenUserState(*action.UserState)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("source_readme_url", action.SourceReadmeURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1009,23 +1009,23 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour if action.Source != nil { err = d.Set("source", dataSourceActionFlattenSource(*action.Source)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("source_type", action.SourceType); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("command_parameter", action.CommandParameter); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("inventory", action.Inventory); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1033,7 +1033,7 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour if action.Credentials != nil { err = d.Set("credentials", dataSourceActionFlattenCredentials(action.Credentials)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1042,7 +1042,7 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour if action.Bastion != nil { err = d.Set("bastion", dataSourceActionFlattenBastion(*action.Bastion)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1051,13 +1051,13 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour if action.BastionCredential != nil { err = d.Set("bastion_credential", dataSourceActionFlattenBastionCredential(*action.BastionCredential)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("targets_ini", action.TargetsIni); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1065,7 +1065,7 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour if action.Inputs != nil { err = d.Set("action_inputs", dataSourceActionFlattenInputs(action.Inputs)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1074,7 +1074,7 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour if action.Outputs != nil { err = d.Set("action_outputs", dataSourceActionFlattenOutputs(action.Outputs)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1083,63 +1083,63 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour if action.Settings != nil { err = d.Set("settings", dataSourceActionFlattenSettings(action.Settings)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("id", action.ID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("crn", action.Crn); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("account", action.Account); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("source_created_at", flex.DateTimeToString(action.SourceCreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("source_created_by", action.SourceCreatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("source_updated_at", flex.DateTimeToString(action.SourceUpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("source_updated_by", action.SourceUpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(action.CreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_by", action.CreatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(action.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", action.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1147,7 +1147,7 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour if action.State != nil { err = d.Set("state", dataSourceActionFlattenState(*action.State)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1156,7 +1156,7 @@ func dataSourceIBMSchematicsActionRead(context context.Context, d *schema.Resour if action.SysLock != nil { err = d.Set("sys_lock", dataSourceActionFlattenSysLock(*action.SysLock)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent.go b/ibm/service/schematics/data_source_ibm_schematics_agent.go index 2235b9c106..55389d7496 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent.go @@ -537,7 +537,7 @@ func DataSourceIbmSchematicsAgent() *schema.Resource { func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -551,7 +551,7 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc agentData, response, err := schematicsClient.GetAgentDataWithContext(context, getAgentDataOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead GetAgentDataWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -559,43 +559,43 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc d.SetId(fmt.Sprintf("%s", *getAgentDataOptions.AgentID)) if err = d.Set("name", agentData.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("description", agentData.Description); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("resource_group", agentData.ResourceGroup); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("version", agentData.Version); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("schematics_location", agentData.SchematicsLocation); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("agent_location", agentData.AgentLocation); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if agentData.Tags != nil { if err = d.Set("tags", agentData.Tags); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -604,14 +604,14 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.AgentInfrastructure != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentInfrastructureToMap(agentData.AgentInfrastructure) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } agentInfrastructure = append(agentInfrastructure, modelMap) } if err = d.Set("agent_infrastructure", agentInfrastructure); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -621,7 +621,7 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc for _, modelItem := range agentData.AgentMetadata { modelMap, err := dataSourceIbmSchematicsAgentAgentMetadataInfoToMap(&modelItem) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -629,7 +629,7 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc } } if err = d.Set("agent_metadata", agentMetadata); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -639,7 +639,7 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc for _, modelItem := range agentData.AgentInputs { modelMap, err := dataSourceIbmSchematicsAgentVariableDataToMap(&modelItem) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -647,7 +647,7 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc } } if err = d.Set("agent_inputs", agentInputs); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -656,50 +656,50 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.UserState != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentUserStateToMap(agentData.UserState) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } userState = append(userState, modelMap) } if err = d.Set("user_state", userState); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("agent_crn", agentData.AgentCrn); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("id", agentData.ID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(agentData.CreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("creation_by", agentData.CreationBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -708,14 +708,14 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.SystemState != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentSystemStatusToMap(agentData.SystemState) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } systemState = append(systemState, modelMap) } if err = d.Set("system_state", systemState); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -724,14 +724,14 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.AgentKpi != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentKPIDataToMap(agentData.AgentKpi) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } agentKpi = append(agentKpi, modelMap) } if err = d.Set("agent_kpi", agentKpi); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -740,14 +740,14 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.RecentPrsJob != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentDataRecentPrsJobToMap(agentData.RecentPrsJob) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } recentPrsJob = append(recentPrsJob, modelMap) } if err = d.Set("recent_prs_job", recentPrsJob); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -756,14 +756,14 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.RecentDeployJob != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentDataRecentDeployJobToMap(agentData.RecentDeployJob) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } recentDeployJob = append(recentDeployJob, modelMap) } if err = d.Set("recent_deploy_job", recentDeployJob); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -772,14 +772,14 @@ func dataSourceIbmSchematicsAgentRead(context context.Context, d *schema.Resourc if agentData.RecentHealthJob != nil { modelMap, err := dataSourceIbmSchematicsAgentAgentDataRecentHealthJobToMap(agentData.RecentHealthJob) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } recentHealthJob = append(recentHealthJob, modelMap) } if err = d.Set("recent_health_job", recentHealthJob); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go b/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go index 8caa3f2528..dbbeeee4f1 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_deploy.go @@ -75,7 +75,7 @@ func dataSourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.R schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentDeployRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -92,7 +92,7 @@ func dataSourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.R return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentDeployRead GetAgentDataWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -101,49 +101,49 @@ func dataSourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.R if agentData.RecentDeployJob != nil { if err = d.Set("agent_id", getAgentDataOptions.AgentID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentDeployJob.JobID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } else if agentData.RecentDeployJob.JobID != nil { d.SetId(fmt.Sprintf("%s", *agentData.RecentDeployJob.JobID)) } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentDeployJob.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentDeployJob.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("is_redeployed", agentData.RecentDeployJob.IsRedeployed); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentDeployJob.StatusCode); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentDeployJob.StatusMessage); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentDeployJob.LogURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_health.go b/ibm/service/schematics/data_source_ibm_schematics_agent_health.go index 85d3685386..e4fb84281e 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_health.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_health.go @@ -70,7 +70,7 @@ func dataSourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.R schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentHealthRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -87,7 +87,7 @@ func dataSourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.R return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentHealthRead GetAgentDataWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -96,44 +96,44 @@ func dataSourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.R if agentData.RecentHealthJob != nil { if err = d.Set("agent_id", getAgentDataOptions.AgentID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentHealthJob.JobID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } else if agentData.RecentHealthJob.JobID != nil { d.SetId(fmt.Sprintf("%s", *agentData.RecentHealthJob.JobID)) } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentHealthJob.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentHealthJob.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentHealthJob.StatusCode); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentHealthJob.StatusMessage); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentHealthJob.LogURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go b/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go index 7e4a3a858f..2eedf7ba83 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agent_prs.go @@ -70,7 +70,7 @@ func DataSourceIbmSchematicsAgentPrs() *schema.Resource { func dataSourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentPrsRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -87,7 +87,7 @@ func dataSourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.Reso return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentPrsRead GetAgentDataWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -96,44 +96,44 @@ func dataSourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.Reso if agentData.RecentPrsJob != nil { if err = d.Set("agent_id", getAgentDataOptions.AgentID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentPrsJob.JobID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } else if agentData.RecentPrsJob.JobID != nil { d.SetId(fmt.Sprintf("%s", *agentData.RecentPrsJob.JobID)) } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentPrsJob.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentPrsJob.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentPrsJob.StatusCode); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentPrsJob.StatusMessage); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentPrsJob.LogURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/data_source_ibm_schematics_agents.go b/ibm/service/schematics/data_source_ibm_schematics_agents.go index f21d1c341f..4dcc7d234f 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_agents.go +++ b/ibm/service/schematics/data_source_ibm_schematics_agents.go @@ -188,7 +188,7 @@ func DataSourceIbmSchematicsAgents() *schema.Resource { func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentsRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agents", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -198,7 +198,7 @@ func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.Resour agentList, response, err := schematicsClient.ListAgentWithContext(context, listAgentOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentsRead ListAgentWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agents", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -224,7 +224,7 @@ func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.Resour if suppliedFilter { if len(agentList.Agents) == 0 { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentsRead failed with error: %s", err), "ibm_schematics_agents", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -234,19 +234,19 @@ func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.Resour } if err = d.Set("total_count", flex.IntValue(agentList.TotalCount)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentsRead failed with error: %s", err), "ibm_schematics_agents", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("limit", flex.IntValue(agentList.Limit)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentsRead failed with error: %s", err), "ibm_schematics_agents", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("offset", flex.IntValue(agentList.Offset)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentsRead failed with error: %s", err), "ibm_schematics_agents", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -256,7 +256,7 @@ func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.Resour for _, modelItem := range agentList.Agents { modelMap, err := dataSourceIbmSchematicsAgentsAgentToMap(&modelItem) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentsRead failed: %s", err.Error()), "ibm_schematics_agents", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -264,7 +264,7 @@ func dataSourceIbmSchematicsAgentsRead(context context.Context, d *schema.Resour } } if err = d.Set("agents", agents); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsAgentsRead failed with error: %s", err), "ibm_schematics_agents", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/data_source_ibm_schematics_inventory.go b/ibm/service/schematics/data_source_ibm_schematics_inventory.go index 830e6a8059..7cacc49ada 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_inventory.go +++ b/ibm/service/schematics/data_source_ibm_schematics_inventory.go @@ -92,7 +92,7 @@ func DataSourceIBMSchematicsInventory() *schema.Resource { func dataSourceIBMSchematicsInventoryRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsInventoryRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -111,59 +111,59 @@ func dataSourceIBMSchematicsInventoryRead(context context.Context, d *schema.Res inventoryResourceRecord, response, err := schematicsClient.GetInventoryWithContext(context, getInventoryOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsInventoryRead GetInventoryWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } d.SetId(*getInventoryOptions.InventoryID) if err = d.Set("name", inventoryResourceRecord.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("id", inventoryResourceRecord.ID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("description", inventoryResourceRecord.Description); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("location", inventoryResourceRecord.Location); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("resource_group", inventoryResourceRecord.ResourceGroup); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(inventoryResourceRecord.CreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_by", inventoryResourceRecord.CreatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(inventoryResourceRecord.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", inventoryResourceRecord.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("inventories_ini", inventoryResourceRecord.InventoriesIni); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/data_source_ibm_schematics_job.go b/ibm/service/schematics/data_source_ibm_schematics_job.go index 5ba36bee12..88b0211e60 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_job.go +++ b/ibm/service/schematics/data_source_ibm_schematics_job.go @@ -2816,7 +2816,7 @@ func DataSourceIBMSchematicsJob() *schema.Resource { func dataSourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -2834,29 +2834,29 @@ func dataSourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceD job, response, err := schematicsClient.GetJobWithContext(context, getJobOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead GetJobWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } d.SetId(*getJobOptions.JobID) if err = d.Set("command_object", job.CommandObject); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("command_object_id", job.CommandObjectID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("command_name", job.CommandName); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("command_parameter", job.CommandParameter); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -2864,7 +2864,7 @@ func dataSourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceD if job.Inputs != nil { err = d.Set("job_inputs", dataSourceJobFlattenInputs(job.Inputs)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -2873,58 +2873,58 @@ func dataSourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceD if job.Settings != nil { err = d.Set("job_env_settings", dataSourceJobFlattenSettings(job.Settings)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("id", job.ID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("name", job.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("description", job.Description); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("location", job.Location); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("resource_group", job.ResourceGroup); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("submitted_at", flex.DateTimeToString(job.SubmittedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("submitted_by", job.SubmittedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("start_at", flex.DateTimeToString(job.StartAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("end_at", flex.DateTimeToString(job.EndAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("duration", job.Duration); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -2932,7 +2932,7 @@ func dataSourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceD if job.Status != nil { err = d.Set("status", dataSourceJobFlattenStatus(*job.Status)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -2941,7 +2941,7 @@ func dataSourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceD if job.Data != nil { err = d.Set("data", dataSourceJobFlattenData(*job.Data)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -2950,7 +2950,7 @@ func dataSourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceD if job.Bastion != nil { err = d.Set("bastion", dataSourceJobFlattenBastion(*job.Bastion)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -2959,28 +2959,28 @@ func dataSourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceD if job.LogSummary != nil { err = d.Set("log_summary", dataSourceJobFlattenLogSummary(*job.LogSummary)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("log_store_url", job.LogStoreURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("state_store_url", job.StateStoreURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("results_url", job.ResultsURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(job.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/data_source_ibm_schematics_output.go b/ibm/service/schematics/data_source_ibm_schematics_output.go index f7a883a11c..3696ff165f 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_output.go +++ b/ibm/service/schematics/data_source_ibm_schematics_output.go @@ -76,7 +76,7 @@ func dataSourceIBMSchematicsOutputRead(d *schema.ResourceData, meta interface{}) outputValuesList, response, err := schematicsClient.GetWorkspaceOutputs(getWorkspaceOutputsOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsOutputRead GetWorkspaceOutputs failed with error: %s and response:\n%s", err, response), "ibm_schematics_output", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return err } diff --git a/ibm/service/schematics/data_source_ibm_schematics_policies.go b/ibm/service/schematics/data_source_ibm_schematics_policies.go index d4173d5fe7..d44c0f59b9 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_policies.go +++ b/ibm/service/schematics/data_source_ibm_schematics_policies.go @@ -145,7 +145,7 @@ func DataSourceIbmSchematicsPolicies() *schema.Resource { func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPoliciesRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_policies", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -155,7 +155,7 @@ func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.Reso policyList, response, err := schematicsClient.ListPolicyWithContext(context, listPolicyOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPoliciesRead ListPolicyWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_policies", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -183,7 +183,7 @@ func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.Reso if suppliedFilter { if len(policyList.Policies) == 0 { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPoliciesRead failed with error: %s", err), "ibm_schematics_policies", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -193,19 +193,19 @@ func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.Reso } if err = d.Set("total_count", flex.IntValue(policyList.TotalCount)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPoliciesRead failed with error: %s", err), "ibm_schematics_policies", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("limit", flex.IntValue(policyList.Limit)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPoliciesRead failed with error: %s", err), "ibm_schematics_policies", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("offset", flex.IntValue(policyList.Offset)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPoliciesRead failed with error: %s", err), "ibm_schematics_policies", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -215,7 +215,7 @@ func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.Reso for _, modelItem := range policyList.Policies { modelMap, err := dataSourceIbmSchematicsPoliciesPolicyLiteToMap(&modelItem) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPoliciesRead failed: %s", err.Error()), "ibm_schematics_policies", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -223,7 +223,7 @@ func dataSourceIbmSchematicsPoliciesRead(context context.Context, d *schema.Reso } } if err = d.Set("policies", policies); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPoliciesRead failed with error: %s", err), "ibm_schematics_policies", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/data_source_ibm_schematics_policy.go b/ibm/service/schematics/data_source_ibm_schematics_policy.go index 51ec47635e..ab09041fb8 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_policy.go +++ b/ibm/service/schematics/data_source_ibm_schematics_policy.go @@ -268,7 +268,7 @@ func DataSourceIbmSchematicsPolicy() *schema.Resource { func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -280,7 +280,7 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour policy, response, err := schematicsClient.GetPolicyWithContext(context, getPolicyOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead GetPolicyWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -288,25 +288,25 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour d.SetId(fmt.Sprintf("%s", *getPolicyOptions.PolicyID)) if err = d.Set("name", policy.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("description", policy.Description); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("resource_group", policy.ResourceGroup); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("location", policy.Location); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -315,27 +315,27 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour if policy.State != nil { modelMap, err := dataSourceIbmSchematicsPolicyUserStateToMap(policy.State) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed: %s", err.Error()), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } state = append(state, modelMap) } if err = d.Set("state", state); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("kind", policy.Kind); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if policy.Tags != nil { if err = d.Set("tags", policy.Tags); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -344,14 +344,14 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour if policy.Target != nil { modelMap, err := dataSourceIbmSchematicsPolicyPolicyObjectsToMap(policy.Target) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed: %s", err.Error()), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } target = append(target, modelMap) } if err = d.Set("target", target); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -360,32 +360,32 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour if policy.Parameter != nil { modelMap, err := dataSourceIbmSchematicsPolicyPolicyParameterToMap(policy.Parameter) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed: %s", err.Error()), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } parameter = append(parameter, modelMap) } if err = d.Set("parameter", parameter); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("id", policy.ID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("crn", policy.Crn); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("account", policy.Account); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -395,7 +395,7 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour for _, modelItem := range policy.ScopedResources { modelMap, err := dataSourceIbmSchematicsPolicyScopedResourceToMap(&modelItem) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed: %s", err.Error()), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -403,25 +403,25 @@ func dataSourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resour } } if err = d.Set("scoped_resources", scopedResources); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(policy.CreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_by", policy.CreatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(policy.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/data_source_ibm_schematics_resource_query.go b/ibm/service/schematics/data_source_ibm_schematics_resource_query.go index ee057b3a84..0efc508045 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_resource_query.go +++ b/ibm/service/schematics/data_source_ibm_schematics_resource_query.go @@ -117,7 +117,7 @@ func DataSourceIBMSchematicsResourceQuery() *schema.Resource { func dataSourceIBMSchematicsResourceQueryRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsResourceQueryRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -136,44 +136,44 @@ func dataSourceIBMSchematicsResourceQueryRead(context context.Context, d *schema resourceQueryRecord, response, err := schematicsClient.GetResourcesQueryWithContext(context, getResourcesQueryOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsResourceQueryRead GetResourcesQueryWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } d.SetId(*getResourcesQueryOptions.QueryID) if err = d.Set("type", resourceQueryRecord.Type); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("name", resourceQueryRecord.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("id", resourceQueryRecord.ID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(resourceQueryRecord.CreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_by", resourceQueryRecord.CreatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(resourceQueryRecord.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", resourceQueryRecord.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -181,7 +181,7 @@ func dataSourceIBMSchematicsResourceQueryRead(context context.Context, d *schema if resourceQueryRecord.Queries != nil { err = d.Set("queries", dataSourceResourceQueryRecordFlattenQueries(resourceQueryRecord.Queries)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/data_source_ibm_schematics_state.go b/ibm/service/schematics/data_source_ibm_schematics_state.go index a8ecfe1c0c..6785aef006 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_state.go +++ b/ibm/service/schematics/data_source_ibm_schematics_state.go @@ -59,7 +59,7 @@ func DataSourceIBMSchematicsState() *schema.Resource { func dataSourceIBMSchematicsStateRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsStateRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_state", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -79,7 +79,7 @@ func dataSourceIBMSchematicsStateRead(context context.Context, d *schema.Resourc _, response, _ := schematicsClient.GetWorkspaceTemplateStateWithContext(context, getWorkspaceTemplateStateOptions) if response.StatusCode != 200 { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsStateRead GetWorkspaceTemplateStateWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_state", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -100,7 +100,7 @@ func dataSourceIBMSchematicsStateRead(context context.Context, d *schema.Resourc stateByte, err := json.MarshalIndent(stateStore, "", "") if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsStateRead failed: %s", err.Error()), "ibm_schematics_state", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -110,7 +110,7 @@ func dataSourceIBMSchematicsStateRead(context context.Context, d *schema.Resourc controller, err := flex.GetBaseController(meta) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsStateRead failed: %s", err.Error()), "ibm_schematics_state", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/data_source_ibm_schematics_workspace.go b/ibm/service/schematics/data_source_ibm_schematics_workspace.go index 9c404e9d11..4d28946df1 100644 --- a/ibm/service/schematics/data_source_ibm_schematics_workspace.go +++ b/ibm/service/schematics/data_source_ibm_schematics_workspace.go @@ -638,7 +638,7 @@ func SchematicsEndpointURL(region, meta interface{}) (string, bool, error) { func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -657,7 +657,7 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res workspaceResponse, response, err := schematicsClient.GetWorkspaceWithContext(context, getWorkspaceOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead GetWorkspaceWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -667,49 +667,49 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res if workspaceResponse.CatalogRef != nil { err = d.Set("catalog_ref", dataSourceWorkspaceResponseFlattenCatalogRef(*workspaceResponse.CatalogRef)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("created_at", flex.DateTimeToString(workspaceResponse.CreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_by", workspaceResponse.CreatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("crn", workspaceResponse.Crn); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("description", workspaceResponse.Description); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("last_health_check_at", flex.DateTimeToString(workspaceResponse.LastHealthCheckAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("location", workspaceResponse.Location); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("name", workspaceResponse.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("resource_group", workspaceResponse.ResourceGroup); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -717,7 +717,7 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res if workspaceResponse.RuntimeData != nil { err = d.Set("runtime_data", dataSourceWorkspaceResponseFlattenRuntimeData(workspaceResponse.RuntimeData)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -726,13 +726,13 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res if workspaceResponse.SharedData != nil { err = d.Set("shared_data", dataSourceWorkspaceResponseFlattenSharedData(*workspaceResponse.SharedData)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("status", workspaceResponse.Status); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -741,32 +741,32 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res templateData := dataSourceWorkspaceResponseFlattenTemplateData(workspaceResponse.TemplateData) if err = d.Set("template_env_settings", templateData[0]["env_values"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_git_folder", templateData[0]["folder"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_init_state_file", templateData[0]["init_state_file"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_type", templateData[0]["type"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_uninstall_script_name", templateData[0]["uninstall_script_name"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_values", templateData[0]["values"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -775,13 +775,13 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res fmt.Println(fmt.Errorf("[ERROR] Error reading template_values_metadata %s", err)) } if err = d.Set("template_inputs", templateData[0]["variablestore"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("template_ref", workspaceResponse.TemplateRef); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -789,32 +789,32 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res if workspaceResponse.TemplateRepo != nil { templateRepoMap := dataSourceWorkspaceResponseFlattenTemplateRepo(*workspaceResponse.TemplateRepo) if err = d.Set("template_git_branch", templateRepoMap[0]["branch"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_git_release", templateRepoMap[0]["release"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_git_repo_sha_value", templateRepoMap[0]["repo_sha_value"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_git_repo_url", templateRepoMap[0]["repo_url"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_git_url", templateRepoMap[0]["url"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_git_has_uploadedgitrepotar", templateRepoMap[0]["has_uploadedgitrepotar"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -824,13 +824,13 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res }*/ if workspaceResponse.UpdatedAt != nil { if err = d.Set("updated_at", workspaceResponse.UpdatedAt.String()); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("updated_by", workspaceResponse.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -838,42 +838,42 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res if workspaceResponse.WorkspaceStatus != nil { workspaceStatusMap := dataSourceWorkspaceResponseFlattenWorkspaceStatus(*workspaceResponse.WorkspaceStatus) if err = d.Set("is_frozen", workspaceStatusMap[0]["frozen"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("frozen", workspaceStatusMap[0]["frozen"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("frozen_at", workspaceStatusMap[0]["frozen_at"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("frozen_by", workspaceStatusMap[0]["frozen_by"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("is_locked", workspaceStatusMap[0]["locked"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("locked", workspaceStatusMap[0]["locked"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("locked_by", workspaceStatusMap[0]["locked_by"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("locked_time", workspaceStatusMap[0]["locked_time"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -882,12 +882,12 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res if workspaceResponse.WorkspaceStatusMsg != nil { workspaceStatusMsgMap := dataSourceWorkspaceResponseFlattenWorkspaceStatusMsg(*workspaceResponse.WorkspaceStatusMsg) if err = d.Set("status_code", workspaceStatusMsgMap[0]["status_code"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_msg", workspaceStatusMsgMap[0]["status_msg"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -895,7 +895,7 @@ func dataSourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Res controller, err := flex.GetBaseController(meta) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("dataSourceIBMSchematicsWorkspaceRead failed: %s", err.Error()), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } From 073816d9ef104598c15408b4d28b863592f58bb1 Mon Sep 17 00:00:00 2001 From: VaishnaviGopal Date: Thu, 5 Dec 2024 17:06:44 +0530 Subject: [PATCH 7/7] all sch resources specific changes for new way of logging --- .../resource_ibm_schematics_action.go | 80 +++++++------- .../resource_ibm_schematics_agent.go | 98 ++++++++--------- .../resource_ibm_schematics_agent_deploy.go | 42 ++++---- .../resource_ibm_schematics_agent_health.go | 38 +++---- .../resource_ibm_schematics_agent_prs.go | 38 +++---- .../resource_ibm_schematics_inventory.go | 36 +++---- .../schematics/resource_ibm_schematics_job.go | 72 ++++++------- .../resource_ibm_schematics_policy.go | 68 ++++++------ .../resource_ibm_schematics_resource_query.go | 30 +++--- .../resource_ibm_schematics_workspace.go | 100 +++++++++--------- 10 files changed, 301 insertions(+), 301 deletions(-) diff --git a/ibm/service/schematics/resource_ibm_schematics_action.go b/ibm/service/schematics/resource_ibm_schematics_action.go index dc633ce4a9..1c3a39313b 100644 --- a/ibm/service/schematics/resource_ibm_schematics_action.go +++ b/ibm/service/schematics/resource_ibm_schematics_action.go @@ -960,7 +960,7 @@ func ResourceIBMSchematicsActionValidator() *validate.ResourceValidator { ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, Type: validate.TypeString, Optional: true, - AllowedValues: "cos_bucket, external_scm, git_hub, git_hub_enterprise, git_lab, ibm_cloud_catalog, ibm_git_lab, local", + AllowedValues: "cos_bucket, external_scm, git_hub, git_hub_enterprise, git_lab, ibm_schematics_action_catalog, ibm_git_lab, local", }, validate.ValidateSchema{ Identifier: actionName, @@ -978,7 +978,7 @@ func ResourceIBMSchematicsActionValidator() *validate.ResourceValidator { func resourceIBMSchematicsActionCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionCreate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_action", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1080,7 +1080,7 @@ func resourceIBMSchematicsActionCreate(context context.Context, d *schema.Resour action, response, err := schematicsClient.CreateActionWithContext(context, createActionOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionCreate CreateActionWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1338,7 +1338,7 @@ func resourceIBMSchematicsActionMapToSystemLock(systemLockMap map[string]interfa func resourceIBMSchematicsActionRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1359,33 +1359,33 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead GetActionWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("name", action.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("description", action.Description); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("location", action.Location); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("resource_group", action.ResourceGroup); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if action.Tags != nil { if err = d.Set("tags", action.Tags); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1393,13 +1393,13 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource if action.UserState != nil { userStateMap := resourceIBMSchematicsActionUserStateToMap(*action.UserState) if err = d.Set("user_state", []map[string]interface{}{userStateMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("source_readme_url", action.SourceReadmeURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1407,24 +1407,24 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource if action.Source != nil { sourceMap := resourceIBMSchematicsActionExternalSourceToMap(*action.Source) if err = d.Set("source", []map[string]interface{}{sourceMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } } if err = d.Set("source_type", action.SourceType); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("command_parameter", action.CommandParameter); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("inventory", action.Inventory); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1435,7 +1435,7 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource credentials = append(credentials, credentialsItemMap) } if err = d.Set("credentials", credentials); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1444,7 +1444,7 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource if action.Bastion != nil { bastionMap := resourceIBMSchematicsActionBastionResourceDefinitionToMap(*action.Bastion) if err = d.Set("bastion", []map[string]interface{}{bastionMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1453,13 +1453,13 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource if action.BastionCredential != nil { bastionCredentialMap := resourceIBMSchematicsActionCredentialVariableDataToMap(*action.BastionCredential) if err = d.Set("bastion_credential", []map[string]interface{}{bastionCredentialMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("targets_ini", action.TargetsIni); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1470,7 +1470,7 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource actionInputs = append(actionInputs, actionInputsItemMap) } if err = d.Set("action_inputs", actionInputs); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1482,7 +1482,7 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource actionOutputs = append(actionOutputs, actionOutputsItemMap) } if err = d.Set("action_outputs", actionOutputs); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1494,7 +1494,7 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource settings = append(settings, settingsItemMap) } if err = d.Set("settings", settings); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1502,7 +1502,7 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource if action.State != nil { stateMap := resourceIBMSchematicsActionActionStateToMap(*action.State) if err = d.Set("state", []map[string]interface{}{stateMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1510,64 +1510,64 @@ func resourceIBMSchematicsActionRead(context context.Context, d *schema.Resource if action.SysLock != nil { sysLockMap := resourceIBMSchematicsActionSystemLockToMap(*action.SysLock) if err = d.Set("sys_lock", []map[string]interface{}{sysLockMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("crn", action.Crn); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("account", action.Account); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("source_created_at", flex.DateTimeToString(action.SourceCreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("source_created_by", action.SourceCreatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("source_updated_at", flex.DateTimeToString(action.SourceUpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("source_updated_by", action.SourceUpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(action.CreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_by", action.CreatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(action.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", action.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if action.PlaybookNames != nil && len(action.PlaybookNames) > 0 { if err = d.Set("playbook_names", action.PlaybookNames); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionRead failed with error: %s", err), "ibm_schematics_action", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1852,7 +1852,7 @@ func resourceIBMSchematicsActionSystemLockToMap(systemLock schematicsv1.SystemLo func resourceIBMSchematicsActionUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionUpdate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_action", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1980,7 +1980,7 @@ func resourceIBMSchematicsActionUpdate(context context.Context, d *schema.Resour _, response, err := schematicsClient.UpdateActionWithContext(context, updateActionOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionUpdate failed with error: %s and response:\n%s", err, response), "ibm_schematics_action", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1992,7 +1992,7 @@ func resourceIBMSchematicsActionUpdate(context context.Context, d *schema.Resour func resourceIBMSchematicsActionDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionDelete schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_action", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -2009,7 +2009,7 @@ func resourceIBMSchematicsActionDelete(context context.Context, d *schema.Resour response, err := schematicsClient.DeleteActionWithContext(context, deleteActionOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsActionDelete DeleteActionWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_action", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/resource_ibm_schematics_agent.go b/ibm/service/schematics/resource_ibm_schematics_agent.go index 5c095e3578..67033ee671 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent.go @@ -558,7 +558,7 @@ func ResourceIbmSchematicsAgent() *schema.Resource { func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentCreate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -572,7 +572,7 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc createAgentDataOptions.SetAgentLocation(d.Get("agent_location").(string)) agentInfrastructureModel, err := resourceIbmSchematicsAgentMapToAgentInfrastructure(d.Get("agent_infrastructure.0").(map[string]interface{})) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentCreate failed: %s", err.Error()), "ibm_schematics_agent", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -589,7 +589,7 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc value := e.(map[string]interface{}) agentMetadataItem, err := resourceIbmSchematicsAgentMapToAgentMetadataInfo(value) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentCreate failed: %s", err.Error()), "ibm_schematics_agent", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -603,7 +603,7 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc value := e.(map[string]interface{}) agentInputsItem, err := resourceIbmSchematicsAgentMapToVariableData(value) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentCreate failed: %s", err.Error()), "ibm_schematics_agent", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -614,7 +614,7 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc if _, ok := d.GetOk("user_state"); ok { userStateModel, err := resourceIbmSchematicsAgentMapToAgentUserState(d.Get("user_state.0").(map[string]interface{})) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentCreate failed: %s", err.Error()), "ibm_schematics_agent", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -624,7 +624,7 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc agentData, response, err := schematicsClient.CreateAgentDataWithContext(context, createAgentDataOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentCreate CreateAgentDataWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -637,7 +637,7 @@ func resourceIbmSchematicsAgentCreate(context context.Context, d *schema.Resourc func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -655,55 +655,55 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead GetAgentDataWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("name", agentData.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("resource_group", agentData.ResourceGroup); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("version", agentData.Version); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("schematics_location", agentData.SchematicsLocation); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("agent_location", agentData.AgentLocation); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } agentInfrastructureMap, err := resourceIbmSchematicsAgentAgentInfrastructureToMap(agentData.AgentInfrastructure) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("agent_infrastructure", []map[string]interface{}{agentInfrastructureMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("description", agentData.Description); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if agentData.Tags != nil { if err = d.Set("tags", agentData.Tags); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -713,7 +713,7 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD for _, agentMetadataItem := range agentData.AgentMetadata { agentMetadataItemMap, err := resourceIbmSchematicsAgentAgentMetadataInfoToMap(&agentMetadataItem) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -721,7 +721,7 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD } } if err = d.Set("agent_metadata", agentMetadata); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -730,7 +730,7 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD for _, agentInputsItem := range agentData.AgentInputs { agentInputsItemMap, err := resourceIbmSchematicsAgentVariableDataToMap(&agentInputsItem) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -738,19 +738,19 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD } } if err = d.Set("agent_inputs", agentInputs); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if agentData.UserState != nil { userStateMap, err := resourceIbmSchematicsAgentAgentUserStateToMap(agentData.UserState) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("user_state", []map[string]interface{}{userStateMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -758,50 +758,50 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD if agentData.AgentKpi != nil { agentKpiMap, err := resourceIbmSchematicsAgentAgentKPIDataToMap(agentData.AgentKpi) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("agent_kpi", []map[string]interface{}{agentKpiMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("agent_crn", agentData.AgentCrn); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(agentData.CreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("creation_by", agentData.CreationBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if agentData.SystemState != nil { systemStateMap, err := resourceIbmSchematicsAgentAgentSystemStatusToMap(agentData.SystemState) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("system_state", []map[string]interface{}{systemStateMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -809,12 +809,12 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD if agentData.RecentPrsJob != nil { recentPrsJobMap, err := resourceIbmSchematicsAgentAgentDataRecentPrsJobToMap(agentData.RecentPrsJob) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("recent_prs_job", []map[string]interface{}{recentPrsJobMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -822,12 +822,12 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD if agentData.RecentDeployJob != nil { recentDeployJobMap, err := resourceIbmSchematicsAgentAgentDataRecentDeployJobToMap(agentData.RecentDeployJob) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("recent_deploy_job", []map[string]interface{}{recentDeployJobMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -835,12 +835,12 @@ func resourceIbmSchematicsAgentRead(context context.Context, d *schema.ResourceD if agentData.RecentHealthJob != nil { recentHealthJobMap, err := resourceIbmSchematicsAgentAgentDataRecentHealthJobToMap(agentData.RecentHealthJob) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed: %s", err.Error()), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("recent_health_job", []map[string]interface{}{recentHealthJobMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentRead failed with error: %s", err), "ibm_schematics_agent", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -880,7 +880,7 @@ func agentDestroyRefreshFunc(schematicsClient *schematicsv1.SchematicsV1, id str func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentUpdate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -888,7 +888,7 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc updateAgentDataOptions := &schematicsv1.UpdateAgentDataOptions{} session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentUpdate bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_agent", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -917,7 +917,7 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentUpdate GetAgentDataWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -974,7 +974,7 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc if d.HasChange("agent_infrastructure") { agentInfrastructure, err := resourceIbmSchematicsAgentMapToAgentInfrastructure(d.Get("agent_infrastructure.0").(map[string]interface{})) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentUpdate failed: %s", err.Error()), "ibm_schematics_agent", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -995,7 +995,7 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc value := e.(map[string]interface{}) agentMetadataItem, err := resourceIbmSchematicsAgentMapToAgentMetadataInfo(value) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentUpdate failed: %s", err.Error()), "ibm_schematics_agent", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1013,7 +1013,7 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc response, err := schematicsClient.DeleteAgentResourcesWithContext(context, deleteAgentResourcesOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentUpdate DeleteAgentResourcesWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) } else { _, err = isWaitForAgentDestroyResources(context, schematicsClient, *deleteAgentResourcesOptions.AgentID, d.Timeout(schema.TimeoutUpdate)) @@ -1026,7 +1026,7 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc _, response, err := schematicsClient.UpdateAgentDataWithContext(context, updateAgentDataOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentUpdate failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1038,7 +1038,7 @@ func resourceIbmSchematicsAgentUpdate(context context.Context, d *schema.Resourc func resourceIbmSchematicsAgentDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDelete schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1048,7 +1048,7 @@ func resourceIbmSchematicsAgentDelete(context context.Context, d *schema.Resourc } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDelete bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_agent", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1072,7 +1072,7 @@ func resourceIbmSchematicsAgentDelete(context context.Context, d *schema.Resourc response, err := schematicsClient.DeleteAgentResourcesWithContext(context, deleteAgentResourcesOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDelete DeleteAgentResourcesWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) } else { _, err = isWaitForAgentDestroyResources(context, schematicsClient, *deleteAgentResourcesOptions.AgentID, d.Timeout(schema.TimeoutDelete)) @@ -1085,7 +1085,7 @@ func resourceIbmSchematicsAgentDelete(context context.Context, d *schema.Resourc deleteresponse, err := schematicsClient.DeleteAgentDataWithContext(context, deleteAgentDataOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, deleteresponse), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDelete DeleteAgentDataWithContext failed with error: %s and response:\n%s", err, deleteresponse), "ibm_schematics_agent", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go b/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go index d3f59ce8af..e40ebefb90 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_deploy.go @@ -91,13 +91,13 @@ func ResourceIbmSchematicsAgentDeploy() *schema.Resource { func resourceIbmSchematicsAgentDeployCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployCreate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent_deploy", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployCreate bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_agent_deploy", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -118,7 +118,7 @@ func resourceIbmSchematicsAgentDeployCreate(context context.Context, d *schema.R agentDeployJob, response, err := schematicsClient.DeployAgentJobWithContext(context, deployAgentJobOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployCreate DeployAgentJobWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent_deploy", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -128,7 +128,7 @@ func resourceIbmSchematicsAgentDeployCreate(context context.Context, d *schema.R _, err = isWaitForAgentAvailable(context, schematicsClient, *deployAgentJobOptions.AgentID, d.Timeout(schema.TimeoutCreate)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployCreate failed with error: %s", err), "ibm_schematics_agent_deploy", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -180,14 +180,14 @@ func agentRefreshFunc(schematicsClient *schematicsv1.SchematicsV1, id string) re func resourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployRead bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -204,49 +204,49 @@ func resourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.Res return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployRead GetAgentDataWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if agentData.RecentDeployJob != nil { if err = d.Set("agent_id", parts[0]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentDeployJob.JobID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentDeployJob.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentDeployJob.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentDeployJob.StatusCode); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentDeployJob.StatusMessage); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentDeployJob.LogURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployRead failed with error: %s", err), "ibm_schematics_agent_deploy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -258,13 +258,13 @@ func resourceIbmSchematicsAgentDeployRead(context context.Context, d *schema.Res func resourceIbmSchematicsAgentDeployUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployUpdate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent_deploy", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployUpdate bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_agent_deploy", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -279,7 +279,7 @@ func resourceIbmSchematicsAgentDeployUpdate(context context.Context, d *schema.R parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployUpdate failed: %s", err.Error()), "ibm_schematics_agent_deploy", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -289,7 +289,7 @@ func resourceIbmSchematicsAgentDeployUpdate(context context.Context, d *schema.R hasChange := false if d.HasChange("agent_id") { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployUpdate failed with error: %s", err), "ibm_schematics_agent_deploy", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -302,7 +302,7 @@ func resourceIbmSchematicsAgentDeployUpdate(context context.Context, d *schema.R agentDeployJob, response, err := schematicsClient.DeployAgentJobWithContext(context, deployAgentJobOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployUpdate DeployAgentJobWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent_deploy", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -310,7 +310,7 @@ func resourceIbmSchematicsAgentDeployUpdate(context context.Context, d *schema.R _, err = isWaitForAgentAvailable(context, schematicsClient, parts[0], d.Timeout(schema.TimeoutUpdate)) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentDeployUpdate failed with error: %s", err), "ibm_schematics_agent_deploy", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_health.go b/ibm/service/schematics/resource_ibm_schematics_agent_health.go index 195a51edf0..1e9f977033 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_health.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_health.go @@ -79,13 +79,13 @@ func ResourceIbmSchematicsAgentHealth() *schema.Resource { func resourceIbmSchematicsAgentHealthCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthCreate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent_health", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthCreate bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_agent_health", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -107,7 +107,7 @@ func resourceIbmSchematicsAgentHealthCreate(context context.Context, d *schema.R agentHealthJob, response, err := schematicsClient.HealthCheckAgentJobWithContext(context, healthCheckAgentJobOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthCreate HealthCheckAgentJobWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent_health", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -120,14 +120,14 @@ func resourceIbmSchematicsAgentHealthCreate(context context.Context, d *schema.R func resourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthRead failed: %s", err.Error()), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -145,7 +145,7 @@ func resourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.Res return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthRead GetAgentDataWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -153,42 +153,42 @@ func resourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.Res if agentData.RecentHealthJob != nil { if err = d.Set("agent_id", parts[0]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentHealthJob.JobID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentHealthJob.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentHealthJob.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentHealthJob.StatusCode); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentHealthJob.StatusMessage); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentHealthJob.LogURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthRead failed with error: %s", err), "ibm_schematics_agent_health", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -201,13 +201,13 @@ func resourceIbmSchematicsAgentHealthRead(context context.Context, d *schema.Res func resourceIbmSchematicsAgentHealthUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthUpdate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent_health", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthUpdate bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_agent_health", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -223,7 +223,7 @@ func resourceIbmSchematicsAgentHealthUpdate(context context.Context, d *schema.R parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthUpdate failed: %s", err.Error()), "ibm_schematics_agent_health", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -233,7 +233,7 @@ func resourceIbmSchematicsAgentHealthUpdate(context context.Context, d *schema.R hasChange := false if d.HasChange("agent_id") { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthUpdate failed with error: %s", err), "ibm_schematics_agent_health", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -246,7 +246,7 @@ func resourceIbmSchematicsAgentHealthUpdate(context context.Context, d *schema.R agentHealthJob, response, err := schematicsClient.HealthCheckAgentJobWithContext(context, healthCheckAgentJobOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentHealthUpdate HealthCheckAgentJobWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent_health", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/resource_ibm_schematics_agent_prs.go b/ibm/service/schematics/resource_ibm_schematics_agent_prs.go index d82ab74e15..935b845d03 100644 --- a/ibm/service/schematics/resource_ibm_schematics_agent_prs.go +++ b/ibm/service/schematics/resource_ibm_schematics_agent_prs.go @@ -79,13 +79,13 @@ func ResourceIbmSchematicsAgentPrs() *schema.Resource { func resourceIbmSchematicsAgentPrsCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsCreate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent_prs", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsCreate bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_agent_prs", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -106,7 +106,7 @@ func resourceIbmSchematicsAgentPrsCreate(context context.Context, d *schema.Reso agentPrsJob, response, err := schematicsClient.PrsAgentJobWithContext(context, prsAgentJobOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsCreate PrsAgentJobWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent_prs", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -119,14 +119,14 @@ func resourceIbmSchematicsAgentPrsCreate(context context.Context, d *schema.Reso func resourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsRead failed: %s", err.Error()), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -144,49 +144,49 @@ func resourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.Resour return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsRead GetAgentDataWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if agentData.RecentPrsJob != nil { if err = d.Set("agent_id", parts[0]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("job_id", agentData.RecentPrsJob.JobID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(agentData.RecentPrsJob.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", agentData.RecentPrsJob.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("agent_version", agentData.Version); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_code", agentData.RecentPrsJob.StatusCode); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_message", agentData.RecentPrsJob.StatusMessage); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("log_url", agentData.RecentPrsJob.LogURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsRead failed with error: %s", err), "ibm_schematics_agent_prs", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -198,13 +198,13 @@ func resourceIbmSchematicsAgentPrsRead(context context.Context, d *schema.Resour func resourceIbmSchematicsAgentPrsUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsUpdate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_agent_prs", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsUpdate bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_agent_prs", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -220,7 +220,7 @@ func resourceIbmSchematicsAgentPrsUpdate(context context.Context, d *schema.Reso parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsUpdate failed: %s", err.Error()), "ibm_schematics_agent_prs", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -230,7 +230,7 @@ func resourceIbmSchematicsAgentPrsUpdate(context context.Context, d *schema.Reso hasChange := false if d.HasChange("agent_id") { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsUpdate failed with error: %s", err), "ibm_schematics_agent_prs", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -243,7 +243,7 @@ func resourceIbmSchematicsAgentPrsUpdate(context context.Context, d *schema.Reso agentPrsJob, response, err := schematicsClient.PrsAgentJobWithContext(context, prsAgentJobOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsAgentPrsUpdate PrsAgentJobWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_agent_prs", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/resource_ibm_schematics_inventory.go b/ibm/service/schematics/resource_ibm_schematics_inventory.go index e0783e315d..b49aebf5be 100644 --- a/ibm/service/schematics/resource_ibm_schematics_inventory.go +++ b/ibm/service/schematics/resource_ibm_schematics_inventory.go @@ -112,7 +112,7 @@ func ResourceIBMSchematicsInventoryValidator() *validate.ResourceValidator { func resourceIBMSchematicsInventoryCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryCreate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_inventory", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -147,7 +147,7 @@ func resourceIBMSchematicsInventoryCreate(context context.Context, d *schema.Res inventoryResourceRecord, response, err := schematicsClient.CreateInventoryWithContext(context, createInventoryOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryCreate CreateInventoryWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_inventory", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -160,7 +160,7 @@ func resourceIBMSchematicsInventoryCreate(context context.Context, d *schema.Res func resourceIBMSchematicsInventoryRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -182,59 +182,59 @@ func resourceIBMSchematicsInventoryRead(context context.Context, d *schema.Resou return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryRead GetInventoryWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("name", inventoryResourceRecord.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("description", inventoryResourceRecord.Description); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("location", inventoryResourceRecord.Location); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("resource_group", inventoryResourceRecord.ResourceGroup); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("inventories_ini", inventoryResourceRecord.InventoriesIni); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if inventoryResourceRecord.ResourceQueries != nil { if err = d.Set("resource_queries", inventoryResourceRecord.ResourceQueries); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("created_at", flex.DateTimeToString(inventoryResourceRecord.CreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_by", inventoryResourceRecord.CreatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(inventoryResourceRecord.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", inventoryResourceRecord.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryRead failed with error: %s", err), "ibm_schematics_inventory", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -245,7 +245,7 @@ func resourceIBMSchematicsInventoryRead(context context.Context, d *schema.Resou func resourceIBMSchematicsInventoryUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryUpdate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_inventory", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -296,7 +296,7 @@ func resourceIBMSchematicsInventoryUpdate(context context.Context, d *schema.Res _, response, err := schematicsClient.ReplaceInventoryWithContext(context, updateInventoryOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryUpdate ReplaceInventoryWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_inventory", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -308,7 +308,7 @@ func resourceIBMSchematicsInventoryUpdate(context context.Context, d *schema.Res func resourceIBMSchematicsInventoryDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryDelete schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_inventory", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -325,7 +325,7 @@ func resourceIBMSchematicsInventoryDelete(context context.Context, d *schema.Res response, err := schematicsClient.DeleteInventoryWithContext(context, deleteInventoryOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsInventoryDelete DeleteInventoryWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_inventory", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/resource_ibm_schematics_job.go b/ibm/service/schematics/resource_ibm_schematics_job.go index b8a96b060d..31665da6b0 100644 --- a/ibm/service/schematics/resource_ibm_schematics_job.go +++ b/ibm/service/schematics/resource_ibm_schematics_job.go @@ -2848,14 +2848,14 @@ func ResourceIBMSchematicsJobValidator() *validate.ResourceValidator { func resourceIBMSchematicsJobCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobCreate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_job", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobCreate bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_job", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -2943,7 +2943,7 @@ func resourceIBMSchematicsJobCreate(context context.Context, d *schema.ResourceD job, response, err := schematicsClient.CreateJobWithContext(context, createJobOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobCreate CreateJobWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_job", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -3909,7 +3909,7 @@ func resourceIBMSchematicsJobMapToJobLogSummarySystemJob(jobLogSummarySystemJobM func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -3930,35 +3930,35 @@ func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceDat return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead GetJobWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("command_object", job.CommandObject); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("command_object_id", job.CommandObjectID); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("command_name", job.CommandName); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if _, ok := d.GetOk("command_parameter"); ok { if err = d.Set("command_parameter", d.Get("command_parameter").(string)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if job.CommandOptions != nil { if err = d.Set("command_options", job.CommandOptions); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -3970,7 +3970,7 @@ func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceDat jobInputs = append(jobInputs, jobInputsItemMap) } if err = d.Set("job_inputs", jobInputs); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -3982,27 +3982,27 @@ func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceDat jobEnvSettings = append(jobEnvSettings, jobEnvSettingsItemMap) } if err = d.Set("job_env_settings", jobEnvSettings); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if job.Tags != nil { if err = d.Set("tags", job.Tags); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("location", job.Location); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if job.Status != nil { statusMap := resourceIBMSchematicsJobJobStatusToMap(*job.Status) if err = d.Set("status", []map[string]interface{}{statusMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -4010,7 +4010,7 @@ func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceDat if job.Data != nil { dataMap := resourceIBMSchematicsJobJobDataToMap(*job.Data) if err = d.Set("data", []map[string]interface{}{dataMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -4018,7 +4018,7 @@ func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceDat if job.Bastion != nil { bastionMap := resourceIBMSchematicsJobBastionResourceDefinitionToMap(*job.Bastion) if err = d.Set("bastion", []map[string]interface{}{bastionMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -4026,68 +4026,68 @@ func resourceIBMSchematicsJobRead(context context.Context, d *schema.ResourceDat if job.LogSummary != nil { logSummaryMap := resourceIBMSchematicsJobJobLogSummaryToMap(*job.LogSummary) if err = d.Set("log_summary", []map[string]interface{}{logSummaryMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("name", job.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("description", job.Description); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("resource_group", job.ResourceGroup); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("submitted_at", flex.DateTimeToString(job.SubmittedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("submitted_by", job.SubmittedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("start_at", flex.DateTimeToString(job.StartAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("end_at", flex.DateTimeToString(job.EndAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("duration", job.Duration); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("log_store_url", job.LogStoreURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("state_store_url", job.StateStoreURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("results_url", job.ResultsURL); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(job.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobRead failed with error: %s", err), "ibm_schematics_job", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -5031,14 +5031,14 @@ func resourceIBMSchematicsJobJobLogSummarySystemJobToMap(jobLogSummarySystemJob func resourceIBMSchematicsJobUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobUpdate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_job", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobUpdate bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_job", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -5126,7 +5126,7 @@ func resourceIBMSchematicsJobUpdate(context context.Context, d *schema.ResourceD _, response, err := schematicsClient.UpdateJobWithContext(context, updateJobOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobUpdate UpdateJobWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_job", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -5138,14 +5138,14 @@ func resourceIBMSchematicsJobDelete(context context.Context, d *schema.ResourceD session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobDelete bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_job", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobDelete schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_job", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -5165,7 +5165,7 @@ func resourceIBMSchematicsJobDelete(context context.Context, d *schema.ResourceD response, err := schematicsClient.DeleteJobWithContext(context, deleteJobOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsJobDelete DeleteJobWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_job", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/resource_ibm_schematics_policy.go b/ibm/service/schematics/resource_ibm_schematics_policy.go index 1419326423..d63effbc5d 100644 --- a/ibm/service/schematics/resource_ibm_schematics_policy.go +++ b/ibm/service/schematics/resource_ibm_schematics_policy.go @@ -290,7 +290,7 @@ func ResourceIbmSchematicsPolicyValidator() *validate.ResourceValidator { func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyCreate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_policy", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -315,7 +315,7 @@ func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.Resour if _, ok := d.GetOk("state"); ok { stateModel, err := resourceIbmSchematicsPolicyMapToUserState(d.Get("state.0").(map[string]interface{})) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyCreate failed: %s", err.Error()), "ibm_schematics_policy", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -327,7 +327,7 @@ func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.Resour if _, ok := d.GetOk("target"); ok { targetModel, err := resourceIbmSchematicsPolicyMapToPolicyObjects(d.Get("target.0").(map[string]interface{})) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyCreate failed: %s", err.Error()), "ibm_schematics_policy", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -336,7 +336,7 @@ func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.Resour if _, ok := d.GetOk("parameter"); ok { parameterModel, err := resourceIbmSchematicsPolicyMapToPolicyParameter(d.Get("parameter.0").(map[string]interface{})) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyCreate failed: %s", err.Error()), "ibm_schematics_policy", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -348,7 +348,7 @@ func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.Resour value := e.(map[string]interface{}) scopedResourcesItem, err := resourceIbmSchematicsPolicyMapToScopedResource(value) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyCreate failed: %s", err.Error()), "ibm_schematics_policy", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -360,7 +360,7 @@ func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.Resour policy, response, err := schematicsClient.CreatePolicyWithContext(context, createPolicyOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyCreate CreatePolicyWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_policy", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -373,7 +373,7 @@ func resourceIbmSchematicsPolicyCreate(context context.Context, d *schema.Resour func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -389,65 +389,65 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead GetPolicyWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("name", policy.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("description", policy.Description); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("resource_group", policy.ResourceGroup); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if policy.Tags != nil { if err = d.Set("tags", policy.Tags); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("location", policy.Location); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if policy.State != nil { stateMap, err := resourceIbmSchematicsPolicyUserStateToMap(policy.State) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed: %s", err.Error()), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("state", []map[string]interface{}{stateMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("kind", policy.Kind); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if policy.Target != nil { targetMap, err := resourceIbmSchematicsPolicyPolicyObjectsToMap(policy.Target) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed: %s", err.Error()), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("target", []map[string]interface{}{targetMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -455,12 +455,12 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource if policy.Parameter != nil { parameterMap, err := resourceIbmSchematicsPolicyPolicyParameterToMap(policy.Parameter) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed: %s", err.Error()), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("parameter", []map[string]interface{}{parameterMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -470,7 +470,7 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource for _, scopedResourcesItem := range policy.ScopedResources { scopedResourcesItemMap, err := resourceIbmSchematicsPolicyScopedResourceToMap(&scopedResourcesItem) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed: %s", err.Error()), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -478,32 +478,32 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource } } if err = d.Set("scoped_resources", scopedResources); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("crn", policy.Crn); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("account", policy.Account); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_at", flex.DateTimeToString(policy.CreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_by", policy.CreatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(policy.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyRead failed with error: %s", err), "ibm_schematics_policy", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -514,7 +514,7 @@ func resourceIbmSchematicsPolicyRead(context context.Context, d *schema.Resource func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyUpdate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_policy", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -544,7 +544,7 @@ func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.Resour if d.HasChange("state") { state, err := resourceIbmSchematicsPolicyMapToUserState(d.Get("state.0").(map[string]interface{})) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyUpdate failed: %s", err.Error()), "ibm_schematics_policy", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -558,7 +558,7 @@ func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.Resour if d.HasChange("target") { target, err := resourceIbmSchematicsPolicyMapToPolicyObjects(d.Get("target.0").(map[string]interface{})) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyUpdate failed: %s", err.Error()), "ibm_schematics_policy", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -568,7 +568,7 @@ func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.Resour if d.HasChange("parameter") { parameter, err := resourceIbmSchematicsPolicyMapToPolicyParameter(d.Get("parameter.0").(map[string]interface{})) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyUpdate failed: %s", err.Error()), "ibm_schematics_policy", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -584,7 +584,7 @@ func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.Resour _, response, err := schematicsClient.UpdatePolicyWithContext(context, updatePolicyOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyUpdate UpdatePolicyWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_policy", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -596,7 +596,7 @@ func resourceIbmSchematicsPolicyUpdate(context context.Context, d *schema.Resour func resourceIbmSchematicsPolicyDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyDelete schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_policy", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -608,7 +608,7 @@ func resourceIbmSchematicsPolicyDelete(context context.Context, d *schema.Resour response, err := schematicsClient.DeletePolicyWithContext(context, deletePolicyOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIbmSchematicsPolicyDelete DeletePolicyWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_policy", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/resource_ibm_schematics_resource_query.go b/ibm/service/schematics/resource_ibm_schematics_resource_query.go index a9c9cb0032..65cf4732f9 100644 --- a/ibm/service/schematics/resource_ibm_schematics_resource_query.go +++ b/ibm/service/schematics/resource_ibm_schematics_resource_query.go @@ -137,7 +137,7 @@ func ResourceIBMSchematicsResourceQueryValidator() *validate.ResourceValidator { func resourceIBMSchematicsResourceQueryCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryCreate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_resource_query", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -169,7 +169,7 @@ func resourceIBMSchematicsResourceQueryCreate(context context.Context, d *schema resourceQueryRecord, response, err := schematicsClient.CreateResourceQueryWithContext(context, createResourceQueryOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryCreate CreateResourceQueryWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_resource_query", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -223,7 +223,7 @@ func resourceIBMSchematicsResourceQueryMapToResourceQueryParam(resourceQueryPara func resourceIBMSchematicsResourceQueryRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -244,17 +244,17 @@ func resourceIBMSchematicsResourceQueryRead(context context.Context, d *schema.R return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryRead GetResourcesQueryWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("type", resourceQueryRecord.Type); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("name", resourceQueryRecord.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -265,28 +265,28 @@ func resourceIBMSchematicsResourceQueryRead(context context.Context, d *schema.R queries = append(queries, queriesItemMap) } if err = d.Set("queries", queries); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("created_at", flex.DateTimeToString(resourceQueryRecord.CreatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("created_by", resourceQueryRecord.CreatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_at", flex.DateTimeToString(resourceQueryRecord.UpdatedAt)); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("updated_by", resourceQueryRecord.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryRead failed with error: %s", err), "ibm_schematics_resource_query", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -335,7 +335,7 @@ func resourceIBMSchematicsResourceQueryResourceQueryParamToMap(resourceQueryPara func resourceIBMSchematicsResourceQueryUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryUpdate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_resource_query", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -367,7 +367,7 @@ func resourceIBMSchematicsResourceQueryUpdate(context context.Context, d *schema _, response, err := schematicsClient.ReplaceResourcesQueryWithContext(context, replaceResourcesQueryOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryUpdate ReplaceResourcesQueryWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_resource_query", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -378,7 +378,7 @@ func resourceIBMSchematicsResourceQueryUpdate(context context.Context, d *schema func resourceIBMSchematicsResourceQueryDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryDelete schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_resource_query", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -395,7 +395,7 @@ func resourceIBMSchematicsResourceQueryDelete(context context.Context, d *schema response, err := schematicsClient.DeleteResourcesQueryWithContext(context, deleteResourcesQueryOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsResourceQueryDelete DeleteResourcesQueryWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_resource_query", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } diff --git a/ibm/service/schematics/resource_ibm_schematics_workspace.go b/ibm/service/schematics/resource_ibm_schematics_workspace.go index 9b0d628760..4d2ac61244 100644 --- a/ibm/service/schematics/resource_ibm_schematics_workspace.go +++ b/ibm/service/schematics/resource_ibm_schematics_workspace.go @@ -592,7 +592,7 @@ func ResourceIBMSchematicsWorkspaceValidator() *validate.ResourceValidator { func resourceIBMSchematicsWorkspaceCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceCreate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_workspace", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -756,7 +756,7 @@ func resourceIBMSchematicsWorkspaceCreate(context context.Context, d *schema.Res workspaceResponse, response, err := schematicsClient.CreateWorkspaceWithContext(context, createWorkspaceOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceCreate CreateWorkspaceWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_workspace", "create") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1081,7 +1081,7 @@ func resourceIBMSchematicsWorkspaceMapToWorkspaceStatusUpdateRequest(workspaceSt func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1102,13 +1102,13 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou return nil } - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead GetWorkspaceWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if workspaceResponse.AppliedShareddataIds != nil { if err = d.Set("applied_shareddata_ids", workspaceResponse.AppliedShareddataIds); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1116,28 +1116,28 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou if workspaceResponse.CatalogRef != nil { catalogRefMap := resourceIBMSchematicsWorkspaceCatalogRefToMap(*workspaceResponse.CatalogRef) if err = d.Set("catalog_ref", []map[string]interface{}{catalogRefMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("description", workspaceResponse.Description); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("location", workspaceResponse.Location); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("name", workspaceResponse.Name); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("resource_group", workspaceResponse.ResourceGroup); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1145,7 +1145,7 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou if workspaceResponse.SharedData != nil { sharedDataMap := resourceIBMSchematicsWorkspaceSharedTargetDataResponseToMap(*workspaceResponse.SharedData) if err = d.Set("shared_data", []map[string]interface{}{sharedDataMap}); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1153,7 +1153,7 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou } if workspaceResponse.Tags != nil { if err = d.Set("tags", workspaceResponse.Tags); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1165,81 +1165,81 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou templateData = append(templateData, templateDataItemMap) } if err = d.Set("template_env_settings", templateData[0]["env_values"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_git_folder", templateData[0]["folder"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_init_state_file", templateData[0]["init_state_file"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_type", templateData[0]["type"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_uninstall_script_name", templateData[0]["uninstall_script_name"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_values", templateData[0]["values"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_values_metadata", templateData[0]["values_metadata"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_inputs", templateData[0]["variablestore"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("template_ref", workspaceResponse.TemplateRef); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if workspaceResponse.TemplateRepo != nil { templateRepoMap := resourceIBMSchematicsWorkspaceTemplateRepoResponseToMap(*workspaceResponse.TemplateRepo) if err = d.Set("template_git_branch", templateRepoMap["branch"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_git_release", templateRepoMap["release"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_git_repo_sha_value", templateRepoMap["repo_sha_value"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_git_repo_url", templateRepoMap["repo_url"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_git_url", templateRepoMap["url"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("template_git_has_uploadedgitrepotar", templateRepoMap["has_uploadedgitrepotar"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1252,56 +1252,56 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou if workspaceResponse.WorkspaceStatus != nil { workspaceStatusMap := resourceIBMSchematicsWorkspaceWorkspaceStatusResponseToMap(*workspaceResponse.WorkspaceStatus) if err = d.Set("frozen", workspaceStatusMap["frozen"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("frozen_at", workspaceStatusMap["frozen_at"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("frozen_by", workspaceStatusMap["frozen_by"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("locked", workspaceStatusMap["locked"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("locked_by", workspaceStatusMap["locked_by"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("locked_time", workspaceStatusMap["locked_time"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if workspaceResponse.CreatedAt != nil { if err = d.Set("created_at", workspaceResponse.CreatedAt.String()); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("created_by", workspaceResponse.CreatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("crn", workspaceResponse.Crn); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if workspaceResponse.LastHealthCheckAt != nil { if err = d.Set("last_health_check_at", workspaceResponse.LastHealthCheckAt.String()); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1313,37 +1313,37 @@ func resourceIBMSchematicsWorkspaceRead(context context.Context, d *schema.Resou runtimeData = append(runtimeData, runtimeDataItemMap) } if err = d.Set("runtime_data", runtimeData); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("status", workspaceResponse.Status); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if workspaceResponse.UpdatedAt != nil { if err = d.Set("updated_at", workspaceResponse.UpdatedAt.String()); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } } if err = d.Set("updated_by", workspaceResponse.UpdatedBy); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if workspaceResponse.WorkspaceStatusMsg != nil { workspaceStatusMsgMap := resourceIBMSchematicsWorkspaceWorkspaceStatusMessageToMap(*workspaceResponse.WorkspaceStatusMsg) if err = d.Set("status_code", workspaceStatusMsgMap["status_code"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } if err = d.Set("status_msg", workspaceStatusMsgMap["status_msg"]); err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s", err), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceRead failed with error: %s", err), "ibm_schematics_workspace", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1710,7 +1710,7 @@ func resourceIBMSchematicsWorkspaceWorkspaceStatusMessageToMap(workspaceStatusMe func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceUpdate schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_workspace", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1903,7 +1903,7 @@ func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.Res _, response, err := schematicsClient.ReplaceWorkspaceWithContext(context, replaceWorkspaceOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceUpdate ReplaceWorkspaceWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_workspace", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1913,7 +1913,7 @@ func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.Res _, response, err := schematicsClient.UpdateWorkspaceWithContext(context, updateWorkspaceOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceUpdate UpdateWorkspaceWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_workspace", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1942,7 +1942,7 @@ func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.Res _, response, err := schematicsClient.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceUpdate ReplaceWorkspaceInputs failed with error: %s and response:\n%s", err, response), "ibm_schematics_workspace", "update") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1957,14 +1957,14 @@ func resourceIBMSchematicsWorkspaceUpdate(context context.Context, d *schema.Res func resourceIBMSchematicsWorkspaceDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { schematicsClient, err := meta.(conns.ClientSession).SchematicsV1() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceDelete schematicsClient initialization failed: %s", err.Error()), "ibm_schematics_workspace", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } session, err := meta.(conns.ClientSession).BluemixSession() if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed: %s", err.Error()), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceDelete bluemixClient initialization failed: %s", err.Error()), "ibm_schematics_workspace", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() } @@ -1984,7 +1984,7 @@ func resourceIBMSchematicsWorkspaceDelete(context context.Context, d *schema.Res _, response, err := schematicsClient.DeleteWorkspaceWithContext(context, deleteWorkspaceOptions) if err != nil { - tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateCloudWithContext failed with error: %s and response:\n%s", err, response), "ibm_cloud", "create") + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceIBMSchematicsWorkspaceDelete DeleteWorkspaceWithContext failed with error: %s and response:\n%s", err, response), "ibm_schematics_workspace", "delete") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) return tfErr.GetDiag() }