Documentation
¶
Overview ¶
Package factory builds and edits the files a repository keeps in .factory/: the builder `kojo config export --factory` and the Move to the repository use, and the editor that changes one setting of factory.yaml or schedules.yaml keeping everything else as people wrote it.
Index ¶
- Constants
- func AddMergePolicy(src []byte, mp config.MergePolicy) ([]byte, error)
- func DecodeContent(o config.ExportObject, v any) error
- func DescribeMergePolicy(before, after config.MergePolicy) string
- func DescribeSchedules(before, after config.Schedules) string
- func EditMergePolicy(src []byte, base, want config.MergePolicy) ([]byte, error)
- func EditSchedules(src []byte, want config.Schedules) ([]byte, error)
- func MarshalYAML(v any) ([]byte, error)
- func OrgTriggerPermission(doc *config.Export) string
- func RemoveMergePolicy(src []byte) ([]byte, error)
- type File
Constants ¶
const ( FactoryPath = skills.FactoryDir + "/factory.yaml" SchedulesPath = skills.FactoryDir + "/schedules.yaml" )
The two files of .factory/ that hold repository settings, by their path in the repository.
Variables ¶
This section is empty.
Functions ¶
func AddMergePolicy ¶
func AddMergePolicy(src []byte, mp config.MergePolicy) ([]byte, error)
AddMergePolicy gives a factory.yaml that has no merge policy one: src is empty, comments only, `{}`, or a merge_policy key with no value.
func DecodeContent ¶
func DecodeContent(o config.ExportObject, v any) error
DecodeContent reads an export object's content into v, through JSON: the form the config types are stored and validated in.
func DescribeMergePolicy ¶
func DescribeMergePolicy(before, after config.MergePolicy) string
DescribeMergePolicy is the change from before to after as the lines of a diff block: one -/+ pair per field that differs, risk fields as risk.<name>, in the order of config.MergePolicy. trigger_permission and inherit are left out, as factory.yaml cannot hold them.
func DescribeSchedules ¶
DescribeSchedules is the change from before to after as the lines of a diff block, schedule by schedule in the order of their names: a removed one with -, an added one with +, a changed one as the old with - and then the new with +.
func EditMergePolicy ¶
func EditMergePolicy(src []byte, base, want config.MergePolicy) ([]byte, error)
EditMergePolicy writes the fields of want that differ from base into the merge_policy mapping of a factory.yaml, src. base is the policy src makes (skills.SyncedMergePolicy of it), want the normalised proposal. Only the keys that change are touched: every other key, comment and blank line stays as it was, so the defaults kōjō applies are not frozen into the file. trigger_permission and inherit are never written.
func EditSchedules ¶
EditSchedules makes a schedules.yaml, src, hold want. src is a bare list or a document with a schedules key, and keeps its form. A schedule that did not change keeps its lines, comments included; a changed one keeps the comment lines directly above it and is written again; new ones are written plainly; all in want's order.
func MarshalYAML ¶
MarshalYAML writes v as YAML indented by two spaces, as the .factory/ examples in the docs are.
func OrgTriggerPermission ¶
OrgTriggerPermission is the org's trigger_permission in the export, or the default.
func RemoveMergePolicy ¶
RemoveMergePolicy takes the merge_policy entry out of a factory.yaml. Comment lines above it stay.