Skip to content

Commit

Permalink
some apply tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhuber committed Aug 4, 2023
1 parent c27e306 commit be4bd38
Show file tree
Hide file tree
Showing 9 changed files with 337 additions and 274 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/onsi/ginkgo/v2 v2.9.2
github.com/onsi/gomega v1.27.4
github.com/patrickhuber/go-di v0.5.2
github.com/patrickhuber/go-xplat v0.2.15
github.com/patrickhuber/go-xplat v0.3.0
github.com/urfave/cli/v2 v2.23.4
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ github.com/patrickhuber/go-xplat v0.2.14 h1:RR3C9YbJ02XeS6CXrqRiSUor+W2UxOENnHr+
github.com/patrickhuber/go-xplat v0.2.14/go.mod h1:ZveaAmQiWcZO0nWACUrbylAF+BbGwEXdVqM3ZoEOxA4=
github.com/patrickhuber/go-xplat v0.2.15 h1:qEqPqjmLp0yqHFCWqE+s41ni55JKs0DhHbK3Mt6xZFo=
github.com/patrickhuber/go-xplat v0.2.15/go.mod h1:ZveaAmQiWcZO0nWACUrbylAF+BbGwEXdVqM3ZoEOxA4=
github.com/patrickhuber/go-xplat v0.2.16 h1:Km8ErsoTq3lbC5Gm65JxYW/sl290jul1+4fLuPp8QeE=
github.com/patrickhuber/go-xplat v0.2.16/go.mod h1:ZveaAmQiWcZO0nWACUrbylAF+BbGwEXdVqM3ZoEOxA4=
github.com/patrickhuber/go-xplat v0.3.0 h1:Q7lFw5HqkljVX4+V4QdyI9T4MfoDcx0ZVF+qhKP4fpM=
github.com/patrickhuber/go-xplat v0.3.0/go.mod h1:ZveaAmQiWcZO0nWACUrbylAF+BbGwEXdVqM3ZoEOxA4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
Expand Down
10 changes: 0 additions & 10 deletions internal/cast/models.go

This file was deleted.

21 changes: 15 additions & 6 deletions internal/cast/service.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package cast

import (
"fmt"
"strings"

"github.com/patrickhuber/caster/internal/interpolate"
"github.com/patrickhuber/caster/internal/models"
"github.com/patrickhuber/go-xplat/filepath"
afs "github.com/patrickhuber/go-xplat/fs"
)

// Request is the request object for casting a template
type Request struct {
Template string
Target string
Variables []models.Variable
}

// Service handles casting of a template
type Service interface {
Cast(req *Request) error
Expand Down Expand Up @@ -50,10 +54,15 @@ func (s *service) Cast(req *Request) error {
return err
}

targetIsSpecified := len(strings.TrimSpace(req.Target)) != 0
// if no target directory specified, use the local directory
if len(req.Target) == 0 {
req.Target = "."
}

if !targetIsSpecified {
return fmt.Errorf("target must be specified")
// resolve relative paths
req.Target, err = s.path.Abs(req.Target)
if err != nil {
return err
}

source := s.path.Dir(resp.SourceFile)
Expand Down
Loading

0 comments on commit be4bd38

Please sign in to comment.