minor error messages and linter cleanups
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
@@ -143,7 +143,7 @@ func (r *Route) State() *compiler.Value {
|
||||
|
||||
// LoadLayout loads the layout
|
||||
func (r *Route) LoadLayout(ctx context.Context, s Solver) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "r.Update")
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "route.Update")
|
||||
defer span.Finish()
|
||||
|
||||
layoutSource, err := r.st.LayoutSource.Compile()
|
||||
@@ -185,7 +185,6 @@ func (r *Route) LocalDirs() map[string]string {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// nolint:goconst
|
||||
// FIXME: merge Env into Route, or fix the linter error
|
||||
if do != "local" {
|
||||
return nil
|
||||
|
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"sync"
|
||||
@@ -11,6 +12,11 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrRouteExist = errors.New("route already exists")
|
||||
ErrRouteNotExist = errors.New("route doesn't exist")
|
||||
)
|
||||
|
||||
const (
|
||||
defaultStoreRoot = "$HOME/.config/dagger/routes"
|
||||
)
|
||||
@@ -144,7 +150,7 @@ func (s *Store) CreateRoute(ctx context.Context, st *RouteState) error {
|
||||
defer s.l.Unlock()
|
||||
|
||||
if _, ok := s.routesByName[st.Name]; ok {
|
||||
return os.ErrExist
|
||||
return fmt.Errorf("%s: %w", st.Name, ErrRouteExist)
|
||||
}
|
||||
|
||||
st.ID = uuid.New().String()
|
||||
@@ -179,7 +185,7 @@ func (s *Store) LookupRouteByID(ctx context.Context, id string) (*RouteState, er
|
||||
|
||||
st, ok := s.routes[id]
|
||||
if !ok {
|
||||
return nil, os.ErrNotExist
|
||||
return nil, fmt.Errorf("%s: %w", id, ErrRouteNotExist)
|
||||
}
|
||||
return st, nil
|
||||
}
|
||||
@@ -190,7 +196,7 @@ func (s *Store) LookupRouteByName(ctx context.Context, name string) (*RouteState
|
||||
|
||||
st, ok := s.routesByName[name]
|
||||
if !ok {
|
||||
return nil, os.ErrNotExist
|
||||
return nil, fmt.Errorf("%s: %w", name, ErrRouteNotExist)
|
||||
}
|
||||
return st, nil
|
||||
}
|
||||
@@ -201,7 +207,7 @@ func (s *Store) LookupRouteByPath(ctx context.Context, path string) (*RouteState
|
||||
|
||||
st, ok := s.routesByPath[path]
|
||||
if !ok {
|
||||
return nil, os.ErrNotExist
|
||||
return nil, fmt.Errorf("%s: %w", path, ErrRouteNotExist)
|
||||
}
|
||||
return st, nil
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ func TestStoreLoad(t *testing.T) {
|
||||
|
||||
_, err = store.LookupRouteByName(ctx, "notexist")
|
||||
require.Error(t, err)
|
||||
require.True(t, errors.Is(err, os.ErrNotExist))
|
||||
require.True(t, errors.Is(err, ErrRouteNotExist))
|
||||
|
||||
st := &RouteState{
|
||||
Name: "test",
|
||||
|
Reference in New Issue
Block a user