Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
destinations
Browse files Browse the repository at this point in the history
  • Loading branch information
GtheSheep committed May 27, 2022
1 parent c91aba5 commit bb403a0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
11 changes: 10 additions & 1 deletion pkg/resources/destinations.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resources
import (
"context"
"fmt"
"strconv"

"github.com/gthesheep/terraform-provider-segment/pkg/segment"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -42,7 +43,7 @@ func ResourceDestination() *schema.Resource {
"settings": &schema.Schema{
Type: schema.TypeMap,
Required: true,
Description: "Map containing settings for the destination",
Description: "Map containing settings for the destination, currently all values must be provided as strings",
Elem: &schema.Schema{
Type: schema.TypeString,
},
Expand Down Expand Up @@ -98,6 +99,14 @@ func resourceDestinationRead(ctx context.Context, d *schema.ResourceData, m inte
if err := d.Set("destination_slug", destination.Metadata.Slug); err != nil {
return diag.FromErr(err)
}
if err := d.Set("source_id", destination.SourceID); err != nil {
return diag.FromErr(err)
}
for k, v := range destination.Settings {
if _, ok := v.(bool); ok {
destination.Settings[k] = strconv.FormatBool(v.(bool))
}
}
if err := d.Set("settings", destination.Settings); err != nil {
return diag.FromErr(err)
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/resources/destinations_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ resource "segment_destination" "test_destination" {
settings = {
containerId = "xxxx"
environment = "gtm_auth=xxxx"
trackAllPages = "false"
trackCategorizedPages = "false"
trackNamedPages = "false"
}
}
`, sourceSlug, sourceName, name, destinationSlug)
Expand Down
2 changes: 1 addition & 1 deletion pkg/segment/destinations.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type DestinationMetadata struct {
type Destination struct {
ID *string `json:"id,omitempty"`
Name string `json:"name"`
Metadata SourceMetadata `json:"metadata"`
Metadata DestinationMetadata `json:"metadata"`
Enabled bool `json:"enabled"`
SourceID string `json:"sourceId"`
Settings map[string]interface{} `json:"settings"`
Expand Down

0 comments on commit bb403a0

Please sign in to comment.