MCPcopy Index your code
hub / github.com/kopia/kopia / applyOptionalInt

Function applyOptionalInt

cli/command_policy_set.go:192–220  ·  view source on GitHub ↗
(ctx context.Context, desc string, val **policy.OptionalInt, str string, changeCount *int)

Source from the content-addressed store, hash-verified

190}
191
192func applyOptionalInt(ctx context.Context, desc string, val **policy.OptionalInt, str string, changeCount *int) error {
193 if str == "" {
194 // not changed
195 return nil
196 }
197
198 if str == inheritPolicyString || str == defaultPolicyString {
199 *changeCount++
200
201 log(ctx).Infof(" - resetting %q to a default value inherited from parent.", desc)
202
203 *val = nil
204
205 return nil
206 }
207
208 v, err := strconv.ParseInt(str, 10, 32)
209 if err != nil {
210 return errors.Wrapf(err, "can't parse the %v %q", desc, str)
211 }
212
213 i := policy.OptionalInt(v)
214 *changeCount++
215
216 log(ctx).Infof(" - setting %q to %v.", desc, i)
217 *val = &i
218
219 return nil
220}
221
222func applyOptionalInt64MiB(ctx context.Context, desc string, val **policy.OptionalInt64, str string, changeCount *int) error {
223 if str == "" {

Callers 2

Calls 1

OptionalIntTypeAlias · 0.92

Tested by

no test coverage detected