Skip to content

Commit

Permalink
Merge branch '3-arguments-and-artifacts'
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Hale <[email protected]>
  • Loading branch information
nebhale committed May 11, 2020
2 parents 77d0788 + f20c372 commit 1c1e78b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
6 changes: 5 additions & 1 deletion application.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ func NewApplication(applicationPath string, arguments []string, artifactResolver
if err != nil {
return Application{}, fmt.Errorf("unable to create file listing for %s\n%w", applicationPath, err)
}
expected := map[string][]sherpa.FileEntry{"files": l}
expected := map[string]interface{}{
"files": l,
"arguments": arguments,
"artifact-pattern": artifactResolver.Pattern(),
}

return Application{
ApplicationPath: applicationPath,
Expand Down
19 changes: 13 additions & 6 deletions resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,21 @@ type ArtifactResolver struct {
InterestingFileDetector InterestingFileDetector
}

// Resolve resolves the artifact that was created by the build system.
func (a *ArtifactResolver) Resolve(applicationPath string) (string, error) {
// Pattern returns the glob that ArtifactResolver will use for resolution.
func (a *ArtifactResolver) Pattern() string {
pattern, ok := a.ConfigurationResolver.Resolve(a.ArtifactConfigurationKey)
if !ok {
if s, ok := a.ConfigurationResolver.Resolve(a.ModuleConfigurationKey); ok {
pattern = filepath.Join(s, pattern)
}
if ok {
return pattern
}
if module, ok := a.ConfigurationResolver.Resolve(a.ModuleConfigurationKey); ok {
return filepath.Join(module, pattern)
}
return pattern
}

// Resolve resolves the artifact that was created by the build system.
func (a *ArtifactResolver) Resolve(applicationPath string) (string, error) {
pattern := a.Pattern()

file := filepath.Join(applicationPath, pattern)
candidates, err := filepath.Glob(file)
Expand Down

0 comments on commit 1c1e78b

Please sign in to comment.