(ctx context.Context, rep repo.RepositoryWriter)
| 21 | } |
| 22 | |
| 23 | func (c *commandACLEnable) run(ctx context.Context, rep repo.RepositoryWriter) error { |
| 24 | entries, err := acl.LoadEntries(ctx, rep, nil) |
| 25 | if err != nil { |
| 26 | return errors.Wrap(err, "error loading ACL entries") |
| 27 | } |
| 28 | |
| 29 | if len(entries) != 0 && !c.reset { |
| 30 | return errors.New("ACLs already enabled") |
| 31 | } |
| 32 | |
| 33 | if c.reset { |
| 34 | for _, e := range entries { |
| 35 | log(ctx).Infof("deleting previous ACL entry %v", e.ManifestID) |
| 36 | |
| 37 | if err := rep.DeleteManifest(ctx, e.ManifestID); err != nil { |
| 38 | return errors.Wrap(err, "unable to delete previous ACL") |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | for _, e := range auth.DefaultACLs { |
| 44 | if err := acl.AddACL(ctx, rep, e, false); err != nil { |
| 45 | return errors.Wrap(err, "unable to add default ACL") |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return nil |
| 50 | } |
nothing calls this directly
no test coverage detected