aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/go-ini/ini/ini.go
diff options
context:
space:
mode:
authorappilon <apilon@hashicorp.com>2019-02-27 16:43:31 -0500
committerGitHub <noreply@github.com>2019-02-27 16:43:31 -0500
commit844b5a68d8af4791755b8f0ad293cc99f5959183 (patch)
tree255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/go-ini/ini/ini.go
parent303b299eeb6b06e939e35905e4b34cb410dd9dc3 (diff)
parent15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (diff)
downloadterraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.tar.gz
terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.tar.zst
terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.zip
Merge pull request #27 from terraform-providers/go-modules-2019-02-22
[MODULES] Switch to Go Modules
Diffstat (limited to 'vendor/github.com/go-ini/ini/ini.go')
-rw-r--r--vendor/github.com/go-ini/ini/ini.go54
1 files changed, 34 insertions, 20 deletions
diff --git a/vendor/github.com/go-ini/ini/ini.go b/vendor/github.com/go-ini/ini/ini.go
index 77e0dbd..68d73aa 100644
--- a/vendor/github.com/go-ini/ini/ini.go
+++ b/vendor/github.com/go-ini/ini/ini.go
@@ -37,7 +37,7 @@ const (
37 37
38 // Maximum allowed depth when recursively substituing variable names. 38 // Maximum allowed depth when recursively substituing variable names.
39 _DEPTH_VALUES = 99 39 _DEPTH_VALUES = 99
40 _VERSION = "1.23.1" 40 _VERSION = "1.25.4"
41) 41)
42 42
43// Version returns current package version literal. 43// Version returns current package version literal.
@@ -176,6 +176,8 @@ type LoadOptions struct {
176 // AllowBooleanKeys indicates whether to allow boolean type keys or treat as value is missing. 176 // AllowBooleanKeys indicates whether to allow boolean type keys or treat as value is missing.
177 // This type of keys are mostly used in my.cnf. 177 // This type of keys are mostly used in my.cnf.
178 AllowBooleanKeys bool 178 AllowBooleanKeys bool
179 // AllowShadows indicates whether to keep track of keys with same name under same section.
180 AllowShadows bool
179 // Some INI formats allow group blocks that store a block of raw content that doesn't otherwise 181 // Some INI formats allow group blocks that store a block of raw content that doesn't otherwise
180 // conform to key/value pairs. Specify the names of those blocks here. 182 // conform to key/value pairs. Specify the names of those blocks here.
181 UnparseableSections []string 183 UnparseableSections []string
@@ -219,6 +221,12 @@ func InsensitiveLoad(source interface{}, others ...interface{}) (*File, error) {
219 return LoadSources(LoadOptions{Insensitive: true}, source, others...) 221 return LoadSources(LoadOptions{Insensitive: true}, source, others...)
220} 222}
221 223
224// InsensitiveLoad has exactly same functionality as Load function
225// except it allows have shadow keys.
226func ShadowLoad(source interface{}, others ...interface{}) (*File, error) {
227 return LoadSources(LoadOptions{AllowShadows: true}, source, others...)
228}
229
222// Empty returns an empty file object. 230// Empty returns an empty file object.
223func Empty() *File { 231func Empty() *File {
224 // Ignore error here, we sure our data is good. 232 // Ignore error here, we sure our data is good.
@@ -441,6 +449,7 @@ func (f *File) WriteToIndent(w io.Writer, indent string) (n int64, err error) {
441 } 449 }
442 alignSpaces := bytes.Repeat([]byte(" "), alignLength) 450 alignSpaces := bytes.Repeat([]byte(" "), alignLength)
443 451
452 KEY_LIST:
444 for _, kname := range sec.keyList { 453 for _, kname := range sec.keyList {
445 key := sec.Key(kname) 454 key := sec.Key(kname)
446 if len(key.Comment) > 0 { 455 if len(key.Comment) > 0 {
@@ -467,28 +476,33 @@ func (f *File) WriteToIndent(w io.Writer, indent string) (n int64, err error) {
467 case strings.Contains(kname, "`"): 476 case strings.Contains(kname, "`"):
468 kname = `"""` + kname + `"""` 477 kname = `"""` + kname + `"""`
469 } 478 }
470 if _, err = buf.WriteString(kname); err != nil {
471 return 0, err
472 }
473 479
474 if key.isBooleanType { 480 for _, val := range key.ValueWithShadows() {
475 continue 481 if _, err = buf.WriteString(kname); err != nil {
476 } 482 return 0, err
483 }
477 484
478 // Write out alignment spaces before "=" sign 485 if key.isBooleanType {
479 if PrettyFormat { 486 if kname != sec.keyList[len(sec.keyList)-1] {
480 buf.Write(alignSpaces[:alignLength-len(kname)]) 487 buf.WriteString(LineBreak)
481 } 488 }
489 continue KEY_LIST
490 }
482 491
483 val := key.value 492 // Write out alignment spaces before "=" sign
484 // In case key value contains "\n", "`", "\"", "#" or ";" 493 if PrettyFormat {
485 if strings.ContainsAny(val, "\n`") { 494 buf.Write(alignSpaces[:alignLength-len(kname)])
486 val = `"""` + val + `"""` 495 }
487 } else if strings.ContainsAny(val, "#;") { 496
488 val = "`" + val + "`" 497 // In case key value contains "\n", "`", "\"", "#" or ";"
489 } 498 if strings.ContainsAny(val, "\n`") {
490 if _, err = buf.WriteString(equalSign + val + LineBreak); err != nil { 499 val = `"""` + val + `"""`
491 return 0, err 500 } else if strings.ContainsAny(val, "#;") {
501 val = "`" + val + "`"
502 }
503 if _, err = buf.WriteString(equalSign + val + LineBreak); err != nil {
504 return 0, err
505 }
492 } 506 }
493 } 507 }
494 508