Skip to content

Commit

Permalink
Fix skip_before skip_after type issue (#30)
Browse files Browse the repository at this point in the history
* Fix skip_before skip_after type issue

* changelog
  • Loading branch information
beevital authored May 13, 2022
1 parent cc76c9f commit ca1a4fc
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 35 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/fivetran/terraform-provider-fivetran/compare/v0.4.1...HEAD)
## [Unreleased](https://github.com/fivetran/terraform-provider-fivetran/compare/v0.4.2...HEAD)

## [0.4.2](https://github.com/fivetran/terraform-provider-fivetran/compare/v0.4.1...v0.4.2) - 2022-05-18

## Fixed
- Issue with `resource_connector.config.skip_before` response value type
- Issue with `resource_connector.config.skip_after` response value type

## [0.4.1](https://github.com/fivetran/terraform-provider-fivetran/compare/v0.4.0...v0.4.1) - 2022-05-06

Expand Down
47 changes: 23 additions & 24 deletions fivetran/data_source_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,34 @@ func dataSourceConnector() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceConnectorRead,
Schema: map[string]*schema.Schema{
"id": {Type: schema.TypeString, Required: true},
"group_id": {Type: schema.TypeString, Computed: true},
"service": {Type: schema.TypeString, Computed: true},
"service_version": {Type: schema.TypeString, Computed: true},
"name": {Type: schema.TypeString, Computed: true},
"destination_schema":dataSourceConnectorDestinationSchemaSchema(),
"connected_by": {Type: schema.TypeString, Computed: true},
"created_at": {Type: schema.TypeString, Computed: true},
"succeeded_at": {Type: schema.TypeString, Computed: true},
"failed_at": {Type: schema.TypeString, Computed: true},
"sync_frequency": {Type: schema.TypeString, Computed: true},
"daily_sync_time": {Type: schema.TypeString, Computed: true},
"schedule_type": {Type: schema.TypeString, Computed: true},
"paused": {Type: schema.TypeString, Computed: true},
"pause_after_trial": {Type: schema.TypeString, Computed: true},
"status": dataSourceConnectorSchemaStatus(),
"config": dataSourceConnectorSchemaConfig(),
"id": {Type: schema.TypeString, Required: true},
"group_id": {Type: schema.TypeString, Computed: true},
"service": {Type: schema.TypeString, Computed: true},
"service_version": {Type: schema.TypeString, Computed: true},
"name": {Type: schema.TypeString, Computed: true},
"destination_schema": dataSourceConnectorDestinationSchemaSchema(),
"connected_by": {Type: schema.TypeString, Computed: true},
"created_at": {Type: schema.TypeString, Computed: true},
"succeeded_at": {Type: schema.TypeString, Computed: true},
"failed_at": {Type: schema.TypeString, Computed: true},
"sync_frequency": {Type: schema.TypeString, Computed: true},
"daily_sync_time": {Type: schema.TypeString, Computed: true},
"schedule_type": {Type: schema.TypeString, Computed: true},
"paused": {Type: schema.TypeString, Computed: true},
"pause_after_trial": {Type: schema.TypeString, Computed: true},
"status": dataSourceConnectorSchemaStatus(),
"config": dataSourceConnectorSchemaConfig(),
},
}
}


