Fix secrets clearing bug in update. Changes to update count behavior for catalogs (#1691)

* Fix secret clearing bug in update.  Always return 1 catalog updated if we can find a catalog w/ a matching version.
This commit is contained in:
Todd authored and GitHub committed 2021-11-12 09:46:40 -07:00
1 parent 5cfcc41f00
commit b16ce175e5
6 files changed
+88 -15

No files matched your search

@@ -247,11 +247,8 @@ func (r *Repository) UpdateCatalog(ctx context.Context, c *HostCatalog, version
case strings.EqualFold("secrets", strings.Split(f, ".")[0]):
// While in a similar format, secrets are passed along
// wholesale (for the time being). Don't append this mask
// field, as secrets do not have a database entry. Clear the
// secrets out of the working set after.
// field, as secrets do not have a database entry.
newCatalog.Secrets = c.Secrets
c.Secrets = nil
default:
return nil, nil, db.NoRowsAffected, errors.New(ctx, errors.InvalidFieldMask, op, fmt.Sprintf("invalid field mask: %s", f))
}
@@ -443,10 +440,10 @@ func (r *Repository) UpdateCatalog(ctx context.Context, c *HostCatalog, version
return nil, nil, db.NoRowsAffected, errors.Wrap(ctx, err, op, errors.WithMsg(fmt.Sprintf("in %s", newCatalog.PublicId)))
}
var numUpdated int
if recordUpdated {
numUpdated = 1
}
// Even if we didn't update any records, if we were able to find the record
// with the appropriate version, returning 1 row updated is consistant with
// static's update catalog behavior.
numUpdated := 1
return returnedCatalog, plg, numUpdated, nil
}