CI: move grafana-build into pkg/build (#105640)

* move grafana-build into pkg/build
This commit is contained in:
Kevin Minehart
2025-05-20 10:48:00 -05:00
committed by GitHub
parent 759933d3e2
commit 13f4cf162e
222 changed files with 17387 additions and 442 deletions
@@ -0,0 +1,29 @@
package containers
import (
"context"
"errors"
"fmt"
"dagger.io/dagger"
)
var (
ErrorNonZero = errors.New("container exited with non-zero exit code")
)
// ExitError functionally replaces '(*container).ExitCode' in a more usable way.
// It will return an error with the container's stderr and stdout if the exit code is not zero.
func ExitError(ctx context.Context, container *dagger.Container) (*dagger.Container, error) {
container, err := container.Sync(ctx)
if err == nil {
return container, nil
}
var e *dagger.ExecError
if errors.As(err, &e) {
return container, fmt.Errorf("%w\nstdout: %s\nstderr: %s", ErrorNonZero, e.Stdout, e.Stderr)
}
return container, err
}