@@ -2,7 +2,6 @@ package dagger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"strings"
|
||||
@@ -311,10 +310,6 @@ func (r *Route) Query(ctx context.Context, expr interface{}, o *QueryOpts) (*com
|
||||
panic("NOT IMPLEMENTED")
|
||||
}
|
||||
|
||||
func (r *Route) FIXME(ctx context.Context) error {
|
||||
return errors.New("FIXME")
|
||||
}
|
||||
|
||||
type QueryOpts struct{}
|
||||
|
||||
func newTaskFunc(inst *cue.Instance, runner cueflow.RunnerFunc) cueflow.TaskFunc {
|
||||
|
@@ -4,8 +4,10 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
@@ -67,6 +69,26 @@ func LoadRoute(ctx context.Context, id string, o *LoadOpts) (*Route, error) {
|
||||
panic("NOT IMPLEMENTED")
|
||||
}
|
||||
|
||||
func ListRoutes(ctx context.Context) ([]string, error) {
|
||||
routes := []string{}
|
||||
|
||||
rootDir := os.ExpandEnv(storeLocation)
|
||||
files, err := ioutil.ReadDir(rootDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
if f.IsDir() || !strings.HasSuffix(f.Name(), ".json") {
|
||||
// There is extra data in the directory, ignore
|
||||
continue
|
||||
}
|
||||
routes = append(routes, f.Name()[:len(f.Name())-5])
|
||||
}
|
||||
|
||||
return routes, nil
|
||||
}
|
||||
|
||||
func routePath(name string) string {
|
||||
return path.Join(os.ExpandEnv(storeLocation), name+".json")
|
||||
}
|
||||
|
Reference in New Issue
Block a user