From f426c152a935dd9d3e8624785fc6591c80720765 Mon Sep 17 00:00:00 2001 From: max furman Date: Fri, 12 Nov 2021 13:12:11 -0800 Subject: [PATCH] backwards compatibility for version of cli older than v0.18.0 --- authority/ssh.go | 7 +++++++ templates/templates.go | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/authority/ssh.go b/authority/ssh.go index 762319ae..da93acaf 100644 --- a/authority/ssh.go +++ b/authority/ssh.go @@ -101,6 +101,13 @@ func (a *Authority) GetSSHConfig(ctx context.Context, typ string, data map[strin if err != nil { return nil, err } + + // Backwards compatibility for version of the cli older than v0.18.0 + if o.Name == "step_includes.tpl" && (data == nil || data["Version"] != "v2") { + o.Type = templates.File + o.Path = strings.TrimPrefix(o.Path, "${STEPPATH}/") + } + output = append(output, o) } return output, nil diff --git a/templates/templates.go b/templates/templates.go index dee7aa5f..b18c176c 100644 --- a/templates/templates.go +++ b/templates/templates.go @@ -271,7 +271,8 @@ func (o *Output) Write() error { case PrependLine: return fileutil.PrependLine(path, o.Content, 0600) default: - return errors.Errorf("unexpected output template type %s", string(o.Type)) + // Default to using a Snippet type if the type is not known. + return fileutil.WriteSnippet(path, o.Content, 0600) } }