Skip to content

Commit 9832d15

Browse files
committed
Avoid nil pointer panic on step ssh config with no templates.
1 parent 91bf745 commit 9832d15

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

authority/ssh.go

+4
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ func (a *Authority) GetSSHConfig(ctx context.Context, typ string, data map[strin
125125
return nil, errs.NotFound("getSSHConfig: ssh is not configured")
126126
}
127127

128+
if a.config.Templates == nil {
129+
return nil, errs.NotFound("getSSHConfig: ssh templates are not configured")
130+
}
131+
128132
var ts []templates.Template
129133
switch typ {
130134
case provisioner.SSHUserCert:

authority/ssh_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ func TestAuthority_GetSSHConfig(t *testing.T) {
455455
{"badType", fields{tmplConfig, userSigner, hostSigner}, args{"bad", nil}, nil, true},
456456
{"userError", fields{tmplConfigErr, userSigner, hostSigner}, args{"user", nil}, nil, true},
457457
{"hostError", fields{tmplConfigErr, userSigner, hostSigner}, args{"host", map[string]string{"Function": "foo"}}, nil, true},
458+
{"noTemplates", fields{nil, userSigner, hostSigner}, args{"user", nil}, nil, true},
458459
}
459460
for _, tt := range tests {
460461
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)