MCPcopy
hub / github.com/kopia/kopia / policyTargets

Method policyTargets

cli/command_policy.go:47–76  ·  view source on GitHub ↗
(ctx context.Context, rep repo.Repository)

Source from the content-addressed store, hash-verified

45}
46
47func (c *policyTargetFlags) policyTargets(ctx context.Context, rep repo.Repository) ([]snapshot.SourceInfo, error) {
48 if c.global == (len(c.targets) > 0) {
49 return nil, errors.New("must pass either '--global' or a list of path targets")
50 }
51
52 if c.global {
53 return []snapshot.SourceInfo{
54 policy.GlobalPolicySourceInfo,
55 }, nil
56 }
57
58 var res []snapshot.SourceInfo
59
60 for _, ts := range c.targets {
61 // try loading policy by its manifest ID
62 if t, err := policy.GetPolicyByID(ctx, rep, manifest.ID(ts)); err == nil {
63 res = append(res, t.Target())
64 continue
65 }
66
67 target, err := snapshot.ParseSourceInfo(ts, rep.ClientOptions().Hostname, rep.ClientOptions().Username)
68 if err != nil {
69 return nil, errors.Wrapf(err, "unable to parse source info: %q", ts)
70 }
71
72 res = append(res, target)
73 }
74
75 return res, nil
76}

Callers 6

runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80

Calls 5

GetPolicyByIDFunction · 0.92
IDTypeAlias · 0.92
ParseSourceInfoFunction · 0.92
TargetMethod · 0.80
ClientOptionsMethod · 0.65

Tested by

no test coverage detected