Skip to content

Commit

Permalink
chore: release version 1.0.0 (#104)
Browse files Browse the repository at this point in the history
* chore: update goreleaser version 2 (#99)

* feat!: make onetrust cm fields source type specific for some destinations (#102)

* chore: fix deprecated release flag to clean (#98)

* feat!:make onetrust cm fields source type specific for some destinations

* fix: test suites

---------

Co-authored-by: Yashasvi Bajpai <33063622+yashasvibajpai@users.noreply.github.com>

---------

Co-authored-by: Sai Kumar Battinoju <88789928+saikumarrs@users.noreply.github.com>
  • Loading branch information
yashasvibajpai and saikumarrs authored Aug 29, 2024
1 parent abb5fc5 commit f1e60a5
Show file tree
Hide file tree
Showing 32 changed files with 1,328 additions and 865 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ HOSTNAME=rudderstack.com
NAMESPACE=rudderlabs
NAME=rudderstack
BINARY=terraform-provider-${NAME}
VERSION=0.8.2
VERSION=1.0.0
OS_ARCH=$(shell go env GOOS)_$(shell go env GOARCH)

default: install
Expand Down
18 changes: 7 additions & 11 deletions cmd/generatetf/generator/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,11 @@ func TestGeneratorTerraform(t *testing.T) {
"categoryToContent": [{ "from": "from", "to": "to" }],
"legacyConversionPixelId": { "from": "from", "to": "to" },
"useNativeSDK": { "web": true },
"oneTrustCookieCategories": {
"web": [
"oneTrustCookieCategories": [
{ "oneTrustCookieCategory": "one" },
{ "oneTrustCookieCategory": "two" },
{ "oneTrustCookieCategory": "three" }
]
},
],
"blacklistedEvents": [
{ "eventName": "one" },
{ "eventName": "two" },
Expand Down Expand Up @@ -146,13 +144,11 @@ resource "rudderstack_destination_facebook_pixel" "dst_id-facebook-pixel" {
from = "from"
to = "to"
}
onetrust_cookie_categories {
web = ["one", "two", "three"]
}
pixel_id = "facebook pixel id"
standard_page_call = true
test_destination = true
test_event_code = "..."
onetrust_cookie_categories = ["one", "two", "three"]
pixel_id = "facebook pixel id"
standard_page_call = true
test_destination = true
test_event_code = "..."
use_native_sdk {
web = true
}
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/import.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ terraform {
required_providers {
rudderstack = {
source = "rudderlabs/rudderstack"
version = "~> 0.8.1"
version = "~> 1.0.0"
}
}
required_version = "~> 1.1.0"
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ terraform {
required_providers {
rudderstack = {
source = "rudderlabs/rudderstack"
version = "~> 0.8.1"
version = "~> 1.0.0"
}
}
required_version = "~> 1.1.0"
Expand All @@ -34,4 +34,4 @@ provider "rudderstack" {
### Optional

- `access_token` (String) The Rudderstack API access token used to authenticate you Rudderstack account. If not set, the provider will look for that value in the `RUDDERSTACK_ACCESS_TOKEN` environmental value, and fail with an error if that is missing.
- `api_url` (String) The base URL of Rudderstack API. If not set, the provider will first look for a value in the `RUDDERSTACK_API_URL` environmental value, and finally default to `https://api.rudderstack.com/v2` if that is missing.
- `api_url` (String) The base URL of Rudderstack API. If not set, the provider will first look for a value in the `RUDDERSTACK_API_URL` environmental value, and finally default to `https://api.rudderstack.com/v2` if that is missing.
14 changes: 13 additions & 1 deletion docs/resources/destination_amplitude.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,19 @@ resource "rudderstack_destination_amplitude" "example" {
# blacklist = ["one", "two", "three"]
# }
# onetrust_cookie_categories = ["one", "two", "three"]
# onetrust_cookie_categories {
# web = ["one", "two", "three"]
# android = ["one", "two", "three"]
# ios = ["one", "two", "three"]
# unity = ["one", "two", "three"]
# reactnative = ["one", "two", "three"]
# flutter = ["one", "two", "three"]
# cordova = ["one", "two", "three"]
# amp = ["one", "two", "three"]
# cloud = ["one", "two", "three"]
# warehouse = ["one", "two", "three"]
# shopify = ["one", "two", "three"]
# }
# residency_server = "EU"
}
Expand Down
14 changes: 13 additions & 1 deletion docs/resources/destination_google_analytics4.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,19 @@ resource "rudderstack_destination_google_analytics4" "example" {
# blacklist = ["one", "two", "three"]
# }
# onetrust_cookie_categories = ["one", "two", "three"]
# onetrust_cookie_categories {
# web = ["one", "two", "three"]
# android = ["one", "two", "three"]
# ios = ["one", "two", "three"]
# unity = ["one", "two", "three"]
# reactnative = ["one", "two", "three"]
# flutter = ["one", "two", "three"]
# cordova = ["one", "two", "three"]
# amp = ["one", "two", "three"]
# cloud = ["one", "two", "three"]
# warehouse = ["one", "two", "three"]
# shopify = ["one", "two", "three"]
# }
}
}
```
Expand Down
4 changes: 3 additions & 1 deletion docs/resources/destination_google_tag_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ resource "rudderstack_destination_google_tag_manager" "example" {
blacklist = ["one", "two", "three"]
}
# onetrust_cookie_categories = ["one", "two", "three"]
# onetrust_cookie_categories {
# web = ["one", "two", "three"]
# }
}
}
```
Expand Down
14 changes: 13 additions & 1 deletion docs/resources/destination_mixpanel.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,19 @@ resource "rudderstack_destination_mixpanel" example{
# blacklist = ["one","two","three"]
# }
# onetrust_cookie_categories = ["one", "two", "three"]
# onetrust_cookie_categories {
# web = ["one", "two", "three"]
# android = ["one", "two", "three"]
# ios = ["one", "two", "three"]
# unity = ["one", "two", "three"]
# reactnative = ["one", "two", "three"]
# flutter = ["one", "two", "three"]
# cordova = ["one", "two", "three"]
# amp = ["one", "two", "three"]
# cloud = ["one", "two", "three"]
# warehouse = ["one", "two", "three"]
# shopify = ["one", "two", "three"]
# }
# use_new_mapping = true
}
}
Expand Down
14 changes: 13 additions & 1 deletion examples/destination_amplitude.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,19 @@ resource "rudderstack_destination_amplitude" "example" {
# blacklist = ["one", "two", "three"]
# }

# onetrust_cookie_categories = ["one", "two", "three"]
# onetrust_cookie_categories {
# web = ["one", "two", "three"]
# android = ["one", "two", "three"]
# ios = ["one", "two", "three"]
# unity = ["one", "two", "three"]
# reactnative = ["one", "two", "three"]
# flutter = ["one", "two", "three"]
# cordova = ["one", "two", "three"]
# amp = ["one", "two", "three"]
# cloud = ["one", "two", "three"]
# warehouse = ["one", "two", "three"]
# shopify = ["one", "two", "three"]
# }

# residency_server = "EU"
}
Expand Down
14 changes: 13 additions & 1 deletion examples/destination_google_analytics4.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ resource "rudderstack_destination_google_analytics4" "example" {
# blacklist = ["one", "two", "three"]
# }

# onetrust_cookie_categories = ["one", "two", "three"]
# onetrust_cookie_categories {
# web = ["one", "two", "three"]
# android = ["one", "two", "three"]
# ios = ["one", "two", "three"]
# unity = ["one", "two", "three"]
# reactnative = ["one", "two", "three"]
# flutter = ["one", "two", "three"]
# cordova = ["one", "two", "three"]
# amp = ["one", "two", "three"]
# cloud = ["one", "two", "three"]
# warehouse = ["one", "two", "three"]
# shopify = ["one", "two", "three"]
# }
}
}
4 changes: 3 additions & 1 deletion examples/destination_google_tag_manager.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ resource "rudderstack_destination_google_tag_manager" "example" {
blacklist = ["one", "two", "three"]
}

# onetrust_cookie_categories = ["one", "two", "three"]
# onetrust_cookie_categories {
# web = ["one", "two", "three"]
# }
}
}
16 changes: 14 additions & 2 deletions examples/destination_mixpanel.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,19 @@ resource "rudderstack_destination_mixpanel" example{
# blacklist = ["one","two","three"]
# }

# onetrust_cookie_categories = ["one", "two", "three"]
# onetrust_cookie_categories {
# web = ["one", "two", "three"]
# android = ["one", "two", "three"]
# ios = ["one", "two", "three"]
# unity = ["one", "two", "three"]
# reactnative = ["one", "two", "three"]
# flutter = ["one", "two", "three"]
# cordova = ["one", "two", "three"]
# amp = ["one", "two", "three"]
# cloud = ["one", "two", "three"]
# warehouse = ["one", "two", "three"]
# shopify = ["one", "two", "three"]
# }
# use_new_mapping = true
}
}
}
2 changes: 1 addition & 1 deletion examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
rudderstack = {
source = "rudderlabs/rudderstack"
version = "~> 0.8.2"
version = "~> 1.0.0"
}
}
required_version = "~> 1.1.0"
Expand Down
58 changes: 58 additions & 0 deletions rudderstack/integrations/destinations/common_config_meta.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package destinations

import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
c "github.com/rudderlabs/terraform-provider-rudderstack/rudderstack/configs"
)

func GetConfigMetaForOneTrustConsents(supportedSourceTypes []string) ([]c.ConfigProperty, map[string]*schema.Schema) {
oneTrustConsentsProperties := []c.ConfigProperty{}
oneTrustConsentsSchema := map[string]*schema.Schema{}

if len(supportedSourceTypes) != 0 && supportedSourceTypes != nil {
onetrust_terraform_key := "onetrust_cookie_categories"
onetrust_elements_schema := make(map[string]*schema.Schema)

// Create property and schema for each source type
for _, sourceType := range supportedSourceTypes {
oneTrustConsentsProperties = append(oneTrustConsentsProperties, c.ArrayWithStrings(fmt.Sprintf("oneTrustCookieCategories.%s", sourceType), "oneTrustCookieCategory", fmt.Sprintf("%s.0.%s", onetrust_terraform_key, sourceType)))

onetrust_elements_schema[sourceType] = &schema.Schema{
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
}
}

oneTrustConsentsSchema[onetrust_terraform_key] = &schema.Schema{
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: "Specify OneTrust category IDs.",
Elem: &schema.Resource{
Schema: onetrust_elements_schema,
},
};
}

return oneTrustConsentsProperties, oneTrustConsentsSchema
}

func GetCommonConfigMeta(supportedSourceTypes []string) ([]c.ConfigProperty, map[string]*schema.Schema) {
commonProperties := []c.ConfigProperty{}
commonSchema := map[string]*schema.Schema{}

oneTrustConsentFieldProperties, oneTrustConsentFieldSchema := GetConfigMetaForOneTrustConsents(supportedSourceTypes)

commonProperties = append(commonProperties, oneTrustConsentFieldProperties...)

for key, value := range oneTrustConsentFieldSchema {
commonSchema[key] = value
}

return commonProperties, commonSchema
}
101 changes: 101 additions & 0 deletions rudderstack/integrations/destinations/common_config_meta_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// write unit tests for the common_config_meta.go file

