extensions

package
v0.0.0-...-a1bc676 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 13 Imported by: 5

README

Package cloudeng.io/glean/gleancli/extensions

import cloudeng.io/glean/gleancli/extensions

Package extensions defines an extension mechanism for gleancli implementations and utilities for creating, managing and implementing extensions.

Functions

Func FirstAPICrawl
func FirstAPICrawl(crawls apicrawlcmd.Crawls) (apicrawlcmd.Crawl[yaml.Node], bool)

Types

Type APIKey
type APIKey struct {
	APIKey string `yaml:"api_key" cmd:"API key in apitokens format (ie. scheme://<value>)"`
}

APIKey represents an API key in apitokens format.

Methods
func (k *APIKey) ParseAndRead(ctx context.Context, filename string, readers *apitokens.Readers) (*apitokens.T, error)

ParseAndRead reads the API key from the specified file and returns it in apitokens format.

Type DynamicResources
type DynamicResources struct {
	PopulateCrawlFS func(ctx context.Context, cfg config.CrawlService, factories map[string]crawlcmd.FSFactory) error

	NewContentFS func(ctx context.Context, cfg crawlcmd.CrawlCacheConfig) (content.FS, error)

	NewCheckpointOp func(ctx context.Context, cfg crawlcmd.CrawlCacheConfig) (checkpoint.Operation, error)

	NewOperationsFS func(ctx context.Context, cfg crawlcmd.CrawlCacheConfig) (operations.FS, error)
}

DynamicResources provides a set of functions that can be used to create the various resources required by commands and command extensions.

Type Extension
type Extension interface {
	subcmd.Extension
	SetOptions(ExtensionOptions)
	Options() ExtensionOptions
	AuthConfigType() any
	ServiceConfigType() any
}

Extension is implemented by all extensions.

Functions
func NewExtension(spec ExtensionSpec, parents []string) Extension

NewExtension creates a new extension from the supplied spec.

func NewExtensions(parents []string, specs ...ExtensionSpec) []Extension

NewExtensions creates all of the command extensions specified by specs.

Type ExtensionOptions
type ExtensionOptions struct {
	StaticResources

	DynamicResources
}

ExtensionsOptions are the options that are passed to each extension.

Methods
func (eo ExtensionOptions) ResourcesForDatasource(ctx context.Context, configFile, authFile, datasource string) (config.Datasource, apicrawlcmd.Resources, error)
Type ExtensionSpec
type ExtensionSpec struct {
	Name       string // Name of the extension
	CmdSpec    string // YAML subcmd spec
	AuthCfg    any    // used for describing the auth configuration
	ServiceCfg any    // used for describing the service configuration
	// called to add the command to its parent cmdSet.
	AddFunc func(extension Extension, cmdSet *subcmd.CommandSetYAML, parents []string) error
}

ExtensionSpec defines an extension.

Type StaticResources
type StaticResources struct {
	DocumentConverters *content.Registry[converters.Document]
	UserConverters     *content.Registry[converters.User]
	Extractors         map[content.Type]outlinks.Extractor

	// TokenReaders provides a set of readers for reading API tokens.
	TokenReaders *apitokens.Readers
}

StaticResources provides a set of resources that are typically required by commands and command extensions that are statically configured per application instance.

Documentation

Overview

Package extensions defines an extension mechanism for gleancli implementations and utilities for creating, managing and implementing extensions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstAPICrawl

func FirstAPICrawl(crawls apicrawlcmd.Crawls) (apicrawlcmd.Crawl[yaml.Node], bool)

Types

type APIKey

type APIKey struct {
	APIKey string `yaml:"api_key" cmd:"API key in apitokens format (ie. scheme://<value>)"`
}

APIKey represents an API key in apitokens format.

func (*APIKey) ParseAndRead

func (k *APIKey) ParseAndRead(ctx context.Context, filename string, readers *apitokens.Readers) (*apitokens.T, error)

ParseAndRead reads the API key from the specified file and returns it in apitokens format.

type DynamicResources

type DynamicResources struct {
	PopulateCrawlFS func(ctx context.Context, cfg config.CrawlService, factories map[string]crawlcmd.FSFactory) error

	NewContentFS func(ctx context.Context, cfg crawlcmd.CrawlCacheConfig) (content.FS, error)

	NewCheckpointOp func(ctx context.Context, cfg crawlcmd.CrawlCacheConfig) (checkpoint.Operation, error)

	NewOperationsFS func(ctx context.Context, cfg crawlcmd.CrawlCacheConfig) (operations.FS, error)
}

DynamicResources provides a set of functions that can be used to create the various resources required by commands and command extensions.

type Extension

type Extension interface {
	subcmd.Extension
	SetOptions(ExtensionOptions)
	Options() ExtensionOptions
	AuthConfigType() any
	ServiceConfigType() any
}

Extension is implemented by all extensions.

func NewExtension

func NewExtension(spec ExtensionSpec, parents []string) Extension

NewExtension creates a new extension from the supplied spec.

func NewExtensions

func NewExtensions(parents []string, specs ...ExtensionSpec) []Extension

NewExtensions creates all of the command extensions specified by specs.

type ExtensionOptions

type ExtensionOptions struct {
	StaticResources

	DynamicResources
}

ExtensionsOptions are the options that are passed to each extension.

func (ExtensionOptions) ResourcesForDatasource

func (eo ExtensionOptions) ResourcesForDatasource(ctx context.Context, configFile, authFile, datasource string) (config.Datasource, apicrawlcmd.Resources, error)

type ExtensionSpec

type ExtensionSpec struct {
	Name       string // Name of the extension
	CmdSpec    string // YAML subcmd spec
	AuthCfg    any    // used for describing the auth configuration
	ServiceCfg any    // used for describing the service configuration
	// called to add the command to its parent cmdSet.
	AddFunc func(extension Extension, cmdSet *subcmd.CommandSetYAML, parents []string) error
}

ExtensionSpec defines an extension.

type StaticResources

type StaticResources struct {
	DocumentConverters *content.Registry[converters.Document]
	UserConverters     *content.Registry[converters.User]
	Extractors         map[content.Type]outlinks.Extractor

	// TokenReaders provides a set of readers for reading API tokens.
	TokenReaders *apitokens.Readers
}

StaticResources provides a set of resources that are typically required by commands and command extensions that are statically configured per application instance.

Jump to

Keyboard shortcuts

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