Skip to content

Commit

Permalink
FIX: [TF] data source "cloudconnexa_ip_service" not working properly
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfmnk committed Jul 29, 2024
1 parent b4ff2f4 commit 3221565
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions cloudconnexa/data_source_ip_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ func dataSourceIPService() *schema.Resource {
ReadContext: dataSourceIPServiceRead,
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Optional: true,
ExactlyOneOf: []string{"id", "name"},
},
"name": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Optional: true,
ExactlyOneOf: []string{"id", "name"},
},
"description": {
Type: schema.TypeString,
Expand Down Expand Up @@ -53,13 +55,20 @@ func dataSourceIPService() *schema.Resource {

func dataSourceIPServiceRead(ctx context.Context, data *schema.ResourceData, i interface{}) diag.Diagnostics {
c := i.(*cloudconnexa.Client)
service, err := c.IPServices.Get(
data.Id(),
)

var service *cloudconnexa.IPServiceResponse
var err error

if id, ok := data.GetOk("id"); ok {
service, err = c.IPServices.Get(id.(string))
} else {
service, err = c.IPServices.GetByName(data.Get("name").(string))

Check failure on line 65 in cloudconnexa/data_source_ip_service.go

View workflow job for this annotation

GitHub Actions / lint

c.IPServices.GetByName undefined (type *"github.com/openvpn/cloudconnexa-go-client/v2/cloudconnexa".IPServicesService has no field or method GetByName)) (typecheck)

Check failure on line 65 in cloudconnexa/data_source_ip_service.go

View workflow job for this annotation

GitHub Actions / lint

c.IPServices.GetByName undefined (type *"github.com/openvpn/cloudconnexa-go-client/v2/cloudconnexa".IPServicesService has no field or method GetByName) (typecheck)

Check failure on line 65 in cloudconnexa/data_source_ip_service.go

View workflow job for this annotation

GitHub Actions / lint

c.IPServices.GetByName undefined (type *"github.com/openvpn/cloudconnexa-go-client/v2/cloudconnexa".IPServicesService has no field or method GetByName)) (typecheck)
}

if err != nil {
return diag.FromErr(err)
}

setResourceData(data, service)
return nil
}

0 comments on commit 3221565

Please sign in to comment.