files

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package files provides utilities for reading and updating version files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadVersion

func ReadVersion(path string) (string, error)

ReadVersion reads the version from a VERSION file.

func UpdateYAMLFile

func UpdateYAMLFile(cfg VersionFileConfig, currentVersion, newVersion string) error

UpdateYAMLFile updates a specific path in a YAML file with a new version. It uses surgical text replacement to preserve the original file formatting. The currentVersion is used to find embedded versions within larger values (e.g., image tags).

func WriteVersion

func WriteVersion(path, version string) error

WriteVersion writes a version to a VERSION file.

Types

type DefaultVersionReader

type DefaultVersionReader struct{}

DefaultVersionReader is the default implementation of VersionReader.

func (*DefaultVersionReader) ReadVersion

func (*DefaultVersionReader) ReadVersion(path string) (string, error)

ReadVersion reads the version from the specified path.

type DefaultVersionWriter

type DefaultVersionWriter struct{}

DefaultVersionWriter is the default implementation of VersionWriter.

func (*DefaultVersionWriter) WriteVersion

func (*DefaultVersionWriter) WriteVersion(path, version string) error

WriteVersion writes the version to the specified path.

type DefaultYAMLUpdater

type DefaultYAMLUpdater struct{}

DefaultYAMLUpdater is the default implementation of YAMLUpdater.

func (*DefaultYAMLUpdater) UpdateYAMLFile

func (*DefaultYAMLUpdater) UpdateYAMLFile(cfg VersionFileConfig, currentVersion, newVersion string) error

UpdateYAMLFile updates a specific path in a YAML file with a new version.

type VersionFileConfig

type VersionFileConfig struct {
	File   string `json:"file"`
	Path   string `json:"path"`
	Prefix string `json:"prefix,omitempty"`
}

VersionFileConfig defines a YAML file and the path to update with the new version.

type VersionReader

type VersionReader interface {
	// ReadVersion reads the version from the specified path.
	ReadVersion(path string) (string, error)
}

VersionReader reads version information from files.

type VersionWriter

type VersionWriter interface {
	// WriteVersion writes the version to the specified path.
	WriteVersion(path, version string) error
}

VersionWriter writes version information to files.

type YAMLUpdater

type YAMLUpdater interface {
	// UpdateYAMLFile updates a specific path in a YAML file with a new version.
	UpdateYAMLFile(cfg VersionFileConfig, currentVersion, newVersion string) error
}

YAMLUpdater updates version information in YAML files.

Jump to

Keyboard shortcuts

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