/** * Simple Docker-style name generator for slices * Generates names in the format: adjective-noun */ const adjectives = [ "awesome", "blazing", "brilliant", "clever", "cool", "dazzling", "dynamic", "elegant", "epic", "fast", "fearless", "friendly", "gentle", "happy", "jolly", "kind", "lively", "mighty", "nimble", "peaceful", "quick", "radiant", "serene", "sharp", "smooth", "stellar", "swift", "tender", "vibrant", "wise", "zen", "cosmic", "digital", "quantum", "cyber", "neon", "pixel", "sonic", "turbo", "ultra" ]; const nouns = [ "slice", "wave", "spark", "pulse", "stream", "beacon", "bridge", "cloud", "comet", "crystal", "delta", "echo", "flame", "galaxy", "harbor", "horizon", "iris", "jet", "lens", "meteor", "nexus", "orbit", "phoenix", "prism", "quasar", "ray", "sphere", "star", "storm", "tide", "vertex", "vortex", "zen", "zone", "arc", "beam", "core", "drift", "edge", "flux" ]; /** * Generates a random slice name in the format: adjective-noun-xxxx * @param separator The separator to use between words (default: "-") * @returns A randomly generated name with 4-digit suffix */ export function generateSliceName(separator: string = "-"): string { const adjective = adjectives[Math.floor(Math.random() * adjectives.length)]; const noun = nouns[Math.floor(Math.random() * nouns.length)]; const randomSuffix = Math.floor(Math.random() * 10000).toString().padStart(4, '0'); return `${adjective}${separator}${noun}${separator}${randomSuffix}`; } /** * Generates a unique slice name with a random number suffix * @param separator The separator to use between words (default: "-") * @returns A randomly generated name with number suffix */ export function generateUniqueSliceName(separator: string = "-"): string { const baseName = generateSliceName(separator); const randomNum = Math.floor(Math.random() * 9999); return `${baseName}${separator}${randomNum}`; } /** * Generates a unique random domain name * @returns A unique domain in the format: network.slices.adjective-noun-xxxx */ export function generateDomain(): string { // Generate a completely random domain, independent of slice name const adjective = adjectives[Math.floor(Math.random() * adjectives.length)]; const noun = nouns[Math.floor(Math.random() * nouns.length)]; const randomSuffix = Math.floor(Math.random() * 10000).toString().padStart(4, '0'); return `network.slices.${adjective}-${noun}-${randomSuffix}`; }