Add generic read/update/delete commands (#3992)
* Add generic read/update/delete commands This adds three generic commands that use the resource prefix to determine the subcommand to run and pass through args over to that subcommand. Since this occurs very early on and to avoid loading essentially every internal resource package, I moved subtype definitions to globals. This replaces #3967 Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> * De-duplicate Subtype code (#4031) Co-authored-by: Timothy Messier <tim.messier@gmail.com> --------- Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Co-authored-by: Timothy Messier <tim.messier@gmail.com>
This commit is contained in:
59 files changed
+1032
-857
No files matched your search
@@ -413,7 +413,7 @@ func (s Service) updateInRepo(
|
||||
var dbMasks []string
|
||||
item := proto.Clone(in).(*pb.Credential)
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case credential.UsernamePasswordSubtype:
|
||||
dbMasks = append(dbMasks, upMaskManager.Translate(masks)...)
|
||||
if len(dbMasks) == 0 {
|
||||
@@ -808,7 +808,7 @@ func validateCreateRequest(req *pbs.CreateCredentialRequest) error {
|
||||
func validateUpdateRequest(req *pbs.UpdateCredentialRequest) error {
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case credential.UsernamePasswordSubtype:
|
||||
attrs := req.GetItem().GetUsernamePasswordAttributes()
|
||||
if handlers.MaskContains(req.GetUpdateMask().GetPaths(), usernameField) && attrs.GetUsername().GetValue() == "" {
|
||||
|
||||
Reference in new issue
Block a user