search

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustRegister

func MustRegister(provider string, searcher AssetSearcherConstructor)

MustRegister will mustRegister a searcher constructor corresponding to the provider to the list. The provider should be a globally unique human-readable identifier which will be used as Asset.Provider and the value of 'cloud-providers[i].provider' in profile. e.g. TencentCloud

All AssetSearcher must call this function in init function to mustRegister itself.

Types

type AssetSearcher

type AssetSearcher interface {
	// List fetches all assets that match the given type.
	// The assetType should be one of constants 'asset.Type*', e.g. asset.TypeCdn.
	List(assetType string) ([]asset.Asseter, error)

	// ListApplicable fetch all assets that match the given type and cert.
	// The assetType should be one of constants 'asset.Type*', e.g. asset.TypeCdn.
	ListApplicable(assetType string, cert []byte) ([]asset.Asseter, error)
}

AssetSearcher is used to list all assets belong to your account.

type AssetSearcherConstructor

type AssetSearcherConstructor = func(options map[string]interface{}) (AssetSearcher, error)

type UnionSearch

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

UnionSearch is a special AssetSearcher. It will not be registered to the list. Instead, it is responsible for instantiating registered searchers based on configuration and call each of them.

The main program usually wants to use this structure to perform the operation.

func NewUnionSearch

func NewUnionSearch(logger *zap.SugaredLogger, providersConfig []config.CloudProvider) *UnionSearch

func (*UnionSearch) List

func (u *UnionSearch) List(assetType string) ([]asset.Asseter, *utils.ErrorCollection)

List calls each of registered searcher and return all the results.

Note: Returning error does not mean that other return values are invalid. It may just be some searcher execution failures.

func (*UnionSearch) ListApplicable

func (u *UnionSearch) ListApplicable(assetType string, cert []byte) ([]asset.Asseter,
	*utils.ErrorCollection)

ListApplicable calls each of registered searcher and return all the results.

Note: Returning error does not mean that other return values are invalid. It may just be some searcher execution failures.

Jump to

Keyboard shortcuts

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