Update github.com/xenolf/lego to 0.4.1
This commit is contained in:
parent
5042c5bf40
commit
e8d63b2a3b
105 changed files with 4299 additions and 2075 deletions
78
vendor/gopkg.in/ini.v1/ini.go
generated
vendored
78
vendor/gopkg.in/ini.v1/ini.go
generated
vendored
|
@ -24,10 +24,8 @@ import (
|
|||
"os"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -37,7 +35,7 @@ const (
|
|||
|
||||
// Maximum allowed depth when recursively substituing variable names.
|
||||
_DEPTH_VALUES = 99
|
||||
_VERSION = "1.27.0"
|
||||
_VERSION = "1.30.0"
|
||||
)
|
||||
|
||||
// Version returns current package version literal.
|
||||
|
@ -60,6 +58,9 @@ var (
|
|||
|
||||
// Explicitly write DEFAULT section header
|
||||
DefaultHeader = false
|
||||
|
||||
// Indicate whether to put a line between sections
|
||||
PrettySection = true
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -180,6 +181,8 @@ type LoadOptions struct {
|
|||
AllowBooleanKeys bool
|
||||
// AllowShadows indicates whether to keep track of keys with same name under same section.
|
||||
AllowShadows bool
|
||||
// UnescapeValueDoubleQuotes indicates whether to unescape double quotes inside value to regular format when value is surrounded by double quotes, e.g. key="a \"value\"" => key=a "value"
|
||||
UnescapeValueDoubleQuotes bool
|
||||
// Some INI formats allow group blocks that store a block of raw content that doesn't otherwise
|
||||
// conform to key/value pairs. Specify the names of those blocks here.
|
||||
UnparseableSections []string
|
||||
|
@ -395,10 +398,7 @@ func (f *File) Append(source interface{}, others ...interface{}) error {
|
|||
return f.Reload()
|
||||
}
|
||||
|
||||
// WriteToIndent writes content into io.Writer with given indention.
|
||||
// If PrettyFormat has been set to be true,
|
||||
// it will align "=" sign with spaces under each section.
|
||||
func (f *File) WriteToIndent(w io.Writer, indent string) (n int64, err error) {
|
||||
func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
|
||||
equalSign := "="
|
||||
if PrettyFormat {
|
||||
equalSign = " = "
|
||||
|
@ -411,15 +411,17 @@ func (f *File) WriteToIndent(w io.Writer, indent string) (n int64, err error) {
|
|||
if len(sec.Comment) > 0 {
|
||||
if sec.Comment[0] != '#' && sec.Comment[0] != ';' {
|
||||
sec.Comment = "; " + sec.Comment
|
||||
} else {
|
||||
sec.Comment = sec.Comment[:1] + " " + strings.TrimSpace(sec.Comment[1:])
|
||||
}
|
||||
if _, err = buf.WriteString(sec.Comment + LineBreak); err != nil {
|
||||
return 0, err
|
||||
if _, err := buf.WriteString(sec.Comment + LineBreak); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if i > 0 || DefaultHeader {
|
||||
if _, err = buf.WriteString("[" + sname + "]" + LineBreak); err != nil {
|
||||
return 0, err
|
||||
if _, err := buf.WriteString("[" + sname + "]" + LineBreak); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// Write nothing if default section is empty
|
||||
|
@ -429,8 +431,8 @@ func (f *File) WriteToIndent(w io.Writer, indent string) (n int64, err error) {
|
|||
}
|
||||
|
||||
if sec.isRawSection {
|
||||
if _, err = buf.WriteString(sec.rawBody); err != nil {
|
||||
return 0, err
|
||||
if _, err := buf.WriteString(sec.rawBody); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
@ -465,9 +467,11 @@ func (f *File) WriteToIndent(w io.Writer, indent string) (n int64, err error) {
|
|||
}
|
||||
if key.Comment[0] != '#' && key.Comment[0] != ';' {
|
||||
key.Comment = "; " + key.Comment
|
||||
} else {
|
||||
key.Comment = key.Comment[:1] + " " + strings.TrimSpace(key.Comment[1:])
|
||||
}
|
||||
if _, err = buf.WriteString(key.Comment + LineBreak); err != nil {
|
||||
return 0, err
|
||||
if _, err := buf.WriteString(key.Comment + LineBreak); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,8 +489,8 @@ func (f *File) WriteToIndent(w io.Writer, indent string) (n int64, err error) {
|
|||
}
|
||||
|
||||
for _, val := range key.ValueWithShadows() {
|
||||
if _, err = buf.WriteString(kname); err != nil {
|
||||
return 0, err
|
||||
if _, err := buf.WriteString(kname); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if key.isBooleanType {
|
||||
|
@ -504,21 +508,34 @@ func (f *File) WriteToIndent(w io.Writer, indent string) (n int64, err error) {
|
|||
// In case key value contains "\n", "`", "\"", "#" or ";"
|
||||
if strings.ContainsAny(val, "\n`") {
|
||||
val = `"""` + val + `"""`
|
||||
} else if strings.ContainsAny(val, "#;") {
|
||||
} else if !f.options.IgnoreInlineComment && strings.ContainsAny(val, "#;") {
|
||||
val = "`" + val + "`"
|
||||
}
|
||||
if _, err = buf.WriteString(equalSign + val + LineBreak); err != nil {
|
||||
return 0, err
|
||||
if _, err := buf.WriteString(equalSign + val + LineBreak); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Put a line between sections
|
||||
if _, err = buf.WriteString(LineBreak); err != nil {
|
||||
return 0, err
|
||||
if PrettySection {
|
||||
// Put a line between sections
|
||||
if _, err := buf.WriteString(LineBreak); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
// WriteToIndent writes content into io.Writer with given indention.
|
||||
// If PrettyFormat has been set to be true,
|
||||
// it will align "=" sign with spaces under each section.
|
||||
func (f *File) WriteToIndent(w io.Writer, indent string) (int64, error) {
|
||||
buf, err := f.writeToBuffer(indent)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return buf.WriteTo(w)
|
||||
}
|
||||
|
||||
|
@ -531,23 +548,12 @@ func (f *File) WriteTo(w io.Writer) (int64, error) {
|
|||
func (f *File) SaveToIndent(filename, indent string) error {
|
||||
// Note: Because we are truncating with os.Create,
|
||||
// so it's safer to save to a temporary file location and rename afte done.
|
||||
tmpPath := filename + "." + strconv.Itoa(time.Now().Nanosecond()) + ".tmp"
|
||||
defer os.Remove(tmpPath)
|
||||
|
||||
fw, err := os.Create(tmpPath)
|
||||
buf, err := f.writeToBuffer(indent)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err = f.WriteToIndent(fw, indent); err != nil {
|
||||
fw.Close()
|
||||
return err
|
||||
}
|
||||
fw.Close()
|
||||
|
||||
// Remove old file and rename the new one.
|
||||
os.Remove(filename)
|
||||
return os.Rename(tmpPath, filename)
|
||||
return ioutil.WriteFile(filename, buf.Bytes(), 0666)
|
||||
}
|
||||
|
||||
// SaveTo writes content to file system.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue