Introduce option multi-dist to the publish commands

This change makes it possible to publish multiple distributions
with packages named the same but with different content by changing
structure of the generated pool hierarchy. The option not enabled
by default as this changes the structure of the output which could
break the expectations of other tools.
This commit is contained in:
Noa Resare
2024-05-18 17:59:55 +01:00
committed by André Roth
parent 4bd26f5977
commit b4cd86aa14
9 changed files with 80 additions and 13 deletions

View File

@@ -101,6 +101,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
Architectures []string
Signing SigningOptions
AcquireByHash *bool
MultiDist bool
}
if c.Bind(&b) != nil {
@@ -226,7 +227,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, publishOutput, b.ForceOverwrite)
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, publishOutput, b.ForceOverwrite, b.MultiDist)
if err != nil {
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to publish: %s", err)
}
@@ -257,6 +258,7 @@ func apiPublishUpdateSwitch(c *gin.Context) {
Name string `binding:"required"`
}
AcquireByHash *bool
MultiDist bool
}
if c.Bind(&b) != nil {
@@ -341,7 +343,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, _ *task.Detail) (*task.ProcessReturnValue, error) {
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, out, b.ForceOverwrite)
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, out, b.ForceOverwrite, b.MultiDist)
if err != nil {
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err)
}