Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions pkg/controller/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ func validateIDs(names []string) error {
return ErrInvalidNames
}

// K8sNameUUIDUnsafe works like K8sNameUUID, but panics instead of returning an error.
// This should only be used in places where the input is guaranteed to be valid.
func K8sNameUUIDUnsafe(names ...string) string {
uuid, err := K8sNameUUID(names...)
if err != nil {
panic(err)
}
return uuid
}

// K8sObjectUUID takes a client object and computes a hash out of the namespace and name, which is then formatted as a version 8 UUID.
// An empty namespace will be replaced by "default".
func K8sObjectUUID(obj client.Object) (string, error) {
Expand All @@ -70,3 +80,13 @@ func K8sObjectUUID(obj client.Object) (string, error) {
}
return K8sNameUUID(namespace, name)
}

// K8sObjectUUIDUnsafe works like K8sObjectUUID, but panics instead of returning an error.
// This should only be used in places where the input is guaranteed to be valid.
func K8sObjectUUIDUnsafe(obj client.Object) string {
uuid, err := K8sObjectUUID(obj)
if err != nil {
panic(err)
}
return uuid
}