From 0e5affc574c4b1696adc5e678e878540923e052d Mon Sep 17 00:00:00 2001 From: Philip Meulengracht Date: Thu, 1 Sep 2022 09:43:16 +0200 Subject: [PATCH] snap/quota: review feedback rename IsZero to Unset --- overlord/servicestate/quota_handlers.go | 2 +- snap/quota/resources.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/overlord/servicestate/quota_handlers.go b/overlord/servicestate/quota_handlers.go index b1a867c5a4..2762de9a6e 100644 --- a/overlord/servicestate/quota_handlers.go +++ b/overlord/servicestate/quota_handlers.go @@ -416,7 +416,7 @@ func quotaRemove(st *state.State, action QuotaControlAction, allGrps map[string] return nil, nil, false, fmt.Errorf("internal error, AddSnaps option cannot be used with remove action") } - if !action.ResourceLimits.IsZero() { + if !action.ResourceLimits.Unset() { return nil, nil, false, fmt.Errorf("internal error, quota limit options cannot be used with remove action") } diff --git a/snap/quota/resources.go b/snap/quota/resources.go index 3f6860be5e..50873c695b 100644 --- a/snap/quota/resources.go +++ b/snap/quota/resources.go @@ -203,8 +203,8 @@ func (qr *Resources) CheckFeatureRequirements() error { return nil } -// IsZero returns true if there is no limit set -func (qr *Resources) IsZero() bool { +// Unset returns true if there is no limit set +func (qr *Resources) Unset() bool { return qr.Memory == nil && qr.CPU == nil && qr.CPUSet == nil && qr.Threads == nil && qr.Journal == nil } @@ -215,7 +215,7 @@ func (qr *Resources) IsZero() bool { // Note that before applying the quota to the system // CheckFeatureRequirements() should be called. func (qr *Resources) Validate() error { - if qr.IsZero() { + if qr.Unset() { return fmt.Errorf("quota group must have at least one resource limit set") }