func dataSourceConnectorDestinationSchemaSchema() *schema.Schema {
return &schema.Schema{Type: schema.TypeList, Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {Type: schema.TypeString, Computed: true},
"table": {Type: schema.TypeString, Computed: true},
"prefix": {Type: schema.TypeString, Computed: true},
"name": {Type: schema.TypeString, Computed: true},
"table": {Type: schema.TypeString, Computed: true},
"prefix": {Type: schema.TypeString, Computed: true},
},
},
}
Expand Down Expand Up @@ -349,7 +348,7 @@ func dataSourceConnectorRead(ctx context.Context, d *schema.ResourceData, m inte
mapAddStr(msi, "group_id", resp.Data.GroupID)
mapAddStr(msi, "service", resp.Data.Service)
mapAddStr(msi, "service_version", intPointerToStr(resp.Data.ServiceVersion))
mapAddStr(msi, "name", resp.Data.Schema)
mapAddStr(msi, "name", resp.Data.Schema)
mapAddXInterface(msi, "destination_schema", dataSourceConnectorReadDestinationSchema(resp.Data.Schema, resp.Data.Service))
mapAddStr(msi, "connected_by", resp.Data.ConnectedBy)
mapAddStr(msi, "created_at", resp.Data.CreatedAt.String())
Expand Down Expand Up @@ -480,8 +479,8 @@ func dataSourceConnectorReadConfig(resp *fivetran.ConnectorDetailsResponse) []in
mapAddStr(c, "null_sequence", resp.Data.Config.NullSequence)
mapAddStr(c, "delimiter", resp.Data.Config.Delimiter)
mapAddStr(c, "escape_char", resp.Data.Config.EscapeChar)
mapAddStr(c, "skip_before", resp.Data.Config.SkipBefore)
mapAddStr(c, "skip_after", resp.Data.Config.SkipAfter)
mapAddStr(c, "skip_before", intPointerToStr(&resp.Data.Config.SkipBefore))
mapAddStr(c, "skip_after", intPointerToStr(&resp.Data.Config.SkipAfter))
mapAddXInterface(c, "project_credentials", dataSourceConnectorReadConfigFlattenProjectCredentials(resp))
mapAddStr(c, "auth_mode", resp.Data.Config.AuthMode)
mapAddStr(c, "username", resp.Data.Config.UserName)
Expand Down
14 changes: 7 additions & 7 deletions fivetran/resource_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func resourceConnectorSchemaConfig() *schema.Schema {
"always_encrypted": {Type: schema.TypeString, Optional: true, Computed: true},
"is_secure": {Type: schema.TypeString, Optional: true, Computed: true},
"use_webhooks": {Type: schema.TypeString, Optional: true, Computed: true},
// Enum values
// Enum & int values
"sync_mode": {Type: schema.TypeString, Optional: true, Computed: true},
"date_granularity": {Type: schema.TypeString, Optional: true, Computed: true},
"timeframe_months": {Type: schema.TypeString, Optional: true, Computed: true},
Expand Down Expand Up @@ -163,6 +163,8 @@ func resourceConnectorSchemaConfig() *schema.Schema {
"append_file_option": {Type: schema.TypeString, Optional: true, Computed: true},
"engagement_attribution_window": {Type: schema.TypeString, Optional: true, Computed: true},
"conversion_report_time": {Type: schema.TypeString, Optional: true, Computed: true},
"skip_before": {Type: schema.TypeString, Optional: true, Computed: true},
"skip_after": {Type: schema.TypeString, Optional: true, Computed: true},

// For db-like connectors it's a readonly field, but it also used in Braintree connector as public field
"public_key": {Type: schema.TypeString, Optional: true, Computed: true},
Expand Down Expand Up @@ -190,8 +192,6 @@ func resourceConnectorSchemaConfig() *schema.Schema {
"null_sequence": {Type: schema.TypeString, Optional: true},
"delimiter": {Type: schema.TypeString, Optional: true},
"escape_char": {Type: schema.TypeString, Optional: true},
"skip_before": {Type: schema.TypeString, Optional: true},
"skip_after": {Type: schema.TypeString, Optional: true},
"auth_mode": {Type: schema.TypeString, Optional: true},
"username": {Type: schema.TypeString, Optional: true},
"certificate": {Type: schema.TypeString, Optional: true},
Expand Down Expand Up @@ -665,10 +665,10 @@ func resourceConnectorUpdateConfig(d *schema.ResourceData, creation bool) *fivet
fivetranConfig.EscapeChar(v)
}
if v := c["skip_before"].(string); v != "" {
fivetranConfig.SkipBefore(v)
fivetranConfig.SkipBefore(strToInt(v))
}
if v := c["skip_after"].(string); v != "" {
fivetranConfig.SkipAfter(v)
fivetranConfig.SkipAfter(strToInt(v))
}
if v := c["project_credentials"].([]interface{}); len(v) > 0 {
fivetranConfig.ProjectCredentials(resourceConnectorCreateConfigProjectCredentials(v))
Expand Down Expand Up @@ -1452,6 +1452,8 @@ func resourceConnectorReadConfig(resp *fivetran.ConnectorDetailsResponse, curren
mapAddStr(c, "api_quota", intPointerToStr(resp.Data.Config.APIQuota))
mapAddStr(c, "tunnel_port", intPointerToStr(resp.Data.Config.TunnelPort))
mapAddStr(c, "daily_api_call_limit", intPointerToStr(resp.Data.Config.DailyAPICallLimit))
mapAddStr(c, "skip_before", intPointerToStr(&resp.Data.Config.SkipBefore))
mapAddStr(c, "skip_after", intPointerToStr(&resp.Data.Config.SkipAfter))

// String fields
mapAddStr(c, "sheet_id", resp.Data.Config.SheetID)
Expand Down Expand Up @@ -1484,8 +1486,6 @@ func resourceConnectorReadConfig(resp *fivetran.ConnectorDetailsResponse, curren
mapAddStr(c, "null_sequence", resp.Data.Config.NullSequence)
mapAddStr(c, "delimiter", resp.Data.Config.Delimiter)
mapAddStr(c, "escape_char", resp.Data.Config.EscapeChar)
mapAddStr(c, "skip_before", resp.Data.Config.SkipBefore)
mapAddStr(c, "skip_after", resp.Data.Config.SkipAfter)
mapAddStr(c, "auth_mode", resp.Data.Config.AuthMode)
mapAddStr(c, "username", resp.Data.Config.UserName)
mapAddStr(c, "certificate", resp.Data.Config.Certificate)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/fivetran/terraform-provider-fivetran

require (
github.com/fivetran/go-fivetran v0.5.6
github.com/fivetran/go-fivetran v0.5.7
github.com/hashicorp/go-getter v1.5.11 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.0
github.com/mattn/go-colorable v0.1.8 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fivetran/go-fivetran v0.5.6 h1:tev5zTD81o09bNPIHj/4YABbG5PYnWgAR4wYhfItz4g=
github.com/fivetran/go-fivetran v0.5.6/go.mod h1:VZveAoj9lWCyGDuBRRbTU4M4j9sjjsAUBQIZld+J4Uc=
github.com/fivetran/go-fivetran v0.5.7 h1:GbmA0QD8To8Jf35rAomu0ObN+YJeKLg+Ljp6W0NKe4A=
github.com/fivetran/go-fivetran v0.5.7/go.mod h1:VZveAoj9lWCyGDuBRRbTU4M4j9sjjsAUBQIZld+J4Uc=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
Expand Down

0 comments on commit ca1a4fc

Please sign in to comment.