skilljson

package
v0.20260506.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package skilljson provides utilities for reading and surgically modifying individual skill.json files. Updates are performed as byte-level substitutions so the original key order, indentation, and trailing newline of the file are preserved across rewrites.

Index

Constants

View Source
const DockyardSkillPrefix = "ghcr.io/stacklok/dockyard/skills/"

DockyardSkillPrefix is the OCI identifier prefix for skills published by the stacklok/dockyard pipeline.

Variables

This section is empty.

Functions

This section is empty.

Types

type SkillFile

type SkillFile struct {
	// Path is the filesystem path to the skill.json file.
	Path string
	// Skill is the parsed skill structure.
	Skill thvregistry.Skill
	// contains filtered or unexported fields
}

SkillFile represents a loaded skill.json with both its parsed structure and its original bytes for round-trip fidelity.

func Load

func Load(path string) (*SkillFile, error)

Load reads and parses a skill.json from the given path.

func (*SkillFile) Bytes

func (sf *SkillFile) Bytes() []byte

Bytes returns the current (possibly modified) raw bytes of the skill.json.

func (*SkillFile) DockyardOCIPackage

func (sf *SkillFile) DockyardOCIPackage() (idx int, skillName, currentTag string)

DockyardOCIPackage returns the index of the first OCI package whose identifier starts with DockyardSkillPrefix, along with the parsed skill name and current tag from the identifier. Returns idx == -1 when no such package is present.

func (*SkillFile) GitPackage

func (sf *SkillFile) GitPackage() int

GitPackage returns the index of the first git package, or -1 if none.

func (*SkillFile) SetIdentifier

func (sf *SkillFile) SetIdentifier(idx int, newIdentifier string) error

SetIdentifier replaces the OCI identifier of the package at idx with a byte-level substitution. The old identifier must occur exactly once in the raw file bytes.

func (*SkillFile) SetRef

func (sf *SkillFile) SetRef(idx int, newRef string) error

SetRef replaces the ref of the package at idx with a byte-level substitution. The match is scoped to a `"ref": "<old>"` token to avoid touching unrelated string occurrences. Both spaced and unspaced forms of the JSON key are accepted.

func (*SkillFile) Write

func (sf *SkillFile) Write() error

Write writes the current raw bytes back to the file path.

Jump to

Keyboard shortcuts

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