inspect

package
v0.0.0-...-88e2702 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFS embed.FS

Functions

This section is empty.

Types

type Application

type Application struct {
	// Renderer renders the application.
	Renderer Renderer
	// Versions are the application versions to be inspected. They will be
	// passed to the Renderer as the ".Version" field.
	//
	// If this is nil, the GoVerions will also be used as the application
	// versions that are passed to the template.
	Versions []*version.Version
	// GoVerions are the versions of Go to build the application with.
	//
	// If this is nil, the latest version of Go will be used.
	GoVerions []*version.Version
}

Application is the information about a template application that needs to be inspected for binary data.

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a cache of struct field offsets.

func NewCache

func NewCache(l logr.Logger, offsetFile string) (*Cache, error)

NewCache loads struct field offsets from offsetFile and returns them as a new Cache.

func (*Cache) GetOffset

func (c *Cache) GetOffset(ver *version.Version, id structfield.ID) (structfield.OffsetKey, bool)

GetOffset returns the cached offset key and true for the id at the specified version is found in the cache. If the cache does not contain a valid offset for the provided values, 0 and false are returned.

type Inspector

type Inspector struct {
	NWorkers int
	Cache    *Cache
	// contains filtered or unexported fields
}

Inspector inspects structure of Go packages.

func New

func New(l logr.Logger, cache *Cache, manifests ...Manifest) (*Inspector, error)

New returns an Inspector that configured to inspect offsets defined in the manifests.

If cache is non-nil, offsets will first be looked up there. Otherwise, the offsets will be found by building the applicatiions in the manifests and inspecting the produced binaries.

func (*Inspector) AddManifest

func (i *Inspector) AddManifest(manifest Manifest) error

AddManifest adds the manifest to the Inspector's set of Manifests to inspect.

func (*Inspector) Do

Do performs the inspections and returns all found offsets.

type Manifest

type Manifest struct {
	// Application is the application to extract binary data from.
	Application Application
	// StructFields are struct fields the application should contain that need
	// offsets to be found.
	StructFields []structfield.ID
}

Manifest contains all information that needs to be inspected for an application.

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer renders templates from an fs.FS.

func NewRenderer

func NewRenderer(l logr.Logger, src string, f fs.FS) Renderer

NewRenderer returns a new *Renderer used to render the template files found in f at the provided src.

If f is nil, DefaultFS will be used instead.

func (Renderer) Render

func (r Renderer) Render(dest string, data interface{}) error

Render renders the Renderer's src in dest using data.

All src will be rendered in the same file-tree with the same names (except for any ".tmpl" suffixes) as found in the Renderer's fs.FS.

Directories

Path Synopsis
cmd
offsetgen
Offsetgen is a utility to generate a static file containing offsets for Go struct fields.
Offsetgen is a utility to generate a static file containing offsets for Go struct fields.

Jump to

Keyboard shortcuts

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