init local route dir

Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
Sam Alba 2021-03-24 15:03:05 -07:00 committed by Solomon Hykes
parent 7bf05d3cc9
commit 43b3af6fff
3 changed files with 21 additions and 4 deletions

View File

@ -2,24 +2,38 @@ package dagger
import (
"context"
"os"
"dagger.io/go/dagger/compiler"
"github.com/google/uuid"
)
const (
routeLocation = "$HOME/.config/dagger/routes"
)
func init() {
f := os.ExpandEnv(routeLocation)
if err := os.MkdirAll(f, 0755); err != nil {
panic(err)
}
}
// A deployment route
type Route struct {
st routeState
}
func (r Route) ID() string {
func (r *Route) ID() string {
return r.st.ID
}
func (r Route) Name() string {
func (r *Route) Name() string {
return r.st.Name
}
func (r Route) LayoutSource() Input {
func (r *Route) LayoutSource() Input {
return r.st.LayoutSource
}
@ -65,7 +79,7 @@ type inputKV struct {
func CreateRoute(ctx context.Context, name string, o *CreateOpts) (*Route, error) {
return &Route{
st: routeState{
ID: "FIXME",
ID: uuid.New().String(),
Name: name,
},
}, nil

1
go.mod
View File

@ -8,6 +8,7 @@ require (
github.com/containerd/console v1.0.1
github.com/docker/distribution v2.7.1+incompatible
github.com/emicklei/proto v1.9.0 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/jaguilar/vt100 v0.0.0-20150826170717-2703a27b14ea
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
github.com/moby/buildkit v0.8.2

2
go.sum
View File

@ -659,6 +659,8 @@ github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/wire v0.3.0/go.mod h1:i1DMg/Lu8Sz5yYl25iOdmc5CT5qusaa+zmRWs16741s=
github.com/google/wire v0.4.0 h1:kXcsA/rIGzJImVqPdhfnr6q0xsS9gU0515q1EPpJ9fE=
github.com/google/wire v0.4.0/go.mod h1:ngWDr9Qvq3yZA10YrxfyGELY/AFWGVpy9c1LTRi1EoU=