system: unexport Op implementations
All checks were successful
Test / Create distribution (push) Successful in 52s
Test / Sandbox (push) Successful in 3m30s
Test / Hakurei (push) Successful in 5m40s
Test / Sandbox (race detector) (push) Successful in 6m30s
Test / Hpkg (push) Successful in 7m21s
Test / Hakurei (race detector) (push) Successful in 3m22s
Test / Flake checks (push) Successful in 2m2s

None of these are valid with their zero value, and the implementations assume they are created by the builder methods. They are by all means an implementation detail and exporting them makes no sense.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-09-06 16:16:03 +09:00
parent ac81cfbedc
commit e68db7fbfc
12 changed files with 157 additions and 157 deletions

View File

@@ -6,30 +6,29 @@ import (
"os"
)
// Ensure appends [MkdirOp] to [I] with its [Enablement] ignored.
// Ensure ensures the existence of a directory.
func (sys *I) Ensure(name string, perm os.FileMode) *I {
sys.ops = append(sys.ops, &MkdirOp{User, name, perm, false})
sys.ops = append(sys.ops, &mkdirOp{User, name, perm, false})
return sys
}
// Ephemeral appends an ephemeral [MkdirOp] to [I].
// Ephemeral ensures the existence of a directory until its [Enablement] is no longer satisfied.
func (sys *I) Ephemeral(et Enablement, name string, perm os.FileMode) *I {
sys.ops = append(sys.ops, &MkdirOp{et, name, perm, true})
sys.ops = append(sys.ops, &mkdirOp{et, name, perm, true})
return sys
}
// MkdirOp ensures the existence of a directory.
// For ephemeral, the directory is destroyed once [Enablement] is no longer satisfied.
type MkdirOp struct {
// mkdirOp implements [I.Ensure] and [I.Ephemeral].
type mkdirOp struct {
et Enablement
path string
perm os.FileMode
ephemeral bool
}
func (m *MkdirOp) Type() Enablement { return m.et }
func (m *mkdirOp) Type() Enablement { return m.et }
func (m *MkdirOp) apply(*I) error {
func (m *mkdirOp) apply(*I) error {
msg.Verbose("ensuring directory", m)
// create directory
@@ -44,7 +43,7 @@ func (m *MkdirOp) apply(*I) error {
}
}
func (m *MkdirOp) revert(_ *I, ec *Criteria) error {
func (m *mkdirOp) revert(_ *I, ec *Criteria) error {
if !m.ephemeral {
// skip non-ephemeral dir and do not log anything
return nil
@@ -59,14 +58,14 @@ func (m *MkdirOp) revert(_ *I, ec *Criteria) error {
}
}
func (m *MkdirOp) Is(o Op) bool {
target, ok := o.(*MkdirOp)
func (m *mkdirOp) Is(o Op) bool {
target, ok := o.(*mkdirOp)
return ok && m != nil && target != nil && *m == *target
}
func (m *MkdirOp) Path() string { return m.path }
func (m *mkdirOp) Path() string { return m.path }
func (m *MkdirOp) String() string {
func (m *mkdirOp) String() string {
t := "ensure"
if m.ephemeral {
t = TypeString(m.Type())