@@ -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"
@@ -223,8 +222,10 @@ func validateSpec(raw *cdi.Spec) error {
223222// This function always returns the same name for the same vendor/class
224223// combination. Therefore it cannot be used as such to generate multiple
225224// Spec file names for a single vendor and class.
225+ //
226+ // Deprecated: Use producer.GenerateSpecName instead
226227func GenerateSpecName (vendor , class string ) string {
227- return vendor + "-" + class
228+ return producer . GenerateSpecName ( vendor , class )
228229}
229230
230231// GenerateTransientSpecName generates a vendor+class scoped transient
@@ -243,35 +244,30 @@ func GenerateSpecName(vendor, class string) string {
243244// The file name is generated without a ".json" or ".yaml" extension.
244245// The caller can append the desired extension to choose a particular
245246// encoding. Otherwise WriteSpec() will use its default encoding.
247+ //
248+ // Deprecated: Use producer.GenerateTransientSpecName instead
246249func GenerateTransientSpecName (vendor , class , transientID string ) string {
247- transientID = strings .ReplaceAll (transientID , "/" , "_" )
248- return GenerateSpecName (vendor , class ) + "_" + transientID
250+ return producer .GenerateTransientSpecName (vendor , class , transientID )
249251}
250252
251253// GenerateNameForSpec generates a name for the given Spec using
252254// GenerateSpecName with the vendor and class taken from the Spec.
253255// On success it returns the generated name and a nil error. If
254256// the Spec does not contain a valid vendor or class, it returns
255257// an empty name and a non-nil error.
258+ //
259+ // Deprecated: Use producer.GenerateNameForSpec instead
256260func GenerateNameForSpec (raw * cdi.Spec ) (string , error ) {
257- vendor , class := parser .ParseQualifier (raw .Kind )
258- if vendor == "" {
259- return "" , fmt .Errorf ("invalid vendor/class %q in Spec" , raw .Kind )
260- }
261-
262- return GenerateSpecName (vendor , class ), nil
261+ return producer .GenerateNameForSpec (raw )
263262}
264263
265264// GenerateNameForTransientSpec generates a name for the given transient
266265// Spec using GenerateTransientSpecName with the vendor and class taken
267266// from the Spec. On success it returns the generated name and a nil error.
268267// If the Spec does not contain a valid vendor or class, it returns an
269268// an empty name and a non-nil error.
269+ //
270+ // Deprecated: Use producer.GenerateNameForTransientSpec instead
270271func GenerateNameForTransientSpec (raw * cdi.Spec , transientID string ) (string , error ) {
271- vendor , class := parser .ParseQualifier (raw .Kind )
272- if vendor == "" {
273- return "" , fmt .Errorf ("invalid vendor/class %q in Spec" , raw .Kind )
274- }
275-
276- return GenerateTransientSpecName (vendor , class , transientID ), nil
272+ return producer .GenerateNameForTransientSpec (raw , transientID )
277273}
0 commit comments