1
0
mirror of https://github.com/smallstep/cli.git synced 2025-08-09 03:22:43 +03:00

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.
This commit is contained in:
Herman Slatman
2023-12-19 11:47:02 +01:00
parent d55769a159
commit ac097ff2e9

View File

@@ -94,10 +94,10 @@ func createAction(ctx *cli.Context) (err error) {
Bundle: clientCert.Certificate, Bundle: clientCert.Certificate,
Audience: ctx.String("audience"), Audience: ctx.String("audience"),
} }
if _, err := uuid.Parse(teamID); err == nil { if err := uuid.Validate(teamID); err != nil {
r.TeamID = teamID
} else {
r.TeamSlug = teamID r.TeamSlug = teamID
} else {
r.TeamID = teamID
} }
err = json.NewEncoder(b).Encode(r) err = json.NewEncoder(b).Encode(r)
if err != nil { if err != nil {