forked from openfaas/faas-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for custom template paths to template store (refs openfaa…
…s#789) To support hosting templates within the directory structure of an existing project, we need to allow for custom paths to the root template directory instead of requiring a separate repo with a root level template directory. Signed-off-by: Justin Israel <[email protected]>
- Loading branch information
Showing
14 changed files
with
154 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ obj | |
*.swp | ||
|
||
.idea | ||
*.iml | ||
.DS_Store | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func Test_TemplateStoreDescribe(t *testing.T) { | ||
localTemplateRepository := setupLocalTemplateRepo(t, "") | ||
defer os.RemoveAll(localTemplateRepository) | ||
|
||
const templatePath = "path/to/template" | ||
nestedTemplateRepository := setupLocalTemplateRepo(t, templatePath) | ||
defer os.RemoveAll(nestedTemplateRepository) | ||
|
||
defer tearDownFetchTemplates(t) | ||
|
||
templateInfo := TemplateInfo{ | ||
TemplateName: "ruby", | ||
Platform: "x86_64", | ||
Language: "Ruby", | ||
Source: "openfaas", | ||
Description: "Classic Ruby 2.5 template", | ||
Repository: "https://github.com/openfaas/templates", | ||
Official: "true", | ||
} | ||
|
||
t.Run("simple", func(t *testing.T) { | ||
defer tearDownFetchTemplates(t) | ||
out := strings.TrimSpace(formatTemplateOutput(templateInfo)) | ||
expect := strings.TrimSpace(` | ||
Name: ruby | ||
Platform: x86_64 | ||
Language: Ruby | ||
Source: openfaas | ||
Description: Classic Ruby 2.5 template | ||
Repository: https://github.com/openfaas/templates | ||
Official Template: true | ||
`) | ||
if out != expect { | ||
t.Errorf("expected %q; got %q", expect, out) | ||
} | ||
}) | ||
|
||
t.Run("nested", func(t *testing.T) { | ||
defer tearDownFetchTemplates(t) | ||
|
||
templateInfo := templateInfo | ||
templateInfo.TemplatePath = templatePath | ||
out := strings.TrimSpace(formatTemplateOutput(templateInfo)) | ||
expect := strings.TrimSpace(fmt.Sprintf(` | ||
Name: ruby | ||
Platform: x86_64 | ||
Language: Ruby | ||
Source: openfaas | ||
Description: Classic Ruby 2.5 template | ||
Repository: https://github.com/openfaas/templates | ||
Path: %s | ||
Official Template: true | ||
`, templatePath)) | ||
|
||
if out != expect { | ||
t.Errorf("expected %q; got %q", expect, out) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters