From ad43fabe835e0288715090b786f49f79a4ca1c27 Mon Sep 17 00:00:00 2001 From: Jeremy Muriel Date: Mon, 28 Aug 2023 20:41:20 +0200 Subject: [PATCH 1/2] r/security_ike_gateway: fix state upgrade when remote_identity is set avoid new arguments in block when read version 0 of schema otherwise there is a 'Value Conversion Error' Fix #533 --- .changes/bugfix-2.1.1.md | 4 ++++ .../providerfwk/upgradestate_security_ike_gateway.go | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 .changes/bugfix-2.1.1.md diff --git a/.changes/bugfix-2.1.1.md b/.changes/bugfix-2.1.1.md new file mode 100644 index 00000000..786654a8 --- /dev/null +++ b/.changes/bugfix-2.1.1.md @@ -0,0 +1,4 @@ + +BUG FIXES: + +* **resource/junos_security_ike_gateway** : fix `Value Conversion Error` when upgrading the provider before `v2.0.0` to `v2.0.0...v2.1.1` and there are this type of resource with `remote_identity` block set in state diff --git a/internal/providerfwk/upgradestate_security_ike_gateway.go b/internal/providerfwk/upgradestate_security_ike_gateway.go index cb5c231d..6cba7a81 100644 --- a/internal/providerfwk/upgradestate_security_ike_gateway.go +++ b/internal/providerfwk/upgradestate_security_ike_gateway.go @@ -172,8 +172,11 @@ func upgradeSecurityIkeGatewayV0toV1( UserAtHostname types.String `tfsdk:"user_at_hostname"` DistinguishedName []securityIkeGatewayBlockDynamicRemoteBlockDistinguishedName `tfsdk:"distinguished_name"` } `tfsdk:"dynamic_remote"` - LocalIdentity []securityIkeGatewayBlockLocalIdentity `tfsdk:"local_identity"` - RemoteIdentity []securityIkeGatewayBlockRemoteIdentity `tfsdk:"remote_identity"` + LocalIdentity []securityIkeGatewayBlockLocalIdentity `tfsdk:"local_identity"` + RemoteIdentity []struct { + Type types.String `tfsdk:"type"` + Value types.String `tfsdk:"value"` + } `tfsdk:"remote_identity"` } var dataV0 modelV0 @@ -216,7 +219,10 @@ func upgradeSecurityIkeGatewayV0toV1( dataV1.LocalIdentity = &dataV0.LocalIdentity[0] } if len(dataV0.RemoteIdentity) > 0 { - dataV1.RemoteIdentity = &dataV0.RemoteIdentity[0] + dataV1.RemoteIdentity = &securityIkeGatewayBlockRemoteIdentity{ + Type: dataV0.RemoteIdentity[0].Type, + Value: dataV0.RemoteIdentity[0].Value, + } } resp.Diagnostics.Append(resp.State.Set(ctx, dataV1)...) From 402c49c2dbf155e183a9322f72a13708fa60f4f1 Mon Sep 17 00:00:00 2001 From: Jeremy Muriel Date: Mon, 28 Aug 2023 20:55:49 +0200 Subject: [PATCH 2/2] Release v2.1.2 --- .changes/bugfix-2.1.1.md | 4 ---- CHANGELOG.md | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) delete mode 100644 .changes/bugfix-2.1.1.md diff --git a/.changes/bugfix-2.1.1.md b/.changes/bugfix-2.1.1.md deleted file mode 100644 index 786654a8..00000000 --- a/.changes/bugfix-2.1.1.md +++ /dev/null @@ -1,4 +0,0 @@ - -BUG FIXES: - -* **resource/junos_security_ike_gateway** : fix `Value Conversion Error` when upgrading the provider before `v2.0.0` to `v2.0.0...v2.1.1` and there are this type of resource with `remote_identity` block set in state diff --git a/CHANGELOG.md b/CHANGELOG.md index bc017040..9d09a113 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # changelog +## v2.1.2 (August 28, 2023) + +BUG FIXES: + +* **resource/junos_security_ike_gateway** : fix `Value Conversion Error` when upgrading the provider before `v2.0.0` to `v2.0.0...v2.1.1` and there are this type of resource with `remote_identity` block set in state (Fix [#533](https://github.com/jeremmfr/terraform-provider-junos/issues/533)) + ## v2.1.1 (August 21, 2023) BUG FIXES: