Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove required table field for share point connector #354

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Fixed
- Issue with resource `fivetran_connector_schedule` when SyncFrequency is unknown.
- Table field in `destination_schema` for `share_point` connector is no longer required

## [1.2.8](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.2.7...v1.2.8)

Expand Down
97 changes: 48 additions & 49 deletions fivetran/framework/core/model/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ type ConnectorDatasourceModel struct {
PauseAfterTrial types.Bool `tfsdk:"pause_after_trial"`
DailySyncTime types.String `tfsdk:"daily_sync_time"`

ProxyAgentId types.String `tfsdk:"proxy_agent_id"`
NetworkingMethod types.String `tfsdk:"networking_method"`
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`
ProxyAgentId types.String `tfsdk:"proxy_agent_id"`
NetworkingMethod types.String `tfsdk:"networking_method"`
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`

Status types.Object `tfsdk:"status"`

Expand Down Expand Up @@ -122,9 +122,9 @@ type ConnectorResourceModel struct {
Service types.String `tfsdk:"service"`
DestinationSchema types.Object `tfsdk:"destination_schema"`

ProxyAgentId types.String `tfsdk:"proxy_agent_id"`
NetworkingMethod types.String `tfsdk:"networking_method"`
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`
ProxyAgentId types.String `tfsdk:"proxy_agent_id"`
NetworkingMethod types.String `tfsdk:"networking_method"`
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`

Config types.Object `tfsdk:"config"`
Auth types.Object `tfsdk:"auth"`
Expand Down Expand Up @@ -195,24 +195,24 @@ func (d *ConnectorResourceModel) ReadFromContainer(c ConnectorModelContainer, fo
d.CreatedAt = types.StringValue(c.CreatedAt)
d.GroupId = types.StringValue(c.GroupId)
d.Service = types.StringValue(c.Service)
if c.LocalProcessingAgentId != "" {
d.LocalProcessingAgentId = types.StringValue(c.LocalProcessingAgentId)
} else {
d.LocalProcessingAgentId = types.StringNull()
}

if c.LocalProcessingAgentId != "" {
d.LocalProcessingAgentId = types.StringValue(c.LocalProcessingAgentId)
} else {
d.LocalProcessingAgentId = types.StringNull()
}

d.DestinationSchema = getDestinationSchemaValue(c.Service, c.Schema)

if c.ProxyAgentId != "" {
d.ProxyAgentId = types.StringValue(c.ProxyAgentId)
} else {
d.ProxyAgentId = types.StringNull()
}
if c.ProxyAgentId != "" {
d.ProxyAgentId = types.StringValue(c.ProxyAgentId)
} else {
d.ProxyAgentId = types.StringNull()
}

if c.NetworkingMethod != "" {
d.NetworkingMethod = types.StringValue(c.NetworkingMethod)
}
if c.NetworkingMethod != "" {
d.NetworkingMethod = types.StringValue(c.NetworkingMethod)
}

if forceReadConfig || (!d.Config.IsNull() && !d.Config.IsUnknown()) {
d.Config = getValue(
Expand All @@ -230,24 +230,24 @@ func (d *ConnectorDatasourceModel) ReadFromContainer(c ConnectorModelContainer)
d.CreatedAt = types.StringValue(c.CreatedAt)
d.GroupId = types.StringValue(c.GroupId)
d.Service = types.StringValue(c.Service)
if c.LocalProcessingAgentId != "" {
d.LocalProcessingAgentId = types.StringValue(c.LocalProcessingAgentId)
} else {
d.LocalProcessingAgentId = types.StringNull()
}

if c.LocalProcessingAgentId != "" {
d.LocalProcessingAgentId = types.StringValue(c.LocalProcessingAgentId)
} else {
d.LocalProcessingAgentId = types.StringNull()
}

d.DestinationSchema = getDestinationSchemaValue(c.Service, c.Schema)

if c.ProxyAgentId != "" {
d.ProxyAgentId = types.StringValue(c.ProxyAgentId)
} else {
d.ProxyAgentId = types.StringNull()
}
if c.ProxyAgentId != "" {
d.ProxyAgentId = types.StringValue(c.ProxyAgentId)
} else {
d.ProxyAgentId = types.StringNull()
}

if c.NetworkingMethod != "" {
d.NetworkingMethod = types.StringValue(c.NetworkingMethod)
}
if c.NetworkingMethod != "" {
d.NetworkingMethod = types.StringValue(c.NetworkingMethod)
}

d.Config = getValue(
types.ObjectType{AttrTypes: getAttrTypes(common.GetConfigFieldsMap())},
Expand All @@ -267,9 +267,9 @@ type ConnectorModelContainer struct {
Service string
Schema string

ProxyAgentId string
NetworkingMethod string
LocalProcessingAgentId string
ProxyAgentId string
NetworkingMethod string
LocalProcessingAgentId string

Config map[string]interface{}

Expand All @@ -288,17 +288,17 @@ func (c *ConnectorModelContainer) ReadFromResponseData(data connectors.DetailsRe
c.Schema = data.Schema
c.Config = config

if data.ProxyAgentId != "" {
c.ProxyAgentId = data.ProxyAgentId
}
if data.ProxyAgentId != "" {
c.ProxyAgentId = data.ProxyAgentId
}

if data.NetworkingMethod != "" {
c.NetworkingMethod = data.NetworkingMethod
}
if data.NetworkingMethod != "" {
c.NetworkingMethod = data.NetworkingMethod
}

if data.LocalProcessingAgentId != "" {
c.LocalProcessingAgentId = data.LocalProcessingAgentId
}
if data.LocalProcessingAgentId != "" {
c.LocalProcessingAgentId = data.LocalProcessingAgentId
}
}

func getDestinatonSchemaForConfig(serviceId, nameAttr, tableAttr, prefixAttr attr.Value) (map[string]interface{}, error) {
Expand Down Expand Up @@ -328,10 +328,9 @@ func getDestinatonSchemaForConfig(serviceId, nameAttr, tableAttr, prefixAttr att
"schema": nameAttr.(types.String).ValueString(),
}
if common.GetDestinationSchemaFields()[service]["table"] {
if tableAttr.IsNull() {
return nil, fmt.Errorf("`destination_schema.table` field is required to create `%v` connector", service)
if !tableAttr.IsNull() && tableAttr.(types.String).ValueString() != "" {
result["table"] = tableAttr.(types.String).ValueString()
}
result["table"] = tableAttr.(types.String).ValueString()
}
return result, nil
}
Expand Down
Loading