(cmd *commander.Command, args []string)
| 9 | ) |
| 10 | |
| 11 | func aptlyRepoCreate(cmd *commander.Command, args []string) error { |
| 12 | var err error |
| 13 | if !(len(args) == 1 || (len(args) == 4 && args[1] == "from" && args[2] == "snapshot")) { // nolint: goconst |
| 14 | cmd.Usage() |
| 15 | return commander.ErrCommandError |
| 16 | } |
| 17 | |
| 18 | repo := deb.NewLocalRepo(args[0], context.Flags().Lookup("comment").Value.String()) |
| 19 | repo.DefaultDistribution = context.Flags().Lookup("distribution").Value.String() |
| 20 | repo.DefaultComponent = context.Flags().Lookup("component").Value.String() |
| 21 | |
| 22 | uploadersFile := context.Flags().Lookup("uploaders-file").Value.Get().(string) |
| 23 | if uploadersFile != "" { |
| 24 | repo.Uploaders, err = deb.NewUploadersFromFile(uploadersFile) |
| 25 | if err != nil { |
| 26 | return err |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | collectionFactory := context.NewCollectionFactory() |
| 31 | if len(args) == 4 { |
| 32 | var snapshot *deb.Snapshot |
| 33 | |
| 34 | snapshot, err = collectionFactory.SnapshotCollection().ByName(args[3]) |
| 35 | if err != nil { |
| 36 | return fmt.Errorf("unable to load source snapshot: %s", err) |
| 37 | } |
| 38 | |
| 39 | err = collectionFactory.SnapshotCollection().LoadComplete(snapshot) |
| 40 | if err != nil { |
| 41 | return fmt.Errorf("unable to load source snapshot: %s", err) |
| 42 | } |
| 43 | |
| 44 | repo.UpdateRefList(snapshot.RefList()) |
| 45 | } |
| 46 | |
| 47 | err = collectionFactory.LocalRepoCollection().Add(repo) |
| 48 | if err != nil { |
| 49 | return fmt.Errorf("unable to add local repo: %s", err) |
| 50 | } |
| 51 | |
| 52 | fmt.Printf("\nLocal repo %s successfully added.\nYou can run 'aptly repo add %s ...' to add packages to repository.\n", repo, repo.Name) |
| 53 | return err |
| 54 | } |
| 55 | |
| 56 | func makeCmdRepoCreate() *commander.Command { |
| 57 | cmd := &commander.Command{ |
nothing calls this directly
no test coverage detected