command_dir

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandlerParametersFromLayerParams

func NewHandlerParametersFromLayerParams(p *config.LayerParams)

NewHandlerParametersFromLayerParams creates a new HandlerParameters from the config file. It currently requires a list of layerDefinitions in order to lookup the correct layers to stored as ParsedParameterLayer. It doesn't fail if configured layers don't exist.

TODO(manuel, 2023-05-31) Add a way to validate the fact that overrides in a config file might have a typo and don't correspond to existing layer definitions in the application.

Types

type CommandDirHandler

type CommandDirHandler struct {
	DevMode bool

	// TemplateName is the name of the template that is lookup up through the given TemplateLookup
	// used to render the glazed command.
	TemplateName string
	// IndexTemplateName is the name of the template that is looked up through TemplateLookup to render
	// command indexes. Leave empty to not render index pages at all.
	IndexTemplateName string
	// TemplateLookup is used to look up both TemplateName and IndexTemplateName
	TemplateLookup render.TemplateLookup

	// Repository is the command repository that is exposed over HTTP through this handler.
	Repository *repositories.Repository

	// AdditionalData is passed to the template being rendered.
	AdditionalData map[string]interface{}

	Overrides *HandlerParameters
	Defaults  *HandlerParameters
}

func NewCommandDirHandlerFromConfig

func NewCommandDirHandlerFromConfig(
	config *config.CommandDir,
	options ...CommandDirHandlerOption,
) (*CommandDirHandler, error)

func (*CommandDirHandler) Serve

func (cd *CommandDirHandler) Serve(server *parka.Server, path string) error

type CommandDirHandlerOption

type CommandDirHandlerOption func(handler *CommandDirHandler)

func WithDefaultArgument added in v0.3.2

func WithDefaultArgument(name string, value string) CommandDirHandlerOption

func WithDefaultFlag added in v0.3.2

func WithDefaultFlag(name string, value string) CommandDirHandlerOption

func WithDefaultIndexTemplateName

func WithDefaultIndexTemplateName(name string) CommandDirHandlerOption

func WithDefaultTemplateName

func WithDefaultTemplateName(name string) CommandDirHandlerOption

func WithDevMode

func WithDevMode(devMode bool) CommandDirHandlerOption

func WithIndexTemplateName

func WithIndexTemplateName(name string) CommandDirHandlerOption

func WithLayerDefaults added in v0.3.2

func WithLayerDefaults(name string, layer map[string]interface{}) CommandDirHandlerOption

WithLayerDefaults populates the defaults for the given layer. If a value is already set, the value is skipped.

func WithMergeAdditionalData added in v0.3.2

func WithMergeAdditionalData(data map[string]interface{}, override bool) CommandDirHandlerOption

WithMergeAdditionalData merges the passed in map with the handler's AdditionalData map. If a value is already set in the AdditionalData map and override is true, it will get overwritten.

func WithMergeDefaultLayer added in v0.3.2

func WithMergeDefaultLayer(name string, layer *layers.ParsedParameterLayer) CommandDirHandlerOption

func WithMergeDefaults added in v0.3.2

func WithMergeDefaults(defaults *HandlerParameters) CommandDirHandlerOption

func WithMergeOverrideLayer

func WithMergeOverrideLayer(name string, layer map[string]interface{}) CommandDirHandlerOption

func WithMergeOverrides

func WithMergeOverrides(overrides *HandlerParameters) CommandDirHandlerOption

func WithOverrideArgument

func WithOverrideArgument(name string, value string) CommandDirHandlerOption

func WithOverrideFlag

func WithOverrideFlag(name string, value string) CommandDirHandlerOption

func WithReplaceDefaultLayer added in v0.3.2

func WithReplaceDefaultLayer(name string, layer map[string]interface{}) CommandDirHandlerOption

func WithReplaceDefaults added in v0.3.2

func WithReplaceDefaults(defaults *HandlerParameters) CommandDirHandlerOption

func WithReplaceOverrideLayer

func WithReplaceOverrideLayer(name string, layer map[string]interface{}) CommandDirHandlerOption

func WithReplaceOverrides

func WithReplaceOverrides(overrides *HandlerParameters) CommandDirHandlerOption

func WithTemplateLookup

func WithTemplateLookup(lookup render.TemplateLookup) CommandDirHandlerOption

func WithTemplateName

func WithTemplateName(name string) CommandDirHandlerOption

type HandlerParameters

type HandlerParameters struct {
	Layers    map[string]map[string]interface{}
	Flags     map[string]interface{}
	Arguments map[string]interface{}
}

func NewHandlerParameters

func NewHandlerParameters() *HandlerParameters

func (*HandlerParameters) Merge

func (ho *HandlerParameters) Merge(other *HandlerParameters)

Merge merges the given overrides into this one. If a layer is already present, it is merged with the given one. Flags and arguments are merged, overrides taking precedence.

Jump to

Keyboard shortcuts

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