|
|
|
|
@@ -11,6 +11,7 @@ import (
|
|
|
|
|
"gitea.maximumdirect.net/eric/distributor/internal/config"
|
|
|
|
|
"gitea.maximumdirect.net/eric/distributor/internal/notify"
|
|
|
|
|
"gitea.maximumdirect.net/eric/distributor/internal/publish"
|
|
|
|
|
"gitea.maximumdirect.net/eric/distributor/internal/storage"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type RunOptions struct {
|
|
|
|
|
@@ -68,7 +69,7 @@ func runConfig(ctx context.Context, cfg config.Config, options RunOptions) error
|
|
|
|
|
for _, destination := range pipeline.Destinations {
|
|
|
|
|
destinationBackend, err := backends.openDestination(ctx, destination)
|
|
|
|
|
if err != nil {
|
|
|
|
|
failures.add(pipeline.ID, destination.ID, displayBundlePath(sourceBundle.RootRelativePath), err)
|
|
|
|
|
failures.add(pipeline.ID, destination.ID, storage.DisplayPath(sourceBundle.RootRelativePath), err)
|
|
|
|
|
summary.recordFailure()
|
|
|
|
|
if options.Stdout != nil {
|
|
|
|
|
writeErrorLine(options.Stdout, sourceBundle.RootRelativePath, destination.ID, err)
|
|
|
|
|
@@ -96,20 +97,20 @@ func runConfig(ctx context.Context, cfg config.Config, options RunOptions) error
|
|
|
|
|
writePlanLine(options.Stdout, plan, err)
|
|
|
|
|
}
|
|
|
|
|
if err != nil {
|
|
|
|
|
failures.add(pipeline.ID, destination.ID, displayBundlePath(sourceBundle.RootRelativePath), err)
|
|
|
|
|
failures.add(pipeline.ID, destination.ID, storage.DisplayPath(sourceBundle.RootRelativePath), err)
|
|
|
|
|
summary.recordFailure()
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
summary.recordPlan(plan.Action)
|
|
|
|
|
if !options.DryRun {
|
|
|
|
|
if err := publish.Execute(ctx, req, plan); err != nil {
|
|
|
|
|
failures.add(pipeline.ID, destination.ID, displayBundlePath(sourceBundle.RootRelativePath), err)
|
|
|
|
|
failures.add(pipeline.ID, destination.ID, storage.DisplayPath(sourceBundle.RootRelativePath), err)
|
|
|
|
|
summary.recordFailure()
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if shouldNotify(plan.Action) {
|
|
|
|
|
if err := notifier.Notify(ctx, notifyEvent(plan)); err != nil {
|
|
|
|
|
failures.add(pipeline.ID, destination.ID, displayBundlePath(sourceBundle.RootRelativePath), err)
|
|
|
|
|
failures.add(pipeline.ID, destination.ID, storage.DisplayPath(sourceBundle.RootRelativePath), err)
|
|
|
|
|
summary.recordFailure()
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
@@ -138,17 +139,17 @@ func writePlanLine(w io.Writer, plan publish.Plan, planErr error) {
|
|
|
|
|
if destinationID == "" {
|
|
|
|
|
destinationID = "unknown"
|
|
|
|
|
}
|
|
|
|
|
fmt.Fprintf(w, " - bundle=%s destination=%s action=error reason=%q\n", displayBundlePath(plan.BundlePath), destinationID, planErr.Error())
|
|
|
|
|
fmt.Fprintf(w, " - bundle=%s destination=%s action=error reason=%q\n", storage.DisplayPath(plan.BundlePath), destinationID, planErr.Error())
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
fmt.Fprintf(w, " - bundle=%s destination=%s action=%s outputs=%s reason=%q\n", displayBundlePath(plan.BundlePath), plan.DestinationID, plan.Action, outputSummary(plan.Outputs), plan.Reason)
|
|
|
|
|
fmt.Fprintf(w, " - bundle=%s destination=%s action=%s outputs=%s reason=%q\n", storage.DisplayPath(plan.BundlePath), plan.DestinationID, plan.Action, outputSummary(plan.Outputs), plan.Reason)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func writeErrorLine(w io.Writer, bundlePath, destinationID string, err error) {
|
|
|
|
|
if w == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
fmt.Fprintf(w, " - bundle=%s destination=%s action=error reason=%q\n", displayBundlePath(bundlePath), destinationID, err.Error())
|
|
|
|
|
fmt.Fprintf(w, " - bundle=%s destination=%s action=error reason=%q\n", storage.DisplayPath(bundlePath), destinationID, err.Error())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func outputSummary(outputs []publish.Output) string {
|
|
|
|
|
|