Skip to content

Commit

Permalink
rename addon files to skel files
Browse files Browse the repository at this point in the history
  • Loading branch information
reglim committed May 31, 2023
1 parent 3fc792b commit 4bcfa21
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions api/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
return &task.ProcessReturnValue{Code: http.StatusBadRequest, Value: nil}, fmt.Errorf("prefix/distribution already used by another published repo: %s", duplicate)
}

err := published.Publish(context.PackagePool(), context, collectionFactory, signer, context.AddonPath(), publishOutput, b.ForceOverwrite)
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, context.SkelPath(), publishOutput, b.ForceOverwrite)

Check warning on line 228 in api/publish.go

View check run for this annotation

Codecov / codecov/patch

api/publish.go#L228

Added line #L228 was not covered by tests
if err != nil {
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to publish: %s", err)
}
Expand Down Expand Up @@ -340,7 +340,7 @@ func apiPublishUpdateSwitch(c *gin.Context) {
resources = append(resources, string(published.Key()))
taskName := fmt.Sprintf("Update published %s (%s): %s", published.SourceKind, strings.Join(updatedComponents, " "), strings.Join(updatedSnapshots, ", "))
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) {
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, context.AddonPath(), out, b.ForceOverwrite)
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, context.SkelPath(), out, b.ForceOverwrite)

Check warning on line 343 in api/publish.go

View check run for this annotation

Codecov / codecov/patch

api/publish.go#L343

Added line #L343 was not covered by tests
if err != nil {
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/publish_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
"the same package pool.\n")
}

