@@ -20,7 +20,6 @@ import (
2020 "fmt"
2121 "os"
2222 "path/filepath"
23- "strings"
2423 "sync"
2524
2625 oci "github.com/opencontainers/runtime-spec/specs-go"
@@ -230,8 +229,10 @@ func validateSpec(raw *cdi.Spec) error {
230229// This function always returns the same name for the same vendor/class
231230// combination. Therefore it cannot be used as such to generate multiple
232231// Spec file names for a single vendor and class.
232+ //
233+ // Deprecated: Use producer.GenerateSpecName instead
233234func GenerateSpecName (vendor , class string ) string {
234- return vendor + "-" + class
235+ return producer . GenerateSpecName ( vendor , class )
235236}
236237
237238// GenerateTransientSpecName generates a vendor+class scoped transient
@@ -250,35 +251,30 @@ func GenerateSpecName(vendor, class string) string {
250251// The file name is generated without a ".json" or ".yaml" extension.
251252// The caller can append the desired extension to choose a particular
252253// encoding. Otherwise WriteSpec() will use its default encoding.
254+ //
255+ // Deprecated: Use producer.GenerateTransientSpecName instead
253256func GenerateTransientSpecName (vendor , class , transientID string ) string {
254- transientID = strings .ReplaceAll (transientID , "/" , "_" )
255- return GenerateSpecName (vendor , class ) + "_" + transientID
257+ return producer .GenerateTransientSpecName (vendor , class , transientID )
256258}
257259
258260// GenerateNameForSpec generates a name for the given Spec using
259261// GenerateSpecName with the vendor and class taken from the Spec.
260262// On success it returns the generated name and a nil error. If
261263// the Spec does not contain a valid vendor or class, it returns
262264// an empty name and a non-nil error.
265+ //
266+ // Deprecated: Use producer.GenerateNameForSpec instead
263267func GenerateNameForSpec (raw * cdi.Spec ) (string , error ) {
264- vendor , class := parser .ParseQualifier (raw .Kind )
265- if vendor == "" {
266- return "" , fmt .Errorf ("invalid vendor/class %q in Spec" , raw .Kind )
267- }
268-
269- return GenerateSpecName (vendor , class ), nil
268+ return producer .GenerateNameForSpec (raw )
270269}
271270
272271// GenerateNameForTransientSpec generates a name for the given transient
273272// Spec using GenerateTransientSpecName with the vendor and class taken
274273// from the Spec. On success it returns the generated name and a nil error.
275274// If the Spec does not contain a valid vendor or class, it returns an
276275// an empty name and a non-nil error.
276+ //
277+ // Deprecated: Use producer.GenerateNameForTransientSpec instead
277278func GenerateNameForTransientSpec (raw * cdi.Spec , transientID string ) (string , error ) {
278- vendor , class := parser .ParseQualifier (raw .Kind )
279- if vendor == "" {
280- return "" , fmt .Errorf ("invalid vendor/class %q in Spec" , raw .Kind )
281- }
282-
283- return GenerateTransientSpecName (vendor , class , transientID ), nil
279+ return producer .GenerateNameForTransientSpec (raw , transientID )
284280}
0 commit comments