Centralize managed state targets

This commit is contained in:
2026-05-31 03:17:40 +00:00
parent 4bd5b19025
commit 61a40ab656
10 changed files with 116 additions and 43 deletions

View File

@@ -6,7 +6,7 @@ import (
"strings"
)
const stateFileName = ".distributor.json"
const StateFileName = ".distributor.json"
func ValidatePath(value string) error {
if value == "" {
@@ -37,9 +37,29 @@ func Join(base, child string) (string, error) {
func StatePath(bundlePath string) (string, error) {
if bundlePath == "" {
return stateFileName, nil
return StateFileName, nil
}
return Join(bundlePath, stateFileName)
return Join(bundlePath, StateFileName)
}
func ManagedBundleTargets(bundlePath string, managedOutputPaths []string) ([]string, error) {
if err := ValidatePrefix(bundlePath); err != nil {
return nil, err
}
targets := make([]string, 0, len(managedOutputPaths)+1)
for _, outputPath := range managedOutputPaths {
target, err := Join(bundlePath, outputPath)
if err != nil {
return nil, err
}
targets = append(targets, target)
}
statePath, err := StatePath(bundlePath)
if err != nil {
return nil, err
}
targets = append(targets, statePath)
return targets, nil
}
func SortEntries(entries []Entry) {