@@ -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"
@@ -223,8 +222,10 @@ func validateSpec(raw *cdi.Spec) error {
223
222
// This function always returns the same name for the same vendor/class
224
223
// combination. Therefore it cannot be used as such to generate multiple
225
224
// Spec file names for a single vendor and class.
225
+ //
226
+ // Deprecated: Use producer.GenerateSpecName instead
226
227
func GenerateSpecName (vendor , class string ) string {
227
- return vendor + "-" + class
228
+ return producer . GenerateSpecName ( vendor , class )
228
229
}
229
230
230
231
// GenerateTransientSpecName generates a vendor+class scoped transient
@@ -243,35 +244,30 @@ func GenerateSpecName(vendor, class string) string {
243
244
// The file name is generated without a ".json" or ".yaml" extension.
244
245
// The caller can append the desired extension to choose a particular
245
246
// encoding. Otherwise WriteSpec() will use its default encoding.
247
+ //
248
+ // Deprecated: Use producer.GenerateTransientSpecName instead
246
249
func GenerateTransientSpecName (vendor , class , transientID string ) string {
247
- transientID = strings .ReplaceAll (transientID , "/" , "_" )
248
- return GenerateSpecName (vendor , class ) + "_" + transientID
250
+ return producer .GenerateTransientSpecName (vendor , class , transientID )
249
251
}
250
252
251
253
// GenerateNameForSpec generates a name for the given Spec using
252
254
// GenerateSpecName with the vendor and class taken from the Spec.
253
255
// On success it returns the generated name and a nil error. If
254
256
// the Spec does not contain a valid vendor or class, it returns
255
257
// an empty name and a non-nil error.
258
+ //
259
+ // Deprecated: Use producer.GenerateNameForSpec instead
256
260
func 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 )
263
262
}
264
263
265
264
// GenerateNameForTransientSpec generates a name for the given transient
266
265
// Spec using GenerateTransientSpecName with the vendor and class taken
267
266
// from the Spec. On success it returns the generated name and a nil error.
268
267
// If the Spec does not contain a valid vendor or class, it returns an
269
268
// an empty name and a non-nil error.
269
+ //
270
+ // Deprecated: Use producer.GenerateNameForTransientSpec instead
270
271
func 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 )
277
273
}
0 commit comments