tempo-api

module
v0.0.0-...-fd62d35 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: MIT

README ΒΆ

tempo-api

The tempo-api package provides core interfaces and types for extending the tempo CLI functionality.

πŸ’» Installation

go get github.com/indaco/tempo-api@latest

πŸ“¦ Packages Overview

tempo-api/templatefuncs

This package defines the TemplateFuncProvider interface, which external function providers must implement to register custom template functions.

Implementing a Custom Template Function Provider

To register custom template functions, your Go package must implement the TemplateFuncProvider interface and define the provider in a file named provider.go.

Example
// provider.go
package myprovider

import (
    "text/template"

    "github.com/indaco/tempo-api/templatefuncs"
)

// MyProvider implements the TemplateFuncProvider interface
type MyProvider struct{}

// GetFunctions returns a map of function names to implementations
func (p *MyProvider) GetFunctions() template.FuncMap {
    return template.FuncMap{
        "myFunc": func() string { return "Hello from myFunc!" },
    }
}

// Provider instance (must be declared in provider.go)
var Provider templatefuncs.TemplateFuncProvider = &MyProvider{}

[!IMPORTANT] The file must be named provider.go for tempo to detect it.

The Provider variable must be:

  • Exported (Provider, not provider).
  • Declared at the package level (not inside a function).
  • Implementing templatefuncs.TemplateFuncProvider.

πŸ”— Registering the Provider in Tempo

Once your provider is implemented, you can register it using the tempo register functions command:

Register from a Git Repository
tempo register functions --url https://github.com/user/myprovider.git
Register from a Local Path
tempo register functions --path /path/to/myprovider_module

Existing Providers

πŸ†“ License

This project is licensed under the MIT License - see the LICENSE file for details.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

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