Skip to content

Commit

Permalink
covered plain Fmt.ErrorF with flex.FmtErrorF wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
prajwal-jarali committed Dec 3, 2024
1 parent d841442 commit 0f9864f
Show file tree
Hide file tree
Showing 19 changed files with 215 additions and 207 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113
github.com/IBM-Cloud/power-go-client v1.8.3
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
github.com/IBM/appconfiguration-go-admin-sdk v0.3.0
github.com/IBM/appconfiguration-go-admin-sdk v0.4.4
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f
github.com/IBM/cloud-databases-go-sdk v0.7.1
github.com/IBM/cloudant-go-sdk v0.8.0
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ github.com/IBM-Cloud/softlayer-go v1.0.5-tf h1:koUAyF9b6X78lLLruGYPSOmrfY2YcGYKO
github.com/IBM-Cloud/softlayer-go v1.0.5-tf/go.mod h1:6HepcfAXROz0Rf63krk5hPZyHT6qyx2MNvYyHof7ik4=
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca h1:crniVcf+YcmgF03NmmfonXwSQ73oJF+IohFYBwknMxs=
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca/go.mod h1:IjXrnOcTe92Q4pEBHmui3H/GM1hw5Pd0zXA5cw5/iZU=
github.com/IBM/appconfiguration-go-admin-sdk v0.3.0 h1:OqFxnDxro0JiRwHBKytCcseY2YKD4n87JN1UcaOD4Ss=
github.com/IBM/appconfiguration-go-admin-sdk v0.3.0/go.mod h1:xPxAYhr/uywUIDEo/JqWbkUdTryPdzRdYBfUpA5IjoE=
github.com/IBM/appconfiguration-go-admin-sdk v0.4.4 h1:VQ+mVavoo3/xrBaVSyxE+B6Uef+m33RcbropwpTRBy4=
github.com/IBM/appconfiguration-go-admin-sdk v0.4.4/go.mod h1:E9cXu9w0EClhZq+E9wBw8QzNLKZd2bNdMrTXwVSWJ1s=
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f h1:4c1kqY4GqmkQ+tO03rneDb74Tv7BhTj8jDiDB1p8mdM=
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f/go.mod h1:d22kTYY7RYBWcQlZpqrSdshpB/lJ16viWS5Sbjtlc8s=
github.com/IBM/cloud-databases-go-sdk v0.7.1 h1:5kK4/3NUsGxZzmuUe+1ftajpOQbeDVh5VeemrPgROP4=
Expand All @@ -151,7 +151,6 @@ github.com/IBM/go-sdk-core/v3 v3.2.4/go.mod h1:lk9eOzNbNltPf3CBpcg1Ewkhw4qC3u2QC
github.com/IBM/go-sdk-core/v5 v5.0.0/go.mod h1:vyNdbFujJtdTj9HbihtvKwwS3k/GKSKpOx9ZIQ6MWDY=
github.com/IBM/go-sdk-core/v5 v5.5.1/go.mod h1:Sn+z+qTDREQvCr+UFa22TqqfXNxx3o723y8GsfLV8e0=
github.com/IBM/go-sdk-core/v5 v5.6.3/go.mod h1:tt/B9rxLkRtglE7pvqLuYikgCXaZFL3btdruJaoUeek=
github.com/IBM/go-sdk-core/v5 v5.7.0/go.mod h1:+YbdhrjCHC84ls4MeBp+Hj4NZCni+tDAc0XQUqRO9Jc=
github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE=
github.com/IBM/go-sdk-core/v5 v5.10.2/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI=
github.com/IBM/go-sdk-core/v5 v5.17.4/go.mod h1:KsAAI7eStAWwQa4F96MLy+whYSh39JzNjklZRbN/8ns=
Expand Down Expand Up @@ -599,7 +598,6 @@ github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6
github.com/go-openapi/strfmt v0.19.4/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk=
github.com/go-openapi/strfmt v0.19.10/go.mod h1:qBBipho+3EoIqn6YDI+4RnQEtj6jT/IdKm+PAlXxSUc=
github.com/go-openapi/strfmt v0.20.1/go.mod h1:43urheQI9dNtE5lTZQfuFJvjYJKPrxicATpEfZwHUNk=
github.com/go-openapi/strfmt v0.20.2/go.mod h1:43urheQI9dNtE5lTZQfuFJvjYJKPrxicATpEfZwHUNk=
github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k=
github.com/go-openapi/strfmt v0.21.3/go.mod h1:k+RzNO0Da+k3FrrynSNN8F7n/peCmQQqbbXjtDfvmGg=
github.com/go-openapi/strfmt v0.21.7/go.mod h1:adeGTkxE44sPyLk0JV235VQAO/ZXUr8KAzYjclFs3ew=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package appconfiguration
import (
"fmt"

"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
"github.com/IBM/appconfiguration-go-admin-sdk/appconfigurationv1"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -122,7 +123,7 @@ func dataSourceIbmAppConfigCollectionRead(d *schema.ResourceData, meta interface

appconfigClient, err := getAppConfigClient(meta, guid)
if err != nil {
return fmt.Errorf("getAppConfigClient failed %s", err)
return flex.FmtErrorf("getAppConfigClient failed %s", err)
}

options := &appconfigurationv1.GetCollectionOptions{}
Expand All @@ -142,50 +143,50 @@ func dataSourceIbmAppConfigCollectionRead(d *schema.ResourceData, meta interface

result, response, err := appconfigClient.GetCollection(options)
if err != nil {
return fmt.Errorf("GetCollection failed %s\n%s", err, response)
return flex.FmtErrorf("GetCollection failed %s\n%s", err, response)
}

d.SetId(fmt.Sprintf("%s/%s", guid, *result.CollectionID))
if result.Name != nil {
if err = d.Set("name", result.Name); err != nil {
return fmt.Errorf("[ERROR] Error setting name: %s", err)
return flex.FmtErrorf("[ERROR] Error setting name: %s", err)
}
}
if result.Description != nil {
if err = d.Set("description", result.Description); err != nil {
return fmt.Errorf("[ERROR] Error setting description: %s", err)
return flex.FmtErrorf("[ERROR] Error setting description: %s", err)
}
}
if result.Tags != nil {
if err = d.Set("tags", result.Tags); err != nil {
return fmt.Errorf("[ERROR] Error setting tags: %s", err)
return flex.FmtErrorf("[ERROR] Error setting tags: %s", err)
}
}
if result.CreatedTime != nil {
if err = d.Set("created_time", result.CreatedTime.String()); err != nil {
return fmt.Errorf("[ERROR] Error setting created_time: %s", err)
return flex.FmtErrorf("[ERROR] Error setting created_time: %s", err)
}
}
if result.UpdatedTime != nil {
if err = d.Set("updated_time", result.UpdatedTime.String()); err != nil {
return fmt.Errorf("[ERROR] Error setting updated_time: %s", err)
return flex.FmtErrorf("[ERROR] Error setting updated_time: %s", err)
}
}
if result.Href != nil {
if err = d.Set("href", result.Href); err != nil {
return fmt.Errorf("[ERROR] Error setting href: %s", err)
return flex.FmtErrorf("[ERROR] Error setting href: %s", err)
}
}
if result.Features != nil {
err = d.Set("features", dataSourceCollectionFlattenFeatures(result.Features))
if err != nil {
return fmt.Errorf("[ERROR] Error setting features %s", err)
return flex.FmtErrorf("[ERROR] Error setting features %s", err)
}
}
if result.Properties != nil {
err = d.Set("properties", dataSourceCollectionFlattenProperties(result.Properties))
if err != nil {
return fmt.Errorf("[ERROR] Error setting properties %s", err)
return flex.FmtErrorf("[ERROR] Error setting properties %s", err)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"reflect"
"strconv"

"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM/appconfiguration-go-admin-sdk/appconfigurationv1"
Expand Down Expand Up @@ -150,7 +151,7 @@ func dataSourceIbmAppConfigCollectionsRead(d *schema.ResourceData, meta interfac

appconfigClient, err := getAppConfigClient(meta, guid)
if err != nil {
return fmt.Errorf("getAppConfigClient failed %s", err)
return flex.FmtErrorf("getAppConfigClient failed %s", err)
}

options := &appconfigurationv1.ListCollectionsOptions{}
Expand Down Expand Up @@ -205,7 +206,7 @@ func dataSourceIbmAppConfigCollectionsRead(d *schema.ResourceData, meta interfac
result, response, err := appconfigClient.ListCollections(options)
collectionsList = result
if err != nil {
return fmt.Errorf("ListCollections failed %s\n%s", err, response)
return flex.FmtErrorf("ListCollections failed %s\n%s", err, response)
}
if isLimit {
offset = 0
Expand All @@ -225,22 +226,22 @@ func dataSourceIbmAppConfigCollectionsRead(d *schema.ResourceData, meta interfac
if collectionsList.Collections != nil {
err = d.Set("collections", dataSourceCollectionListFlattenCollections(collectionsList.Collections))
if err != nil {
return fmt.Errorf("[ERROR] Error setting collections %s", err)
return flex.FmtErrorf("[ERROR] Error setting collections %s", err)
}
}
if collectionsList.Limit != nil {
if err = d.Set("limit", collectionsList.Limit); err != nil {
return fmt.Errorf("[ERROR] Error setting limit: %s", err)
return flex.FmtErrorf("[ERROR] Error setting limit: %s", err)
}
}
if collectionsList.Offset != nil {
if err = d.Set("offset", collectionsList.Offset); err != nil {
return fmt.Errorf("[ERROR] Error setting offset: %s", err)
return flex.FmtErrorf("[ERROR] Error setting offset: %s", err)
}
}
if collectionsList.TotalCount != nil {
if err = d.Set("total_count", collectionsList.TotalCount); err != nil {
return fmt.Errorf("[ERROR] Error setting total_count: %s", err)
return flex.FmtErrorf("[ERROR] Error setting total_count: %s", err)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"log"

"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM/appconfiguration-go-admin-sdk/appconfigurationv1"
Expand Down Expand Up @@ -96,37 +97,37 @@ func dataSourceIbmAppConfigEnvironmentRead(d *schema.ResourceData, meta interfac

if result.Name != nil {
if err = d.Set("name", result.Name); err != nil {
return fmt.Errorf("[ERROR] Error setting name: %s", err)
return flex.FmtErrorf("[ERROR] Error setting name: %s", err)
}
}
if result.Description != nil {
if err = d.Set("description", result.Description); err != nil {
return fmt.Errorf("[ERROR] Error setting description: %s", err)
return flex.FmtErrorf("[ERROR] Error setting description: %s", err)
}
}
if result.Tags != nil {
if err = d.Set("tags", result.Tags); err != nil {
return fmt.Errorf("[ERROR] Error setting tags: %s", err)
return flex.FmtErrorf("[ERROR] Error setting tags: %s", err)
}
}
if result.ColorCode != nil {
if err = d.Set("color_code", result.ColorCode); err != nil {
return fmt.Errorf("[ERROR] Error setting color_code: %s", err)
return flex.FmtErrorf("[ERROR] Error setting color_code: %s", err)
}
}
if result.CreatedTime != nil {
if err = d.Set("created_time", result.CreatedTime.String()); err != nil {
return fmt.Errorf("[ERROR] Error setting created_time: %s", err)
return flex.FmtErrorf("[ERROR] Error setting created_time: %s", err)
}
}
if result.UpdatedTime != nil {
if err = d.Set("updated_time", result.UpdatedTime.String()); err != nil {
return fmt.Errorf("[ERROR] Error setting updated_time: %s", err)
return flex.FmtErrorf("[ERROR] Error setting updated_time: %s", err)
}
}
if result.Href != nil {
if err = d.Set("href", result.Href); err != nil {
return fmt.Errorf("[ERROR] Error setting href: %s", err)
return flex.FmtErrorf("[ERROR] Error setting href: %s", err)
}
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
package appconfiguration

import (
"fmt"
"log"
"net/url"
"reflect"
"strconv"

"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM/appconfiguration-go-admin-sdk/appconfigurationv1"
Expand Down Expand Up @@ -198,7 +198,7 @@ func dataSourceIbmAppConfigEnvironmentsRead(d *schema.ResourceData, meta interfa
result, response, err := appconfigClient.ListEnvironments(options)
environmentList = result
if err != nil {
log.Printf("[DEBUG] ListEnvironments failed %s\n%s", err, response)
log.Printf("[ERROR] Listing Environments failed %s\n%s", err, response)
return err
}
if isLimit {
Expand All @@ -219,48 +219,48 @@ func dataSourceIbmAppConfigEnvironmentsRead(d *schema.ResourceData, meta interfa
if environmentList.Environments != nil {
err = d.Set("environments", dataSourceEnvironmentListFlattenEnvironments(environmentList.Environments))
if err != nil {
return fmt.Errorf("[ERROR] Error setting environments %s", err)
return flex.FmtErrorf("[ERROR] Error setting environments %s", err)
}
}
if environmentList.TotalCount != nil {
if err = d.Set("total_count", environmentList.TotalCount); err != nil {
return fmt.Errorf("[ERROR] Error setting total_count: %s", err)
return flex.FmtErrorf("[ERROR] Error setting total_count: %s", err)
}
}
if environmentList.Limit != nil {
if err = d.Set("limit", environmentList.Limit); err != nil {
return fmt.Errorf("[ERROR] Error setting limit: %s", err)
return flex.FmtErrorf("[ERROR] Error setting limit: %s", err)
}
}
if environmentList.Offset != nil {
if err = d.Set("offset", environmentList.Offset); err != nil {
return fmt.Errorf("[ERROR] Error setting offset: %s", err)
return flex.FmtErrorf("[ERROR] Error setting offset: %s", err)
}
}
if environmentList.First != nil {
err = d.Set("first", dataSourceEnvironmentListFlattenPagination(*environmentList.First))
if err != nil {
return fmt.Errorf("[ERROR] Error setting first %s", err)
return flex.FmtErrorf("[ERROR] Error setting first %s", err)
}
}

if environmentList.Previous != nil {
err = d.Set("previous", dataSourceEnvironmentListFlattenPagination(*environmentList.Previous))
if err != nil {
return fmt.Errorf("[ERROR] Error setting previous %s", err)
return flex.FmtErrorf("[ERROR] Error setting previous %s", err)
}
}

if environmentList.Last != nil {
err = d.Set("last", dataSourceEnvironmentListFlattenPagination(*environmentList.Last))
if err != nil {
return fmt.Errorf("[ERROR] Error setting last %s", err)
return flex.FmtErrorf("[ERROR] Error setting last %s", err)
}
}
if environmentList.Next != nil {
err = d.Set("next", dataSourceEnvironmentListFlattenPagination(*environmentList.Next))
if err != nil {
return fmt.Errorf("[ERROR] Error setting next %s", err)
return flex.FmtErrorf("[ERROR] Error setting next %s", err)
}
}

Expand Down
Loading

0 comments on commit 0f9864f

Please sign in to comment.