@@ -20,7 +20,6 @@ import (
20
20
"fmt"
21
21
"os"
22
22
"path/filepath"
23
- "strings"
24
23
"sync"
25
24
26
25
oci "github.com/opencontainers/runtime-spec/specs-go"
@@ -230,8 +229,10 @@ func validateSpec(raw *cdi.Spec) error {
230
229
// This function always returns the same name for the same vendor/class
231
230
// combination. Therefore it cannot be used as such to generate multiple
232
231
// Spec file names for a single vendor and class.
232
+ //
233
+ // Deprecated: Use producer.GenerateSpecName instead
233
234
func GenerateSpecName (vendor , class string ) string {
234
- return vendor + "-" + class
235
+ return producer . GenerateSpecName ( vendor , class )
235
236
}
236
237
237
238
// GenerateTransientSpecName generates a vendor+class scoped transient
@@ -250,35 +251,30 @@ func GenerateSpecName(vendor, class string) string {
250
251
// The file name is generated without a ".json" or ".yaml" extension.
251
252
// The caller can append the desired extension to choose a particular
252
253
// encoding. Otherwise WriteSpec() will use its default encoding.
254
+ //
255
+ // Deprecated: Use producer.GenerateTransientSpecName instead
253
256
func GenerateTransientSpecName (vendor , class , transientID string ) string {
254
- transientID = strings .ReplaceAll (transientID , "/" , "_" )
255
- return GenerateSpecName (vendor , class ) + "_" + transientID
257
+ return producer .GenerateTransientSpecName (vendor , class , transientID )
256
258
}
257
259
258
260
// GenerateNameForSpec generates a name for the given Spec using
259
261
// GenerateSpecName with the vendor and class taken from the Spec.
260
262
// On success it returns the generated name and a nil error. If
261
263
// the Spec does not contain a valid vendor or class, it returns
262
264
// an empty name and a non-nil error.
265
+ //
266
+ // Deprecated: Use producer.GenerateNameForSpec instead
263
267
func 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 )
270
269
}
271
270
272
271
// GenerateNameForTransientSpec generates a name for the given transient
273
272
// Spec using GenerateTransientSpecName with the vendor and class taken
274
273
// from the Spec. On success it returns the generated name and a nil error.
275
274
// If the Spec does not contain a valid vendor or class, it returns an
276
275
// an empty name and a non-nil error.
276
+ //
277
+ // Deprecated: Use producer.GenerateNameForTransientSpec instead
277
278
func 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 )
284
280
}
0 commit comments