MCPcopy Index your code
hub / github.com/aptly-dev/aptly / aptlyRepoCreate

Function aptlyRepoCreate

cmd/repo_create.go:11–54  ·  view source on GitHub ↗
(cmd *commander.Command, args []string)

Source from the content-addressed store, hash-verified

9)
10
11func 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
56func makeCmdRepoCreate() *commander.Command {
57 cmd := &commander.Command{

Callers

nothing calls this directly

Calls 14

SnapshotCollectionMethod · 0.95
UpdateRefListMethod · 0.95
RefListMethod · 0.95
LocalRepoCollectionMethod · 0.95
NewLocalRepoFunction · 0.92
NewUploadersFromFileFunction · 0.92
FlagsMethod · 0.80
NewCollectionFactoryMethod · 0.80
StringMethod · 0.65
GetMethod · 0.65
PrintfMethod · 0.65
ByNameMethod · 0.45

Tested by

no test coverage detected