Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 78b9ff1

Browse files
jacobbednarzstainless-app[bot]
authored andcommittedMar 13, 2025
fix(authenticated_origin_pulls_certificate): handle private_key write only field
`private_key` is a write only attribute which requires some manual mapping to ensure we persist it across state and plan runs. Signed-off-by: Jacob Bednarz <jacob.bednarz@gmail.com>
1 parent 2b53245 commit 78b9ff1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎internal/services/authenticated_origin_pulls_certificate/resource.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func (r *AuthenticatedOriginPullsCertificateResource) Create(ctx context.Context
6161
return
6262
}
6363

64+
privateKey := data.PrivateKey
6465
dataBytes, err := data.MarshalJSON()
6566
if err != nil {
6667
resp.Diagnostics.AddError("failed to serialize http request", err.Error())
@@ -89,6 +90,7 @@ func (r *AuthenticatedOriginPullsCertificateResource) Create(ctx context.Context
8990
}
9091
data = &env.Result
9192
data.CertificateID = data.ID
93+
data.PrivateKey = privateKey
9294

9395
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
9496
}
@@ -138,6 +140,7 @@ func (r *AuthenticatedOriginPullsCertificateResource) Update(ctx context.Context
138140
}
139141
data = &env.Result
140142
data.CertificateID = data.ID
143+
data.PrivateKey = state.PrivateKey
141144

142145
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
143146
}
@@ -150,7 +153,7 @@ func (r *AuthenticatedOriginPullsCertificateResource) Read(ctx context.Context,
150153
if resp.Diagnostics.HasError() {
151154
return
152155
}
153-
156+
privateKey := data.PrivateKey
154157
res := new(http.Response)
155158
env := AuthenticatedOriginPullsCertificateResultEnvelope{*data}
156159
_, err := r.client.OriginTLSClientAuth.Get(
@@ -179,6 +182,7 @@ func (r *AuthenticatedOriginPullsCertificateResource) Read(ctx context.Context,
179182
}
180183
data = &env.Result
181184
data.CertificateID = data.ID
185+
data.PrivateKey = privateKey
182186

183187
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
184188
}

‎internal/services/authenticated_origin_pulls_certificate/schema.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func ResourceSchema(ctx context.Context) schema.Schema {
3737
"private_key": schema.StringAttribute{
3838
Description: "The zone's private key.",
3939
Required: true,
40-
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
40+
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()},
4141
},
4242
"enabled": schema.BoolAttribute{
4343
Description: "Indicates whether zone-level authenticated origin pulls is enabled.",

0 commit comments

Comments
 (0)
Please sign in to comment.