Providers are now required to state their name/package

This commit is contained in:
Sasha Koshka 2024-12-10 12:22:58 -05:00
parent 4a1b78b857
commit ab167234d0
10 changed files with 47 additions and 11 deletions

View File

@ -3,7 +3,13 @@ package step
import "html/template" import "html/template"
// Provider is an object which provides extra functionality to an environment. // Provider is an object which provides extra functionality to an environment.
type Provider any type Provider interface {
// Package returns the package identifier of the provider. For example:
// git.tebibyte.media/sashakoshka/step/examples/testplugin. The only
// exception is providers within the providers sub-package, which just
// return their basename.
Package () string
}
// Configurable is an object that can be configured according to metadata. // Configurable is an object that can be configured according to metadata.
type Configurable interface { type Configurable interface {

View File

@ -12,6 +12,11 @@ type Provider struct {
} }
// Package fulfills the step.Provider interface.
func (this *Provider) Package () string {
return "http"
}
// FuncMap fulfills the step.FuncProvider interface. // FuncMap fulfills the step.FuncProvider interface.
func (this *Provider) FuncMap () template.FuncMap { func (this *Provider) FuncMap () template.FuncMap {
return template.FuncMap { return template.FuncMap {

View File

@ -13,9 +13,9 @@ type Provider struct {
} }
// FuncMap fulfills the step.FuncProvider interface. // Package fulfills the step.Provider interface.
func (this *Provider) FuncMap () template.FuncMap { func (this *Provider) Package () string {
return nil return "import"
} }
// FuncMapFor fulfills the step.FuncProviderFor interface. // FuncMapFor fulfills the step.FuncProviderFor interface.

View File

@ -20,6 +20,11 @@ type Provider struct {
RendererOptions []renderer.Option RendererOptions []renderer.Option
} }
// Package fulfills the step.Provider interface.
func (this *Provider) Package () string {
return "markdown"
}
// Default returns a provider with the default configuration. // Default returns a provider with the default configuration.
func Default () *Provider { func Default () *Provider {
return &Provider { return &Provider {

View File

@ -11,6 +11,11 @@ type Provider struct {
} }
// Package fulfills the step.Provider interface.
func (this *Provider) Package () string {
return "math"
}
// FuncMap fulfills the step.FuncProvider interface. // FuncMap fulfills the step.FuncProvider interface.
func (this *Provider) FuncMap () template.FuncMap { func (this *Provider) FuncMap () template.FuncMap {
return template.FuncMap { return template.FuncMap {

View File

@ -6,16 +6,16 @@ import "git.tebibyte.media/sashakoshka/step"
const hiddenPrefix = "." const hiddenPrefix = "."
var _ step.FuncProvider = new(Provider) var _ step.FuncProviderFor = new(Provider)
// Provider provides MIME functions. // Provider provides MIME functions.
type Provider struct { type Provider struct {
} }
// FuncMap fulfills the step.FuncProvider interface. // Package fulfills the step.Provider interface.
func (this *Provider) FuncMap () template.FuncMap { func (this *Provider) Package () string {
return nil return "mime"
} }
// FuncMapFor fulfills the step.FuncProviderFor interface. // FuncMapFor fulfills the step.FuncProviderFor interface.

View File

@ -13,9 +13,9 @@ type Provider struct {
} }
// FuncMap fulfills the step.FuncProvider interface. // Package fulfills the step.Provider interface.
func (this *Provider) FuncMap () template.FuncMap { func (this *Provider) Package () string {
return nil return "os"
} }
// FuncMapFor fulfills the step.FuncProviderFor interface. // FuncMapFor fulfills the step.FuncProviderFor interface.

View File

@ -15,6 +15,11 @@ type Provider struct {
} }
// Package fulfills the step.Provider interface.
func (this *Provider) Package () string {
return "path"
}
// FuncMap fulfills the step.FuncProvider interface. // FuncMap fulfills the step.FuncProvider interface.
func (this *Provider) FuncMap () template.FuncMap { func (this *Provider) FuncMap () template.FuncMap {
return template.FuncMap { return template.FuncMap {

View File

@ -13,6 +13,11 @@ type Provider struct {
} }
// Package fulfills the step.Provider interface.
func (this *Provider) Package () string {
return "slice"
}
// FuncMap fulfills the step.FuncProvider interface. // FuncMap fulfills the step.FuncProvider interface.
func (this *Provider) FuncMap () template.FuncMap { func (this *Provider) FuncMap () template.FuncMap {
return template.FuncMap { return template.FuncMap {

View File

@ -11,6 +11,11 @@ type Provider struct {
} }
// Package fulfills the step.Provider interface.
func (this *Provider) Package () string {
return "sprig"
}
// FuncMap fulfills the step.FuncProvider interface. // FuncMap fulfills the step.FuncProvider interface.
func (this *Provider) FuncMap () template.FuncMap { func (this *Provider) FuncMap () template.FuncMap {
return sprig.FuncMap() return sprig.FuncMap()