Skip to content

Commit cd62038

Browse files
deprecate K8sNameUUID
1 parent 2d1995b commit cd62038

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pkg/controller/hash.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ var (
1717
ErrMaxLenTooSmall = errors.New("maxLen must be greater than 10")
1818
)
1919

20-
// Version8UUID creates a new UUID (version 8) from a byte slice. Returns an error if the slice does not have a length of 16. The bytes are copied from the slice.
20+
// version8UUID creates a new UUID (version 8) from a byte slice. Returns an error if the slice does not have a length of 16. The bytes are copied from the slice.
2121
// The bits 48-51 and 64-65 are modified to make the output recognizable as a version 8 UUID, so only 122 out of 128 bits from the input data will be kept.
22-
func Version8UUID(data []byte) (uuid.UUID, error) {
22+
func version8UUID(data []byte) (uuid.UUID, error) {
2323
if len(data) != 16 {
2424
return uuid.Nil, fmt.Errorf("invalid data (got %d bytes)", len(data))
2525
}
@@ -41,14 +41,15 @@ func Version8UUID(data []byte) (uuid.UUID, error) {
4141
// K8sNameUUID takes any number of string arguments and computes a hash out of it, which is then formatted as a version 8 UUID.
4242
// The arguments are joined with '/' before being hashed.
4343
// Returns an error if the list of ids is empty or contains only empty strings.
44+
// Deprecated: Use ObjectHashSHAKE128Base32 instead.
4445
func K8sNameUUID(names ...string) (string, error) {
4546
if err := validateIDs(names); err != nil {
4647
return "", err
4748
}
4849

4950
name := strings.Join(names, "/")
5051
hash := sha3.SumSHAKE128([]byte(name), 16)
51-
u, err := Version8UUID(hash)
52+
u, err := version8UUID(hash)
5253

5354
return u.String(), err
5455
}

pkg/controller/hash_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func Test_Version8UUID(t *testing.T) {
4444
}
4545
for _, tC := range testCases {
4646
t.Run(tC.desc, func(t *testing.T) {
47-
u, err := Version8UUID(tC.data)
47+
u, err := version8UUID(tC.data)
4848
if tC.expectedErr == nil {
4949
assert.NoError(t, err)
5050
assert.Equal(t, uuid.Version(8), u.Version(), "unexpected version")

0 commit comments

Comments
 (0)