Skip to content

Commit fbb765e

Browse files
committed
fix: Always initialize distroHandler in customizeOSContents()
1 parent eb5def4 commit fbb765e

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

toolkit/tools/pkg/imagecustomizerlib/imagecustomizer.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,14 @@ func qemuImgEscapeOptionValue(value string) string {
446446
func customizeOSContents(ctx context.Context, rc *ResolvedConfig) (imageMetadata, error) {
447447
im := imageMetadata{}
448448

449+
distroHandler, err := validateTargetOs(ctx, rc)
450+
if err != nil {
451+
return im, fmt.Errorf("%w:\n%w", ErrCannotValidateTargetOS, err)
452+
}
453+
454+
// Save target OS information
455+
im.distroHandler = distroHandler
456+
449457
// If there are OS customizations, then we proceed as usual.
450458
// If there are no OS customizations, and the input is an iso, we just
451459
// return because this function is mainly about OS customizations.
@@ -461,14 +469,6 @@ func customizeOSContents(ctx context.Context, rc *ResolvedConfig) (imageMetadata
461469
ctx, span := otel.GetTracerProvider().Tracer(OtelTracerName).Start(ctx, "customize_os_contents")
462470
defer span.End()
463471

464-
distroHandler, err := validateTargetOs(ctx, rc)
465-
if err != nil {
466-
return im, fmt.Errorf("%w:\n%w", ErrCannotValidateTargetOS, err)
467-
}
468-
469-
// Save target OS information
470-
im.distroHandler = distroHandler
471-
472472
// Customize the partitions.
473473
partitionsCustomized, newRawImageFile, partIdToPartUuid, err := customizePartitions(ctx, rc.BuildDirAbs,
474474
rc.Storage, rc.RawImageFile, im.distroHandler)

0 commit comments

Comments
 (0)