name

package
v0.9.2-66-g859184ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.

Index

Constants

View Source
const (
	MachineIDLen      = 64
	MachineIDShortLen = 12
)

Variables

View Source
var (
	NullMachineID = MachineID("")
)

Functions

func IsShortMachineID

func IsShortMachineID(id string) bool

IsShortID determines if an arbitrary string *looks like* a short ID.

func NewRandomMachineName

func NewRandomMachineName(retry int) string

GetRandomName generates a random name from the list of adjectives and surnames in this package formatted as "adjective_surname". For example 'focused_turing'. If retry is non-zero, a random integer between 0 and 10 will be added to the end of the name, e.g `focused_turing3`

func ValidateMachineID

func ValidateMachineID(id string) error

ValidateMachineID checks whether a MachineID string is a valid image MachineID.

Types

type MachineID

type MachineID string

MachineID is a 16 byte universally unique identifier.

func NewRandomMachineID

func NewRandomMachineID() (MachineID, error)

NewRandomMachineID returns a random machine ID.

It uses the crypto/rand reader as a source of randomness.

func (MachineID) Short

func (mid MachineID) Short() MachineShortID

func (MachineID) ShortString

func (mid MachineID) ShortString() string

func (MachineID) String

func (mid MachineID) String() string

type MachineShortID

type MachineShortID string

MachineID is a 16 byte universally unique identifier.

func TruncateMachineID

func TruncateMachineID(mid MachineID) MachineShortID

TruncateMachineID returns a shorthand version of a string identifier for convenience.

A collision with other shorthands is very unlikely, but possible. In case of a collision a lookup with TruncIndex.Get() will fail, and the caller will need to use a longer prefix, or the full-length Id.

func (MachineShortID) String

func (mid MachineShortID) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL