aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/aws/aws-sdk-go/aws/awsutil
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/aws/awsutil')
-rw-r--r--vendor/github.com/aws/aws-sdk-go/aws/awsutil/copy.go108
-rw-r--r--vendor/github.com/aws/aws-sdk-go/aws/awsutil/equal.go27
-rw-r--r--vendor/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go222
-rw-r--r--vendor/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go113
-rw-r--r--vendor/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go89
5 files changed, 0 insertions, 559 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/copy.go b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/copy.go
deleted file mode 100644
index 1a3d106..0000000
--- a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/copy.go
+++ /dev/null
@@ -1,108 +0,0 @@
-package awsutil
-
-import (
- "io"
- "reflect"
- "time"
-)
-
-// Copy deeply copies a src structure to dst. Useful for copying request and
-// response structures.
-//
-// Can copy between structs of different type, but will only copy fields which
-// are assignable, and exist in both structs. Fields which are not assignable,
-// or do not exist in both structs are ignored.
-func Copy(dst, src interface{}) {
- dstval := reflect.ValueOf(dst)
- if !dstval.IsValid() {
- panic("Copy dst cannot be nil")
- }
-
- rcopy(dstval, reflect.ValueOf(src), true)
-}
-
-// CopyOf returns a copy of src while also allocating the memory for dst.
-// src must be a pointer type or this operation will fail.
-func CopyOf(src interface{}) (dst interface{}) {
- dsti := reflect.New(reflect.TypeOf(src).Elem())
- dst = dsti.Interface()
- rcopy(dsti, reflect.ValueOf(src), true)
- return
-}
-
-// rcopy performs a recursive copy of values from the source to destination.
-//
-// root is used to skip certain aspects of the copy which are not valid
-// for the root node of a object.
-func rcopy(dst, src reflect.Value, root bool) {
- if !src.IsValid() {
- return
- }
-
- switch src.Kind() {
- case reflect.Ptr:
- if _, ok := src.Interface().(io.Reader); ok {
- if dst.Kind() == reflect.Ptr && dst.Elem().CanSet() {
- dst.Elem().Set(src)
- } else if dst.CanSet() {
- dst.Set(src)
- }
- } else {
- e := src.Type().Elem()
- if dst.CanSet() && !src.IsNil() {
- if _, ok := src.Interface().(*time.Time); !ok {
- dst.Set(reflect.New(e))
- } else {
- tempValue := reflect.New(e)
- tempValue.Elem().Set(src.Elem())
- // Sets time.Time's unexported values
- dst.Set(tempValue)
- }
- }
- if src.Elem().IsValid() {
- // Keep the current root state since the depth hasn't changed
- rcopy(dst.Elem(), src.Elem(), root)
- }
- }
- case reflect.Struct:
- t := dst.Type()
- for i := 0; i < t.NumField(); i++ {
- name := t.Field(i).Name
- srcVal := src.FieldByName(name)
- dstVal := dst.FieldByName(name)
- if srcVal.IsValid() && dstVal.CanSet() {
- rcopy(dstVal, srcVal, false)
- }
- }
- case reflect.Slice:
- if src.IsNil() {
- break
- }
-
- s := reflect.MakeSlice(src.Type(), src.Len(), src.Cap())
- dst.Set(s)
- for i := 0; i < src.Len(); i++ {
- rcopy(dst.Index(i), src.Index(i), false)
- }
- case reflect.Map:
- if src.IsNil() {
- break
- }
-
- s := reflect.MakeMap(src.Type())
- dst.Set(s)
- for _, k := range src.MapKeys() {
- v := src.MapIndex(k)
- v2 := reflect.New(v.Type()).Elem()
- rcopy(v2, v, false)
- dst.SetMapIndex(k, v2)
- }
- default:
- // Assign the value if possible. If its not assignable, the value would
- // need to be converted and the impact of that may be unexpected, or is
- // not compatible with the dst type.
- if src.Type().AssignableTo(dst.Type()) {
- dst.Set(src)
- }
- }
-}
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/equal.go b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/equal.go
deleted file mode 100644
index 59fa4a5..0000000
--- a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/equal.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package awsutil
-
-import (
- "reflect"
-)
-
-// DeepEqual returns if the two values are deeply equal like reflect.DeepEqual.
-// In addition to this, this method will also dereference the input values if
-// possible so the DeepEqual performed will not fail if one parameter is a
-// pointer and the other is not.
-//
-// DeepEqual will not perform indirection of nested values of the input parameters.
-func DeepEqual(a, b interface{}) bool {
- ra := reflect.Indirect(reflect.ValueOf(a))
- rb := reflect.Indirect(reflect.ValueOf(b))
-
- if raValid, rbValid := ra.IsValid(), rb.IsValid(); !raValid && !rbValid {
- // If the elements are both nil, and of the same type the are equal
- // If they are of different types they are not equal
- return reflect.TypeOf(a) == reflect.TypeOf(b)
- } else if raValid != rbValid {
- // Both values must be valid to be equal
- return false
- }
-
- return reflect.DeepEqual(ra.Interface(), rb.Interface())
-}
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go
deleted file mode 100644
index 11c52c3..0000000
--- a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go
+++ /dev/null
@@ -1,222 +0,0 @@
-package awsutil
-
-import (
- "reflect"
- "regexp"
- "strconv"
- "strings"
-
- "github.com/jmespath/go-jmespath"
-)
-
-var indexRe = regexp.MustCompile(`(.+)\[(-?\d+)?\]$`)
-
-// rValuesAtPath returns a slice of values found in value v. The values
-// in v are explored recursively so all nested values are collected.
-func rValuesAtPath(v interface{}, path string, createPath, caseSensitive, nilTerm bool) []reflect.Value {
- pathparts := strings.Split(path, "||")
- if len(pathparts) > 1 {
- for _, pathpart := range pathparts {
- vals := rValuesAtPath(v, pathpart, createPath, caseSensitive, nilTerm)
- if len(vals) > 0 {
- return vals
- }
- }
- return nil
- }
-
- values := []reflect.Value{reflect.Indirect(reflect.ValueOf(v))}
- components := strings.Split(path, ".")
- for len(values) > 0 && len(components) > 0 {
- var index *int64
- var indexStar bool
- c := strings.TrimSpace(components[0])
- if c == "" { // no actual component, illegal syntax
- return nil
- } else if caseSensitive && c != "*" && strings.ToLower(c[0:1]) == c[0:1] {
- // TODO normalize case for user
- return nil // don't support unexported fields
- }
-
- // parse this component
- if m := indexRe.FindStringSubmatch(c); m != nil {
- c = m[1]
- if m[2] == "" {
- index = nil
- indexStar = true
- } else {
- i, _ := strconv.ParseInt(m[2], 10, 32)
- index = &i
- indexStar = false
- }
- }
-
- nextvals := []reflect.Value{}
- for _, value := range values {
- // pull component name out of struct member
- if value.Kind() != reflect.Struct {
- continue
- }
-
- if c == "*" { // pull all members
- for i := 0; i < value.NumField(); i++ {
- if f := reflect.Indirect(value.Field(i)); f.IsValid() {
- nextvals = append(nextvals, f)
- }
- }
- continue
- }
-
- value = value.FieldByNameFunc(func(name string) bool {
- if c == name {
- return true
- } else if !caseSensitive && strings.ToLower(name) == strings.ToLower(c) {
- return true
- }
- return false
- })
-
- if nilTerm && value.Kind() == reflect.Ptr && len(components[1:]) == 0 {
- if !value.IsNil() {
- value.Set(reflect.Zero(value.Type()))
- }
- return []reflect.Value{value}
- }
-
- if createPath && value.Kind() == reflect.Ptr && value.IsNil() {
- // TODO if the value is the terminus it should not be created
- // if the value to be set to its position is nil.
- value.Set(reflect.New(value.Type().Elem()))
- value = value.Elem()
- } else {
- value = reflect.Indirect(value)
- }
-
- if value.Kind() == reflect.Slice || value.Kind() == reflect.Map {
- if !createPath && value.IsNil() {
- value = reflect.ValueOf(nil)
- }
- }
-
- if value.IsValid() {
- nextvals = append(nextvals, value)
- }
- }
- values = nextvals
-
- if indexStar || index != nil {
- nextvals = []reflect.Value{}
- for _, valItem := range values {
- value := reflect.Indirect(valItem)
- if value.Kind() != reflect.Slice {
- continue
- }
-
- if indexStar { // grab all indices
- for i := 0; i < value.Len(); i++ {
- idx := reflect.Indirect(value.Index(i))
- if idx.IsValid() {
- nextvals = append(nextvals, idx)
- }
- }
- continue
- }
-
- // pull out index
- i := int(*index)
- if i >= value.Len() { // check out of bounds
- if createPath {
- // TODO resize slice
- } else {
- continue
- }
- } else if i < 0 { // support negative indexing
- i = value.Len() + i
- }
- value = reflect.Indirect(value.Index(i))
-
- if value.Kind() == reflect.Slice || value.Kind() == reflect.Map {
- if !createPath && value.IsNil() {
- value = reflect.ValueOf(nil)
- }
- }
-
- if value.IsValid() {
- nextvals = append(nextvals, value)
- }
- }
- values = nextvals
- }
-
- components = components[1:]
- }
- return values
-}
-
-// ValuesAtPath returns a list of values at the case insensitive lexical
-// path inside of a structure.
-func ValuesAtPath(i interface{}, path string) ([]interface{}, error) {
- result, err := jmespath.Search(path, i)
- if err != nil {
- return nil, err
- }
-
- v := reflect.ValueOf(result)
- if !v.IsValid() || (v.Kind() == reflect.Ptr && v.IsNil()) {
- return nil, nil
- }
- if s, ok := result.([]interface{}); ok {
- return s, err
- }
- if v.Kind() == reflect.Map && v.Len() == 0 {
- return nil, nil
- }
- if v.Kind() == reflect.Slice {
- out := make([]interface{}, v.Len())
- for i := 0; i < v.Len(); i++ {
- out[i] = v.Index(i).Interface()
- }
- return out, nil
- }
-
- return []interface{}{result}, nil
-}
-
-// SetValueAtPath sets a value at the case insensitive lexical path inside
-// of a structure.
-func SetValueAtPath(i interface{}, path string, v interface{}) {
- if rvals := rValuesAtPath(i, path, true, false, v == nil); rvals != nil {
- for _, rval := range rvals {
- if rval.Kind() == reflect.Ptr && rval.IsNil() {
- continue
- }
- setValue(rval, v)
- }
- }
-}
-
-func setValue(dstVal reflect.Value, src interface{}) {
- if dstVal.Kind() == reflect.Ptr {
- dstVal = reflect.Indirect(dstVal)
- }
- srcVal := reflect.ValueOf(src)
-
- if !srcVal.IsValid() { // src is literal nil
- if dstVal.CanAddr() {
- // Convert to pointer so that pointer's value can be nil'ed
- // dstVal = dstVal.Addr()
- }
- dstVal.Set(reflect.Zero(dstVal.Type()))
-
- } else if srcVal.Kind() == reflect.Ptr {
- if srcVal.IsNil() {
- srcVal = reflect.Zero(dstVal.Type())
- } else {
- srcVal = reflect.ValueOf(src).Elem()
- }
- dstVal.Set(srcVal)
- } else {
- dstVal.Set(srcVal)
- }
-
-}
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go
deleted file mode 100644
index 710eb43..0000000
--- a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go
+++ /dev/null
@@ -1,113 +0,0 @@
-package awsutil
-
-import (
- "bytes"
- "fmt"
- "io"
- "reflect"
- "strings"
-)
-
-// Prettify returns the string representation of a value.
-func Prettify(i interface{}) string {
- var buf bytes.Buffer
- prettify(reflect.ValueOf(i), 0, &buf)
- return buf.String()
-}
-
-// prettify will recursively walk value v to build a textual
-// representation of the value.
-func prettify(v reflect.Value, indent int, buf *bytes.Buffer) {
- for v.Kind() == reflect.Ptr {
- v = v.Elem()
- }
-
- switch v.Kind() {
- case reflect.Struct:
- strtype := v.Type().String()
- if strtype == "time.Time" {
- fmt.Fprintf(buf, "%s", v.Interface())
- break
- } else if strings.HasPrefix(strtype, "io.") {
- buf.WriteString("<buffer>")
- break
- }
-
- buf.WriteString("{\n")
-
- names := []string{}
- for i := 0; i < v.Type().NumField(); i++ {
- name := v.Type().Field(i).Name
- f := v.Field(i)
- if name[0:1] == strings.ToLower(name[0:1]) {
- continue // ignore unexported fields
- }
- if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice || f.Kind() == reflect.Map) && f.IsNil() {
- continue // ignore unset fields
- }
- names = append(names, name)
- }
-
- for i, n := range names {
- val := v.FieldByName(n)
- buf.WriteString(strings.Repeat(" ", indent+2))
- buf.WriteString(n + ": ")
- prettify(val, indent+2, buf)
-
- if i < len(names)-1 {
- buf.WriteString(",\n")
- }
- }
-
- buf.WriteString("\n" + strings.Repeat(" ", indent) + "}")
- case reflect.Slice:
- strtype := v.Type().String()
- if strtype == "[]uint8" {
- fmt.Fprintf(buf, "<binary> len %d", v.Len())
- break
- }
-
- nl, id, id2 := "", "", ""
- if v.Len() > 3 {
- nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2)
- }
- buf.WriteString("[" + nl)
- for i := 0; i < v.Len(); i++ {
- buf.WriteString(id2)
- prettify(v.Index(i), indent+2, buf)
-
- if i < v.Len()-1 {
- buf.WriteString("," + nl)
- }
- }
-
- buf.WriteString(nl + id + "]")
- case reflect.Map:
- buf.WriteString("{\n")
-
- for i, k := range v.MapKeys() {
- buf.WriteString(strings.Repeat(" ", indent+2))
- buf.WriteString(k.String() + ": ")
- prettify(v.MapIndex(k), indent+2, buf)
-
- if i < v.Len()-1 {
- buf.WriteString(",\n")
- }
- }
-
- buf.WriteString("\n" + strings.Repeat(" ", indent) + "}")
- default:
- if !v.IsValid() {
- fmt.Fprint(buf, "<invalid value>")
- return
- }
- format := "%v"
- switch v.Interface().(type) {
- case string:
- format = "%q"
- case io.ReadSeeker, io.Reader:
- format = "buffer(%p)"
- }
- fmt.Fprintf(buf, format, v.Interface())
- }
-}
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go
deleted file mode 100644
index b6432f1..0000000
--- a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package awsutil
-
-import (
- "bytes"
- "fmt"
- "reflect"
- "strings"
-)
-
-// StringValue returns the string representation of a value.
-func StringValue(i interface{}) string {
- var buf bytes.Buffer
- stringValue(reflect.ValueOf(i), 0, &buf)
- return buf.String()
-}
-
-func stringValue(v reflect.Value, indent int, buf *bytes.Buffer) {
- for v.Kind() == reflect.Ptr {
- v = v.Elem()
- }
-
- switch v.Kind() {
- case reflect.Struct:
- buf.WriteString("{\n")
-
- names := []string{}
- for i := 0; i < v.Type().NumField(); i++ {
- name := v.Type().Field(i).Name
- f := v.Field(i)
- if name[0:1] == strings.ToLower(name[0:1]) {
- continue // ignore unexported fields
- }
- if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice) && f.IsNil() {
- continue // ignore unset fields
- }
- names = append(names, name)
- }
-
- for i, n := range names {
- val := v.FieldByName(n)
- buf.WriteString(strings.Repeat(" ", indent+2))
- buf.WriteString(n + ": ")
- stringValue(val, indent+2, buf)
-
- if i < len(names)-1 {
- buf.WriteString(",\n")
- }
- }
-
- buf.WriteString("\n" + strings.Repeat(" ", indent) + "}")
- case reflect.Slice:
- nl, id, id2 := "", "", ""
- if v.Len() > 3 {
- nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2)
- }
- buf.WriteString("[" + nl)
- for i := 0; i < v.Len(); i++ {
- buf.WriteString(id2)
- stringValue(v.Index(i), indent+2, buf)
-
- if i < v.Len()-1 {
- buf.WriteString("," + nl)
- }
- }
-
- buf.WriteString(nl + id + "]")
- case reflect.Map:
- buf.WriteString("{\n")
-
- for i, k := range v.MapKeys() {
- buf.WriteString(strings.Repeat(" ", indent+2))
- buf.WriteString(k.String() + ": ")
- stringValue(v.MapIndex(k), indent+2, buf)
-
- if i < v.Len()-1 {
- buf.WriteString(",\n")
- }
- }
-
- buf.WriteString("\n" + strings.Repeat(" ", indent) + "}")
- default:
- format := "%v"
- switch v.Interface().(type) {
- case string:
- format = "%q"
- }
- fmt.Fprintf(buf, format, v.Interface())
- }
-}