inspectioncore_impl

package
v0.52.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

InspectionTimeProducer is a provider of inspection time. Tasks shouldn't use time.Now() directly to make test easier.

View Source
var SerializeTask = inspectiontaskbase.NewProgressReportableInspectionTask(inspectioncore_contract.SerializerTaskID, []taskid.UntypedTaskReference{}, func(ctx context.Context, taskMode inspectioncore_contract.InspectionTaskModeType, progress *inspectionmetadata.TaskProgressMetadata) (*inspectioncore_contract.FileSystemStore, error) {
	if taskMode == inspectioncore_contract.TaskModeDryRun {
		slog.DebugContext(ctx, "Skipping because this is in dryrun mode")
		return nil, nil
	}
	inspectionID := khictx.MustGetValue(ctx, inspectioncore_contract.InspectionTaskInspectionID)
	metadataSet := khictx.MustGetValue(ctx, inspectioncore_contract.InspectionRunMetadata)
	ioConfig := khictx.MustGetValue(ctx, inspectioncore_contract.CurrentIOConfig)
	builder := khictx.MustGetValue(ctx, inspectioncore_contract.CurrentHistoryBuilder)
	store := inspectioncore_contract.NewFileSystemInspectionResultRepository(filepath.Join(ioConfig.DataDestination, inspectionID+".khi"))

	writer, err := store.GetWriter()
	if err != nil {
		return nil, err
	}
	defer writer.Close()
	resultMetadata, err := inspectionmetadata.GetSerializableSubsetMapFromMetadataSet(metadataSet, filter.NewEqualFilter(inspectionmetadata.LabelKeyIncludedInResultBinaryFlag, true, false))
	if err != nil {
		return nil, err
	}
	fileSize, err := builder.Finalize(ctx, resultMetadata, writer, progress)
	if err != nil {
		return nil, err
	}
	header, found := typedmap.Get(metadataSet, inspectionmetadata.HeaderMetadataKey)
	if found {
		header.FileSize = fileSize
	}
	return store, nil
})
View Source
var TestInspectionTimeTaskProducer func(timeStr string) common_task.Task[time.Time] = func(timeStr string) common_task.Task[time.Time] {
	return common_task.NewTask(inspectioncore_contract.InspectionTimeTaskID, []taskid.UntypedTaskReference{}, func(ctx context.Context) (time.Time, error) {
		t, err := time.Parse(time.RFC3339, timeStr)
		if err != nil {
			return time.Time{}, err
		}
		return t, nil
	})
}

TestInspectionTimeTaskProducer is a function to generate a fake InspectionTimeProducer task with the given time string.

View Source
var TimeZoneShiftInputTask = inspectiontaskbase.NewInspectionTask(inspectioncore_contract.TimeZoneShiftInputTaskID, []taskid.UntypedTaskReference{}, func(ctx context.Context, taskMode inspectioncore_contract.InspectionTaskModeType) (*time.Location, error) {
	req := khictx.MustGetValue(ctx, inspectioncore_contract.InspectionTaskInput)
	if tzShiftAny, found := req["timezoneShift"]; found {
		if tzShiftFloat, convertible := tzShiftAny.(float64); convertible {
			return time.FixedZone("Unknown", int(tzShiftFloat*3600)), nil
		} else {
			return time.UTC, nil
		}
	} else {
		return time.UTC, nil
	}
})

Functions

func Register

func Register(registry coretask.TaskRegistry) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL