diff --git a/go.mod b/go.mod index 3b7c0f3a..346e0102 100644 --- a/go.mod +++ b/go.mod @@ -49,5 +49,3 @@ require ( //replace go.step.sm/crypto => ../crypto replace go.step.sm/cli-utils => ../cli-utils - -replace go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1 => github.com/omorsi/pkcs7 v0.0.0-20210217142924-a7b80a2a8568 diff --git a/templates/templates.go b/templates/templates.go index aa77a2ff..bfc5b596 100644 --- a/templates/templates.go +++ b/templates/templates.go @@ -20,8 +20,8 @@ type TemplateType string const ( // Snippet will mark a template as a part of a file. Snippet TemplateType = "snippet" - // FullSnippet will mark a template that includes header and footer as a part of a file. - FullSnippet TemplateType = "fullSnippet" + // Fragment will mark a template that includes header and footer as a part of a file. + Fragment TemplateType = "fragment" // File will mark a templates as a full file. File TemplateType = "file" // Directory will mark a template as a directory. @@ -120,8 +120,8 @@ func (t *Template) Validate() error { return nil case t.Name == "": return errors.New("template name cannot be empty") - case t.Type != Snippet && t.Type != File && t.Type != Directory && t.Type != FullSnippet: - return errors.Errorf("invalid template type %s, it must be %s, %s, %s, or %s", t.Type, Snippet, FullSnippet, File, Directory) + case t.Type != Snippet && t.Type != File && t.Type != Directory && t.Type != Fragment: + return errors.Errorf("invalid template type %s, it must be %s, %s, %s, or %s", t.Type, Snippet, Fragment, File, Directory) case t.TemplatePath == "" && t.Type != Directory && len(t.Content) == 0: return errors.New("template template cannot be empty") case t.TemplatePath != "" && t.Type == Directory: @@ -264,9 +264,9 @@ func (o *Output) Write() error { return fileutil.WriteFile(path, o.Content, 0600) case Snippet: return fileutil.WriteSnippet(path, o.Content, 0600) - case FullSnippet: + case Fragment: lines := strings.Split(string(o.Content), "\n") - return fileutil.WriteFullSnippet(path, o.Content, lines[0], lines[len(lines)-1], 0600) + return fileutil.WriteFragment(path, o.Content, lines[0], lines[len(lines)-1], 0600) default: return errors.Errorf("unexpected output template type %s", string(o.Type)) } diff --git a/templates/values.go b/templates/values.go index 0117cf52..3749f9f0 100644 --- a/templates/values.go +++ b/templates/values.go @@ -23,7 +23,7 @@ var DefaultSSHTemplates = SSHTemplates{ User: []Template{ { Name: "include.tpl", - Type: FullSnippet, + Type: Fragment, TemplatePath: "templates/ssh/include.tpl", Path: "~/.ssh/config", Comment: "#",