| 59 | } |
| 60 | |
| 61 | func (o *repoRemoveOptions) run(out io.Writer) error { |
| 62 | r, err := repo.LoadFile(o.repoFile) |
| 63 | if isNotExist(err) || len(r.Repositories) == 0 { |
| 64 | return errors.New("no repositories configured") |
| 65 | } |
| 66 | |
| 67 | for _, name := range o.names { |
| 68 | if !r.Remove(name) { |
| 69 | return fmt.Errorf("no repo named %q found", name) |
| 70 | } |
| 71 | if err := r.WriteFile(o.repoFile, 0600); err != nil { |
| 72 | return err |
| 73 | } |
| 74 | |
| 75 | if err := removeRepoCache(o.repoCache, name); err != nil { |
| 76 | return err |
| 77 | } |
| 78 | fmt.Fprintf(out, "%q has been removed from your repositories\n", name) |
| 79 | } |
| 80 | |
| 81 | return nil |
| 82 | } |
| 83 | |
| 84 | func removeRepoCache(root, name string) error { |
| 85 | idx := filepath.Join(root, helmpath.CacheChartsFile(name)) |