(ctx context.Context, sourceRepo repo.Repository, destRepo repo.RepositoryWriter, si snapshot.SourceInfo)
| 184 | } |
| 185 | |
| 186 | func (c *commandSnapshotMigrate) migrateSinglePolicy(ctx context.Context, sourceRepo repo.Repository, destRepo repo.RepositoryWriter, si snapshot.SourceInfo) error { |
| 187 | pol, err := policy.GetDefinedPolicy(ctx, sourceRepo, si) |
| 188 | if errors.Is(err, policy.ErrPolicyNotFound) { |
| 189 | return nil |
| 190 | } |
| 191 | |
| 192 | if err != nil { |
| 193 | return errors.Wrapf(err, "unable to migrate policy for %v", si) |
| 194 | } |
| 195 | |
| 196 | _, err = policy.GetDefinedPolicy(ctx, destRepo, si) |
| 197 | if err == nil { |
| 198 | if !c.migrateOverwritePolicies { |
| 199 | log(ctx).Infof("policy already set for %v", si) |
| 200 | // already have destination policy |
| 201 | return nil |
| 202 | } |
| 203 | } else if !errors.Is(err, policy.ErrPolicyNotFound) { |
| 204 | return errors.Wrapf(err, "unable to migrate policy for %v", si) |
| 205 | } |
| 206 | |
| 207 | log(ctx).Infof("migrating policy for %v", si) |
| 208 | |
| 209 | return errors.Wrap(policy.SetPolicy(ctx, destRepo, si, pol), "error setting policy") |
| 210 | } |
| 211 | |
| 212 | func (c *commandSnapshotMigrate) findPreviousSnapshotManifestWithStartTime(ctx context.Context, rep repo.Repository, sourceInfo snapshot.SourceInfo, startTime fs.UTCTimestamp) (*snapshot.Manifest, error) { |
| 213 | previous, err := snapshot.ListSnapshots(ctx, rep, sourceInfo) |
no test coverage detected