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
- func MarshalNewSkill(s NewSkill) ([]byte, error)
- type Icon
- type NewPackage
- type NewSkill
- type Repository
- type SkillFile
- func (sf *SkillFile) Bytes() []byte
- func (sf *SkillFile) DockyardOCIPackage() (idx int, skillName, currentTag string)
- func (sf *SkillFile) GitPackage() int
- func (sf *SkillFile) SetIdentifier(idx int, newIdentifier string) error
- func (sf *SkillFile) SetRef(idx int, newRef string) error
- func (sf *SkillFile) Write() error
Constants ¶
const DockyardSkillPrefix = "ghcr.io/stacklok/dockyard/skills/"
DockyardSkillPrefix is the OCI identifier prefix for skills published by the stacklok/dockyard pipeline.
const RegistryTypeGit = "git"
RegistryTypeGit is the package registryType value for git-sourced packages.
Variables ¶
This section is empty.
Functions ¶
func MarshalNewSkill ¶ added in v0.20260706.0
MarshalNewSkill renders a NewSkill in the on-disk skill.json convention: two-space indentation, no HTML escaping (descriptions may contain raw < or &), and a trailing newline.
Types ¶
type NewPackage ¶ added in v0.20260706.0
type NewPackage struct {
RegistryType string `json:"registryType"`
Identifier string `json:"identifier,omitempty"`
URL string `json:"url,omitempty"`
Ref string `json:"ref,omitempty"`
Subfolder string `json:"subfolder,omitempty"`
}
NewPackage is a package entry of a generated skill.json. OCI packages set Identifier; git packages set URL, Ref, and Subfolder.
type NewSkill ¶ added in v0.20260706.0
type NewSkill struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
Title string `json:"title"`
Description string `json:"description"`
Version string `json:"version"`
Status string `json:"status"`
Repository Repository `json:"repository"`
Icons []Icon `json:"icons"`
Packages []NewPackage `json:"packages"`
}
NewSkill describes a skill.json to be created from scratch. The struct field order matches the conventional key order of existing entries under registries/<reg>/skills/ so generated files look hand-written.
type Repository ¶ added in v0.20260706.0
Repository is the upstream source repository of a skill.
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 (*SkillFile) Bytes ¶
Bytes returns the current (possibly modified) raw bytes of the skill.json.
func (*SkillFile) DockyardOCIPackage ¶
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 ¶
GitPackage returns the index of the first git package, or -1 if none.
func (*SkillFile) SetIdentifier ¶
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.