Fix setting nil attributes on host sets (#1746)
This is the analogue of #1743 but for host sets
This commit is contained in:
1 parent
dba5bc88a0
commit
5417cc5cb0
4 files changed
+66
-41
No files matched your search
@@ -553,7 +553,7 @@ func (s Service) updatePluginInRepo(ctx context.Context, scopeId string, req *pb
|
||||
return nil, nil, nil, errors.Wrap(ctx, err, op, errors.WithMsg("Unable to build host set for update"))
|
||||
}
|
||||
h.PublicId = req.GetId()
|
||||
dbMask := maskManager[plugin.Subtype].Translate(req.GetUpdateMask().GetPaths(), "attributes.")
|
||||
dbMask := maskManager[plugin.Subtype].Translate(req.GetUpdateMask().GetPaths(), "attributes")
|
||||
if len(dbMask) == 0 {
|
||||
return nil, nil, nil, handlers.InvalidArgumentErrorf("No valid fields included in the update mask.", map[string]string{"update_mask": "No valid fields provided in the update mask."})
|
||||
}
|
||||
|
||||
@@ -1570,6 +1570,20 @@ func TestUpdate_Plugin(t *testing.T) {
|
||||
assert.Equal(t, map[string]interface{}{"newkey": "newvalue"}, in.GetAttributes().AsMap())
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Set attributes null",
|
||||
masks: []string{"attributes"},
|
||||
changes: []updateFn{
|
||||
clearReadOnlyFields(),
|
||||
updateAttrs(func() *structpb.Struct {
|
||||
ret, _ := structpb.NewStruct(nil)
|
||||
return ret
|
||||
}()),
|
||||
},
|
||||
check: func(t *testing.T, in *pb.HostSet) {
|
||||
assert.Equal(t, (*structpb.Struct)(nil), in.GetAttributes())
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Update preferred endpoints",
|
||||
masks: []string{"preferred_endpoints"},
|
||||
|
||||
Reference in new issue
Block a user