Skip to content

Commit

Permalink
Fix connector schema migrations (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
beevital authored Jul 3, 2024
1 parent ec236a8 commit 821aec1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 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/v1.2.0...HEAD)
## [Unreleased](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.2.1...HEAD)

## [1.2.1](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.2.0...v1.2.1)

## Fixed

Issue with upgrade `fivetran_connector` resource state on version upgrade.

## [1.2.0](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.1.27...v1.2.0)

Expand Down
2 changes: 1 addition & 1 deletion fivetran/framework/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

const Version = "1.2.0" // Current provider version
const Version = "1.2.1" // Current provider version

type fivetranProvider struct {
mockClient httputils.HttpClient
Expand Down
20 changes: 12 additions & 8 deletions fivetran/framework/resources/connector_migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ func upgradeConnectorState(ctx context.Context, req resource.UpgradeStateRequest
dynamicValue, err := tfprotov6.NewDynamicValue(
getConnectorStateModel(3),
tftypes.NewValue(getConnectorStateModel(3), map[string]tftypes.Value{
"id": rawState["id"],
"name": rawState["name"],
"connected_by": rawState["connected_by"],
"created_at": rawState["created_at"],
"group_id": rawState["group_id"],
"service": rawState["service"],
"timeouts": rawState["timeouts"],
"id": rawState["id"],
"name": rawState["name"],
"connected_by": rawState["connected_by"],
"created_at": rawState["created_at"],
"group_id": rawState["group_id"],
"service": rawState["service"],
"timeouts": rawState["timeouts"],
"networking_method": tftypes.NewValue(tftypes.String, nil),
"proxy_agent_id": tftypes.NewValue(tftypes.String, nil),
"local_processing_agent_id": tftypes.NewValue(tftypes.String, nil),

"run_setup_tests": convertStringStateValueToBool("run_setup_tests", rawState["run_setup_tests"], resp.Diagnostics),
"trust_fingerprints": convertStringStateValueToBool("trust_fingerprints", rawState["trust_fingerprints"], resp.Diagnostics),
Expand Down Expand Up @@ -101,7 +104,8 @@ func getConnectorStateModel(version int) tftypes.Type {

base["proxy_agent_id"] = tftypes.String
base["networking_method"] = tftypes.String

base["local_processing_agent_id"] = tftypes.String

base["config"] = tftypes.Object{AttributeTypes: model.GetTfTypes(common.GetConfigFieldsMap(), 3)}
base["auth"] = tftypes.Object{AttributeTypes: model.GetTfTypes(common.GetAuthFieldsMap(), 3)}
} else {
Expand Down

0 comments on commit 821aec1

Please sign in to comment.