diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-09-06 16:16:03 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-09-06 16:16:03 +0900 |
| commit | e68db7fbfc367f25ccbaf57ec43f0f4b3c93cba7 (patch) | |
| tree | cf6c16503c64bc5ca90d155bd7960809d10f272b /system/mkdir.go | |
| parent | ac81cfbedc438593f3b504d53728914ac6a3d359 (diff) | |
system: unexport Op implementations
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>
Diffstat (limited to 'system/mkdir.go')
| -rw-r--r-- | system/mkdir.go | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/system/mkdir.go b/system/mkdir.go index 9b92c0f9..64b02496 100644 --- a/system/mkdir.go +++ b/system/mkdir.go @@ -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()) |
