Merge pull request #9519 from containerd/dependabot/go_modules/github.com/google/uuid-1.5.0
build(deps): bump github.com/google/uuid from 1.3.1 to 1.5.0
This commit is contained in:
		
							
								
								
									
										18
									
								
								vendor/github.com/google/uuid/CHANGELOG.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								vendor/github.com/google/uuid/CHANGELOG.md
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,5 +1,23 @@
 | 
			
		||||
# Changelog
 | 
			
		||||
 | 
			
		||||
## [1.5.0](https://github.com/google/uuid/compare/v1.4.0...v1.5.0) (2023-12-12)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Features
 | 
			
		||||
 | 
			
		||||
* Validate UUID without creating new UUID ([#141](https://github.com/google/uuid/issues/141)) ([9ee7366](https://github.com/google/uuid/commit/9ee7366e66c9ad96bab89139418a713dc584ae29))
 | 
			
		||||
 | 
			
		||||
## [1.4.0](https://github.com/google/uuid/compare/v1.3.1...v1.4.0) (2023-10-26)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Features
 | 
			
		||||
 | 
			
		||||
* UUIDs slice type with Strings() convenience method ([#133](https://github.com/google/uuid/issues/133)) ([cd5fbbd](https://github.com/google/uuid/commit/cd5fbbdd02f3e3467ac18940e07e062be1f864b4))
 | 
			
		||||
 | 
			
		||||
### Fixes
 | 
			
		||||
 | 
			
		||||
* Clarify that Parse's job is to parse but not necessarily validate strings. (Documents current behavior)
 | 
			
		||||
 | 
			
		||||
## [1.3.1](https://github.com/google/uuid/compare/v1.3.0...v1.3.1) (2023-08-18)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/google/uuid/CONTRIBUTING.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/google/uuid/CONTRIBUTING.md
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -11,7 +11,7 @@ please explain why in the pull request description.
 | 
			
		||||
 | 
			
		||||
### Releasing
 | 
			
		||||
 | 
			
		||||
Commits that would precipitate a SemVer change, as desrcibed in the Conventional
 | 
			
		||||
Commits that would precipitate a SemVer change, as described in the Conventional
 | 
			
		||||
Commits Specification, will trigger [`release-please`](https://github.com/google-github-actions/release-please-action)
 | 
			
		||||
to create a release candidate pull request. Once submitted, `release-please`
 | 
			
		||||
will create a release.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										21
									
								
								vendor/github.com/google/uuid/time.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								vendor/github.com/google/uuid/time.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -108,12 +108,23 @@ func setClockSequence(seq int) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in
 | 
			
		||||
// uuid.  The time is only defined for version 1 and 2 UUIDs.
 | 
			
		||||
// uuid.  The time is only defined for version 1, 2, 6 and 7 UUIDs.
 | 
			
		||||
func (uuid UUID) Time() Time {
 | 
			
		||||
	time := int64(binary.BigEndian.Uint32(uuid[0:4]))
 | 
			
		||||
	time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32
 | 
			
		||||
	time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48
 | 
			
		||||
	return Time(time)
 | 
			
		||||
	var t Time
 | 
			
		||||
	switch uuid.Version() {
 | 
			
		||||
	case 6:
 | 
			
		||||
		time := binary.BigEndian.Uint64(uuid[:8]) // Ignore uuid[6] version b0110
 | 
			
		||||
		t = Time(time)
 | 
			
		||||
	case 7:
 | 
			
		||||
		time := binary.BigEndian.Uint64(uuid[:8])
 | 
			
		||||
		t = Time((time>>16)*10000 + g1582ns100)
 | 
			
		||||
	default: // forward compatible
 | 
			
		||||
		time := int64(binary.BigEndian.Uint32(uuid[0:4]))
 | 
			
		||||
		time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32
 | 
			
		||||
		time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48
 | 
			
		||||
		t = Time(time)
 | 
			
		||||
	}
 | 
			
		||||
	return t
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ClockSequence returns the clock sequence encoded in uuid.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										79
									
								
								vendor/github.com/google/uuid/uuid.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										79
									
								
								vendor/github.com/google/uuid/uuid.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -56,11 +56,15 @@ func IsInvalidLengthError(err error) bool {
 | 
			
		||||
	return ok
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Parse decodes s into a UUID or returns an error.  Both the standard UUID
 | 
			
		||||
// forms of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and
 | 
			
		||||
// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded as well as the
 | 
			
		||||
// Microsoft encoding {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} and the raw hex
 | 
			
		||||
// encoding: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
 | 
			
		||||
// Parse decodes s into a UUID or returns an error if it cannot be parsed.  Both
 | 
			
		||||
// the standard UUID forms defined in RFC 4122
 | 
			
		||||
// (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and
 | 
			
		||||
// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) are decoded.  In addition,
 | 
			
		||||
// Parse accepts non-standard strings such as the raw hex encoding
 | 
			
		||||
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx and 38 byte "Microsoft style" encodings,
 | 
			
		||||
// e.g.  {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.  Only the middle 36 bytes are
 | 
			
		||||
// examined in the latter case.  Parse should not be used to validate strings as
 | 
			
		||||
// it parses non-standard encodings as indicated above.
 | 
			
		||||
func Parse(s string) (UUID, error) {
 | 
			
		||||
	var uuid UUID
 | 
			
		||||
	switch len(s) {
 | 
			
		||||
@@ -182,6 +186,59 @@ func Must(uuid UUID, err error) UUID {
 | 
			
		||||
	return uuid
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Validate returns an error if s is not a properly formatted UUID in one of the following formats:
 | 
			
		||||
//   xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
 | 
			
		||||
//   urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
 | 
			
		||||
//   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 | 
			
		||||
//   {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
 | 
			
		||||
// It returns an error if the format is invalid, otherwise nil.
 | 
			
		||||
func Validate(s string) error {
 | 
			
		||||
	switch len(s) {
 | 
			
		||||
	// Standard UUID format
 | 
			
		||||
	case 36:
 | 
			
		||||
 | 
			
		||||
	// UUID with "urn:uuid:" prefix
 | 
			
		||||
	case 36 + 9:
 | 
			
		||||
		if !strings.EqualFold(s[:9], "urn:uuid:") {
 | 
			
		||||
			return fmt.Errorf("invalid urn prefix: %q", s[:9])
 | 
			
		||||
		}
 | 
			
		||||
		s = s[9:]
 | 
			
		||||
 | 
			
		||||
	// UUID enclosed in braces
 | 
			
		||||
	case 36 + 2:
 | 
			
		||||
		if s[0] != '{' || s[len(s)-1] != '}' {
 | 
			
		||||
			return fmt.Errorf("invalid bracketed UUID format")
 | 
			
		||||
		}
 | 
			
		||||
		s = s[1 : len(s)-1]
 | 
			
		||||
 | 
			
		||||
	// UUID without hyphens
 | 
			
		||||
	case 32:
 | 
			
		||||
		for i := 0; i < len(s); i += 2 {
 | 
			
		||||
			_, ok := xtob(s[i], s[i+1])
 | 
			
		||||
			if !ok {
 | 
			
		||||
				return errors.New("invalid UUID format")
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		return invalidLengthError{len(s)}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Check for standard UUID format
 | 
			
		||||
	if len(s) == 36 {
 | 
			
		||||
		if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' {
 | 
			
		||||
			return errors.New("invalid UUID format")
 | 
			
		||||
		}
 | 
			
		||||
		for _, x := range []int{0, 2, 4, 6, 9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34} {
 | 
			
		||||
			if _, ok := xtob(s[x], s[x+1]); !ok {
 | 
			
		||||
				return errors.New("invalid UUID format")
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
 | 
			
		||||
// , or "" if uuid is invalid.
 | 
			
		||||
func (uuid UUID) String() string {
 | 
			
		||||
@@ -294,3 +351,15 @@ func DisableRandPool() {
 | 
			
		||||
	poolMu.Lock()
 | 
			
		||||
	poolPos = randPoolSize
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UUIDs is a slice of UUID types.
 | 
			
		||||
type UUIDs []UUID
 | 
			
		||||
 | 
			
		||||
// Strings returns a string slice containing the string form of each UUID in uuids.
 | 
			
		||||
func (uuids UUIDs) Strings() []string {
 | 
			
		||||
	var uuidStrs = make([]string, len(uuids))
 | 
			
		||||
	for i, uuid := range uuids {
 | 
			
		||||
		uuidStrs[i] = uuid.String()
 | 
			
		||||
	}
 | 
			
		||||
	return uuidStrs
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										56
									
								
								vendor/github.com/google/uuid/version6.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								vendor/github.com/google/uuid/version6.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,56 @@
 | 
			
		||||
// Copyright 2023 Google Inc.  All rights reserved.
 | 
			
		||||
// Use of this source code is governed by a BSD-style
 | 
			
		||||
// license that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
package uuid
 | 
			
		||||
 | 
			
		||||
import "encoding/binary"
 | 
			
		||||
 | 
			
		||||
// UUID version 6 is a field-compatible version of UUIDv1, reordered for improved DB locality.
 | 
			
		||||
// It is expected that UUIDv6 will primarily be used in contexts where there are existing v1 UUIDs.
 | 
			
		||||
// Systems that do not involve legacy UUIDv1 SHOULD consider using UUIDv7 instead.
 | 
			
		||||
//
 | 
			
		||||
// see https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-03#uuidv6
 | 
			
		||||
//
 | 
			
		||||
// NewV6 returns a Version 6 UUID based on the current NodeID and clock
 | 
			
		||||
// sequence, and the current time. If the NodeID has not been set by SetNodeID
 | 
			
		||||
// or SetNodeInterface then it will be set automatically. If the NodeID cannot
 | 
			
		||||
// be set NewV6 set NodeID is random bits automatically . If clock sequence has not been set by
 | 
			
		||||
// SetClockSequence then it will be set automatically. If GetTime fails to
 | 
			
		||||
// return the current NewV6 returns Nil and an error.
 | 
			
		||||
func NewV6() (UUID, error) {
 | 
			
		||||
	var uuid UUID
 | 
			
		||||
	now, seq, err := GetTime()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return uuid, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	    0                   1                   2                   3
 | 
			
		||||
	    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 | 
			
		||||
	   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | 
			
		||||
	   |                           time_high                           |
 | 
			
		||||
	   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | 
			
		||||
	   |           time_mid            |      time_low_and_version     |
 | 
			
		||||
	   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | 
			
		||||
	   |clk_seq_hi_res |  clk_seq_low  |         node (0-1)            |
 | 
			
		||||
	   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | 
			
		||||
	   |                         node (2-5)                            |
 | 
			
		||||
	   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | 
			
		||||
	*/
 | 
			
		||||
 | 
			
		||||
	binary.BigEndian.PutUint64(uuid[0:], uint64(now))
 | 
			
		||||
	binary.BigEndian.PutUint16(uuid[8:], seq)
 | 
			
		||||
 | 
			
		||||
	uuid[6] = 0x60 | (uuid[6] & 0x0F)
 | 
			
		||||
	uuid[8] = 0x80 | (uuid[8] & 0x3F)
 | 
			
		||||
 | 
			
		||||
	nodeMu.Lock()
 | 
			
		||||
	if nodeID == zeroID {
 | 
			
		||||
		setNodeInterface("")
 | 
			
		||||
	}
 | 
			
		||||
	copy(uuid[10:], nodeID[:])
 | 
			
		||||
	nodeMu.Unlock()
 | 
			
		||||
 | 
			
		||||
	return uuid, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										75
									
								
								vendor/github.com/google/uuid/version7.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								vendor/github.com/google/uuid/version7.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
			
		||||
// Copyright 2023 Google Inc.  All rights reserved.
 | 
			
		||||
// Use of this source code is governed by a BSD-style
 | 
			
		||||
// license that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
package uuid
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"io"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// UUID version 7 features a time-ordered value field derived from the widely
 | 
			
		||||
// implemented and well known Unix Epoch timestamp source,
 | 
			
		||||
// the number of milliseconds seconds since midnight 1 Jan 1970 UTC, leap seconds excluded.
 | 
			
		||||
// As well as improved entropy characteristics over versions 1 or 6.
 | 
			
		||||
//
 | 
			
		||||
// see https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-03#name-uuid-version-7
 | 
			
		||||
//
 | 
			
		||||
// Implementations SHOULD utilize UUID version 7 over UUID version 1 and 6 if possible.
 | 
			
		||||
//
 | 
			
		||||
// NewV7 returns a Version 7 UUID based on the current time(Unix Epoch).
 | 
			
		||||
// Uses the randomness pool if it was enabled with EnableRandPool.
 | 
			
		||||
// On error, NewV7 returns Nil and an error
 | 
			
		||||
func NewV7() (UUID, error) {
 | 
			
		||||
	uuid, err := NewRandom()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return uuid, err
 | 
			
		||||
	}
 | 
			
		||||
	makeV7(uuid[:])
 | 
			
		||||
	return uuid, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewV7FromReader returns a Version 7 UUID based on the current time(Unix Epoch).
 | 
			
		||||
// it use NewRandomFromReader fill random bits.
 | 
			
		||||
// On error, NewV7FromReader returns Nil and an error.
 | 
			
		||||
func NewV7FromReader(r io.Reader) (UUID, error) {
 | 
			
		||||
	uuid, err := NewRandomFromReader(r)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return uuid, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	makeV7(uuid[:])
 | 
			
		||||
	return uuid, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// makeV7 fill 48 bits time (uuid[0] - uuid[5]), set version b0111 (uuid[6])
 | 
			
		||||
// uuid[8] already has the right version number (Variant is 10)
 | 
			
		||||
// see function  NewV7 and NewV7FromReader
 | 
			
		||||
func makeV7(uuid []byte) {
 | 
			
		||||
	/*
 | 
			
		||||
		 0                   1                   2                   3
 | 
			
		||||
		 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 | 
			
		||||
		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | 
			
		||||
		|                           unix_ts_ms                          |
 | 
			
		||||
		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | 
			
		||||
		|          unix_ts_ms           |  ver  |       rand_a          |
 | 
			
		||||
		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | 
			
		||||
		|var|                        rand_b                             |
 | 
			
		||||
		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | 
			
		||||
		|                            rand_b                             |
 | 
			
		||||
		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | 
			
		||||
	*/
 | 
			
		||||
	_ = uuid[15] // bounds check
 | 
			
		||||
 | 
			
		||||
	t := timeNow().UnixMilli()
 | 
			
		||||
 | 
			
		||||
	uuid[0] = byte(t >> 40)
 | 
			
		||||
	uuid[1] = byte(t >> 32)
 | 
			
		||||
	uuid[2] = byte(t >> 24)
 | 
			
		||||
	uuid[3] = byte(t >> 16)
 | 
			
		||||
	uuid[4] = byte(t >> 8)
 | 
			
		||||
	uuid[5] = byte(t)
 | 
			
		||||
 | 
			
		||||
	uuid[6] = 0x70 | (uuid[6] & 0x0F)
 | 
			
		||||
	// uuid[8] has already has right version
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user