yamlpath

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 7 Imported by: 0

README

YAMLPath Extractor Modifier (yp)

This plugin provides a YAML JSONPath modifier for spelunk. It allows you to extract specific values from YAML secrets using JSONPath syntax.

Usage

package main

import (
	"context"
	"fmt"

	"github.com/detro/spelunk"
	"github.com/detro/spelunk/plugin/modifier/yamlpath"
)

func main() {
	s, _ := spelunk.NewSpelunker(yamlpath.WithYAMLPath())
	
	// Assuming `plain://...` contains `data: { foo: bar }`
	res, _ := s.DigUp(context.Background(), "plain://.../?yp=$.data.foo")
	
	fmt.Println(res) // Outputs: bar
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrYAMLPathInvalid        = fmt.Errorf("invalid YAML JSONPath expression")
	ErrYAMLPathFailed         = fmt.Errorf("failed to apply YAML JSONPath")
	ErrYAMLPathMatchingFailed = fmt.Errorf("failed to match YAML JSONPath")
	ErrSecretNotYAML          = fmt.Errorf("secret is not a valid YAML")
)

Functions

func WithYAMLPath

func WithYAMLPath() spelunk.SpelunkerOption

WithYAMLPath adds the YAML JSONPath modifier to a Spelunker.

Types

type SecretModifierYAMLPath

type SecretModifierYAMLPath struct{}

SecretModifierYAMLPath is a modifier that can extract a specific field out of a YAML stored in a secret value. It parses the YAML into an object and applies standard JSONPath to it.

func (*SecretModifierYAMLPath) Modify

func (s *SecretModifierYAMLPath) Modify(
	_ context.Context,
	secretValue string,
	mod string,
) (string, error)

func (*SecretModifierYAMLPath) Type

func (s *SecretModifierYAMLPath) Type() string

Jump to

Keyboard shortcuts

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