From ac097ff2e96a68a2d4a486df35b6123b7da9b07a Mon Sep 17 00:00:00 2001 From: Herman Slatman Date: Tue, 19 Dec 2023 11:47:02 +0100 Subject: [PATCH] Use `uuid.Validate` for cases where the UUID isn't used In https://github.com/google/uuid/pull/141 a new `Validate` function was added to the `uuid` package. This can be used when no UUID struct is required, so can be used instead of `Parse`. This takes https://github.com/smallstep/cli/pull/1087, but uses `uuid.Validate` in one location. --- command/api/token/create.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/command/api/token/create.go b/command/api/token/create.go index d7df3bc4d..689c3d980 100644 --- a/command/api/token/create.go +++ b/command/api/token/create.go @@ -94,10 +94,10 @@ func createAction(ctx *cli.Context) (err error) { Bundle: clientCert.Certificate, Audience: ctx.String("audience"), } - if _, err := uuid.Parse(teamID); err == nil { - r.TeamID = teamID - } else { + if err := uuid.Validate(teamID); err != nil { r.TeamSlug = teamID + } else { + r.TeamID = teamID } err = json.NewEncoder(b).Encode(r) if err != nil {