err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.AddonPath(), context.Progress(), forceOverwrite)
err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.SkelPath(), context.Progress(), forceOverwrite)
if err != nil {
return fmt.Errorf("unable to publish: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/publish_switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error {
published.SkipBz2 = context.Flags().Lookup("skip-bz2").Value.Get().(bool)
}

err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.AddonPath(), context.Progress(), forceOverwrite)
err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.SkelPath(), context.Progress(), forceOverwrite)
if err != nil {
return fmt.Errorf("unable to publish: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/publish_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func aptlyPublishUpdate(cmd *commander.Command, args []string) error {
published.SkipBz2 = context.Flags().Lookup("skip-bz2").Value.Get().(bool)
}

err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.AddonPath(), context.Progress(), forceOverwrite)
err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.SkelPath(), context.Progress(), forceOverwrite)
if err != nil {
return fmt.Errorf("unable to publish: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,9 @@ func (context *AptlyContext) GetVerifier() pgp.Verifier {
return pgp.NewGpgVerifier(context.getGPGFinder(provider))
}

// AddonPath builds the local addon folder
func (context *AptlyContext) AddonPath() string {
return filepath.Join(context.config().RootDir, "addon")
// SkelPath builds the local skeleton folder
func (context *AptlyContext) SkelPath() string {
return filepath.Join(context.config().RootDir, "skel")
}

// UpdateFlags sets internal copy of flags in the context
Expand Down
4 changes: 2 additions & 2 deletions deb/index_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ func (files *indexFiles) LegacyContentsIndex(arch string, udeb bool) *indexFile
return file
}

func (files *indexFiles) AddonIndex(component, path string) *indexFile {
key := fmt.Sprintf("ai-%s-%s", component, path)
func (files *indexFiles) SkelIndex(component, path string) *indexFile {
key := fmt.Sprintf("si-%s-%s", component, path)
file, ok := files.indexes[key]

if !ok {
Expand Down
24 changes: 12 additions & 12 deletions deb/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,16 @@ func (p *PublishedRepo) GetCodename() string {
return p.Codename
}

// GetAddonFiles returns a map of files to be added to a repo. Key being the relative
// GetSkelFiles returns a map of files to be added to a repo. Key being the relative
// path from component folder, and value being the full local FS path.
func (p *PublishedRepo) GetAddonFiles(addonDir string, component string) (map[string]string, error) {
func (p *PublishedRepo) GetSkelFiles(skelDir string, component string) (map[string]string, error) {
files := make(map[string]string)

if addonDir == "" {
if skelDir == "" {
return files, nil
}

fsPath := filepath.Join(addonDir, p.Prefix, "dists", p.Distribution, component)
fsPath := filepath.Join(skelDir, p.Prefix, "dists", p.Distribution, component)
if err := filepath.Walk(fsPath, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
Expand Down Expand Up @@ -589,7 +589,7 @@ func (p *PublishedRepo) GetAddonFiles(addonDir string, component string) (map[st

// Publish publishes snapshot (repository) contents, links package files, generates Packages & Release files, signs them
func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageProvider aptly.PublishedStorageProvider,
collectionFactory *CollectionFactory, signer pgp.Signer, addonDirectory string, progress aptly.Progress, forceOverwrite bool) error {
collectionFactory *CollectionFactory, signer pgp.Signer, skelDir string, progress aptly.Progress, forceOverwrite bool) error {
publishedStorage := publishedStorageProvider.GetPublishedStorage(p.Storage)

err := publishedStorage.MkDir(filepath.Join(p.Prefix, "pool"))
Expand Down Expand Up @@ -790,25 +790,25 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
}

for component := range p.sourceItems {
addonFiles, err := p.GetAddonFiles(addonDirectory, component)
skelFiles, err := p.GetSkelFiles(skelDir, component)
if err != nil {
return fmt.Errorf("unable to get addon files: %v", err)
return fmt.Errorf("unable to get skeleton files: %v", err)
}

Check warning on line 796 in deb/publish.go

View check run for this annotation

Codecov / codecov/patch

deb/publish.go#L795-L796

Added lines #L795 - L796 were not covered by tests

for relPath, absPath := range addonFiles {
bufWriter, err := indexes.AddonIndex(component, relPath).BufWriter()
for relPath, absPath := range skelFiles {
bufWriter, err := indexes.SkelIndex(component, relPath).BufWriter()
if err != nil {
return fmt.Errorf("unable to generate addon index: %v", err)
return fmt.Errorf("unable to generate skeleton index: %v", err)
}

Check warning on line 802 in deb/publish.go

View check run for this annotation

Codecov / codecov/patch

deb/publish.go#L801-L802

Added lines #L801 - L802 were not covered by tests

file, err := os.Open(absPath)
if err != nil {
return fmt.Errorf("unable to read addon file: %v", err)
return fmt.Errorf("unable to read skeleton file: %v", err)
}

Check warning on line 807 in deb/publish.go

View check run for this annotation

Codecov / codecov/patch

deb/publish.go#L806-L807

Added lines #L806 - L807 were not covered by tests

_, err = bufio.NewReader(file).WriteTo(bufWriter)
if err != nil {
return fmt.Errorf("unable to write addon file: %v", err)
return fmt.Errorf("unable to write skeleton file: %v", err)
}

Check warning on line 812 in deb/publish.go

View check run for this annotation

Codecov / codecov/patch

deb/publish.go#L811-L812

Added lines #L811 - L812 were not covered by tests
}
}
Expand Down
2 changes: 1 addition & 1 deletion man/aptly.1.ronn.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Options:

* `rootDir`:
is root of directory storage to store database (`rootDir`/db), downloaded packages (`rootDir`/pool),
the default for published repositories (`rootDir`/public) and addon files (`rootDir`/addon)
the default for published repositories (`rootDir`/public) and skeleton files (`rootDir`/skel)

* `downloadConcurrency`:
is a number of parallel download threads to use when downloading packages
Expand Down
4 changes: 2 additions & 2 deletions system/t06_publish/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ def check(self):

class PublishRepo34Test(BaseTest):
"""
publish repo: addon files
publish repo: skeleton files
"""
fixtureCmds = [
"aptly repo create local-repo",
Expand All @@ -904,7 +904,7 @@ class PublishRepo34Test(BaseTest):
def prepare_fixture(self):
super(PublishRepo34Test, self).prepare_fixture()

self.write_file(os.path.join('addon', 'dists', 'maverick', 'main', 'dep11', 'README'), 'README test file')
self.write_file(os.path.join('skel', 'dists', 'maverick', 'main', 'dep11', 'README'), 'README test file')

def check(self):
super(PublishRepo34Test, self).check()
Expand Down

0 comments on commit 4bcfa21

Please sign in to comment.