Fixing tests and fix cleanup.

Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de>
This commit is contained in:
Christoph Fiehe
2024-10-11 23:09:30 +02:00
committed by André Roth
parent ac5ecf946d
commit f8f28e9554
83 changed files with 540 additions and 174 deletions

View File

@@ -267,7 +267,7 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
return fmt.Errorf("unable to update: %s", err)
}
context.Progress().Printf("\nMirror `%s` has been successfully updated.\n", repo.Name)
context.Progress().Printf("\nMirror `%s` has been updated successfully.\n", repo.Name)
return err
}

View File

@@ -44,9 +44,9 @@ func aptlyPublishSourceAdd(cmd *commander.Command, args []string) error {
name := names[i]
_, exists := sources[component]
if exists {
return fmt.Errorf("unable to add: component %q has already been added", component)
return fmt.Errorf("unable to add: component '%s' has already been added", component)
}
context.Progress().Printf("Adding component %q with source %q [%s]...\n", component, name, published.SourceKind)
context.Progress().Printf("Adding component '%s' with source '%s' [%s]...\n", component, name, published.SourceKind)
sources[component] = names[i]
}

View File

@@ -42,9 +42,9 @@ func aptlyPublishSourceRemove(cmd *commander.Command, args []string) error {
for _, component := range components {
name, exists := sources[component]
if !exists {
return fmt.Errorf("unable to remove: component %q does not exist", component)
return fmt.Errorf("unable to remove: component '%s' does not exist", component)
}
context.Progress().Printf("Removing component %q with source %q [%s]...\n", component, name, published.SourceKind)
context.Progress().Printf("Removing component '%s' with source '%s' [%s]...\n", component, name, published.SourceKind)
delete(sources, component)
}

View File

@@ -44,9 +44,9 @@ func aptlyPublishSourceUpdate(cmd *commander.Command, args []string) error {
name := names[i]
_, exists := sources[component]
if !exists {
return fmt.Errorf("unable to update: component %q does not exist", component)
return fmt.Errorf("unable to update: component '%s' does not exist", component)
}
context.Progress().Printf("Updating component %q with source %q [%s]...\n", component, name, published.SourceKind)
context.Progress().Printf("Updating component '%s' with source '%s' [%s]...\n", component, name, published.SourceKind)
sources[component] = name
}

View File

@@ -115,8 +115,7 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error {
skipCleanup := context.Flags().Lookup("skip-cleanup").Value.Get().(bool)
if !skipCleanup {
err = collectionFactory.PublishedRepoCollection().CleanupPrefixComponentFiles(context, published,
[]string{}, components, []string{}, collectionFactory, context.Progress())
err = collectionFactory.PublishedRepoCollection().CleanupPrefixComponentFiles(context, published, components, collectionFactory, context.Progress())
if err != nil {
return fmt.Errorf("unable to switch: %s", err)
}

View File

@@ -76,14 +76,15 @@ func aptlyPublishUpdate(cmd *commander.Command, args []string) error {
skipCleanup := context.Flags().Lookup("skip-cleanup").Value.Get().(bool)
if !skipCleanup {
err = collectionFactory.PublishedRepoCollection().CleanupPrefixComponentFiles(context, published,
result.AddedComponents(), result.UpdatedComponents(), result.RemovedComponents(), collectionFactory, context.Progress())
cleanComponents := make([]string, 0, len(result.UpdatedSources)+len(result.RemovedSources))
cleanComponents = append(append(cleanComponents, result.UpdatedComponents()...), result.RemovedComponents()...)
err = collectionFactory.PublishedRepoCollection().CleanupPrefixComponentFiles(context, published, cleanComponents, collectionFactory, context.Progress())
if err != nil {
return fmt.Errorf("unable to update: %s", err)
}
}
context.Progress().Printf("\nPublished %s repository %s has been successfully updated.\n", published.SourceKind, published.String())
context.Progress().Printf("\nPublished %s repository %s has been updated successfully.\n", published.SourceKind, published.String())
return err
}