Documentation
¶
Overview ¶
Package files provides utilities for reading and updating version files.
Index ¶
- func ReadVersion(path string) (string, error)
- func UpdateYAMLFile(cfg VersionFileConfig, currentVersion, newVersion string) error
- func WriteVersion(path, version string) error
- type DefaultVersionReader
- type DefaultVersionWriter
- type DefaultYAMLUpdater
- type VersionFileConfig
- type VersionReader
- type VersionWriter
- type YAMLUpdater
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadVersion ¶
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 ¶
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.