From 43b3af6fff9a5f2bc5f144e3d9db6bd61a3cb039 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Wed, 24 Mar 2021 15:03:05 -0700 Subject: [PATCH] init local route dir Signed-off-by: Sam Alba --- dagger/route.go | 22 ++++++++++++++++++---- go.mod | 1 + go.sum | 2 ++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/dagger/route.go b/dagger/route.go index 5d02e0db..5a9764fb 100644 --- a/dagger/route.go +++ b/dagger/route.go @@ -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 diff --git a/go.mod b/go.mod index e23764ae..c5d39008 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 90a59599..4275008e 100644 --- a/go.sum +++ b/go.sum @@ -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=