github.com/kubeshop/testkube@v1.17.23/pkg/tcl/testworkflowstcl/testworkflowprocessor/refcounter.go (about) 1 // Copyright 2024 Testkube. 2 // 3 // Licensed as a Testkube Pro file under the Testkube Community 4 // License (the "License"); you may not use this file except in compliance with 5 // the License. You may obtain a copy of the License at 6 // 7 // https://github.com/kubeshop/testkube/blob/main/licenses/TCL.txt 8 9 package testworkflowprocessor 10 11 import ( 12 "fmt" 13 "strconv" 14 15 "k8s.io/apimachinery/pkg/util/rand" 16 ) 17 18 type RefCounter interface { 19 NextRef() string 20 } 21 22 type refCounter struct { 23 refCount uint64 24 } 25 26 func NewRefCounter() RefCounter { 27 return &refCounter{} 28 } 29 30 func (r *refCounter) NextRef() string { 31 return fmt.Sprintf("r%s%s", rand.String(5), strconv.FormatUint(r.refCount, 36)) 32 }