Skip to content

Commit

Permalink
svc: Return an error when the expiration, if defined, is in the past (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vadmeste authored Apr 23, 2024
1 parent 10da385 commit a687cbc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions user-commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ func (r *AddServiceAccountReq) Validate() error {
if err != nil {
return err
}
if r.Expiration != nil && r.Expiration.Before(time.Now()) {
return errors.New("the expiration time should be in the future")
}
return validateSADescription(r.Description)
}

Expand Down Expand Up @@ -488,6 +491,10 @@ func (u *UpdateServiceAccountReq) Validate() error {
if err := validateSAName(u.NewName); err != nil {
return err
}

if u.NewExpiration != nil && u.NewExpiration.Before(time.Now()) {
return errors.New("the expiration time should be in the future")
}
return validateSADescription(u.NewDescription)
}

Expand Down

0 comments on commit a687cbc

Please sign in to comment.