Make templates public.

This commit is contained in:
Mariano Cano 2019-11-04 18:30:03 -08:00 committed by max furman
parent 45d94fa4bd
commit 491286e2b8

View file

@ -11,9 +11,9 @@ import (
"github.com/smallstep/cli/utils" "github.com/smallstep/cli/utils"
) )
// sshTemplates contains the configuration of default templates used on ssh. // SSHTemplates contains the configuration of default templates used on ssh.
// Relative paths are relative to the StepPath. // Relative paths are relative to the StepPath.
var sshTemplates = &templates.SSHTemplates{ var SSHTemplates = &templates.SSHTemplates{
User: []templates.Template{ User: []templates.Template{
{Name: "include.tpl", Type: templates.Snippet, TemplatePath: "templates/ssh/include.tpl", Path: "~/.ssh/config", Comment: "#"}, {Name: "include.tpl", Type: templates.Snippet, TemplatePath: "templates/ssh/include.tpl", Path: "~/.ssh/config", Comment: "#"},
{Name: "config.tpl", Type: templates.File, TemplatePath: "templates/ssh/config.tpl", Path: "ssh/config", Comment: "#"}, {Name: "config.tpl", Type: templates.File, TemplatePath: "templates/ssh/config.tpl", Path: "ssh/config", Comment: "#"},
@ -25,8 +25,8 @@ var sshTemplates = &templates.SSHTemplates{
}, },
} }
// sshTemplateData contains the data of the default templates used on ssh. // SSHTemplateData contains the data of the default templates used on ssh.
var sshTemplateData = map[string]string{ var SSHTemplateData = map[string]string{
// include.tpl adds the step ssh config file // include.tpl adds the step ssh config file
"include.tpl": `Host * "include.tpl": `Host *
Include {{.User.StepPath}}/ssh/config`, Include {{.User.StepPath}}/ssh/config`,
@ -65,7 +65,7 @@ func (p *PKI) getTemplates() *templates.Templates {
} }
return &templates.Templates{ return &templates.Templates{
SSH: sshTemplates, SSH: SSHTemplates,
Data: map[string]interface{}{}, Data: map[string]interface{}{},
} }
} }
@ -88,7 +88,7 @@ func generateTemplates(t *templates.Templates) error {
} }
// Create all templates // Create all templates
for _, t := range t.SSH.User { for _, t := range t.SSH.User {
data, ok := sshTemplateData[t.Name] data, ok := SSHTemplateData[t.Name]
if !ok { if !ok {
return errors.Errorf("template %s does not exists", t.Name) return errors.Errorf("template %s does not exists", t.Name)
} }
@ -97,7 +97,7 @@ func generateTemplates(t *templates.Templates) error {
} }
} }
for _, t := range t.SSH.Host { for _, t := range t.SSH.Host {
data, ok := sshTemplateData[t.Name] data, ok := SSHTemplateData[t.Name]
if !ok { if !ok {
return errors.Errorf("template %s does not exists", t.Name) return errors.Errorf("template %s does not exists", t.Name)
} }