Merge pull request #122 from dagger/go-1.13-errors
cleanup: wrap errors using go 1.13 built-ins
This commit is contained in:
commit
cabf3317d9
@ -2,13 +2,13 @@ package dagger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
cueerrors "cuelang.org/go/cue/errors"
|
||||
cueload "cuelang.org/go/cue/load"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"dagger.cloud/go/dagger/compiler"
|
||||
|
@ -3,12 +3,12 @@ package dagger
|
||||
import (
|
||||
"archive/tar"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
@ -45,7 +45,7 @@ func NewClient(ctx context.Context, host string) (*Client, error) {
|
||||
}
|
||||
c, err := bk.New(ctx, host)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "buildkit client")
|
||||
return nil, fmt.Errorf("buildkit client: %w", err)
|
||||
}
|
||||
return &Client{
|
||||
c: c,
|
||||
@ -143,7 +143,7 @@ func (c *Client) buildfn(ctx context.Context, env *Env, ch chan *bk.SolveStatus,
|
||||
return outdir.Result(ctx)
|
||||
}, ch)
|
||||
if err != nil {
|
||||
return errors.Wrap(bkCleanError(err), "buildkit solve")
|
||||
return fmt.Errorf("buildkit solve: %w", bkCleanError(err))
|
||||
}
|
||||
for k, v := range resp.ExporterResponse {
|
||||
// FIXME consume exporter response
|
||||
@ -173,7 +173,7 @@ func (c *Client) outputfn(ctx context.Context, r io.Reader) (*compiler.Value, er
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "read tar stream")
|
||||
return nil, fmt.Errorf("read tar stream: %w", err)
|
||||
}
|
||||
|
||||
lg := lg.
|
||||
@ -192,7 +192,7 @@ func (c *Client) outputfn(ctx context.Context, r io.Reader) (*compiler.Value, er
|
||||
return nil, err
|
||||
}
|
||||
if err := out.Fill(v); err != nil {
|
||||
return nil, errors.Wrap(err, h.Name)
|
||||
return nil, fmt.Errorf("%s: %w", h.Name, err)
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
|
@ -2,10 +2,10 @@ package dagger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"cuelang.org/go/cue"
|
||||
cueflow "cuelang.org/go/tools/flow"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"dagger.cloud/go/dagger/compiler"
|
||||
@ -102,7 +102,7 @@ func (env *Env) Update(ctx context.Context, s Solver) error {
|
||||
// FIXME: BuildAll() to force all files (no required package..)
|
||||
base, err := CueBuild(ctx, p.FS())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "base config")
|
||||
return fmt.Errorf("base config: %w", err)
|
||||
}
|
||||
// Commit
|
||||
return env.set(
|
||||
@ -176,15 +176,15 @@ func (env *Env) set(base, input, output *compiler.Value) (err error) {
|
||||
|
||||
stateInst, err = stateInst.Fill(base.Cue())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "merge base & input")
|
||||
return fmt.Errorf("merge base & input: %w", err)
|
||||
}
|
||||
stateInst, err = stateInst.Fill(input.Cue())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "merge base & input")
|
||||
return fmt.Errorf("merge base & input: %w", err)
|
||||
}
|
||||
stateInst, err = stateInst.Fill(output.Cue())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "merge output with base & input")
|
||||
return fmt.Errorf("merge output with base & input: %w", err)
|
||||
}
|
||||
|
||||
state := compiler.Wrap(stateInst.Value(), stateInst)
|
||||
|
@ -2,13 +2,13 @@ package dagger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/moby/buildkit/client/llb"
|
||||
bkgw "github.com/moby/buildkit/frontend/gateway/client"
|
||||
"github.com/pkg/errors"
|
||||
fstypes "github.com/tonistiigi/fsutil/types"
|
||||
|
||||
"dagger.cloud/go/dagger/compiler"
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/moby/buildkit/client/llb"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
@ -349,7 +348,7 @@ func (p *Pipeline) Export(ctx context.Context, op *compiler.Value) error {
|
||||
}
|
||||
contents, err := p.fs.ReadFile(ctx, source)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "export %s", source)
|
||||
return fmt.Errorf("export %s: %w", source, err)
|
||||
}
|
||||
switch format {
|
||||
case "string":
|
||||
|
@ -3,12 +3,12 @@ package dagger
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/moby/buildkit/client/llb"
|
||||
bkgw "github.com/moby/buildkit/frontend/gateway/client"
|
||||
"github.com/moby/buildkit/solver/pb"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
@ -81,7 +81,7 @@ func dumpLLB(def *llb.Definition) ([]byte, error) {
|
||||
for _, dt := range def.Def {
|
||||
var op pb.Op
|
||||
if err := (&op).Unmarshal(dt); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to parse op")
|
||||
return nil, fmt.Errorf("failed to parse op: %w", err)
|
||||
}
|
||||
dgst := digest.FromBytes(dt)
|
||||
ent := llbOp{Op: op, Digest: dgst, OpMetadata: def.Metadata[dgst]}
|
||||
|
Reference in New Issue
Block a user