Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fivetran-aleksandrboldyrev committed Oct 31, 2024
1 parent d606f66 commit 192ee5b
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 52 deletions.
4 changes: 2 additions & 2 deletions fivetran/framework/core/model/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type ConnectorDatasourceModel struct {

ProxyAgentId types.String `tfsdk:"proxy_agent_id"`
NetworkingMethod types.String `tfsdk:"networking_method"`
HybridDeploymentAgentId types.String `tfsdk:"local_processing_agent_id"`
HybridDeploymentAgentId types.String `tfsdk:"hybrid_deployment_agent_id"`
PrivateLinkId types.String `tfsdk:"private_link_id"`

Status types.Object `tfsdk:"status"`
Expand Down Expand Up @@ -126,7 +126,7 @@ type ConnectorResourceModel struct {

ProxyAgentId types.String `tfsdk:"proxy_agent_id"`
NetworkingMethod types.String `tfsdk:"networking_method"`
HybridDeploymentAgentId types.String `tfsdk:"local_processing_agent_id"`
HybridDeploymentAgentId types.String `tfsdk:"hybrid_deployment_agent_id"`
PrivateLinkId types.String `tfsdk:"private_link_id"`

Config types.Object `tfsdk:"config"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type DestinationDatasourceModel struct {
TimeZoneOffset types.String `tfsdk:"time_zone_offset"`
SetupStatus types.String `tfsdk:"setup_status"`
DaylightSavingTimeEnabled types.Bool `tfsdk:"daylight_saving_time_enabled"`
HybridDeploymentAgentId types.String `tfsdk:"local_processing_agent_id"`
HybridDeploymentAgentId types.String `tfsdk:"hybrid_deployment_agent_id"`
NetworkingMethod types.String `tfsdk:"networking_method"`
PrivateLinkId types.String `tfsdk:"private_link_id"`
Config types.Object `tfsdk:"config"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type DestinationResourceModel struct {
DaylightSavingTimeEnabled types.Bool `tfsdk:"daylight_saving_time_enabled"`
Config types.Object `tfsdk:"config"`
Timeouts timeouts.Value `tfsdk:"timeouts"`
HybridDeploymentAgentId types.String `tfsdk:"local_processing_agent_id"`
HybridDeploymentAgentId types.String `tfsdk:"hybrid_deployment_agent_id"`
NetworkingMethod types.String `tfsdk:"networking_method"`
PrivateLinkId types.String `tfsdk:"private_link_id"`

Expand Down
14 changes: 4 additions & 10 deletions fivetran/framework/datasources/hybrid_deployment_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func setupMockClientHybridDeploymentAgentDataSourceConfigMapping(t *testing.T) {
func TestDataSourceHybridDeploymentAgentMappingMock(t *testing.T) {
step1 := resource.TestStep{
Config: `
data "fivetran_local_processing_agent" "test_lpa" {
data "fivetran_hybrid_deployment_agent" "test_lpa" {
provider = fivetran-provider
id = "lpa_id"
}`,
Expand All @@ -63,15 +63,9 @@ func TestDataSourceHybridDeploymentAgentMappingMock(t *testing.T) {
tfmock.AssertNotEmpty(t, hdaDataSourceMockData)
return nil
},
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "display_name", "display_name"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "group_id", "group_id"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "registered_at", "registered_at"),
/*resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "usage.0.connection_id", "connection_id1"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "usage.0.schema", "schema1"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "usage.0.service", "service1"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "usage.1.connection_id", "connection_id2"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "usage.1.schema", "schema2"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "usage.1.service", "service2"),*/
resource.TestCheckResourceAttr("data.fivetran_hybrid_deployment_agent.test_lpa", "display_name", "display_name"),
resource.TestCheckResourceAttr("data.fivetran_hybrid_deployment_agent.test_lpa", "group_id", "group_id"),
resource.TestCheckResourceAttr("data.fivetran_hybrid_deployment_agent.test_lpa", "registered_at", "registered_at"),
),
}

Expand Down
27 changes: 7 additions & 20 deletions fivetran/framework/datasources/hybrid_deployment_agents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func setupMockClientHybridDeploymentAgentsDataSourceConfigMapping(t *testing.T)
func TestDataSourceHybridDeploymentAgentsMappingMock(t *testing.T) {
step1 := resource.TestStep{
Config: `
data "fivetran_local_processing_agents" "test_lpa" {
data "fivetran_hybrid_deployment_agents" "test_lpa" {
provider = fivetran-provider
}`,

Expand All @@ -84,25 +84,12 @@ func TestDataSourceHybridDeploymentAgentsMappingMock(t *testing.T) {
tfmock.AssertNotEmpty(t, hybridDeploymentAgentsDataSourceMockData)
return nil
},
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.display_name", "display_name1"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.group_id", "group_id1"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.registered_at", "registered_at1"),
/*resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.usage.0.connection_id", "connection_id11"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.usage.0.schema", "schema11"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.usage.0.service", "service11"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.usage.1.connection_id", "connection_id12"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.usage.1.schema", "schema12"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.usage.1.service", "service12"),*/

resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.display_name", "display_name2"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.group_id", "group_id2"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.registered_at", "registered_at2"),
/*resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.usage.0.connection_id", "connection_id21"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.usage.0.schema", "schema21"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.usage.0.service", "service21"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.usage.1.connection_id", "connection_id22"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.usage.1.schema", "schema22"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.usage.1.service", "service22"),*/
resource.TestCheckResourceAttr("data.fivetran_hybrid_deployment_agents.test_lpa", "items.0.display_name", "display_name1"),
resource.TestCheckResourceAttr("data.fivetran_hybrid_deployment_agents.test_lpa", "items.0.group_id", "group_id1"),
resource.TestCheckResourceAttr("data.fivetran_hybrid_deployment_agents.test_lpa", "items.0.registered_at", "registered_at1"),
resource.TestCheckResourceAttr("data.fivetran_hybrid_deployment_agents.test_lpa", "items.1.display_name", "display_name2"),
resource.TestCheckResourceAttr("data.fivetran_hybrid_deployment_agents.test_lpa", "items.1.group_id", "group_id2"),
resource.TestCheckResourceAttr("data.fivetran_hybrid_deployment_agents.test_lpa", "items.1.registered_at", "registered_at2"),
),
}

Expand Down
4 changes: 2 additions & 2 deletions fivetran/framework/resources/connector_migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func upgradeConnectorState(ctx context.Context, req resource.UpgradeStateRequest
"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),
"hybrid_deployment_agent_id": rawState["local_processing_agent_id"],

"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 @@ -96,7 +96,7 @@ func getConnectorStateModel(version int) tftypes.Type {
},
},
}
if version == 3 {
if version == 3 || version == 4 {
base["destination_schema"] = dsObj
base["run_setup_tests"] = tftypes.Bool
base["trust_certificates"] = tftypes.Bool
Expand Down
5 changes: 5 additions & 0 deletions fivetran/framework/resources/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func (r *destination) UpgradeState(ctx context.Context) map[int64]resource.State
upgradeDestinationState(ctx, req, resp, 0)
},
},
1: {
StateUpgrader: func(ctx context.Context, req resource.UpgradeStateRequest, resp *resource.UpgradeStateResponse) {
upgradeDestinationState(ctx, req, resp, 1)
},
},
}
}

