Explorar el Código

Update includes template to use STEPPATH as the replace var

max furman hace 5 años
padre
commit
9d4a7cf9fc
Se han modificado 2 ficheros con 10 adiciones y 7 borrados
  1. 3 0
      templates/templates.go
  2. 7 7
      templates/values.go

+ 3 - 0
templates/templates.go

@@ -249,6 +249,9 @@ type Output struct {
 
 
 // Write writes the Output to the filesystem as a directory, file or snippet.
 // Write writes the Output to the filesystem as a directory, file or snippet.
 func (o *Output) Write() error {
 func (o *Output) Write() error {
+	// Replace ${STEPPATH} with the base step path.
+	o.Path = strings.Replace(o.Path, "${STEPPATH}", step.BasePath(), -1)
+
 	path := step.Abs(o.Path)
 	path := step.Abs(o.Path)
 	if o.Type == Directory {
 	if o.Type == Directory {
 		return mkdir(path, 0700)
 		return mkdir(path, 0700)

+ 7 - 7
templates/values.go

@@ -29,10 +29,10 @@ var DefaultSSHTemplates = SSHTemplates{
 			Comment:      "#",
 			Comment:      "#",
 		},
 		},
 		{
 		{
-			Name:         "include.tpl",
+			Name:         "includes.tpl",
 			Type:         Line,
 			Type:         Line,
-			TemplatePath: "templates/ssh/include.tpl",
-			Path:         "~/.ssh/include",
+			TemplatePath: "templates/ssh/includes.tpl",
+			Path:         "${STEPPATH}/ssh/includes",
 			Comment:      "#",
 			Comment:      "#",
 		},
 		},
 		{
 		{
@@ -77,22 +77,22 @@ var DefaultSSHTemplateData = map[string]string{
 	"base_config.tpl": `Host *
 	"base_config.tpl": `Host *
 {{- if or .User.GOOS "none" | eq "windows" }}
 {{- if or .User.GOOS "none" | eq "windows" }}
 {{- if .User.Authority }}
 {{- if .User.Authority }}
-	Include "{{ .User.Home | replace "\\" "/" | trimPrefix "C:" }}/.ssh/include"
+	Include "{{ .User.StepBasePath | replace "\\" "/" | trimPrefix "C:" }}/ssh/includes"
 {{- else }}
 {{- else }}
 	Include "{{ .User.StepPath | replace "\\" "/" | trimPrefix "C:" }}/ssh/config"
 	Include "{{ .User.StepPath | replace "\\" "/" | trimPrefix "C:" }}/ssh/config"
 {{- end }}
 {{- end }}
 {{- else }}
 {{- else }}
 {{- if .User.Authority }}
 {{- if .User.Authority }}
-	Include "{{.User.Home}}/.ssh/include"
+	Include "{{.User.StepBasePath}}/ssh/includes"
 {{- else }}
 {{- else }}
 	Include "{{.User.StepPath}}/ssh/config"
 	Include "{{.User.StepPath}}/ssh/config"
 {{- end }}
 {{- end }}
 {{- end }}`,
 {{- end }}`,
 
 
-	// include.tpl adds the step ssh config file.
+	// includes.tpl adds the step ssh config file.
 	//
 	//
 	// Note: on windows `Include C:\...` is treated as a relative path.
 	// Note: on windows `Include C:\...` is treated as a relative path.
-	"include.tpl": `{{- if or .User.GOOS "none" | eq "windows" }}Include "{{ .User.StepPath | replace "\\" "/" | trimPrefix "C:" }}/ssh/config"{{- else }}Include "{{.User.StepPath}}/ssh/config"{{- end }}`,
+	"includes.tpl": `{{- if or .User.GOOS "none" | eq "windows" }}Include "{{ .User.StepPath | replace "\\" "/" | trimPrefix "C:" }}/ssh/config"{{- else }}Include "{{.User.StepPath}}/ssh/config"{{- end }}`,
 
 
 	// config.tpl is the step ssh config file, it includes the Match rule and
 	// config.tpl is the step ssh config file, it includes the Match rule and
 	// references the step known_hosts file.
 	// references the step known_hosts file.