wart

package
v1.5.48 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package wart is a parking lot for miscellaneous shims while doing any internal refactoring.

"Wart" is slightly more descriptive than "misc" or "util". This package isn't actually deprecated per-se, but adding the annotation makes some editors display a nice note near the import.

The API for this package is *not* stable; ideally it's empty and unused.

Deprecated: importing "wart" means there refactoring work to be done here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsPointer added in v1.5.38

func AsPointer[T any](seq iter.Seq[T]) iter.Seq[*T]

AsPointer returns a sequence of pointers to the values of the inner sequence.

func CollectPointer added in v1.5.38

func CollectPointer[T any](seq iter.Seq[T]) []*T

CollectPointer is the equivalent of "slices.Collect(AsPointer(seq))".

func CopyLayerPointers

func CopyLayerPointers[L LayerOrPointer](dst []*claircore.Layer, src []L)

CopyLayerPointers ensures that "dst" ends up with pointers to the equivalent [claircore.Layer]s (as determined by claircore.Layer.Hash equality) in "src".

This function is O(n²), so if one can prove that "src" is unmodified without walking both slices, the call to this function should be omitted.

Needing to use this indicates the API that's being shimmed has subtle state assumptions and should really be redesigned.

func DescriptionsToLayers

func DescriptionsToLayers(ds []claircore.LayerDescription) []*claircore.Layer

DescriptionsToLayers takes a slice of [claircore.LayerDescription]s and creates equivalent claircore.Layer pointers.

This is a helper for shims from a new API that takes a claircore.LayerDescription slice to a previous API that takes a claircore.Layer pointer slice.

func LayersToDescriptions

func LayersToDescriptions(ls []*claircore.Layer) (ds []claircore.LayerDescription)

LayersToDescriptions takes a slice of claircore.Layer pointers and creates equivalent [claircore.LayerDescription]s.

This is a helper for shims from a previous API that takes a claircore.Layer pointer slice to a new one that takes a claircore.LayerDescription slice.

If the previous API is expected to mutate the claircore.Layer pointers, make sure to call CopyLayerPointers to ensure the correct values end up in the original slice.

Types

type LayerOrPointer

type LayerOrPointer interface {
	claircore.Layer | *claircore.Layer
}

LayerOrPointer abstracts over a claircore.Layer or a pointer to a claircore.Layer. A user of this type will still need to do runtime reflection due to the lack of sum types.

Notes

Bugs

  • There's currently extra copies between claircore.Layer and claircore.LayerDescription because of the original sin of making the internal layer object also the external layer description. In the future, the external API should not accept claircore.Layer and instead deal in claircore.LayerDescription.

  • There's currently a lot of API surface that that uses []*T types. While this minimizes the size of these slices, it increases the amount of pointer-chasing the GC has to do and makes it hard to think about allocations. In the future, we should use an iter.Seq with our domain types instead of slices. This makes the compiler work harder to be able to reduce allocations, but allows for the data to be handled in a streaming manner.

Jump to

Keyboard shortcuts

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