wart

package
v1.5.29 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 1 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 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

Jump to

Keyboard shortcuts

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