func NewInflater()

in cli_tools/common/image/importer/inflater.go [54:100]


func NewInflater(request ImageImportRequest, computeClient daisyCompute.Client, storageClient domain.StorageClientInterface,
	inspector imagefile.Inspector, logger logging.Logger) (Inflater, error) {

	var fileMetadata = imagefile.Metadata{}
	if !isImage(request.Source) {
		// 1. To reduce the runtime permissions used on the inflation worker, we pre-allocate
		// disks sufficient to hold the disk file and the inflated disk. If inspection fails,
		// then the default values in the daisy workflow will be used. The scratch disk gets
		// a padding factor to account for filesystem overhead.
		// 2. Inspection also returns checksum of the image file for sanitary check. If it's
		// failed to get the checksum, the following sanitary check will be skipped.
		deadline, cancelFunc := context.WithDeadline(context.Background(), time.Now().Add(inspectionTimeout))
		defer cancelFunc()
		logger.User("Inspecting the image file...")
		fileMetadata, _ = inspector.Inspect(deadline, request.Source.Path())
	}

	di, err := newDaisyInflater(request, fileMetadata, logger)
	if err != nil {
		return nil, err
	}

	// This boolean switch controls whether native PD inflation is used, either
	// as the primary inflation method or in a shadow test mode
	tryNativePDInflation := true
	if isImage(request.Source) || !tryNativePDInflation {
		return di, nil
	}

	if isShadowTestFormat(request) {
		return &shadowTestInflaterFacade{
			mainInflater:   di,
			shadowInflater: createAPIInflater(&apiInflaterProperties{request, computeClient, storageClient, logger, true, true}),
			logger:         logger,
			qemuChecksum:   fileMetadata.Checksum,
		}, nil
	}

	return &inflaterFacade{
		apiInflater:   createAPIInflater(&apiInflaterProperties{request, computeClient, storageClient, logger, false, fileMetadata.Checksum != ""}),
		daisyInflater: di,
		logger:        logger,
		qemuChecksum:  fileMetadata.Checksum,
		computeClient: computeClient,
		request:       request,
	}, nil
}