| 1 | package filesystemsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/" |
| 5 | "stringsscip-go gomod github.com/golang/go/src go1.13 strings/" |
| 6 | ) |
| 7 | |
| 8 | func buildPropertiesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems`/buildProperties().(input map[string]string) string { |
| 9 | // properties has to be a comma-separated key-value pair |
| 10 | properties := make([]string, 0) |
| 11 | |
| 12 | for k, v := range input { |
| 13 | properties = append(properties, fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("%s=%s", k, v)) |
| 14 | } |
| 15 | |
| 16 | return stringsscip-go gomod github.com/golang/go/src go1.13 strings/.Joinscip-go gomod github.com/golang/go/src go1.13 strings/Join().(properties, ",") |
| 17 | } |
| 18 | |
| 19 | func parsePropertiesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems`/parseProperties().(input string) (*map[string]string, error) { |
| 20 | properties := make(map[string]string) |
| 21 | if input == "" { |
| 22 | return &properties, nil |
| 23 | } |
| 24 | |
| 25 | // properties is a comma-separated list of key-value pairs |
| 26 | splitProperties := stringsscip-go gomod github.com/golang/go/src go1.13 strings/.Splitscip-go gomod github.com/golang/go/src go1.13 strings/Split().(input, ",") |
| 27 | for _, propertyRaw := range splitProperties { |
| 28 | // because these are base64-encoded they're likely to end in at least one = |
| 29 | // as such we can't string split on that -_- |
| 30 | position := stringsscip-go gomod github.com/golang/go/src go1.13 strings/.Indexscip-go gomod github.com/golang/go/src go1.13 strings/Index().(propertyRaw, "=") |
| 31 | if position < 0 { |
| 32 | return nil, fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("Expected there to be an equals in the key value pair: %q", propertyRaw) |
| 33 | } |
| 34 | |
| 35 | key := propertyRaw[0:position] |
| 36 | value := propertyRaw[position+1:] |
| 37 | properties[key] = value |
| 38 | } |
| 39 | return &properties, nil |
| 40 | } |