apitools

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 9 Imported by: 7

README

apitools

Tools for working with sensu's API types.

Distributions of sensu-go, namely the enterprise edition, can register additional api types at startup that sensu-go and related tools need to handle. This module functions provides the necessary tools for working with this dynamic set of types.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIModuleVersions

func APIModuleVersions() map[string]string

APIModuleVersions returns a map of Sensu API modules that are compiled into the product.

func FindTypesOf added in v0.2.0

func FindTypesOf[T any]() []T

FindTypesOf finds resources that match a particular interface.

func IterTypes added in v0.2.0

func IterTypes(fn func(apiGroup, typename string, t any) (cont bool))

IterTypes iterates a copy of the typemap, calling fn for each type, with the API group, type name, and type.

func RegisterType

func RegisterType(apiGroup string, t interface{}, opts ...ResolveOption)

RegisterType allows modules to register API types to be resolved.

func Resolve

func Resolve(apiVersion string, typename string) (interface{}, error)

Resolve resolves the raw type for the requested api version and type.

Types

type ResolveOption

type ResolveOption interface {
	// contains filtered or unexported methods
}

ResolveOption a customization on how types are resolved

func WithAlias

func WithAlias(alias ...string) ResolveOption

WithAlias Option allows a type to be resolved by names other than its type name

func WithResolveHook

func WithResolveHook(fn func(interface{})) ResolveOption

WithResolveHook allows modules to preform initalization on resolved types

Jump to

Keyboard shortcuts

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