Skip to content

Commit 00a15e7

Browse files
committed
handle instant-logs being returned from the API despite not being a valid config value
1 parent 30b69ac commit 00a15e7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

internal/services/logpush_job/resource.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ func (r *LogpushJobResource) Update(ctx context.Context, req resource.UpdateRequ
118118
return
119119
}
120120

121+
// Handle kind field: treat "" and "instant-logs" as semantically equivalent
122+
// The API doesn't allow changing kind, and "instant-logs" is deprecated in v5
123+
// If both plan and state have semantically equivalent values, omit kind from the update
124+
planKind := data.Kind.ValueString()
125+
stateKind := state.Kind.ValueString()
126+
127+
// Treat "" and "instant-logs" as equivalent
128+
if (planKind == "" || planKind == "instant-logs") && (stateKind == "" || stateKind == "instant-logs") {
129+
// Make kind null so it won't be sent in the update at all
130+
data.Kind = types.StringNull()
131+
}
132+
121133
dataBytes, err := data.MarshalJSONForUpdate(*state)
122134
if err != nil {
123135
resp.Diagnostics.AddError("failed to serialize http request", err.Error())
@@ -153,6 +165,12 @@ func (r *LogpushJobResource) Update(ctx context.Context, req resource.UpdateRequ
153165
}
154166
data = &env.Result
155167

168+
// Normalize instant-logs to empty string (v5 no longer supports instant-logs as a valid value)
169+
// The API may still return "instant-logs" for backwards compatibility, but we treat it as ""
170+
if data.Kind.ValueString() == "instant-logs" {
171+
data.Kind = types.StringValue("")
172+
}
173+
156174
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
157175
}
158176

@@ -199,6 +217,12 @@ func (r *LogpushJobResource) Read(ctx context.Context, req resource.ReadRequest,
199217
}
200218
data = &env.Result
201219

220+
// Normalize instant-logs to empty string (v5 no longer supports instant-logs as a valid value)
221+
// The API may still return "instant-logs" for backwards compatibility, but we treat it as ""
222+
if data.Kind.ValueString() == "instant-logs" {
223+
data.Kind = types.StringValue("")
224+
}
225+
202226
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
203227
}
204228

0 commit comments

Comments
 (0)