Skip to content

Commit 3a8c668

Browse files
committed
maybe json
1 parent 3348ea6 commit 3a8c668

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

internal/fleet/agent_policy/models.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,17 @@ func (model *agentPolicyModel) toAPICreateModel(ctx context.Context, serverVersi
122122
}
123123

124124
str := model.GlobalDataTags.ValueStringPointer()
125-
err := json.Unmarshal([]byte(*str), &body.GlobalDataTags)
125+
var items []struct {
126+
Name string `json:"name"`
127+
Value kbapi.PostFleetAgentPoliciesJSONBody_GlobalDataTags_Value `json:"value"`
128+
}
129+
130+
err := json.Unmarshal([]byte(utils.Deref(str)), &items)
126131
if err != nil {
127132
diags.AddError(err.Error(), "")
128133
return kbapi.PostFleetAgentPoliciesJSONRequestBody{}, diags
129134
}
135+
*body.GlobalDataTags = items
130136
}
131137
return body, nil
132138
}
@@ -157,14 +163,17 @@ func (model *agentPolicyModel) toAPIUpdateModel(ctx context.Context, serverVersi
157163
diags.AddError("global_data_tags ES version error", "Global data tags are only supported in Elastic Stack 8.15.0 and above")
158164
return kbapi.PutFleetAgentPoliciesAgentpolicyidJSONRequestBody{}, diags
159165
}
160-
161166
str := model.GlobalDataTags.ValueStringPointer()
162-
err := json.Unmarshal([]byte(*str), &body.GlobalDataTags)
167+
var items []struct {
168+
Name string `json:"name"`
169+
Value kbapi.PutFleetAgentPoliciesAgentpolicyidJSONBody_GlobalDataTags_Value `json:"value"`
170+
}
171+
err := json.Unmarshal([]byte(utils.Deref(str)), &items)
163172
if err != nil {
164173
diags.AddError(err.Error(), "")
165174
return kbapi.PutFleetAgentPoliciesAgentpolicyidJSONRequestBody{}, diags
166175
}
167-
176+
*body.GlobalDataTags = items
168177
}
169178

170179
return body, nil

0 commit comments

Comments
 (0)