Expand Down
9 changes: 4 additions & 5 deletions fivetran/framework/resources/destination_migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func upgradeDestinationState(ctx context.Context, req resource.UpgradeStateReque
}

dynamicValue, err := tfprotov6.NewDynamicValue(
getDestinationStateModel(1),
tftypes.NewValue(getDestinationStateModel(1), map[string]tftypes.Value{
getDestinationStateModel(2),
tftypes.NewValue(getDestinationStateModel(2), map[string]tftypes.Value{
"id": rawState["id"],
"group_id": rawState["group_id"],
"service": rawState["service"],
Expand All @@ -42,8 +42,7 @@ func upgradeDestinationState(ctx context.Context, req resource.UpgradeStateReque
"time_zone_offset": rawState["time_zone_offset"],
"setup_status": rawState["setup_status"],
"daylight_saving_time_enabled": tftypes.NewValue(tftypes.Bool, nil),
"local_processing_agent_id": tftypes.NewValue(tftypes.String, nil),
"networking_method": tftypes.NewValue(tftypes.String, nil),
"hybrid_deployment_agent_id": rawState["local_processing_agent_id"],

"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 @@ -75,7 +74,7 @@ func getDestinationStateModel(version int) tftypes.Type {
},
},
}
if version == 1 {
if version == 1 || version == 2 {
base["run_setup_tests"] = tftypes.Bool
base["trust_certificates"] = tftypes.Bool
base["trust_fingerprints"] = tftypes.Bool
Expand Down
14 changes: 7 additions & 7 deletions fivetran/framework/resources/hybrid_deployment_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func setupMockClientHybridDeploymentAgentResource(t *testing.T) {
func TestResourceHybridDeploymentAgentMock(t *testing.T) {
step1 := resource.TestStep{
Config: `
resource "fivetran_local_processing_agent" "test_lpa" {
resource "fivetran_hybrid_deployment_agent" "test_lpa" {
provider = fivetran-provider
display_name = "display_name"
Expand All @@ -66,12 +66,12 @@ func TestResourceHybridDeploymentAgentMock(t *testing.T) {
tfmock.AssertEqual(t, hybridDeploymentAgentPostHandler.Interactions, 1)
return nil
},
resource.TestCheckResourceAttr("fivetran_local_processing_agent.test_lpa", "display_name", "display_name"),
resource.TestCheckResourceAttr("fivetran_local_processing_agent.test_lpa", "group_id", "group_id"),
resource.TestCheckResourceAttr("fivetran_local_processing_agent.test_lpa", "registered_at", "registered_at"),
resource.TestCheckResourceAttr("fivetran_local_processing_agent.test_lpa", "config_json", "config_json"),
resource.TestCheckResourceAttr("fivetran_local_processing_agent.test_lpa", "auth_json", "auth_json"),
resource.TestCheckResourceAttr("fivetran_local_processing_agent.test_lpa", "docker_compose_yaml", "docker_compose_yaml"),
resource.TestCheckResourceAttr("fivetran_hybrid_deployment_agent.test_lpa", "display_name", "display_name"),
resource.TestCheckResourceAttr("fivetran_hybrid_deployment_agent.test_lpa", "group_id", "group_id"),
resource.TestCheckResourceAttr("fivetran_hybrid_deployment_agent.test_lpa", "registered_at", "registered_at"),
resource.TestCheckResourceAttr("fivetran_hybrid_deployment_agent.test_lpa", "config_json", "config_json"),
resource.TestCheckResourceAttr("fivetran_hybrid_deployment_agent.test_lpa", "auth_json", "auth_json"),
resource.TestCheckResourceAttr("fivetran_hybrid_deployment_agent.test_lpa", "docker_compose_yaml", "docker_compose_yaml"),
),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func TestResourceHybridDeploymentAgentE2E(t *testing.T) {
name = "TestResourceHybridDeploymentAgentE2E"
}
resource "fivetran_local_processing_agent" "test_lpa" {
resource "fivetran_hybrid_deployment_agent" "test_lpa" {
provider = fivetran-provider
display_name = "TestResourceHybridDeploymentAgentE2E"
group_id = fivetran_group.testgroup.id
}`,
Check: resource.ComposeAggregateTestCheckFunc(
testFivetranHybridDeploymentAgentResourceCreate(t, "fivetran_local_processing_agent.test_lpa"),
resource.TestCheckResourceAttr("fivetran_local_processing_agent.test_lpa", "display_name", "TestResourceHybridDeploymentAgentE2E"),
testFivetranHybridDeploymentAgentResourceCreate(t, "fivetran_hybrid_deployment_agent.test_lpa"),
resource.TestCheckResourceAttr("fivetran_hybrid_deployment_agent.test_lpa", "display_name", "TestResourceHybridDeploymentAgentE2E"),
),
},
},
Expand All @@ -55,7 +55,7 @@ func testFivetranHybridDeploymentAgentResourceCreate(t *testing.T, resourceName

func testFivetranHybridDeploymentAgentResourceDestroy(s *terraform.State) error {
for _, rs := range s.RootModule().Resources {
if rs.Type != "fivetran_local_processing_agent" {
if rs.Type != "fivetran_hybrid_deployment_agent" {
continue
}

Expand Down

0 comments on commit 192ee5b

Please sign in to comment.