Skip to content
This repository has been archived by the owner on Mar 10, 2023. It is now read-only.

Commit

Permalink
Follow up #264 (Add support for custom templates)
Browse files Browse the repository at this point in the history
This addresses pull #264 comments

Signed-off-by: Ivana Yovcheva <iyovcheva@vmware.com>
  • Loading branch information
ivanayov authored and alexellis committed Oct 30, 2018
1 parent 5f7f4c9 commit e854b7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
5 changes: 3 additions & 2 deletions gateway_config.yml
Expand Up @@ -6,8 +6,9 @@ environment:
audit_url: http://gateway.openfaas:8080/function/audit-event
# Remove gateway_pretty_url if not using pretty URL
gateway_pretty_url: https://user.o6s.io/function
# Comment out for custom templates and separate URLs using unicode.IsSpace
# custom_templates: "https://github.com/custom/template.git, https://github.com/custom/template2.git"
# Add your custom templates by adding a coma separated URL, i.e. extend the current value with:
# ", https://github.com/custom/template.git, https://github.com/custom/template2.git"
custom_templates: "https://github.com/openfaas-incubator/node8-express-template.git, https://github.com/openfaas-incubator/golang-http-template.git"

# Security
customers_url: "https://raw.githubusercontent.com/openfaas/openfaas-cloud/master/CUSTOMERS"
Expand Down
22 changes: 8 additions & 14 deletions git-tar/function/ops.go
Expand Up @@ -488,24 +488,18 @@ func importSecrets(pushEvent sdk.PushEvent, stack *stack.Services, clonePath str
return nil
}

// getShortSHA returns shorter version of git commit SHA
func getShortSHA(sha string) string {
if len(sha) <= 7 {
return sha
}
return sha[:7]
}

func formatTemplateRepos() []string {
templateRepos := []string{"https://github.com/openfaas/templates",
"https://github.com/openfaas-incubator/node8-express-template.git",
"https://github.com/openfaas-incubator/golang-http-template.git"}
templateRepos := []string{"https://github.com/openfaas/templates"}

if envTemplates := os.Getenv("custom_templates"); len(envTemplates) > 0 && strings.Contains(envTemplates, "https://") {
if envTemplates := os.Getenv("custom_templates"); len(envTemplates) > 0 {
customTemplates := strings.Split(envTemplates, ",")
for _, repo := range customTemplates {
repo = strings.Trim(repo, " ")
templateRepos = append(templateRepos, repo)
if strings.Contains(envTemplates, "https://") || strings.Contains(envTemplates, "http://") {
repo = strings.Trim(repo, " ")
templateRepos = append(templateRepos, repo)
} else {
fmt.Println("Non-valid template URL is configured in custom_templates: ", repo)
}
}
}
return templateRepos
Expand Down

0 comments on commit e854b7e

Please sign in to comment.