package destinations

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
c "github.com/rudderlabs/terraform-provider-rudderstack/rudderstack/configs"
"github.com/stretchr/testify/require"
)

func TestGetCommonConfigMeta(t *testing.T) {
testCases := []struct {
description string
supportedSourceTypes []string
expectedProperties []c.ConfigProperty
expectedSchema map[string]*schema.Schema
}{
{
description: "Valid list of supported source types",
supportedSourceTypes: []string{"web", "android", "ios"},
expectedProperties: []c.ConfigProperty{
c.ArrayWithStrings("oneTrustCookieCategories.web", "oneTrustCookieCategory", "onetrust_cookie_categories.0.web"),
c.ArrayWithStrings("oneTrustCookieCategories.android", "oneTrustCookieCategory", "onetrust_cookie_categories.0.android"),
c.ArrayWithStrings("oneTrustCookieCategories.ios", "oneTrustCookieCategory", "onetrust_cookie_categories.0.ios"),
},
expectedSchema: map[string]*schema.Schema{
"onetrust_cookie_categories": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: "Specify OneTrust category IDs.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"web": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"android": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"ios": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
},
},
},
},
{
description: "Empty list of supported source types",
supportedSourceTypes: []string{},
expectedProperties: []c.ConfigProperty{},
expectedSchema: map[string]*schema.Schema{},
},
{
description: "Nil supported source types",
supportedSourceTypes: nil,
expectedProperties: []c.ConfigProperty{},
expectedSchema: map[string]*schema.Schema{},
},
{
description: "A single supported source type",
supportedSourceTypes: []string{"web"},
expectedProperties: []c.ConfigProperty{
c.ArrayWithStrings("oneTrustCookieCategories.web", "oneTrustCookieCategory", "onetrust_cookie_categories.0.web"),
},
expectedSchema: map[string]*schema.Schema{
"onetrust_cookie_categories": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: "Specify OneTrust category IDs.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"web": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
},
},
},
},
}

for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
actualProperties, actualSchema := GetCommonConfigMeta(tc.supportedSourceTypes)
require.EqualValues(t, tc.expectedSchema, actualSchema)
require.True(t, len(actualProperties) == len(tc.expectedProperties))
})
}
}
Loading

0 comments on commit f1e60a5

Please sign in to comment.