spec

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package spec handles local pricing specifications.

When plugins don't provide pricing for a resource type, the engine falls back to local YAML-based pricing specifications.

Specification Location

Specs are stored in ~/.finfocus/specs/ as YAML files.

Specification Format

Example pricing spec (aws-ec2-t3-micro.yaml):

resource_type: aws:ec2:Instance
instance_type: t3.micro
pricing:
  hourly: 0.0104
  currency: USD

Usage

Specs provide fallback pricing when:

  • No plugin is available for a resource type
  • Plugin returns no pricing data
  • Plugin query fails

Index

Constants

View Source
const (
	// ExpectedPartsCount is the number of parts expected in a spec filename (provider-service-sku).
	ExpectedPartsCount = 3
)

Variables

View Source
var (
	// ErrSpecNotFound is returned when a requested spec file does not exist.
	ErrSpecNotFound = errors.New("spec file not found")
)

Functions

func ParseSpecFilename

func ParseSpecFilename(filename string) (string, string, string, bool)

ParseSpecFilename parses a spec filename to extract provider, service, and SKU.

func ValidateSpec

func ValidateSpec(spec *PricingSpec) error

ValidateSpec validates that a pricing spec has all required fields.

Types

type Loader

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

Loader loads pricing specifications from a directory.

func NewLoader

func NewLoader(specDir string) *Loader

NewLoader creates a new spec loader for the given directory.

func (*Loader) ListSpecs

func (l *Loader) ListSpecs() ([]string, error)

ListSpecs returns a list of all available spec filenames in the spec directory.

func (*Loader) LoadSpec

func (l *Loader) LoadSpec(provider, service, sku string) (interface{}, error)

LoadSpec loads a pricing specification by provider, service, and SKU.

func (*Loader) LoadSpecWithContext

func (l *Loader) LoadSpecWithContext(
	ctx context.Context,
	provider, service, sku string,
) (interface{}, error)

LoadSpecWithContext loads a pricing specification by provider, service, and SKU with logging.

type PricingSpec

type PricingSpec struct {
	Provider string                 `yaml:"provider"`
	Service  string                 `yaml:"service"`
	SKU      string                 `yaml:"sku"`
	Currency string                 `yaml:"currency"`
	Pricing  map[string]interface{} `yaml:"pricing"`
	Metadata map[string]interface{} `yaml:"metadata,omitempty"`
}

PricingSpec represents a pricing specification for a cloud service SKU.

Jump to

Keyboard shortcuts

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