-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
abb5fc5
commit f1e60a5
Showing
32 changed files
with
1,328 additions
and
865 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
rudderstack/integrations/destinations/common_config_meta.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
101
rudderstack/integrations/destinations/common_config_meta_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
}) | ||
} | ||
} |
Oops, something went wrong.