mirror of
https://github.com/dokku/dokku.git
synced 2026-09-02 04:00:22 +02:00
Adds typed JSON build records under data/builds/<app>/<build-id>.{json,log} keyed on a stable base36 ULID-style DOKKU_BUILD_ID generated for every deploy. The new commands surface that history (builds:list, builds:info, builds:prune) and an operator-configurable retention via builds:set retention. The existing builds:cancel and builds:output now key on the build-id (with safe handling for already-finalized and abandoned records), and the per-build log file replaces journalctl as the durable source of truth for builds:output.
45 lines
1023 B
Go
45 lines
1023 B
Go
package builds
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/dokku/dokku/plugins/common"
|
|
)
|
|
|
|
// CommandSet writes (or clears) a builds property for an app or globally.
|
|
func CommandSet(appName, property, value string) error {
|
|
if appName != "--global" {
|
|
if err := common.VerifyAppName(appName); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
if _, ok := DefaultProperties[property]; !ok {
|
|
return fmt.Errorf("Invalid property %q (allowed: retention)", property)
|
|
}
|
|
|
|
if value != "" {
|
|
if err := validateSetValue(property, value); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
common.CommandPropertySet("builds", appName, property, value, DefaultProperties, GlobalProperties)
|
|
return nil
|
|
}
|
|
|
|
func validateSetValue(property, value string) error {
|
|
switch property {
|
|
case "retention":
|
|
n, err := strconv.Atoi(value)
|
|
if err != nil {
|
|
return fmt.Errorf("Invalid retention %q: must be a positive integer", value)
|
|
}
|
|
if n < MinimumRetention {
|
|
return fmt.Errorf("Invalid retention %d: must be >= %d", n, MinimumRetention)
|
|
}
|
|
}
|
|
return nil
|
|
}
|