MCPcopy Create free account
hub / github.com/kopia/kopia / applyPolicyStringList

Function applyPolicyStringList

cli/command_policy_set.go:151–190  ·  view source on GitHub ↗
(ctx context.Context, desc string, val *[]string, add, remove []string, clearList bool, changeCount *int)

Source from the content-addressed store, hash-verified

149}
150
151func applyPolicyStringList(ctx context.Context, desc string, val *[]string, add, remove []string, clearList bool, changeCount *int) {
152 if clearList {
153 log(ctx).Infof(" - removing all from %q", desc)
154
155 *changeCount++
156
157 *val = nil
158
159 return
160 }
161
162 entries := map[string]bool{}
163 for _, b := range *val {
164 entries[b] = true
165 }
166
167 for _, b := range add {
168 *changeCount++
169
170 log(ctx).Infof(" - adding %q to %q", b, desc)
171
172 entries[b] = true
173 }
174
175 for _, b := range remove {
176 *changeCount++
177
178 log(ctx).Infof(" - removing %q from %q", b, desc)
179 delete(entries, b)
180 }
181
182 var s []string
183 for k := range entries {
184 s = append(s, k)
185 }
186
187 sort.Strings(s)
188
189 *val = s
190}
191
192func applyOptionalInt(ctx context.Context, desc string, val **policy.OptionalInt, str string, changeCount *int) error {
193 if str == "" {

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…