files

package
v1.3.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 added in v1.1.0

type DefaultVersionReader struct{}

DefaultVersionReader is the default implementation of VersionReader.

func (*DefaultVersionReader) ReadVersion added in v1.1.0

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

ReadVersion reads the version from the specified path.

type DefaultVersionWriter added in v1.1.0

type DefaultVersionWriter struct{}

DefaultVersionWriter is the default implementation of VersionWriter.

func (*DefaultVersionWriter) WriteVersion added in v1.1.0

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

WriteVersion writes the version to the specified path.

type DefaultYAMLUpdater added in v1.1.0

type DefaultYAMLUpdater struct{}

DefaultYAMLUpdater is the default implementation of YAMLUpdater.

func (*DefaultYAMLUpdater) UpdateYAMLFile added in v1.1.0

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 added in v1.1.0

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

VersionReader reads version information from files.

type VersionWriter added in v1.1.0

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

VersionWriter writes version information to files.

type YAMLUpdater added in v1.1.0

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