Skip to content

Commit

Permalink
Move Source schema settings to Source - Tracking Plan connection reso…
Browse files Browse the repository at this point in the history
…urce (#76)
  • Loading branch information
deanhuynh authored Nov 16, 2023
1 parent 220ec6c commit 0d82651
Show file tree
Hide file tree
Showing 18 changed files with 1,119 additions and 800 deletions.
33 changes: 31 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
## 0.1.0 (Unreleased)
## 0.8.0 (November 16, 2023)
**BREAKING CHANGE**

FEATURES:
Move Source schema settings configuration to `segment_source_tracking_plan_connection` resource. Also adds schema settings to Source data source.

## 0.7.0 (November 1, 2023)
Support Insert Function instance resource.

## 0.6.0 (October 31, 2023)
Adds support for Source schema settings in the Source resource. Also removes the description field from Labels fields in various resources since it is not populated and not likely to be used for configuration.

## 0.5.1 (October 27, 2023)
Fixes an issue where Function setting type could not be set to `TEXT_MAP``.

## 0.5.0 (October 26, 2023)
Adds support for Reverse ETL model resource.
(Previously misreleased as 0.0.5)

## 0.4.0 (October 19, 2023)
Adds support for Destination subscriptions and Source - Tracking Plan connection resources.

## 0.3.0 (October 16, 2023)
Adds support for Profiles Warehouse and fixes nil pointer access issues with Destination metadata.

## 0.2.0 (October 13, 2023)
Adds support for destination filters and functions.

## 0.1.0 (October 6, 2023)
Adds support for IAM resource (users, user groups)

## 0.0.2 (September 22, 2023)
Initial release
4 changes: 2 additions & 2 deletions docs/resources/label.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "segment_label Resource - terraform-provider-segment"
subcategory: ""
description: |-
A label associated with the current Workspace. To import a label into Terraform, use the following format: 'key:value'
A label associated with the current Workspace. To import a label into Terraform, use the following format: 'key:value'.
---

# segment_label (Resource)

A label associated with the current Workspace. To import a label into Terraform, use the following format: 'key:value'
A label associated with the current Workspace. To import a label into Terraform, use the following format: 'key:value'.

## Example Usage

Expand Down
82 changes: 0 additions & 82 deletions docs/resources/source.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,6 @@ resource "segment_source" "my_source" {
},
]
}
resource "segment_source" "my_source_with_schema_settings" {
slug = "my_source_slug"
name = "My Source"
enabled = true
metadata = {
id = "abc123"
}
settings = jsonencode({
"token" : "xyz321",
})
labels = [
{
key = "env"
value = "dev"
},
]
schema_settings = {
forwarding_blocked_events_to = segment_source.my_source.id
track = {
allow_unplanned_events = true
allow_unplanned_event_properties = true
allow_event_on_violations = false
allow_properties_on_violations = true
common_event_on_violations = "ALLOW"
}
identify = {
allow_traits_on_violations = false
allow_unplanned_traits = false
common_event_on_violations = "ALLOW"
}
group = {
allow_traits_on_violations = true
allow_unplanned_traits = true
common_event_on_violations = "ALLOW"
}
}
}
```

<!-- schema generated by tfplugindocs -->
Expand All @@ -85,7 +47,6 @@ resource "segment_source" "my_source_with_schema_settings" {

- `labels` (Attributes Set) A list of labels applied to the Source. (see [below for nested schema](#nestedatt--labels))
- `name` (String) The name of the Source.
- `schema_settings` (Attributes) The schema settings associated with the Source. Upon import, this field will be empty even if the settings have already been configured due to Terraform limitations, but will be populated on the first apply. Fields not present in the config will not be managed by Terraform. (see [below for nested schema](#nestedatt--schema_settings))

### Read-Only

Expand Down Expand Up @@ -141,46 +102,3 @@ Required:

- `key` (String) The key that represents the name of this label.
- `value` (String) The value associated with the key of this label.


<a id="nestedatt--schema_settings"></a>
### Nested Schema for `schema_settings`

Optional:

- `forwarding_blocked_events_to` (String) Source id to forward blocked events to.
- `forwarding_violations_to` (String) Source id to forward violations to.
- `group` (Attributes) Group settings. (see [below for nested schema](#nestedatt--schema_settings--group))
- `identify` (Attributes) Identify settings. (see [below for nested schema](#nestedatt--schema_settings--identify))
- `track` (Attributes) Track settings. (see [below for nested schema](#nestedatt--schema_settings--track))

<a id="nestedatt--schema_settings--group"></a>
### Nested Schema for `schema_settings.group`

Optional:

- `allow_traits_on_violations` (Boolean) Enable to allow group traits on violations.
- `allow_unplanned_traits` (Boolean) Enable to allow unplanned group traits.
- `common_event_on_violations` (String) The common group event on violations.


<a id="nestedatt--schema_settings--identify"></a>
### Nested Schema for `schema_settings.identify`

Optional:

- `allow_traits_on_violations` (Boolean) Enable to allow identify traits on violations.
- `allow_unplanned_traits` (Boolean) Enable to allow unplanned identify traits.
- `common_event_on_violations` (String) The common identify event on violations.


<a id="nestedatt--schema_settings--track"></a>
### Nested Schema for `schema_settings.track`

Optional:

- `allow_event_on_violations` (Boolean) Allow track event on violations.
- `allow_properties_on_violations` (Boolean) Enable to allow track properties on violations.
- `allow_unplanned_event_properties` (Boolean) Enable to allow unplanned track event properties.
- `allow_unplanned_events` (Boolean) Enable to allow unplanned track events.
- `common_event_on_violations` (String) The common track event on violations.
70 changes: 68 additions & 2 deletions docs/resources/source_tracking_plan_connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "segment_source_tracking_plan_connection Resource - terraform-provider-segment"
subcategory: ""
description: |-
Represents a connection between a Source and a Tracking Plan
Represents a connection between a Source and a Tracking Plan. To import a connection into Terraform, use the following format: 'sourceid:trackingplan_id'.
---

# segment_source_tracking_plan_connection (Resource)

Represents a connection between a Source and a Tracking Plan
Represents a connection between a Source and a Tracking Plan. To import a connection into Terraform, use the following format: 'source_id:tracking_plan_id'.

## Example Usage

Expand All @@ -17,6 +17,26 @@ Represents a connection between a Source and a Tracking Plan
resource "segment_source_tracking_plan_connection" "example" {
source_id = "abc123"
tracking_plan_id = "xyz321"
schema_settings = {
forwarding_blocked_events_to = segment_source.my_source.id
track = {
allow_unplanned_events = true
allow_unplanned_event_properties = true
allow_event_on_violations = false
allow_properties_on_violations = true
common_event_on_violations = "ALLOW"
}
identify = {
allow_traits_on_violations = false
allow_unplanned_traits = false
common_event_on_violations = "ALLOW"
}
group = {
allow_traits_on_violations = true
allow_unplanned_traits = true
common_event_on_violations = "ALLOW"
}
}
}
```

Expand All @@ -27,3 +47,49 @@ resource "segment_source_tracking_plan_connection" "example" {

- `source_id` (String) The id of the Source.
- `tracking_plan_id` (String) The id of the Tracking Plan.

### Optional

- `schema_settings` (Attributes) The schema settings associated with the Source. Upon import, this field will be empty even if the settings have already been configured due to Terraform limitations, but will be populated on the first apply. Fields not present in the config will not be managed by Terraform. (see [below for nested schema](#nestedatt--schema_settings))

<a id="nestedatt--schema_settings"></a>
### Nested Schema for `schema_settings`

Optional:

- `forwarding_blocked_events_to` (String) Source id to forward blocked events to.
- `forwarding_violations_to` (String) Source id to forward violations to.
- `group` (Attributes) Group settings. (see [below for nested schema](#nestedatt--schema_settings--group))
- `identify` (Attributes) Identify settings. (see [below for nested schema](#nestedatt--schema_settings--identify))
- `track` (Attributes) Track settings. (see [below for nested schema](#nestedatt--schema_settings--track))

<a id="nestedatt--schema_settings--group"></a>
### Nested Schema for `schema_settings.group`

Optional:

- `allow_traits_on_violations` (Boolean) Enable to allow group traits on violations.
- `allow_unplanned_traits` (Boolean) Enable to allow unplanned group traits.
- `common_event_on_violations` (String) The common group event on violations.


<a id="nestedatt--schema_settings--identify"></a>
### Nested Schema for `schema_settings.identify`

Optional:

- `allow_traits_on_violations` (Boolean) Enable to allow identify traits on violations.
- `allow_unplanned_traits` (Boolean) Enable to allow unplanned identify traits.
- `common_event_on_violations` (String) The common identify event on violations.


<a id="nestedatt--schema_settings--track"></a>
### Nested Schema for `schema_settings.track`

Optional:

- `allow_event_on_violations` (Boolean) Allow track event on violations.
- `allow_properties_on_violations` (Boolean) Enable to allow track properties on violations.
- `allow_unplanned_event_properties` (Boolean) Enable to allow unplanned track event properties.
- `allow_unplanned_events` (Boolean) Enable to allow unplanned track events.
- `common_event_on_violations` (String) The common track event on violations.
38 changes: 0 additions & 38 deletions examples/resources/segment_source/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,3 @@ resource "segment_source" "my_source" {
},
]
}

resource "segment_source" "my_source_with_schema_settings" {
slug = "my_source_slug"
name = "My Source"
enabled = true
metadata = {
id = "abc123"
}
settings = jsonencode({
"token" : "xyz321",
})
labels = [
{
key = "env"
value = "dev"
},
]
schema_settings = {
forwarding_blocked_events_to = segment_source.my_source.id
track = {
allow_unplanned_events = true
allow_unplanned_event_properties = true
allow_event_on_violations = false
allow_properties_on_violations = true
common_event_on_violations = "ALLOW"
}
identify = {
allow_traits_on_violations = false
allow_unplanned_traits = false
common_event_on_violations = "ALLOW"
}
group = {
allow_traits_on_violations = true
allow_unplanned_traits = true
common_event_on_violations = "ALLOW"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,24 @@
resource "segment_source_tracking_plan_connection" "example" {
source_id = "abc123"
tracking_plan_id = "xyz321"
schema_settings = {
forwarding_blocked_events_to = segment_source.my_source.id
track = {
allow_unplanned_events = true
allow_unplanned_event_properties = true
allow_event_on_violations = false
allow_properties_on_violations = true
common_event_on_violations = "ALLOW"
}
identify = {
allow_traits_on_violations = false
allow_unplanned_traits = false
common_event_on_violations = "ALLOW"
}
group = {
allow_traits_on_violations = true
allow_unplanned_traits = true
common_event_on_violations = "ALLOW"
}
}
}
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ require (
gotest.tools/gotestsum v1.11.0
)

require github.com/bitfield/gotestdox v0.2.1 // indirect
require (
github.com/avast/retry-go/v4 v4.5.1 // indirect
github.com/bitfield/gotestdox v0.2.1 // indirect
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmms
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/avast/retry-go/v4 v4.5.1 h1:AxIx0HGi4VZ3I02jr78j5lZ3M6x1E0Ivxa6b0pUUh7o=
github.com/avast/retry-go/v4 v4.5.1/go.mod h1:/sipNsvNB3RRuT5iNcb6h73nw3IBmXJ/H3XrCQYSOpc=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bitfield/gotestdox v0.2.1 h1:Zj8IMLAO5/oiAKoMmtN96eyFiPZraJRTH2p0zDgtxc0=
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/label_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (r *labelResource) Metadata(_ context.Context, req resource.MetadataRequest

func (r *labelResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "A label associated with the current Workspace. To import a label into Terraform, use the following format: 'key:value'",
Description: "A label associated with the current Workspace. To import a label into Terraform, use the following format: 'key:value'.",
Attributes: map[string]schema.Attribute{
"key": schema.StringAttribute{
Description: "The key that represents the name of this label.",
Expand Down
1 change: 1 addition & 0 deletions internal/provider/misc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package provider

const MaxPageSize = 200
const DefaultRetryDelay = 1000
Loading

0 comments on commit 0d82651

Please sign in to comment.