Просмотр исходного кода

Use a more distint map key to indicate template version

- make the key a variable that can be reused on the CLI side.
max furman 5 лет назад
Родитель
Сommit
507be61e8c
2 измененных файлов с 5 добавлено и 1 удалено
  1. 1 1
      authority/ssh.go
  2. 4 0
      templates/values.go

+ 1 - 1
authority/ssh.go

@@ -103,7 +103,7 @@ func (a *Authority) GetSSHConfig(ctx context.Context, typ string, data map[strin
 		}
 
 		// Backwards compatibility for version of the cli older than v0.18.0
-		if o.Name == "step_includes.tpl" && (data == nil || data["Version"] != "v2") {
+		if o.Name == "step_includes.tpl" && (data == nil || data[templates.SSHTemplateVersionKey] != "v2") {
 			o.Type = templates.File
 			o.Path = strings.TrimPrefix(o.Path, "${STEPPATH}/")
 		}

+ 4 - 0
templates/values.go

@@ -4,6 +4,10 @@ import (
 	"golang.org/x/crypto/ssh"
 )
 
+// SSHTemplateVersionKey is a key that can be submitted by a client to select
+// the template version that will be returned by the server.
+var SSHTemplateVersionKey = "StepSSHTemplateVersion"
+
 // Step represents the default variables available in the CA.
 type Step struct {
 	SSH StepSSH