diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-21 00:18:50 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-21 00:18:50 +0900 |
| commit | 5d8a2199b6c8dc5f75b529a39d196c6cb14c98c2 (patch) | |
| tree | 5ad693466483081342b24df929365490015b4efa /container/autoetc.go | |
| parent | a1482ecdd0f98728f4b97137cd7b2fa17f67bb89 (diff) | |
container/init: op interface valid method
Check ops early and eliminate duplicate checks.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/autoetc.go')
| -rw-r--r-- | container/autoetc.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/container/autoetc.go b/container/autoetc.go index 44b5d761..0334ad14 100644 --- a/container/autoetc.go +++ b/container/autoetc.go @@ -21,6 +21,7 @@ func (f *Ops) Etc(host *Absolute, prefix string) *Ops { type AutoEtcOp struct{ Prefix string } +func (e *AutoEtcOp) Valid() bool { return e != nil } func (e *AutoEtcOp) early(*setupState) error { return nil } func (e *AutoEtcOp) apply(state *setupState) error { if state.nonrepeatable&nrAutoEtc != 0 { @@ -66,7 +67,7 @@ func (e *AutoEtcOp) hostRel() string { return ".host/" + e.Prefix } func (e *AutoEtcOp) Is(op Op) bool { ve, ok := op.(*AutoEtcOp) - return ok && ((e == nil && ve == nil) || (e != nil && ve != nil && *e == *ve)) + return ok && e.Valid() && ve.Valid() && *e == *ve } func (*AutoEtcOp) prefix() string { return "setting up" } func (e *AutoEtcOp) String() string { return fmt.Sprintf("auto etc %s", e.Prefix) } |
