Files
kopia/cli/command_repository_throttle_set.go
Julio López 1f9f9a1846 chore(general): use non-formatting log variants when there is no formatting (#3931)
Use non-formatting logging functions for message without formatting.
For example, `log.Info("message")` instead of `log.Infof("message")`

Configure linter for printf-like functions
2024-06-18 23:13:17 -07:00

39 lines
814 B
Go

package cli
import (
"context"
"github.com/pkg/errors"
"github.com/kopia/kopia/repo"
)
type commandRepositoryThrottleSet struct {
cts commonThrottleSet
}
func (c *commandRepositoryThrottleSet) setup(svc appServices, parent commandParent) {
cmd := parent.Command("set", "Set throttling parameters for a repository")
c.cts.setup(cmd)
cmd.Action(svc.directRepositoryWriteAction(c.run))
}
func (c *commandRepositoryThrottleSet) run(ctx context.Context, rep repo.DirectRepositoryWriter) error {
thr := rep.Throttler()
limits := thr.Limits()
var changeCount int
if err := c.cts.apply(ctx, &limits, &changeCount); err != nil {
return err
}
if changeCount == 0 {
log(ctx).Info("No changes made.")
return nil
}
return errors.Wrap(rep.Throttler().SetLimits(limits), "error setting limits")
}