-func (b *BaseError) ErrorWithExtra(extra string) string {
- msg := fmt.Sprintf("%s: %s", b.code, b.message)
- if extra != "" {
- msg = fmt.Sprintf("%s\n\t%s", msg, extra)
- }
- if b.origErr != nil {
- msg = fmt.Sprintf("%s\ncaused by: %s", msg, b.origErr.Error())
- }
- return msg
-}
-
-// A RequestError wraps a request or service error.
-//
-// Composed of BaseError for code, message, and original error.
-type RequestError struct {
- *BaseError
- statusCode int
- requestID string
-}
-
-// NewRequestError returns a wrapped error with additional information for request
-// status code, and service requestID.
-//
-// Should be used to wrap all request which involve service requests. Even if
-// the request failed without a service response, but had an HTTP status code
-// that may be meaningful.
-//
-// Also wraps original errors via the BaseError.
-func NewRequestError(base *BaseError, statusCode int, requestID string) *RequestError {
- return &RequestError{
- BaseError: base,
- statusCode: statusCode,
- requestID: requestID,
- }
-}
-
-// Error returns the string representation of the error.
-// Satisfies the error interface.
-func (r *RequestError) Error() string {
- return r.ErrorWithExtra(fmt.Sprintf("status code: %d, request id: [%s]",
- r.statusCode, r.requestID))
-}
-
-// String returns the string representation of the error.
-// Alias for Error to satisfy the stringer interface.
-func (r *RequestError) String() string {
- return r.Error()
-}
-
-// StatusCode returns the wrapped status code for the error
-func (r *RequestError) StatusCode() int {
- return r.statusCode
-}
-
-// RequestID returns the wrapped requestID
-func (r *RequestError) RequestID() string {
- return r.requestID
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/endpoints/endpoints.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/endpoints/endpoints.go
deleted file mode 100644
index d040cccd..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/endpoints/endpoints.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// Package endpoints validates regional endpoints for services.
-package endpoints
-
-//go:generate go run ../model/cli/gen-endpoints/main.go endpoints.json endpoints_map.go
-//go:generate gofmt -s -w endpoints_map.go
-
-import "strings"
-
-// EndpointForRegion returns an endpoint and its signing region for a service and region.
-// if the service and region pair are not found endpoint and signingRegion will be empty.
-func EndpointForRegion(svcName, region string) (endpoint, signingRegion string) {
- derivedKeys := []string{
- region + "/" + svcName,
- region + "/*",
- "*/" + svcName,
- "*/*",
- }
-
- for _, key := range derivedKeys {
- if val, ok := endpointsMap.Endpoints[key]; ok {
- ep := val.Endpoint
- ep = strings.Replace(ep, "{region}", region, -1)
- ep = strings.Replace(ep, "{service}", svcName, -1)
-
- endpoint = ep
- signingRegion = val.SigningRegion
- return
- }
- }
- return
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/endpoints/endpoints.json b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/endpoints/endpoints.json
deleted file mode 100644
index 4c588090..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/endpoints/endpoints.json
+++ /dev/null
@@ -1,77 +0,0 @@
-{
- "version": 2,
- "endpoints": {
- "*/*": {
- "endpoint": "{service}.{region}.amazonaws.com"
- },
- "cn-north-1/*": {
- "endpoint": "{service}.{region}.amazonaws.com.cn",
- "signatureVersion": "v4"
- },
- "us-gov-west-1/iam": {
- "endpoint": "iam.us-gov.amazonaws.com"
- },
- "us-gov-west-1/sts": {
- "endpoint": "sts.us-gov-west-1.amazonaws.com"
- },
- "us-gov-west-1/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "*/cloudfront": {
- "endpoint": "cloudfront.amazonaws.com",
- "signingRegion": "us-east-1"
- },
- "*/cloudsearchdomain": {
- "endpoint": "",
- "signingRegion": "us-east-1"
- },
- "*/iam": {
- "endpoint": "iam.amazonaws.com",
- "signingRegion": "us-east-1"
- },
- "*/importexport": {
- "endpoint": "importexport.amazonaws.com",
- "signingRegion": "us-east-1"
- },
- "*/route53": {
- "endpoint": "route53.amazonaws.com",
- "signingRegion": "us-east-1"
- },
- "*/sts": {
- "endpoint": "sts.amazonaws.com",
- "signingRegion": "us-east-1"
- },
- "us-east-1/sdb": {
- "endpoint": "sdb.amazonaws.com",
- "signingRegion": "us-east-1"
- },
- "us-east-1/s3": {
- "endpoint": "s3.amazonaws.com"
- },
- "us-west-1/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "us-west-2/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "eu-west-1/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "ap-southeast-1/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "ap-southeast-2/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "ap-northeast-1/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "sa-east-1/s3": {
- "endpoint": "s3-{region}.amazonaws.com"
- },
- "eu-central-1/s3": {
- "endpoint": "{service}.{region}.amazonaws.com",
- "signatureVersion": "v4"
- }
- }
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/endpoints/endpoints_map.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/endpoints/endpoints_map.go
deleted file mode 100644
index 894c1a64..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/endpoints/endpoints_map.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package endpoints
-
-// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
-
-type endpointStruct struct {
- Version int
- Endpoints map[string]endpointEntry
-}
-
-type endpointEntry struct {
- Endpoint string
- SigningRegion string
-}
-
-var endpointsMap = endpointStruct{
- Version: 2,
- Endpoints: map[string]endpointEntry{
- "*/*": {
- Endpoint: "{service}.{region}.amazonaws.com",
- },
- "*/cloudfront": {
- Endpoint: "cloudfront.amazonaws.com",
- SigningRegion: "us-east-1",
- },
- "*/cloudsearchdomain": {
- Endpoint: "",
- SigningRegion: "us-east-1",
- },
- "*/iam": {
- Endpoint: "iam.amazonaws.com",
- SigningRegion: "us-east-1",
- },
- "*/importexport": {
- Endpoint: "importexport.amazonaws.com",
- SigningRegion: "us-east-1",
- },
- "*/route53": {
- Endpoint: "route53.amazonaws.com",
- SigningRegion: "us-east-1",
- },
- "*/sts": {
- Endpoint: "sts.amazonaws.com",
- SigningRegion: "us-east-1",
- },
- "ap-northeast-1/s3": {
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "ap-southeast-1/s3": {
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "ap-southeast-2/s3": {
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "cn-north-1/*": {
- Endpoint: "{service}.{region}.amazonaws.com.cn",
- },
- "eu-central-1/s3": {
- Endpoint: "{service}.{region}.amazonaws.com",
- },
- "eu-west-1/s3": {
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "sa-east-1/s3": {
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "us-east-1/s3": {
- Endpoint: "s3.amazonaws.com",
- },
- "us-east-1/sdb": {
- Endpoint: "sdb.amazonaws.com",
- SigningRegion: "us-east-1",
- },
- "us-gov-west-1/iam": {
- Endpoint: "iam.us-gov.amazonaws.com",
- },
- "us-gov-west-1/s3": {
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "us-gov-west-1/sts": {
- Endpoint: "sts.us-gov-west-1.amazonaws.com",
- },
- "us-west-1/s3": {
- Endpoint: "s3-{region}.amazonaws.com",
- },
- "us-west-2/s3": {
- Endpoint: "s3-{region}.amazonaws.com",
- },
- },
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/build.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/build.go
deleted file mode 100644
index 0d3c0af4..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/build.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Package query provides serialisation of AWS query requests, and responses.
-package query
-
-//go:generate go run ../../fixtures/protocol/generate.go ../../fixtures/protocol/input/query.json build_test.go
-
-import (
- "net/url"
-
- "github.com/ks3sdklib/aws-sdk-go/aws"
- "github.com/ks3sdklib/aws-sdk-go/internal/apierr"
- "github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/queryutil"
-)
-
-// Build builds a request for an AWS Query service.
-func Build(r *aws.Request) {
- body := url.Values{
- "Action": {r.Operation.Name},
- "Version": {r.Service.APIVersion},
- }
- if err := queryutil.Parse(body, r.Params, false); err != nil {
- r.Error = apierr.New("Marshal", "failed encoding Query request", err)
- return
- }
-
- if r.ExpireTime == 0 {
- r.HTTPRequest.Method = "POST"
- r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
- r.SetBufferBody([]byte(body.Encode()))
- } else { // This is a pre-signed request
- r.HTTPRequest.Method = "GET"
- r.HTTPRequest.URL.RawQuery = body.Encode()
- }
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/queryutil/queryutil.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/queryutil/queryutil.go
deleted file mode 100644
index 3b417a89..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/queryutil/queryutil.go
+++ /dev/null
@@ -1,223 +0,0 @@
-package queryutil
-
-import (
- "encoding/base64"
- "fmt"
- "net/url"
- "reflect"
- "sort"
- "strconv"
- "strings"
- "time"
-)
-
-// Parse parses an object i and fills a url.Values object. The isEC2 flag
-// indicates if this is the EC2 Query sub-protocol.
-func Parse(body url.Values, i interface{}, isEC2 bool) error {
- q := queryParser{isEC2: isEC2}
- return q.parseValue(body, reflect.ValueOf(i), "", "")
-}
-
-func elemOf(value reflect.Value) reflect.Value {
- for value.Kind() == reflect.Ptr {
- value = value.Elem()
- }
- return value
-}
-
-type queryParser struct {
- isEC2 bool
-}
-
-func (q *queryParser) parseValue(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error {
- value = elemOf(value)
-
- // no need to handle zero values
- if !value.IsValid() {
- return nil
- }
-
- t := tag.Get("type")
- if t == "" {
- switch value.Kind() {
- case reflect.Struct:
- t = "structure"
- case reflect.Slice:
- t = "list"
- case reflect.Map:
- t = "map"
- }
- }
-
- switch t {
- case "structure":
- return q.parseStruct(v, value, prefix)
- case "list":
- return q.parseList(v, value, prefix, tag)
- case "map":
- return q.parseMap(v, value, prefix, tag)
- default:
- return q.parseScalar(v, value, prefix, tag)
- }
-}
-
-func (q *queryParser) parseStruct(v url.Values, value reflect.Value, prefix string) error {
- if !value.IsValid() {
- return nil
- }
-
- t := value.Type()
- for i := 0; i < value.NumField(); i++ {
- if c := t.Field(i).Name[0:1]; strings.ToLower(c) == c {
- continue // ignore unexported fields
- }
-
- value := elemOf(value.Field(i))
- field := t.Field(i)
- var name string
-
- if q.isEC2 {
- name = field.Tag.Get("queryName")
- }
- if name == "" {
- if field.Tag.Get("flattened") != "" && field.Tag.Get("locationNameList") != "" {
- name = field.Tag.Get("locationNameList")
- } else if locName := field.Tag.Get("locationName"); locName != "" {
- name = locName
- }
- if name != "" && q.isEC2 {
- name = strings.ToUpper(name[0:1]) + name[1:]
- }
- }
- if name == "" {
- name = field.Name
- }
-
- if prefix != "" {
- name = prefix + "." + name
- }
-
- if err := q.parseValue(v, value, name, field.Tag); err != nil {
- return err
- }
- }
- return nil
-}
-
-func (q *queryParser) parseList(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error {
- // If it's empty, generate an empty value
- if !value.IsNil() && value.Len() == 0 {
- v.Set(prefix, "")
- return nil
- }
-
- // check for unflattened list member
- if !q.isEC2 && tag.Get("flattened") == "" {
- prefix += ".member"
- }
-
- for i := 0; i < value.Len(); i++ {
- slicePrefix := prefix
- if slicePrefix == "" {
- slicePrefix = strconv.Itoa(i + 1)
- } else {
- slicePrefix = slicePrefix + "." + strconv.Itoa(i+1)
- }
- if err := q.parseValue(v, value.Index(i), slicePrefix, ""); err != nil {
- return err
- }
- }
- return nil
-}
-
-func (q *queryParser) parseMap(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error {
- // If it's empty, generate an empty value
- if !value.IsNil() && value.Len() == 0 {
- v.Set(prefix, "")
- return nil
- }
-
- // check for unflattened list member
- if !q.isEC2 && tag.Get("flattened") == "" {
- prefix += ".entry"
- }
-
- // sort keys for improved serialization consistency.
- // this is not strictly necessary for protocol support.
- mapKeyValues := value.MapKeys()
- mapKeys := map[string]reflect.Value{}
- mapKeyNames := make([]string, len(mapKeyValues))
- for i, mapKey := range mapKeyValues {
- name := mapKey.String()
- mapKeys[name] = mapKey
- mapKeyNames[i] = name
- }
- sort.Strings(mapKeyNames)
-
- for i, mapKeyName := range mapKeyNames {
- mapKey := mapKeys[mapKeyName]
- mapValue := value.MapIndex(mapKey)
-
- kname := tag.Get("locationNameKey")
- if kname == "" {
- kname = "key"
- }
- vname := tag.Get("locationNameValue")
- if vname == "" {
- vname = "value"
- }
-
- // serialize key
- var keyName string
- if prefix == "" {
- keyName = strconv.Itoa(i+1) + "." + kname
- } else {
- keyName = prefix + "." + strconv.Itoa(i+1) + "." + kname
- }
-
- if err := q.parseValue(v, mapKey, keyName, ""); err != nil {
- return err
- }
-
- // serialize value
- var valueName string
- if prefix == "" {
- valueName = strconv.Itoa(i+1) + "." + vname
- } else {
- valueName = prefix + "." + strconv.Itoa(i+1) + "." + vname
- }
-
- if err := q.parseValue(v, mapValue, valueName, ""); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func (q *queryParser) parseScalar(v url.Values, r reflect.Value, name string, tag reflect.StructTag) error {
- switch value := r.Interface().(type) {
- case string:
- v.Set(name, value)
- case []byte:
- if !r.IsNil() {
- v.Set(name, base64.StdEncoding.EncodeToString(value))
- }
- case bool:
- v.Set(name, strconv.FormatBool(value))
- case int64:
- v.Set(name, strconv.FormatInt(value, 10))
- case int:
- v.Set(name, strconv.Itoa(value))
- case float64:
- v.Set(name, strconv.FormatFloat(value, 'f', -1, 64))
- case float32:
- v.Set(name, strconv.FormatFloat(float64(value), 'f', -1, 32))
- case time.Time:
- const ISO8601UTC = "2006-01-02T15:04:05Z"
- v.Set(name, value.UTC().Format(ISO8601UTC))
- default:
- return fmt.Errorf("unsupported value for param %s: %v (%s)", name, r.Interface(), r.Type().Name())
- }
- return nil
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/unmarshal.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/unmarshal.go
deleted file mode 100644
index db688671..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/unmarshal.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package query
-
-//go:generate go run ../../fixtures/protocol/generate.go ../../fixtures/protocol/output/query.json unmarshal_test.go
-
-import (
- "encoding/xml"
-
- "github.com/ks3sdklib/aws-sdk-go/aws"
- "github.com/ks3sdklib/aws-sdk-go/internal/apierr"
- "github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil"
-)
-
-// Unmarshal unmarshals a response for an AWS Query service.
-func Unmarshal(r *aws.Request) {
- defer r.HTTPResponse.Body.Close()
- if r.DataFilled() {
- decoder := xml.NewDecoder(r.HTTPResponse.Body)
- err := xmlutil.UnmarshalXML(r.Data, decoder, r.Operation.Name+"Result")
- if err != nil {
- r.Error = apierr.New("Unmarshal", "failed decoding Query response", err)
- return
- }
- }
-}
-
-// UnmarshalMeta unmarshals header response values for an AWS Query service.
-func UnmarshalMeta(r *aws.Request) {
- // TODO implement unmarshaling of request IDs
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/unmarshal_error.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/unmarshal_error.go
deleted file mode 100644
index ee9a08e8..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/unmarshal_error.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package query
-
-import (
- "encoding/xml"
- "io"
- "io/ioutil"
- "log"
-
- "github.com/ks3sdklib/aws-sdk-go/aws"
- "github.com/ks3sdklib/aws-sdk-go/internal/apierr"
-)
-
-type XmlErrorResponse struct {
- XMLName xml.Name `xml:"Error"`
- Code string `xml:"Code"`
- StatusCode int `"StatusCode"`
- Message string `xml:"Message"`
- Resource string `xml:"Resource"`
- RequestID string `xml:"RequestId"`
-}
-
-// UnmarshalError unmarshals an error response for an AWS Query service.
-func UnmarshalError(r *aws.Request) {
- defer r.HTTPResponse.Body.Close()
-
- resp := &XmlErrorResponse{}
- body, err := ioutil.ReadAll(r.HTTPResponse.Body)
- if err != nil {
- log.Printf("read body err, %v\n", err)
- return
- }
- err = xml.Unmarshal(body, &resp)
- resp.StatusCode = r.HTTPResponse.StatusCode
-
- if err != nil && err != io.EOF {
- r.Error = apierr.New("Unmarshal", "failed to decode query XML error response", err)
- } else {
- r.Error = apierr.NewRequestError(
- apierr.New(resp.Code, resp.Message, nil),
- r.HTTPResponse.StatusCode,
- resp.RequestID,
- )
- }
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest/build.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest/build.go
deleted file mode 100644
index b5afe298..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest/build.go
+++ /dev/null
@@ -1,225 +0,0 @@
-// Package rest provides RESTful serialisation of AWS requests and responses.
-package rest
-
-import (
- "bytes"
- "encoding/base64"
- "fmt"
- "io"
- "net/url"
- "path"
- "reflect"
- "strconv"
- "strings"
- "time"
- "github.com/ks3sdklib/aws-sdk-go/aws"
- "github.com/ks3sdklib/aws-sdk-go/internal/apierr"
-)
-
-// RFC822 returns an RFC822 formatted timestamp for AWS protocols
-const RFC822 = "Mon, 2 Jan 2006 15:04:05 GMT"
-
-// Whether the byte value can be sent without escaping in AWS URLs
-var noEscape [256]bool
-
-func init() {
- for i := 0; i < len(noEscape); i++ {
- // AWS expects every character except these to be escaped
- noEscape[i] = (i >= 'A' && i <= 'Z') ||
- (i >= 'a' && i <= 'z') ||
- (i >= '0' && i <= '9') ||
- i == '-' ||
- i == '.' ||
- i == '_' ||
- i == '~'
- }
-}
-
-// Build builds the REST component of a service request.
-func Build(r *aws.Request) {
- if r.ParamsFilled() {
- v := reflect.ValueOf(r.Params).Elem()
- buildLocationElements(r, v)
- buildBody(r, v)
- }
-}
-
-func buildLocationElements(r *aws.Request, v reflect.Value) {
- query := r.HTTPRequest.URL.Query()
-
- for i := 0; i < v.NumField(); i++ {
- m := v.Field(i)
- if n := v.Type().Field(i).Name; n[0:1] == strings.ToLower(n[0:1]) {
- continue
- }
-
- if m.IsValid() {
- field := v.Type().Field(i)
- name := field.Tag.Get("locationName")
- if name == "" {
- name = field.Name
- }
- if m.Kind() == reflect.Ptr {
- m = m.Elem()
- }
- if !m.IsValid() {
- continue
- }
-
- switch field.Tag.Get("location") {
- case "headers": // header maps
- buildHeaderMap(r, m, field.Tag.Get("locationName"))
- case "header":
- buildHeader(r, m, name)
- case "uri":
- buildURI(r, m, name)
- case "querystring":
- buildQueryString(r, m, name, query)
- }
- }
- if r.Error != nil {
- return
- }
- }
-
- r.HTTPRequest.URL.RawQuery = query.Encode()
- updatePath(r.HTTPRequest.URL, r.HTTPRequest.URL.Path)
-}
-
-func buildBody(r *aws.Request, v reflect.Value) {
- if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok {
- if payloadName := field.Tag.Get("payload"); payloadName != "" {
- pfield, _ := v.Type().FieldByName(payloadName)
- if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" {
- payload := reflect.Indirect(v.FieldByName(payloadName))
- if payload.IsValid() && payload.Interface() != nil {
- switch reader := payload.Interface().(type) {
- case io.ReadSeeker:
- r.SetReaderBody(reader)
- case []byte:
- r.SetBufferBody(reader)
- case string:
- r.SetStringBody(reader)
- default:
- r.Error = apierr.New("Marshal",
- "failed to encode REST request",
- fmt.Errorf("unknown payload type %s", payload.Type()))
- }
- }
- }
- }
- }
-}
-
-func buildHeader(r *aws.Request, v reflect.Value, name string) {
- str, err := convertType(v)
- if err != nil {
- r.Error = apierr.New("Marshal", "failed to encode REST request", err)
- } else if str != nil {
- r.HTTPRequest.Header.Add(name, *str)
- }
-}
-
-func buildHeaderMap(r *aws.Request, v reflect.Value, prefix string) {
- for _, key := range v.MapKeys() {
- str, err := convertType(v.MapIndex(key))
- if err != nil {
- r.Error = apierr.New("Marshal", "failed to encode REST request", err)
- } else if str != nil {
- r.HTTPRequest.Header.Add(prefix+key.String(), *str)
- }
- }
-}
-
-func buildURI(r *aws.Request, v reflect.Value, name string) {
- value, err := convertType(v)
- if err != nil {
- r.Error = apierr.New("Marshal", "failed to encode REST request", err)
- } else if value != nil {
- uri := r.HTTPRequest.URL.Path
- uri = strings.Replace(uri, "{"+name+"}", EscapePath(*value, true), -1)
- uri = strings.Replace(uri, "{"+name+"+}", EscapePath(*value, false), -1)
- r.HTTPRequest.URL.Path = uri
- }
-}
-
-func buildQueryString(r *aws.Request, v reflect.Value, name string, query url.Values) {
- str, err := convertType(v)
- if err != nil {
- r.Error = apierr.New("Marshal", "failed to encode REST request", err)
- } else if str != nil {
- query.Set(name, *str)
- }
-}
-
-func updatePath(url *url.URL, urlPath string) {
- scheme, query := url.Scheme, url.RawQuery
-
- //path.Clean会去掉最后的斜杠,导致无法创建目录。所以添加以下逻辑
- add := false
- if urlPath[len(urlPath)-1] == '/'&&len(urlPath)>1{
- add = true
- }
-
- // path.Clean will remove duplicate leading /
- // this will make deleting / started key impossible
- // so escape it here first
- urlPath = strings.Replace(urlPath, "//", "/%2F", -1)
-
- // clean up path
- urlPath = path.Clean(urlPath)
- if add{
- urlPath += "/"
- }
-
- // get formatted URL minus scheme so we can build this into Opaque
- url.Scheme, url.Path, url.RawQuery = "", "", ""
- s := url.String()
- url.Scheme = scheme
- url.RawQuery = query
-
- // build opaque URI
- url.Opaque = s + urlPath
-}
-
-// EscapePath escapes part of a URL path in Amazon style
-func EscapePath(path string, encodeSep bool) string {
- var buf bytes.Buffer
- for i := 0; i < len(path); i++ {
- c := path[i]
- if noEscape[c] || (c == '/' && !encodeSep) {
- buf.WriteByte(c)
- } else {
- buf.WriteByte('%')
- buf.WriteString(strings.ToUpper(strconv.FormatUint(uint64(c), 16)))
- }
- }
- return buf.String()
-}
-
-func convertType(v reflect.Value) (*string, error) {
- v = reflect.Indirect(v)
- if !v.IsValid() {
- return nil, nil
- }
-
- var str string
- switch value := v.Interface().(type) {
- case string:
- str = value
- case []byte:
- str = base64.StdEncoding.EncodeToString(value)
- case bool:
- str = strconv.FormatBool(value)
- case int64:
- str = strconv.FormatInt(value, 10)
- case float64:
- str = strconv.FormatFloat(value, 'f', -1, 64)
- case time.Time:
- str = value.UTC().Format(RFC822)
- default:
- err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type())
- return nil, err
- }
- return &str, nil
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest/payload.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest/payload.go
deleted file mode 100644
index 1f603bb7..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest/payload.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package rest
-
-import "reflect"
-
-// PayloadMember returns the payload field member of i if there is one, or nil.
-func PayloadMember(i interface{}) interface{} {
- if i == nil {
- return nil
- }
-
- v := reflect.ValueOf(i).Elem()
- if !v.IsValid() {
- return nil
- }
- if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok {
- if payloadName := field.Tag.Get("payload"); payloadName != "" {
- field, _ := v.Type().FieldByName(payloadName)
- if field.Tag.Get("type") != "structure" {
- return nil
- }
-
- payload := v.FieldByName(payloadName)
- if payload.IsValid() || (payload.Kind() == reflect.Ptr && !payload.IsNil()) {
- return payload.Interface()
- }
- }
- }
- return nil
-}
-
-// PayloadType returns the type of a payload field member of i if there is one, or "".
-func PayloadType(i interface{}) string {
- v := reflect.Indirect(reflect.ValueOf(i))
- if !v.IsValid() {
- return ""
- }
- if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok {
- if payloadName := field.Tag.Get("payload"); payloadName != "" {
- if member, ok := v.Type().FieldByName(payloadName); ok {
- return member.Tag.Get("type")
- }
- }
- }
- return ""
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest/unmarshal.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest/unmarshal.go
deleted file mode 100644
index 715c1963..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest/unmarshal.go
+++ /dev/null
@@ -1,174 +0,0 @@
-package rest
-
-import (
- "encoding/base64"
- "fmt"
- "io/ioutil"
- "net/http"
- "reflect"
- "strconv"
- "strings"
- "time"
-
- "github.com/ks3sdklib/aws-sdk-go/aws"
- "github.com/ks3sdklib/aws-sdk-go/internal/apierr"
-)
-
-// Unmarshal unmarshals the REST component of a response in a REST service.
-func Unmarshal(r *aws.Request) {
- if r.DataFilled() {
- v := reflect.Indirect(reflect.ValueOf(r.Data))
- unmarshalBody(r, v)
- unmarshalLocationElements(r, v)
- }
-}
-
-func unmarshalBody(r *aws.Request, v reflect.Value) {
- if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok {
- if payloadName := field.Tag.Get("payload"); payloadName != "" {
- pfield, _ := v.Type().FieldByName(payloadName)
- if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" {
- payload := v.FieldByName(payloadName)
- if payload.IsValid() {
- switch payload.Interface().(type) {
- case []byte:
- b, err := ioutil.ReadAll(r.HTTPResponse.Body)
- if err != nil {
- r.Error = apierr.New("Unmarshal", "failed to decode REST response", err)
- } else {
- payload.Set(reflect.ValueOf(b))
- }
- case *string:
- b, err := ioutil.ReadAll(r.HTTPResponse.Body)
- if err != nil {
- r.Error = apierr.New("Unmarshal", "failed to decode REST response", err)
- } else {
- str := string(b)
- payload.Set(reflect.ValueOf(&str))
- }
- default:
- switch payload.Type().String() {
- case "io.ReadSeeker":
- payload.Set(reflect.ValueOf(aws.ReadSeekCloser(r.HTTPResponse.Body)))
- case "aws.ReadSeekCloser", "io.ReadCloser":
- payload.Set(reflect.ValueOf(r.HTTPResponse.Body))
- default:
- r.Error = apierr.New("Unmarshal",
- "failed to decode REST response",
- fmt.Errorf("unknown payload type %s", payload.Type()))
- }
- }
- }
- }
- }
- }
-}
-
-func unmarshalLocationElements(r *aws.Request, v reflect.Value) {
- for i := 0; i < v.NumField(); i++ {
- m, field := v.Field(i), v.Type().Field(i)
- if n := field.Name; n[0:1] == strings.ToLower(n[0:1]) {
- continue
- }
-
- if m.IsValid() {
- name := field.Tag.Get("locationName")
- if name == "" {
- name = field.Name
- }
-
- switch field.Tag.Get("location") {
- case "statusCode":
- unmarshalStatusCode(m, r.HTTPResponse.StatusCode)
- case "header":
- err := unmarshalHeader(m, r.HTTPResponse.Header.Get(name))
- if err != nil {
- r.Error = apierr.New("Unmarshal", "failed to decode REST response", err)
- break
- }
- case "headers":
- prefix := field.Tag.Get("locationName")
- err := unmarshalHeaderMap(m, r.HTTPResponse.Header, prefix)
- if err != nil {
- r.Error = apierr.New("Unmarshal", "failed to decode REST response", err)
- break
- }
- }
- }
- if r.Error != nil {
- return
- }
- }
-}
-
-func unmarshalStatusCode(v reflect.Value, statusCode int) {
- if !v.IsValid() {
- return
- }
-
- switch v.Interface().(type) {
- case *int64:
- s := int64(statusCode)
- v.Set(reflect.ValueOf(&s))
- }
-}
-
-func unmarshalHeaderMap(r reflect.Value, headers http.Header, prefix string) error {
- switch r.Interface().(type) {
- case map[string]*string: // we only support string map value types
- out := map[string]*string{}
- for k, v := range headers {
- k = http.CanonicalHeaderKey(k)
- if strings.HasPrefix(strings.ToLower(k), strings.ToLower(prefix)) {
- out[k[len(prefix):]] = &v[0]
- }
- }
- r.Set(reflect.ValueOf(out))
- }
- return nil
-}
-
-func unmarshalHeader(v reflect.Value, header string) error {
- if !v.IsValid() || (header == "" && v.Elem().Kind() != reflect.String) {
- return nil
- }
-
- switch v.Interface().(type) {
- case *string:
- v.Set(reflect.ValueOf(&header))
- case []byte:
- b, err := base64.StdEncoding.DecodeString(header)
- if err != nil {
- return err
- }
- v.Set(reflect.ValueOf(&b))
- case *bool:
- b, err := strconv.ParseBool(header)
- if err != nil {
- return err
- }
- v.Set(reflect.ValueOf(&b))
- case *int64:
- i, err := strconv.ParseInt(header, 10, 64)
- if err != nil {
- return err
- }
- v.Set(reflect.ValueOf(&i))
- case *float64:
- f, err := strconv.ParseFloat(header, 64)
- if err != nil {
- return err
- }
- v.Set(reflect.ValueOf(&f))
- case *time.Time:
- t, err := time.Parse(RFC822, header)
- if err != nil {
- return err
- }
- v.Set(reflect.ValueOf(&t))
- default:
- err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type())
- return err
- }
- return nil
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/restxml/restxml.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/restxml/restxml.go
deleted file mode 100644
index e281e3b8..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/restxml/restxml.go
+++ /dev/null
@@ -1,54 +0,0 @@
-// Package restxml provides RESTful XML serialisation of AWS
-// requests and responses.
-package restxml
-
-//go:generate go run ../../fixtures/protocol/generate.go ../../fixtures/protocol/input/rest-xml.json build_test.go
-//go:generate go run ../../fixtures/protocol/generate.go ../../fixtures/protocol/output/rest-xml.json unmarshal_test.go
-
-import (
- "bytes"
- "encoding/xml"
- "github.com/ks3sdklib/aws-sdk-go/aws"
- "github.com/ks3sdklib/aws-sdk-go/internal/apierr"
- "github.com/ks3sdklib/aws-sdk-go/internal/protocol/query"
- "github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest"
- "github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil"
-)
-
-// Build builds a request payload for the REST XML protocol.
-func Build(r *aws.Request) {
- rest.Build(r)
-
- if t := rest.PayloadType(r.Params); t == "structure" || t == "" {
- var buf bytes.Buffer
- err := xmlutil.BuildXML(r.Params, xml.NewEncoder(&buf))
- if err != nil {
- r.Error = apierr.New("Marshal", "failed to enode rest XML request", err)
- return
- }
- r.SetBufferBody(buf.Bytes())
- }
-}
-
-// Unmarshal unmarshals a payload response for the REST XML protocol.
-func Unmarshal(r *aws.Request) {
- if t := rest.PayloadType(r.Data); t == "structure" || t == "" {
- defer r.HTTPResponse.Body.Close()
- decoder := xml.NewDecoder(r.HTTPResponse.Body)
- err := xmlutil.UnmarshalXML(r.Data, decoder, "")
- if err != nil {
- r.Error = apierr.New("Unmarshal", "failed to decode REST XML response", err)
- return
- }
- }
-}
-
-// UnmarshalMeta unmarshals response headers for the REST XML protocol.
-func UnmarshalMeta(r *aws.Request) {
- rest.Unmarshal(r)
-}
-
-// UnmarshalError unmarshals a response error for the REST XML protocol.
-func UnmarshalError(r *aws.Request) {
- query.UnmarshalError(r)
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil/build.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil/build.go
deleted file mode 100644
index d3db2502..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil/build.go
+++ /dev/null
@@ -1,287 +0,0 @@
-// Package xmlutil provides XML serialisation of AWS requests and responses.
-package xmlutil
-
-import (
- "encoding/base64"
- "encoding/xml"
- "fmt"
- "reflect"
- "sort"
- "strconv"
- "strings"
- "time"
-)
-
-// BuildXML will serialize params into an xml.Encoder.
-// Error will be returned if the serialization of any of the params or nested values fails.
-func BuildXML(params interface{}, e *xml.Encoder) error {
- b := xmlBuilder{encoder: e, namespaces: map[string]string{}}
- root := NewXMLElement(xml.Name{})
- if err := b.buildValue(reflect.ValueOf(params), root, ""); err != nil {
- return err
- }
- for _, c := range root.Children {
- for _, v := range c {
- return StructToXML(e, v, false)
- }
- }
- return nil
-}
-
-// Returns the reflection element of a value, if it is a pointer.
-func elemOf(value reflect.Value) reflect.Value {
- for value.Kind() == reflect.Ptr {
- value = value.Elem()
- }
- return value
-}
-
-// A xmlBuilder serializes values from Go code to XML
-type xmlBuilder struct {
- encoder *xml.Encoder
- namespaces map[string]string
-}
-
-// buildValue generic XMLNode builder for any type. Will build value for their specific type
-// struct, list, map, scalar.
-//
-// Also takes a "type" tag value to set what type a value should be converted to XMLNode as. If
-// type is not provided reflect will be used to determine the value's type.
-func (b *xmlBuilder) buildValue(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
- value = elemOf(value)
- if !value.IsValid() { // no need to handle zero values
- return nil
- } else if tag.Get("location") != "" { // don't handle non-body location values
- return nil
- }
-
- t := tag.Get("type")
- if t == "" {
- switch value.Kind() {
- case reflect.Struct:
- t = "structure"
- case reflect.Slice:
- t = "list"
- case reflect.Map:
- t = "map"
- }
- }
-
- switch t {
- case "structure":
- if field, ok := value.Type().FieldByName("SDKShapeTraits"); ok {
- tag = tag + reflect.StructTag(" ") + field.Tag
- }
- return b.buildStruct(value, current, tag)
- case "list":
- return b.buildList(value, current, tag)
- case "map":
- return b.buildMap(value, current, tag)
- default:
- return b.buildScalar(value, current, tag)
- }
-}
-
-// buildStruct adds a struct and its fields to the current XMLNode. All fields any any nested
-// types are converted to XMLNodes also.
-func (b *xmlBuilder) buildStruct(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
- if !value.IsValid() {
- return nil
- }
-
- fieldAdded := false
-
- // unwrap payloads
- if payload := tag.Get("payload"); payload != "" {
- field, _ := value.Type().FieldByName(payload)
- tag = field.Tag
- value = elemOf(value.FieldByName(payload))
-
- if !value.IsValid() {
- return nil
- }
- }
-
- child := NewXMLElement(xml.Name{Local: tag.Get("locationName")})
-
- // there is an xmlNamespace associated with this struct
- if prefix, uri := tag.Get("xmlPrefix"), tag.Get("xmlURI"); uri != "" {
- ns := xml.Attr{
- Name: xml.Name{Local: "xmlns"},
- Value: uri,
- }
- if prefix != "" {
- b.namespaces[prefix] = uri // register the namespace
- ns.Name.Local = "xmlns:" + prefix
- }
-
- child.Attr = append(child.Attr, ns)
- }
-
- t := value.Type()
- for i := 0; i < value.NumField(); i++ {
- if c := t.Field(i).Name[0:1]; strings.ToLower(c) == c {
- continue // ignore unexported fields
- }
-
- member := elemOf(value.Field(i))
- field := t.Field(i)
- mTag := field.Tag
-
- if mTag.Get("location") != "" { // skip non-body members
- continue
- }
-
- memberName := mTag.Get("locationName")
- if memberName == "" {
- memberName = field.Name
- mTag = reflect.StructTag(string(mTag) + ` locationName:"` + memberName + `"`)
- }
- if err := b.buildValue(member, child, mTag); err != nil {
- return err
- }
-
- fieldAdded = true
- }
-
- if fieldAdded { // only append this child if we have one ore more valid members
- current.AddChild(child)
- }
-
- return nil
-}
-
-// buildList adds the value's list items to the current XMLNode as children nodes. All
-// nested values in the list are converted to XMLNodes also.
-func (b *xmlBuilder) buildList(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
- if value.IsNil() { // don't build omitted lists
- return nil
- }
-
- // check for unflattened list member
- flattened := tag.Get("flattened") != ""
-
- xname := xml.Name{Local: tag.Get("locationName")}
- if flattened {
- for i := 0; i < value.Len(); i++ {
- child := NewXMLElement(xname)
- current.AddChild(child)
- if err := b.buildValue(value.Index(i), child, ""); err != nil {
- return err
- }
- }
- } else {
- list := NewXMLElement(xname)
- current.AddChild(list)
-
- for i := 0; i < value.Len(); i++ {
- iname := tag.Get("locationNameList")
- if iname == "" {
- iname = "member"
- }
-
- child := NewXMLElement(xml.Name{Local: iname})
- list.AddChild(child)
- if err := b.buildValue(value.Index(i), child, ""); err != nil {
- return err
- }
- }
- }
-
- return nil
-}
-
-// buildMap adds the value's key/value pairs to the current XMLNode as children nodes. All
-// nested values in the map are converted to XMLNodes also.
-//
-// Error will be returned if it is unable to build the map's values into XMLNodes
-func (b *xmlBuilder) buildMap(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
- if value.IsNil() { // don't build omitted maps
- return nil
- }
-
- maproot := NewXMLElement(xml.Name{Local: tag.Get("locationName")})
- current.AddChild(maproot)
- current = maproot
-
- kname, vname := "key", "value"
- if n := tag.Get("locationNameKey"); n != "" {
- kname = n
- }
- if n := tag.Get("locationNameValue"); n != "" {
- vname = n
- }
-
- // sorting is not required for compliance, but it makes testing easier
- keys := make([]string, value.Len())
- for i, k := range value.MapKeys() {
- keys[i] = k.String()
- }
- sort.Strings(keys)
-
- for _, k := range keys {
- v := value.MapIndex(reflect.ValueOf(k))
-
- mapcur := current
- if tag.Get("flattened") == "" { // add "entry" tag to non-flat maps
- child := NewXMLElement(xml.Name{Local: "entry"})
- mapcur.AddChild(child)
- mapcur = child
- }
-
- kchild := NewXMLElement(xml.Name{Local: kname})
- kchild.Text = k
- vchild := NewXMLElement(xml.Name{Local: vname})
- mapcur.AddChild(kchild)
- mapcur.AddChild(vchild)
-
- if err := b.buildValue(v, vchild, ""); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-// buildScalar will convert the value into a string and append it as a attribute or child
-// of the current XMLNode.
-//
-// The value will be added as an attribute if tag contains a "xmlAttribute" attribute value.
-//
-// Error will be returned if the value type is unsupported.
-func (b *xmlBuilder) buildScalar(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
- var str string
- switch converted := value.Interface().(type) {
- case string:
- str = converted
- case []byte:
- if !value.IsNil() {
- str = base64.StdEncoding.EncodeToString(converted)
- }
- case bool:
- str = strconv.FormatBool(converted)
- case int64:
- str = strconv.FormatInt(converted, 10)
- case int:
- str = strconv.Itoa(converted)
- case float64:
- str = strconv.FormatFloat(converted, 'f', -1, 64)
- case float32:
- str = strconv.FormatFloat(float64(converted), 'f', -1, 32)
- case time.Time:
- const ISO8601UTC = "2006-01-02T15:04:05Z"
- str = converted.UTC().Format(ISO8601UTC)
- default:
- return fmt.Errorf("unsupported value for param %s: %v (%s)",
- tag.Get("locationName"), value.Interface(), value.Type().Name())
- }
-
- xname := xml.Name{Local: tag.Get("locationName")}
- if tag.Get("xmlAttribute") != "" { // put into current node's attribute list
- attr := xml.Attr{Name: xname, Value: str}
- current.Attr = append(current.Attr, attr)
- } else { // regular text node
- current.AddChild(&XMLNode{Name: xname, Text: str})
- }
- return nil
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil/unmarshal.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil/unmarshal.go
deleted file mode 100644
index d5535d31..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil/unmarshal.go
+++ /dev/null
@@ -1,263 +0,0 @@
-package xmlutil
-
-import (
- "encoding/base64"
- "encoding/xml"
- "fmt"
- "io"
- "reflect"
- "strconv"
- "strings"
- "time"
-)
-
-// UnmarshalXML deserializes an xml.Decoder into the container v. V
-// needs to match the shape of the XML expected to be decoded.
-// If the shape doesn't match unmarshaling will fail.
-func UnmarshalXML(v interface{}, d *xml.Decoder, wrapper string) error {
- n, _ := XMLToStruct(d, nil)
- if n.Children != nil {
- for _, root := range n.Children {
- for _, c := range root {
- if wrappedChild, ok := c.Children[wrapper]; ok {
- c = wrappedChild[0] // pull out wrapped element
- }
-
- err := parse(reflect.ValueOf(v), c, "")
- if err != nil {
- if err == io.EOF {
- return nil
- }
- return err
- }
- }
- }
- return nil
- }
- return nil
-}
-
-// parse deserializes any value from the XMLNode. The type tag is used to infer the type, or reflect
-// will be used to determine the type from r.
-func parse(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
- rtype := r.Type()
- if rtype.Kind() == reflect.Ptr {
- rtype = rtype.Elem() // check kind of actual element type
- }
-
- t := tag.Get("type")
- if t == "" {
- switch rtype.Kind() {
- case reflect.Struct:
- t = "structure"
- case reflect.Slice:
- t = "list"
- case reflect.Map:
- t = "map"
- }
- }
-
- switch t {
- case "structure":
- if field, ok := rtype.FieldByName("SDKShapeTraits"); ok {
- tag = field.Tag
- }
- return parseStruct(r, node, tag)
- case "list":
- return parseList(r, node, tag)
- case "map":
- return parseMap(r, node, tag)
- default:
- return parseScalar(r, node, tag)
- }
-}
-
-// parseStruct deserializes a structure and its fields from an XMLNode. Any nested
-// types in the structure will also be deserialized.
-func parseStruct(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
- t := r.Type()
- if r.Kind() == reflect.Ptr {
- if r.IsNil() { // create the structure if it's nil
- s := reflect.New(r.Type().Elem())
- r.Set(s)
- r = s
- }
-
- r = r.Elem()
- t = t.Elem()
- }
-
- // unwrap any payloads
- if payload := tag.Get("payload"); payload != "" {
- field, _ := t.FieldByName(payload)
- return parseStruct(r.FieldByName(payload), node, field.Tag)
- }
-
- for i := 0; i < t.NumField(); i++ {
- field := t.Field(i)
- if c := field.Name[0:1]; strings.ToLower(c) == c {
- continue // ignore unexported fields
- }
-
- // figure out what this field is called
- name := field.Name
- if field.Tag.Get("flattened") != "" && field.Tag.Get("locationNameList") != "" {
- name = field.Tag.Get("locationNameList")
- } else if locName := field.Tag.Get("locationName"); locName != "" {
- name = locName
- }
-
- // try to find the field by name in elements
- elems := node.Children[name]
-
- if elems == nil { // try to find the field in attributes
- for _, a := range node.Attr {
- if name == a.Name.Local {
- // turn this into a text node for de-serializing
- elems = []*XMLNode{{Text: a.Value}}
- }
- }
- }
-
- member := r.FieldByName(field.Name)
- for _, elem := range elems {
- err := parse(member, elem, field.Tag)
- if err != nil {
- return err
- }
- }
- }
- return nil
-}
-
-// parseList deserializes a list of values from an XML node. Each list entry
-// will also be deserialized.
-func parseList(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
- t := r.Type()
-
- if tag.Get("flattened") == "" { // look at all item entries
- mname := "member"
- if name := tag.Get("locationNameList"); name != "" {
- mname = name
- }
-
- if Children, ok := node.Children[mname]; ok {
- if r.IsNil() {
- r.Set(reflect.MakeSlice(t, len(Children), len(Children)))
- }
-
- for i, c := range Children {
- err := parse(r.Index(i), c, "")
- if err != nil {
- return err
- }
- }
- }
- } else { // flattened list means this is a single element
- if r.IsNil() {
- r.Set(reflect.MakeSlice(t, 0, 0))
- }
-
- childR := reflect.Zero(t.Elem())
- r.Set(reflect.Append(r, childR))
- err := parse(r.Index(r.Len()-1), node, "")
- if err != nil {
- return err
- }
- }
-
- return nil
-}
-
-// parseMap deserializes a map from an XMLNode. The direct children of the XMLNode
-// will also be deserialized as map entries.
-func parseMap(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
- if r.IsNil() {
- r.Set(reflect.MakeMap(r.Type()))
- }
-
- if tag.Get("flattened") == "" { // look at all child entries
- for _, entry := range node.Children["entry"] {
- parseMapEntry(r, entry, tag)
- }
- } else { // this element is itself an entry
- parseMapEntry(r, node, tag)
- }
-
- return nil
-}
-
-// parseMapEntry deserializes a map entry from a XML node.
-func parseMapEntry(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
- kname, vname := "key", "value"
- if n := tag.Get("locationNameKey"); n != "" {
- kname = n
- }
- if n := tag.Get("locationNameValue"); n != "" {
- vname = n
- }
-
- keys, ok := node.Children[kname]
- values := node.Children[vname]
- if ok {
- for i, key := range keys {
- keyR := reflect.ValueOf(key.Text)
- value := values[i]
- valueR := reflect.New(r.Type().Elem()).Elem()
-
- parse(valueR, value, "")
- r.SetMapIndex(keyR, valueR)
- }
- }
- return nil
-}
-
-// parseScaller deserializes an XMLNode value into a concrete type based on the
-// interface type of r.
-//
-// Error is returned if the deserialization fails due to invalid type conversion,
-// or unsupported interface type.
-func parseScalar(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
- switch r.Interface().(type) {
- case *string:
- r.Set(reflect.ValueOf(&node.Text))
- return nil
- case []byte:
- b, err := base64.StdEncoding.DecodeString(node.Text)
- if err != nil {
- return err
- }
- r.Set(reflect.ValueOf(b))
- case *bool:
- v, err := strconv.ParseBool(node.Text)
- if err != nil {
- return err
- }
- r.Set(reflect.ValueOf(&v))
- case *int64:
- v, err := strconv.ParseInt(node.Text, 10, 64)
- if err != nil {
- return err
- }
- r.Set(reflect.ValueOf(&v))
- case *float64:
- v, err := strconv.ParseFloat(node.Text, 64)
- if err != nil {
- return err
- }
- r.Set(reflect.ValueOf(&v))
- case *time.Time:
- const ISO8601UTC = "2006-01-02T15:04:05Z"
- t, err := time.Parse(ISO8601UTC, node.Text)
- if err != nil {
- t, err = time.Parse("2006-01-02T15:04:05-07:00", node.Text)
- if err != nil {
- return err
- }
- }
- r.Set(reflect.ValueOf(&t))
- default:
- return fmt.Errorf("unsupported value: %v (%s)", r.Interface(), r.Type())
- }
- return nil
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil/xml_to_struct.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil/xml_to_struct.go
deleted file mode 100644
index 72c198a9..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil/xml_to_struct.go
+++ /dev/null
@@ -1,105 +0,0 @@
-package xmlutil
-
-import (
- "encoding/xml"
- "io"
- "sort"
-)
-
-// A XMLNode contains the values to be encoded or decoded.
-type XMLNode struct {
- Name xml.Name `json:",omitempty"`
- Children map[string][]*XMLNode `json:",omitempty"`
- Text string `json:",omitempty"`
- Attr []xml.Attr `json:",omitempty"`
-}
-
-// NewXMLElement returns a pointer to a new XMLNode initialized to default values.
-func NewXMLElement(name xml.Name) *XMLNode {
- return &XMLNode{
- Name: name,
- Children: map[string][]*XMLNode{},
- Attr: []xml.Attr{},
- }
-}
-
-// AddChild adds child to the XMLNode.
-func (n *XMLNode) AddChild(child *XMLNode) {
- if _, ok := n.Children[child.Name.Local]; !ok {
- n.Children[child.Name.Local] = []*XMLNode{}
- }
- n.Children[child.Name.Local] = append(n.Children[child.Name.Local], child)
-}
-
-// XMLToStruct converts a xml.Decoder stream to XMLNode with nested values.
-func XMLToStruct(d *xml.Decoder, s *xml.StartElement) (*XMLNode, error) {
- out := &XMLNode{}
- for {
- tok, err := d.Token()
- if tok == nil || err == io.EOF {
- break
- }
- if err != nil {
- return out, err
- }
-
- switch typed := tok.(type) {
- case xml.CharData:
- out.Text = string(typed.Copy())
- case xml.StartElement:
- el := typed.Copy()
- out.Attr = el.Attr
- if out.Children == nil {
- out.Children = map[string][]*XMLNode{}
- }
-
- name := typed.Name.Local
- slice := out.Children[name]
- if slice == nil {
- slice = []*XMLNode{}
- }
- node, e := XMLToStruct(d, &el)
- if e != nil {
- return out, e
- }
- node.Name = typed.Name
- slice = append(slice, node)
- out.Children[name] = slice
- case xml.EndElement:
- if s != nil && s.Name.Local == typed.Name.Local { // matching end token
- return out, nil
- }
- }
- }
- return out, nil
-}
-
-// StructToXML writes an XMLNode to a xml.Encoder as tokens.
-func StructToXML(e *xml.Encoder, node *XMLNode, sorted bool) error {
- e.EncodeToken(xml.StartElement{Name: node.Name, Attr: node.Attr})
-
- if node.Text != "" {
- e.EncodeToken(xml.CharData([]byte(node.Text)))
- } else if sorted {
- sortedNames := []string{}
- for k := range node.Children {
- sortedNames = append(sortedNames, k)
- }
- sort.Strings(sortedNames)
-
- for _, k := range sortedNames {
- for _, v := range node.Children[k] {
- StructToXML(e, v, sorted)
- }
- }
- } else {
- for _, c := range node.Children {
- for _, v := range c {
- StructToXML(e, v, sorted)
- }
- }
- }
-
- e.EncodeToken(xml.EndElement{Name: node.Name})
- return e.Flush()
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/signer/v2/v2.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/signer/v2/v2.go
deleted file mode 100644
index a699ca33..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/signer/v2/v2.go
+++ /dev/null
@@ -1,357 +0,0 @@
-package v2
-
-import (
- "crypto/hmac"
- "crypto/sha1"
- "encoding/base64"
- "fmt"
- "github.com/ks3sdklib/aws-sdk-go/aws/awsutil"
- "io"
- "net/http"
- "net/url"
- "sort"
- "strconv"
- "strings"
- "time"
-
- "github.com/ks3sdklib/aws-sdk-go/aws/credentials"
- "github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest"
-
- "github.com/ks3sdklib/aws-sdk-go/aws"
-)
-
-const (
- authHeaderPrefix = "AWS"
- timeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
-)
-
-var signQuerys = map[string]bool{
- "acl": true,
- "lifecycle": true,
- "location": true,
- "logging": true,
- "notification": true,
- "policy": true,
- "requestPayment": true,
- "torrent": true,
- "uploadId": true,
- "uploads": true,
- "versionId": true,
- "versioning": true,
- "versions": true,
- "website": true,
- "delete": true,
- "thumbnail": true,
- "cors": true,
- "pfop": true,
- "querypfop": true,
- "partNumber": true,
- "response-content-type": true,
- "response-content-language": true,
- "response-expires": true,
- "response-cache-control": true,
- "response-content-disposition": true,
- "response-content-encoding": true,
- "tagging": true,
- "fetch": true,
- "copy": true,
- "mirror": true,
-}
-
-type signer struct {
- Service *aws.Service
- Request *http.Request
- Time time.Time
- ExpireTime time.Duration
- ServiceName string
- Region string
- CredValues credentials.Value
- Credentials *credentials.Credentials
- Query url.Values
- Body io.ReadSeeker
- Debug uint
- Logger io.Writer
-
- isPresign bool
- formattedTime string
-
- canonicalHeaders string
- canonicalResource string
- stringToSign string
- signature string
- authorization string
- awsRequest *aws.Request
-}
-
-func Sign(req *aws.Request) {
- if req.Service.Config.Credentials == credentials.AnonymousCredentials {
- return
- }
-
- region := req.Service.SigningRegion
- if region == "" {
- region = req.Service.Config.Region
- }
-
- name := req.Service.SigningName
- if name == "" {
- name = req.Service.ServiceName
- }
-
- s := signer{
- Service: req.Service,
- Request: req.HTTPRequest,
- Time: req.Time,
- ExpireTime: req.ExpireTime,
- Query: req.HTTPRequest.URL.Query(),
- Body: req.Body,
- ServiceName: name,
- Region: region,
- Credentials: req.Service.Config.Credentials,
- Debug: req.Service.Config.LogLevel,
- Logger: req.Service.Config.Logger,
- awsRequest: req,
- }
-
- req.Error = s.sign()
-}
-
-func (v2 *signer) sign() error {
- if v2.ExpireTime != 0 {
- v2.isPresign = true
- }
-
- if v2.isRequestSigned() {
- if !v2.Credentials.IsExpired() {
- // If the request is already signed, and the credentials have not
- // expired yet ignore the signing request.
- return nil
- }
-
- // The credentials have expired for this request. The current signing
- // is invalid, and needs to be request because the request will fail.
- if v2.isPresign {
- v2.removePresign()
- // Update the request's query string to ensure the values stays in
- // sync in the case retrieving the new credentials fails.
- v2.Request.URL.RawQuery = v2.Query.Encode()
- }
- }
-
- var err error
- v2.CredValues, err = v2.Credentials.Get()
- if err != nil {
- return err
- }
-
- v2.build()
-
- if v2.Debug > 0 {
- v2.logSigningInfo()
- }
-
- return nil
-}
-
-func (v2 *signer) logSigningInfo() {
- out := v2.Logger
- fmt.Fprintf(out, "---[ STRING TO SIGN ]--------------------------------\n")
- fmt.Fprintln(out, v2.stringToSign)
- if v2.isPresign {
- fmt.Fprintf(out, "---[ SIGNED URL ]--------------------------------\n")
- fmt.Fprintln(out, v2.Request.URL)
- }
- fmt.Fprintf(out, "-----------------------------------------------------\n")
-}
-
-func (v2 *signer) build() {
-
- v2.buildTime() // no depends
- v2.buildCanonicalHeaders() // depends on cred string
- v2.buildCanonicalResource() // depends on canon headers / signed headers
- v2.buildStringToSign() // depends on canon string
- v2.buildSignature() // depends on string to sign
-
- if v2.isPresign {
- var querys url.Values
- querys = make(map[string][]string)
- querys.Add("Signature", v2.signature)
- querys.Add("AWSAccessKeyId", v2.CredValues.AccessKeyID)
- v2.Request.URL.RawQuery += "&" + querys.Encode()
- } else {
- v2.Request.Header.Set("Authorization", "AWS "+v2.CredValues.AccessKeyID+":"+v2.signature)
- }
-}
-
-func (v2 *signer) buildTime() {
- v2.formattedTime = v2.Time.UTC().Format(timeFormat)
-
- if v2.isPresign {
- duration := int64(v2.ExpireTime / time.Second)
- v2.Query.Set("Expires", strconv.FormatInt(duration, 10))
- } else {
- v2.Request.Header.Set("Date", v2.formattedTime)
- }
-}
-
-func (v2 *signer) buildCanonicalHeaders() {
- var headers []string
- for k, v := range v2.Request.Header {
- if strings.HasPrefix(k, "X-Amz-") {
- key := strings.ToLower(http.CanonicalHeaderKey(k))
- v2.Request.Header[key] = v
- v2.Request.Header.Del(http.CanonicalHeaderKey(k))
- headers = append(headers, key)
- }
- }
- sort.Strings(headers)
-
- headerValues := make([]string, len(headers))
- for i, k := range headers {
- key := strings.ToLower(http.CanonicalHeaderKey(k))
- headerValues[i] = key + ":" + strings.Join(v2.Request.Header[key], ",")
- }
-
- v2.canonicalHeaders = strings.Join(headerValues, "\n")
-}
-
-func (v2 *signer) buildCanonicalResource() {
- endpoint := v2.Service.Endpoint
-
- v2.Request.URL.RawQuery = strings.Replace(v2.Query.Encode(), "+", "%20", -1)
- url := v2.Request.URL.String()
- //在aws.service.go,buildEndpoint会把sheme也加上
- pathStyle := strings.HasPrefix(url, endpoint)
- uri := v2.Request.URL.Opaque
- b := awsutil.ValuesAtPath(v2.awsRequest.Params, "Bucket")
- bucket := b[0].(string)
- bucketInHost := ""
- if !pathStyle {
- if strings.HasPrefix(url, "http://") {
- url = url[7:]
- endpoint = endpoint[7:]
- } else if strings.HasPrefix(url, "https://") {
- url = url[8:]
- endpoint = endpoint[8:]
- }
- bucketInHost = url[0 : strings.Index(url, endpoint)-1]
- }
- if uri != "" {
- uris := strings.Split(uri, "/")[3:]
- append := false
- if len(uris) == 1 && uris[0] != "" && bucketInHost == "" {
- //只有bucket
- append = true
- } else if len(uris) == 0 && bucketInHost != "" {
- append = true
- }
- uri = "/" + strings.Join(strings.Split(uri, "/")[3:], "/")
- if bucketInHost != "" {
- uri = "/" + bucketInHost + uri
- }
- if v2.awsRequest.Config.DomainMode {
- uri = "/" + bucket + uri
- append = false
- }
- if append {
- uri += "/"
- }
- } else {
- uri = v2.Request.URL.Path
- }
- if uri == "" {
- uri = "/"
- }
-
- if v2.ServiceName != "s3" {
- uri = rest.EscapePath(uri, false)
- }
-
- var querys []string
- for k := range v2.Query {
- if _, ok := signQuerys[k]; ok {
- querys = append(querys, k)
- }
- }
- sort.Strings(querys)
-
- queryValues := make([]string, len(querys))
- for i, k := range querys {
- v := v2.Query[k]
- vString := strings.Join(v, ",")
- if vString != "" {
- queryValues[i] = k + "=" + vString
- } else {
- queryValues[i] = k
- }
- }
- queryString := strings.Join(queryValues, "&")
- if queryString == "" {
- v2.canonicalResource = uri
- } else {
- v2.canonicalResource = uri + "?" + queryString
- }
-}
-
-func (v2 *signer) buildStringToSign() {
- md5list := v2.Request.Header["Content-Md5"]
- md5 := ""
- if len(md5list) > 0 {
- md5 = v2.Request.Header["Content-Md5"][0]
- }
-
- typelist := v2.Request.Header["Content-Type"]
- contenttype := ""
- if len(typelist) > 0 {
- contenttype = v2.Request.Header["Content-Type"][0]
- }
-
- signItems := []string{v2.Request.Method, md5, contenttype}
- if v2.isPresign {
- signItems = append(signItems, v2.Query["Expires"][0])
- } else {
- signItems = append(signItems, v2.formattedTime)
- }
- if v2.canonicalHeaders != "" {
- signItems = append(signItems, v2.canonicalHeaders)
- }
- signItems = append(signItems, v2.canonicalResource)
-
- v2.stringToSign = strings.Join(signItems, "\n")
-
-}
-
-func (v2 *signer) buildSignature() {
- secret := v2.CredValues.SecretAccessKey
- signature := string(base64Encode(makeHmac([]byte(secret), []byte(v2.stringToSign))))
- v2.signature = signature
-}
-
-// isRequestSigned returns if the request is currently signed or presigned
-func (v2 *signer) isRequestSigned() bool {
- if v2.isPresign && v2.Query.Get("Signature") != "" {
- return true
- }
- if v2.Request.Header.Get("Authorization") != "" {
- return true
- }
-
- return false
-}
-
-// unsign removes signing flags for both signed and presigned requests.
-func (v2 *signer) removePresign() {
- v2.Query.Del("AWSAccessKeyId")
- v2.Query.Del("Signature")
- v2.Query.Del("Expires")
-
-}
-
-func makeHmac(key []byte, data []byte) []byte {
- hash := hmac.New(sha1.New, key)
- hash.Write(data)
- return hash.Sum(nil)
-}
-func base64Encode(src []byte) []byte {
- return []byte(base64.StdEncoding.EncodeToString(src))
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/signer/v4/v4.go b/vendor/github.com/ks3sdklib/aws-sdk-go/internal/signer/v4/v4.go
deleted file mode 100644
index 52674083..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/internal/signer/v4/v4.go
+++ /dev/null
@@ -1,371 +0,0 @@
-// Package v4 implements signing for AWS V4 signer
-package v4
-
-import (
- "crypto/hmac"
- "crypto/sha256"
- "encoding/hex"
- "fmt"
- "io"
- "net/http"
- "net/url"
- "sort"
- "strconv"
- "strings"
- "time"
-
- "github.com/ks3sdklib/aws-sdk-go/aws/credentials"
- "github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest"
-
- "github.com/ks3sdklib/aws-sdk-go/aws"
-)
-
-const (
- authHeaderPrefix = "AWS4-HMAC-SHA256"
- timeFormat = "20060102T150405Z"
- shortTimeFormat = "20060102"
-)
-
-var ignoredHeaders = map[string]bool{
- "Authorization": true,
- "Content-Type": true,
- "Content-Length": true,
- "User-Agent": true,
-}
-
-type signer struct {
- Request *http.Request
- Time time.Time
- ExpireTime time.Duration
- ServiceName string
- Region string
- CredValues credentials.Value
- Credentials *credentials.Credentials
- Query url.Values
- Body io.ReadSeeker
- Debug uint
- Logger io.Writer
-
- isPresign bool
- isSignBody bool
- formattedTime string
- formattedShortTime string
-
- signedHeaders string
- canonicalHeaders string
- canonicalString string
- credentialString string
- stringToSign string
- signature string
- authorization string
-}
-
-// Sign requests with signature version 4.
-//
-// Will sign the requests with the service config's Credentials object
-// Signing is skipped if the credentials is the credentials.AnonymousCredentials
-// object.
-func Sign(req *aws.Request) {
- // If the request does not need to be signed ignore the signing of the
- // request if the AnonymousCredentials object is used.
- if req.Service.Config.Credentials == credentials.AnonymousCredentials {
- return
- }
-
- region := req.Service.SigningRegion
- if region == "" {
- region = req.Service.Config.Region
- }
-
- name := req.Service.SigningName
- if name == "" {
- name = req.Service.ServiceName
- }
-
- s := signer{
- Request: req.HTTPRequest,
- Time: req.Time,
- ExpireTime: req.ExpireTime,
- Query: req.HTTPRequest.URL.Query(),
- Body: req.Body,
- ServiceName: name,
- Region: region,
- Credentials: req.Service.Config.Credentials,
- Debug: req.Service.Config.LogLevel,
- Logger: req.Service.Config.Logger,
- }
- if req.Service.Config.SignerVersion == "V4_UNSIGNED_PAYLOAD_SIGNER" {
- s.isSignBody = false
- } else {
- s.isSignBody = true
- }
- req.Error = s.sign()
-}
-
-func (v4 *signer) sign() error {
- if v4.ExpireTime != 0 {
- v4.isPresign = true
- }
-
- if v4.isRequestSigned() {
- if !v4.Credentials.IsExpired() {
- // If the request is already signed, and the credentials have not
- // expired yet ignore the signing request.
- return nil
- }
-
- // The credentials have expired for this request. The current signing
- // is invalid, and needs to be request because the request will fail.
- if v4.isPresign {
- v4.removePresign()
- // Update the request's query string to ensure the values stays in
- // sync in the case retrieving the new credentials fails.
- v4.Request.URL.RawQuery = v4.Query.Encode()
- }
- }
-
- var err error
- v4.CredValues, err = v4.Credentials.Get()
- if err != nil {
- return err
- }
-
- if v4.isPresign {
- v4.Query.Set("X-Amz-Algorithm", authHeaderPrefix)
- if v4.CredValues.SessionToken != "" {
- v4.Query.Set("X-Amz-Security-Token", v4.CredValues.SessionToken)
- } else {
- v4.Query.Del("X-Amz-Security-Token")
- }
- } else if v4.CredValues.SessionToken != "" {
- v4.Request.Header.Set("X-Amz-Security-Token", v4.CredValues.SessionToken)
- }
-
- v4.build()
-
- if v4.Debug > 0 {
- v4.logSigningInfo()
- }
-
- return nil
-}
-
-func (v4 *signer) logSigningInfo() {
- out := v4.Logger
- fmt.Fprintf(out, "---[ CANONICAL STRING ]-----------------------------\n")
- fmt.Fprintln(out, v4.canonicalString)
- fmt.Fprintf(out, "---[ STRING TO SIGN ]--------------------------------\n")
- fmt.Fprintln(out, v4.stringToSign)
- if v4.isPresign {
- fmt.Fprintf(out, "---[ SIGNED URL ]--------------------------------\n")
- fmt.Fprintln(out, v4.Request.URL)
- }
- fmt.Fprintf(out, "-----------------------------------------------------\n")
-}
-
-func (v4 *signer) build() {
-
- v4.buildTime() // no depends
- v4.buildCredentialString() // no depends
- if v4.isPresign {
- v4.buildQuery() // no depends
- }
- v4.buildCanonicalHeaders() // depends on cred string
- v4.buildCanonicalString() // depends on canon headers / signed headers
- v4.buildStringToSign() // depends on canon string
- v4.buildSignature() // depends on string to sign
-
- if v4.isPresign {
- v4.Request.URL.RawQuery += "&X-Amz-Signature=" + v4.signature
- } else {
- parts := []string{
- authHeaderPrefix + " Credential=" + v4.CredValues.AccessKeyID + "/" + v4.credentialString,
- "SignedHeaders=" + v4.signedHeaders,
- "Signature=" + v4.signature,
- }
- v4.Request.Header.Set("Authorization", strings.Join(parts, ", "))
- }
-}
-
-func (v4 *signer) buildTime() {
- v4.formattedTime = v4.Time.UTC().Format(timeFormat)
- v4.formattedShortTime = v4.Time.UTC().Format(shortTimeFormat)
-
- if v4.isPresign {
- duration := int64(v4.ExpireTime / time.Second)
- v4.Query.Set("X-Amz-Date", v4.formattedTime)
- v4.Query.Set("X-Amz-Expires", strconv.FormatInt(duration, 10))
- } else {
- v4.Request.Header.Set("X-Amz-Date", v4.formattedTime)
- }
-}
-
-func (v4 *signer) buildCredentialString() {
- v4.credentialString = strings.Join([]string{
- v4.formattedShortTime,
- v4.Region,
- v4.ServiceName,
- "aws4_request",
- }, "/")
-
- if v4.isPresign {
- v4.Query.Set("X-Amz-Credential", v4.CredValues.AccessKeyID+"/"+v4.credentialString)
- }
-}
-
-func (v4 *signer) buildQuery() {
- for k, h := range v4.Request.Header {
- if strings.HasPrefix(http.CanonicalHeaderKey(k), "X-Amz-") {
- continue // never hoist x-amz-* headers, they must be signed
- }
- if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok {
- continue // never hoist ignored headers
- }
-
- v4.Request.Header.Del(k)
- v4.Query.Del(k)
- for _, v := range h {
- v4.Query.Add(k, v)
- }
- }
-}
-
-func (v4 *signer) buildCanonicalHeaders() {
- var headers []string
- headers = append(headers, "host")
- for k := range v4.Request.Header {
- if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok {
- continue // ignored header
- }
- headers = append(headers, strings.ToLower(k))
- }
- sort.Strings(headers)
-
- v4.signedHeaders = strings.Join(headers, ";")
-
- if v4.isPresign {
- v4.Query.Set("X-Amz-SignedHeaders", v4.signedHeaders)
- }
-
- headerValues := make([]string, len(headers))
- for i, k := range headers {
- if k == "host" {
- headerValues[i] = "host:" + v4.Request.URL.Host
- } else {
- headerValues[i] = k + ":" +
- strings.Join(v4.Request.Header[http.CanonicalHeaderKey(k)], ",")
- }
- }
-
- v4.canonicalHeaders = strings.Join(headerValues, "\n")
-}
-
-func (v4 *signer) buildCanonicalString() {
- v4.Request.URL.RawQuery = strings.Replace(v4.Query.Encode(), "+", "%20", -1)
- uri := v4.Request.URL.Opaque
- if uri != "" {
- uri = "/" + strings.Join(strings.Split(uri, "/")[3:], "/")
- } else {
- uri = v4.Request.URL.Path
- }
- if uri == "" {
- uri = "/"
- }
-
- if v4.ServiceName != "s3" {
- uri = rest.EscapePath(uri, false)
- }
-
- v4.canonicalString = strings.Join([]string{
- v4.Request.Method,
- uri,
- v4.Request.URL.RawQuery,
- v4.canonicalHeaders + "\n",
- v4.signedHeaders,
- v4.bodyDigest(),
- }, "\n")
-}
-
-func (v4 *signer) buildStringToSign() {
- v4.stringToSign = strings.Join([]string{
- authHeaderPrefix,
- v4.formattedTime,
- v4.credentialString,
- hex.EncodeToString(makeSha256([]byte(v4.canonicalString))),
- }, "\n")
-}
-
-func (v4 *signer) buildSignature() {
- secret := v4.CredValues.SecretAccessKey
- date := makeHmac([]byte("AWS4"+secret), []byte(v4.formattedShortTime))
- region := makeHmac(date, []byte(v4.Region))
- service := makeHmac(region, []byte(v4.ServiceName))
- credentials := makeHmac(service, []byte("aws4_request"))
- signature := makeHmac(credentials, []byte(v4.stringToSign))
- v4.signature = hex.EncodeToString(signature)
-}
-
-func (v4 *signer) bodyDigest() string {
- hash := v4.Request.Header.Get("X-Amz-Content-Sha256")
- if hash == "" {
- if v4.isPresign && v4.ServiceName == "s3" {
- hash = "UNSIGNED-PAYLOAD"
- } else {
- if v4.isSignBody {
- if v4.Body == nil {
- hash = hex.EncodeToString(makeSha256([]byte{}))
- } else {
- hash = hex.EncodeToString(makeSha256Reader(v4.Body))
- }
- } else {
- hash = "UNSIGNED-PAYLOAD"
- }
- }
- v4.Request.Header.Add("X-Amz-Content-Sha256", hash)
- }
- return hash
-}
-
-// isRequestSigned returns if the request is currently signed or presigned
-func (v4 *signer) isRequestSigned() bool {
- if v4.isPresign && v4.Query.Get("X-Amz-Signature") != "" {
- return true
- }
- if v4.Request.Header.Get("Authorization") != "" {
- return true
- }
-
- return false
-}
-
-// unsign removes signing flags for both signed and presigned requests.
-func (v4 *signer) removePresign() {
- v4.Query.Del("X-Amz-Algorithm")
- v4.Query.Del("X-Amz-Signature")
- v4.Query.Del("X-Amz-Security-Token")
- v4.Query.Del("X-Amz-Date")
- v4.Query.Del("X-Amz-Expires")
- v4.Query.Del("X-Amz-Credential")
- v4.Query.Del("X-Amz-SignedHeaders")
-}
-
-func makeHmac(key []byte, data []byte) []byte {
- hash := hmac.New(sha256.New, key)
- hash.Write(data)
- return hash.Sum(nil)
-}
-
-func makeSha256(data []byte) []byte {
- hash := sha256.New()
- hash.Write(data)
- return hash.Sum(nil)
-}
-
-func makeSha256Reader(reader io.ReadSeeker) []byte {
- hash := sha256.New()
- start, _ := reader.Seek(0, 1)
- defer reader.Seek(start, 0)
-
- io.Copy(hash, reader)
- return hash.Sum(nil)
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/api.go b/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/api.go
deleted file mode 100644
index c01359de..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/api.go
+++ /dev/null
@@ -1,6626 +0,0 @@
-// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
-
-// Package s3 provides a client for Amazon Simple Storage Service.
-package s3
-
-import (
- "bytes"
- "crypto/hmac"
- "crypto/sha1"
- "encoding/base64"
- "encoding/json"
- "encoding/xml"
- "errors"
- "fmt"
- "github.com/ks3sdklib/aws-sdk-go/aws"
- "github.com/ks3sdklib/aws-sdk-go/aws/awserr"
- "hash"
- "io"
- "io/ioutil"
- "net/http"
- "net/url"
- "os"
- "sort"
- "strings"
- "sync"
- "time"
-)
-
-var oprw sync.Mutex
-var TempFileSuffix = ".temp" // Temp file suffix
-
-// AbortMultipartUploadRequest generates a request for the AbortMultipartUpload operation.
-func (c *S3) AbortMultipartUploadRequest(input *AbortMultipartUploadInput) (req *aws.Request, output *AbortMultipartUploadOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opAbortMultipartUpload == nil {
- opAbortMultipartUpload = &aws.Operation{
- Name: "AbortMultipartUpload",
- HTTPMethod: "DELETE",
- HTTPPath: "/{Bucket}/{Key+}",
- }
- }
-
- if input == nil {
- input = &AbortMultipartUploadInput{}
- }
-
- req = c.newRequest(opAbortMultipartUpload, input, output)
- output = &AbortMultipartUploadOutput{}
- req.Data = output
- return
-}
-
-// Aborts a multipart upload.
-//
-// To verify that all parts have been removed, so you don't get charged for
-// the part storage, you should call the List Parts operation and ensure the
-// parts list is empty.
-func (c *S3) AbortMultipartUpload(input *AbortMultipartUploadInput) (*AbortMultipartUploadOutput, error) {
- req, out := c.AbortMultipartUploadRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) AbortMultipartUploadPresignedUrl(input *AbortMultipartUploadInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.AbortMultipartUploadRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opAbortMultipartUpload *aws.Operation
-
-// CompleteMultipartUploadRequest generates a request for the CompleteMultipartUpload operation.
-func (c *S3) CompleteMultipartUploadRequest(input *CompleteMultipartUploadInput) (req *aws.Request, output *CompleteMultipartUploadOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opCompleteMultipartUpload == nil {
- opCompleteMultipartUpload = &aws.Operation{
- Name: "CompleteMultipartUpload",
- HTTPMethod: "POST",
- HTTPPath: "/{Bucket}/{Key+}",
- }
- }
-
- if input == nil {
- input = &CompleteMultipartUploadInput{}
- }
-
- req = c.newRequest(opCompleteMultipartUpload, input, output)
- output = &CompleteMultipartUploadOutput{}
- req.Data = output
- return
-}
-
-// Completes a multipart upload by assembling previously uploaded parts.
-func (c *S3) CompleteMultipartUpload(input *CompleteMultipartUploadInput) (*CompleteMultipartUploadOutput, error) {
- req, out := c.CompleteMultipartUploadRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) CompleteMultipartUploadPresignedUrl(input *CompleteMultipartUploadInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.CompleteMultipartUploadRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opCompleteMultipartUpload *aws.Operation
-
-// CopyObjectRequest generates a request for the CopyObject operation.
-func (c *S3) CopyObjectRequest(input *CopyObjectInput) (req *aws.Request, output *CopyObjectOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opCopyObject == nil {
- opCopyObject = &aws.Operation{
- Name: "CopyObject",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}/{Key+}",
- }
- }
-
- if input == nil {
- input = &CopyObjectInput{}
- }
-
- req = c.newRequest(opCopyObject, input, output)
- output = &CopyObjectOutput{}
- req.Data = output
- return
-}
-
-// Creates a copy of an object that is already stored in Amazon S3.
-func (c *S3) CopyObject(input *CopyObjectInput) (*CopyObjectOutput, error) {
- req, out := c.CopyObjectRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) CopyObjectPresignedUrl(input *CopyObjectInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.CopyObjectRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opCopyObject *aws.Operation
-
-// CreateBucketRequest generates a request for the CreateBucket operation.
-func (c *S3) CreateBucketRequest(input *CreateBucketInput) (req *aws.Request, output *CreateBucketOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opCreateBucket == nil {
- if input.ProjectId == nil {
- opCreateBucket = &aws.Operation{
- Name: "CreateBucket",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}",
- }
- } else {
- opCreateBucket = &aws.Operation{
- Name: "CreateBucket",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?projectId=" + *input.ProjectId,
- }
- }
- }
-
- if input == nil {
- input = &CreateBucketInput{}
- }
-
- req = c.newRequest(opCreateBucket, input, output)
- output = &CreateBucketOutput{}
- req.Data = output
- return
-}
-
-// Creates a new bucket.
-func (c *S3) CreateBucket(input *CreateBucketInput) (*CreateBucketOutput, error) {
- req, out := c.CreateBucketRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) CreateBucketPresignedUrl(input *CreateBucketInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.CreateBucketRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opCreateBucket *aws.Operation
-
-// CreateMultipartUploadRequest generates a request for the CreateMultipartUpload operation.
-func (c *S3) CreateMultipartUploadRequest(input *CreateMultipartUploadInput) (req *aws.Request, output *CreateMultipartUploadOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opCreateMultipartUpload == nil {
- opCreateMultipartUpload = &aws.Operation{
- Name: "CreateMultipartUpload",
- HTTPMethod: "POST",
- HTTPPath: "/{Bucket}/{Key+}?uploads",
- }
- }
-
- if input == nil {
- input = &CreateMultipartUploadInput{}
- }
-
- req = c.newRequest(opCreateMultipartUpload, input, output)
- output = &CreateMultipartUploadOutput{}
- req.Data = output
- return
-}
-
-// Initiates a multipart upload and returns an upload ID.
-//
-// Note: After you initiate multipart upload and upload one or more parts,
-// you must either complete or abort multipart upload in order to stop getting
-// charged for storage of the uploaded parts. Only after you either complete
-// or abort multipart upload, Amazon S3 frees up the parts storage and stops
-// charging you for the parts storage.
-func (c *S3) CreateMultipartUpload(input *CreateMultipartUploadInput) (*CreateMultipartUploadOutput, error) {
- req, out := c.CreateMultipartUploadRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) CreateMultipartUploadPresignedUrl(input *CreateMultipartUploadInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.CreateMultipartUploadRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opCreateMultipartUpload *aws.Operation
-
-// DeleteBucketRequest generates a request for the DeleteBucket operation.
-func (c *S3) DeleteBucketRequest(input *DeleteBucketInput) (req *aws.Request, output *DeleteBucketOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opDeleteBucket == nil {
- opDeleteBucket = &aws.Operation{
- Name: "DeleteBucket",
- HTTPMethod: "DELETE",
- HTTPPath: "/{Bucket}",
- }
- }
-
- if input == nil {
- input = &DeleteBucketInput{}
- }
-
- req = c.newRequest(opDeleteBucket, input, output)
- output = &DeleteBucketOutput{}
- req.Data = output
- return
-}
-
-// Deletes the bucket. All objects (including all object versions and Delete
-// Markers) in the bucket must be deleted before the bucket itself can be deleted.
-func (c *S3) DeleteBucket(input *DeleteBucketInput) (*DeleteBucketOutput, error) {
- req, out := c.DeleteBucketRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) DeleteBucketPresignedUrl(input *DeleteBucketInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.DeleteBucketRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opDeleteBucket *aws.Operation
-
-// DeleteBucketCORSRequest generates a request for the DeleteBucketCORS operation.
-func (c *S3) DeleteBucketCORSRequest(input *DeleteBucketCORSInput) (req *aws.Request, output *DeleteBucketCORSOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opDeleteBucketCORS == nil {
- opDeleteBucketCORS = &aws.Operation{
- Name: "DeleteBucketCors",
- HTTPMethod: "DELETE",
- HTTPPath: "/{Bucket}?cors",
- }
- }
-
- if input == nil {
- input = &DeleteBucketCORSInput{}
- }
-
- req = c.newRequest(opDeleteBucketCORS, input, output)
- output = &DeleteBucketCORSOutput{}
- req.Data = output
- return
-}
-
-// Deletes the cors configuration information set for the bucket.
-func (c *S3) DeleteBucketCORS(input *DeleteBucketCORSInput) (*DeleteBucketCORSOutput, error) {
- req, out := c.DeleteBucketCORSRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) DeleteBucketCORSPresignedUrl(input *DeleteBucketCORSInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.DeleteBucketCORSRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opDeleteBucketCORS *aws.Operation
-
-// DeleteBucketLifecycleRequest generates a request for the DeleteBucketLifecycle operation.
-func (c *S3) DeleteBucketLifecycleRequest(input *DeleteBucketLifecycleInput) (req *aws.Request, output *DeleteBucketLifecycleOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opDeleteBucketLifecycle == nil {
- opDeleteBucketLifecycle = &aws.Operation{
- Name: "DeleteBucketLifecycle",
- HTTPMethod: "DELETE",
- HTTPPath: "/{Bucket}?lifecycle",
- }
- }
-
- if input == nil {
- input = &DeleteBucketLifecycleInput{}
- }
-
- req = c.newRequest(opDeleteBucketLifecycle, input, output)
- output = &DeleteBucketLifecycleOutput{}
- req.Data = output
- return
-}
-
-// Deletes the lifecycle configuration from the bucket.
-func (c *S3) DeleteBucketLifecycle(input *DeleteBucketLifecycleInput) (*DeleteBucketLifecycleOutput, error) {
- req, out := c.DeleteBucketLifecycleRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) DeleteBucketLifecyclePresignedUrl(input *DeleteBucketLifecycleInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.DeleteBucketLifecycleRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opDeleteBucketLifecycle *aws.Operation
-
-// DeleteBucketPolicyRequest generates a request for the DeleteBucketPolicy operation.
-func (c *S3) DeleteBucketPolicyRequest(input *DeleteBucketPolicyInput) (req *aws.Request, output *DeleteBucketPolicyOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opDeleteBucketPolicy == nil {
- opDeleteBucketPolicy = &aws.Operation{
- Name: "DeleteBucketPolicy",
- HTTPMethod: "DELETE",
- HTTPPath: "/{Bucket}?policy",
- }
- }
-
- if input == nil {
- input = &DeleteBucketPolicyInput{}
- }
-
- req = c.newRequest(opDeleteBucketPolicy, input, output)
- output = &DeleteBucketPolicyOutput{}
- req.Data = output
- return
-}
-
-// Deletes the policy from the bucket.
-func (c *S3) DeleteBucketPolicy(input *DeleteBucketPolicyInput) (*DeleteBucketPolicyOutput, error) {
- req, out := c.DeleteBucketPolicyRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) DeleteBucketPolicyPresignedUrl(input *DeleteBucketPolicyInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.DeleteBucketPolicyRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opDeleteBucketPolicy *aws.Operation
-
-// DeleteBucketReplicationRequest generates a request for the DeleteBucketReplication operation.
-func (c *S3) DeleteBucketReplicationRequest(input *DeleteBucketReplicationInput) (req *aws.Request, output *DeleteBucketReplicationOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opDeleteBucketReplication == nil {
- opDeleteBucketReplication = &aws.Operation{
- Name: "DeleteBucketReplication",
- HTTPMethod: "DELETE",
- HTTPPath: "/{Bucket}?replication",
- }
- }
-
- if input == nil {
- input = &DeleteBucketReplicationInput{}
- }
-
- req = c.newRequest(opDeleteBucketReplication, input, output)
- output = &DeleteBucketReplicationOutput{}
- req.Data = output
- return
-}
-
-func (c *S3) DeleteBucketReplication(input *DeleteBucketReplicationInput) (*DeleteBucketReplicationOutput, error) {
- req, out := c.DeleteBucketReplicationRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) DeleteBucketReplicationPresignedUrl(input *DeleteBucketReplicationInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.DeleteBucketReplicationRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opDeleteBucketReplication *aws.Operation
-
-// DeleteBucketTaggingRequest generates a request for the DeleteBucketTagging operation.
-func (c *S3) DeleteBucketTaggingRequest(input *DeleteBucketTaggingInput) (req *aws.Request, output *DeleteBucketTaggingOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opDeleteBucketTagging == nil {
- opDeleteBucketTagging = &aws.Operation{
- Name: "DeleteBucketTagging",
- HTTPMethod: "DELETE",
- HTTPPath: "/{Bucket}?tagging",
- }
- }
-
- if input == nil {
- input = &DeleteBucketTaggingInput{}
- }
-
- req = c.newRequest(opDeleteBucketTagging, input, output)
- output = &DeleteBucketTaggingOutput{}
- req.Data = output
- return
-}
-
-// Deletes the tags from the bucket.
-func (c *S3) DeleteBucketTagging(input *DeleteBucketTaggingInput) (*DeleteBucketTaggingOutput, error) {
- req, out := c.DeleteBucketTaggingRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) DeleteBucketTaggingPresignedUrl(input *DeleteBucketTaggingInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.DeleteBucketTaggingRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opDeleteBucketTagging *aws.Operation
-
-// DeleteBucketWebsiteRequest generates a request for the DeleteBucketWebsite operation.
-func (c *S3) DeleteBucketWebsiteRequest(input *DeleteBucketWebsiteInput) (req *aws.Request, output *DeleteBucketWebsiteOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opDeleteBucketWebsite == nil {
- opDeleteBucketWebsite = &aws.Operation{
- Name: "DeleteBucketWebsite",
- HTTPMethod: "DELETE",
- HTTPPath: "/{Bucket}?website",
- }
- }
-
- if input == nil {
- input = &DeleteBucketWebsiteInput{}
- }
-
- req = c.newRequest(opDeleteBucketWebsite, input, output)
- output = &DeleteBucketWebsiteOutput{}
- req.Data = output
- return
-}
-
-// This operation removes the website configuration from the bucket.
-func (c *S3) DeleteBucketWebsite(input *DeleteBucketWebsiteInput) (*DeleteBucketWebsiteOutput, error) {
- req, out := c.DeleteBucketWebsiteRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) DeleteBucketWebsitePresignedUrl(input *DeleteBucketWebsiteInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.DeleteBucketWebsiteRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opDeleteBucketWebsite *aws.Operation
-
-// DeleteObjectRequest generates a request for the DeleteObject operation.
-func (c *S3) DeleteObjectRequest(input *DeleteObjectInput) (req *aws.Request, output *DeleteObjectOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opDeleteObject == nil {
- opDeleteObject = &aws.Operation{
- Name: "DeleteObject",
- HTTPMethod: "DELETE",
- HTTPPath: "/{Bucket}/{Key+}",
- }
- }
-
- if input == nil {
- input = &DeleteObjectInput{}
- }
-
- req = c.newRequest(opDeleteObject, input, output)
- output = &DeleteObjectOutput{}
- req.Data = output
- return
-}
-
-// Removes the null version (if there is one) of an object and inserts a delete
-// marker, which becomes the latest version of the object. If there isn't a
-// null version, Amazon S3 does not remove any objects.
-func (c *S3) DeleteObject(input *DeleteObjectInput) (*DeleteObjectOutput, error) {
- req, out := c.DeleteObjectRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) DeleteObjectPresignedUrl(input *DeleteObjectInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.DeleteObjectRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opDeleteObject *aws.Operation
-
-// DeleteObjectsRequest generates a request for the DeleteObjects operation.
-func (c *S3) DeleteObjectsRequest(input *DeleteObjectsInput) (req *aws.Request, output *DeleteObjectsOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opDeleteObjects == nil {
- opDeleteObjects = &aws.Operation{
- Name: "DeleteObjects",
- HTTPMethod: "POST",
- HTTPPath: "/{Bucket}?delete",
- }
- }
-
- if input == nil {
- input = &DeleteObjectsInput{}
- }
-
- req = c.newRequest(opDeleteObjects, input, output)
- output = &DeleteObjectsOutput{}
- req.Data = output
- return
-}
-
-// This operation enables you to delete multiple objects from a bucket using
-// a single HTTP request. You may specify up to 1000 keys.
-func (c *S3) DeleteObjects(input *DeleteObjectsInput) *DeleteObjectsOutput {
- var errors []*Error
- var okList []*DeletedObject
- if input == nil {
- input = &DeleteObjectsInput{}
- }
- for _, t := range input.Delete.Objects {
- _, err := c.DeleteObject(&DeleteObjectInput{Bucket: input.Bucket, Key: t.Key})
- if input.IsReTurnResults == aws.Boolean(false) {
- if err != nil {
- aerr, _ := err.(awserr.Error)
- errors = append(errors, &Error{Key: t.Key, Code: aws.String(aerr.Code()), Message: aws.String(aerr.Message())})
- } else {
- okList = append(okList, &DeletedObject{Key: t.Key})
- }
- }
- }
- output := &DeleteObjectsOutput{
- Deleted: okList,
- Errors: errors,
- }
- return output
-}
-func (c *S3) DeleteBucketPrefix(input *DeleteBucketPrefixInput) (*DeleteObjectsOutput, error) {
-
- var errors []*Error
- var okList []*DeletedObject
-
- marker := aws.String("")
- prefix := input.Prefix
- var output = &DeleteObjectsOutput{
- Deleted: okList,
- Errors: errors,
- }
- if input == nil {
- input = &DeleteBucketPrefixInput{}
- }
- for {
- resp, err := c.ListObjects(&ListObjectsInput{
- Bucket: input.Bucket,
- Prefix: prefix,
- Marker: marker,
- MaxKeys: aws.Long(1000),
- })
- if err == nil {
- for _, t := range resp.Contents {
- _, err := c.DeleteObject(&DeleteObjectInput{Bucket: input.Bucket, Key: t.Key})
- if input.IsReTurnResults == aws.Boolean(false) {
- if err != nil {
- aerr, _ := err.(awserr.Error)
- errors = append(errors, &Error{Key: t.Key, Code: aws.String(aerr.Code()), Message: aws.String(aerr.Message())})
- output.Errors = errors
- } else {
- okList = append(okList, &DeletedObject{Key: t.Key})
- output.Deleted = okList
- }
- }
- }
- if *resp.IsTruncated == false {
- break
- }
- marker = resp.Contents[999].Key
- } else {
- return output, err
- }
- }
- return output, nil
-}
-
-/**
-重试删除前缀
-*/
-func (c *S3) TryDeleteBucketPrefix(input *DeleteBucketPrefixInput) (*DeleteObjectsOutput, error) {
-
- params := input
- var output *DeleteObjectsOutput
- err := Do(func(attempt int) (bool, error) {
- var err error
- output, err = c.DeleteBucketPrefix(params)
- if err != nil {
- fmt.Println("DeleteBucketPrefix - ", err)
- }
- return attempt < 3, err // 重试3次
- })
- if err != nil {
- fmt.Println("error:", err)
- }
- return output, nil
-}
-
-func (c *S3) DeleteObjectsPresignedUrl(input *DeleteObjectsInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.DeleteObjectsRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opDeleteObjects *aws.Operation
-
-// GetBucketACLRequest generates a request for the GetBucketACL operation.
-func (c *S3) GetBucketACLRequest(input *GetBucketACLInput) (req *aws.Request, output *GetBucketACLOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketACL == nil {
- opGetBucketACL = &aws.Operation{
- Name: "GetBucketAcl",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?acl",
- }
- }
-
- if input == nil {
- input = &GetBucketACLInput{}
- }
-
- req = c.newRequest(opGetBucketACL, input, output)
- output = &GetBucketACLOutput{}
- req.Data = output
- return
-}
-
-// Gets the access control policy for the bucket.
-func (c *S3) GetBucketACL(input *GetBucketACLInput) (*GetBucketACLOutput, error) {
- req, out := c.GetBucketACLRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketACLPresignedUrl(input *GetBucketACLInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketACLRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketACL *aws.Operation
-
-// GetBucketCORSRequest generates a request for the GetBucketCORS operation.
-func (c *S3) GetBucketCORSRequest(input *GetBucketCORSInput) (req *aws.Request, output *GetBucketCORSOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketCORS == nil {
- opGetBucketCORS = &aws.Operation{
- Name: "GetBucketCors",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?cors",
- }
- }
-
- if input == nil {
- input = &GetBucketCORSInput{}
- }
-
- req = c.newRequest(opGetBucketCORS, input, output)
- output = &GetBucketCORSOutput{}
- req.Data = output
- return
-}
-
-// Returns the cors configuration for the bucket.
-func (c *S3) GetBucketCORS(input *GetBucketCORSInput) (*GetBucketCORSOutput, error) {
- req, out := c.GetBucketCORSRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketCORSPresignedUrl(input *GetBucketCORSInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketCORSRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketCORS *aws.Operation
-
-// GetBucketLifecycleRequest generates a request for the GetBucketLifecycle operation.
-func (c *S3) GetBucketLifecycleRequest(input *GetBucketLifecycleInput) (req *aws.Request, output *GetBucketLifecycleOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketLifecycle == nil {
- opGetBucketLifecycle = &aws.Operation{
- Name: "GetBucketLifecycle",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?lifecycle",
- }
- }
-
- if input == nil {
- input = &GetBucketLifecycleInput{}
- }
-
- req = c.newRequest(opGetBucketLifecycle, input, output)
- output = &GetBucketLifecycleOutput{}
- req.Data = output
- return
-}
-
-// Returns the lifecycle configuration information set on the bucket.
-func (c *S3) GetBucketLifecycle(input *GetBucketLifecycleInput) (*GetBucketLifecycleOutput, error) {
- req, out := c.GetBucketLifecycleRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketLifecyclePresignedUrl(input *GetBucketLifecycleInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketLifecycleRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketLifecycle *aws.Operation
-
-// GetBucketLocationRequest generates a request for the GetBucketLocation operation.
-func (c *S3) GetBucketLocationRequest(input *GetBucketLocationInput) (req *aws.Request, output *GetBucketLocationOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketLocation == nil {
- opGetBucketLocation = &aws.Operation{
- Name: "GetBucketLocation",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?location",
- }
- }
-
- if input == nil {
- input = &GetBucketLocationInput{}
- }
-
- req = c.newRequest(opGetBucketLocation, input, output)
- output = &GetBucketLocationOutput{}
- req.Data = output
- return
-}
-
-// Returns the region the bucket resides in.
-func (c *S3) GetBucketLocation(input *GetBucketLocationInput) (*GetBucketLocationOutput, error) {
- req, out := c.GetBucketLocationRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketLocationPresignedUrl(input *GetBucketLocationInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketLocationRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketLocation *aws.Operation
-
-// GetBucketLoggingRequest generates a request for the GetBucketLogging operation.
-func (c *S3) GetBucketLoggingRequest(input *GetBucketLoggingInput) (req *aws.Request, output *GetBucketLoggingOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketLogging == nil {
- opGetBucketLogging = &aws.Operation{
- Name: "GetBucketLogging",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?logging",
- }
- }
-
- if input == nil {
- input = &GetBucketLoggingInput{}
- }
-
- req = c.newRequest(opGetBucketLogging, input, output)
- output = &GetBucketLoggingOutput{}
- req.Data = output
- return
-}
-
-// Returns the logging status of a bucket and the permissions users have to
-// view and modify that status. To use GET, you must be the bucket owner.
-func (c *S3) GetBucketLogging(input *GetBucketLoggingInput) (*GetBucketLoggingOutput, error) {
- req, out := c.GetBucketLoggingRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketLoggingPresignedUrl(input *GetBucketLoggingInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketLoggingRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketLogging *aws.Operation
-
-// GetBucketNotificationRequest generates a request for the GetBucketNotification operation.
-func (c *S3) GetBucketNotificationRequest(input *GetBucketNotificationConfigurationRequest) (req *aws.Request, output *NotificationConfigurationDeprecated) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketNotification == nil {
- opGetBucketNotification = &aws.Operation{
- Name: "GetBucketNotification",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?notification",
- }
- }
-
- if input == nil {
- input = &GetBucketNotificationConfigurationRequest{}
- }
-
- req = c.newRequest(opGetBucketNotification, input, output)
- output = &NotificationConfigurationDeprecated{}
- req.Data = output
- return
-}
-
-// Deprecated, see the GetBucketNotificationConfiguration operation.
-func (c *S3) GetBucketNotification(input *GetBucketNotificationConfigurationRequest) (*NotificationConfigurationDeprecated, error) {
- req, out := c.GetBucketNotificationRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketNotificationPresignedUrl(input *GetBucketNotificationConfigurationRequest, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketNotificationRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketNotification *aws.Operation
-
-// GetBucketNotificationConfigurationRequest generates a request for the GetBucketNotificationConfiguration operation.
-func (c *S3) GetBucketNotificationConfigurationRequest(input *GetBucketNotificationConfigurationRequest) (req *aws.Request, output *NotificationConfiguration) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketNotificationConfiguration == nil {
- opGetBucketNotificationConfiguration = &aws.Operation{
- Name: "GetBucketNotificationConfiguration",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?notification",
- }
- }
-
- if input == nil {
- input = &GetBucketNotificationConfigurationRequest{}
- }
-
- req = c.newRequest(opGetBucketNotificationConfiguration, input, output)
- output = &NotificationConfiguration{}
- req.Data = output
- return
-}
-
-// Returns the notification configuration of a bucket.
-func (c *S3) GetBucketNotificationConfiguration(input *GetBucketNotificationConfigurationRequest) (*NotificationConfiguration, error) {
- req, out := c.GetBucketNotificationConfigurationRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketNotificationConfigurationPresignedUrl(input *GetBucketNotificationConfigurationRequest, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketNotificationConfigurationRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketNotificationConfiguration *aws.Operation
-
-// GetBucketPolicyRequest generates a request for the GetBucketPolicy operation.
-func (c *S3) GetBucketPolicyRequest(input *GetBucketPolicyInput) (req *aws.Request, output *GetBucketPolicyOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketPolicy == nil {
- opGetBucketPolicy = &aws.Operation{
- Name: "GetBucketPolicy",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?policy",
- }
- }
-
- if input == nil {
- input = &GetBucketPolicyInput{}
- }
-
- req = c.newRequest(opGetBucketPolicy, input, output)
- output = &GetBucketPolicyOutput{}
- req.Data = output
- return
-}
-
-// Returns the policy of a specified bucket.
-func (c *S3) GetBucketPolicy(input *GetBucketPolicyInput) (*GetBucketPolicyOutput, error) {
- req, out := c.GetBucketPolicyRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketPolicyPresignedUrl(input *GetBucketPolicyInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketPolicyRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketPolicy *aws.Operation
-
-// GetBucketReplicationRequest generates a request for the GetBucketReplication operation.
-func (c *S3) GetBucketReplicationRequest(input *GetBucketReplicationInput) (req *aws.Request, output *GetBucketReplicationOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketReplication == nil {
- opGetBucketReplication = &aws.Operation{
- Name: "GetBucketReplication",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?replication",
- }
- }
-
- if input == nil {
- input = &GetBucketReplicationInput{}
- }
-
- req = c.newRequest(opGetBucketReplication, input, output)
- output = &GetBucketReplicationOutput{}
- req.Data = output
- return
-}
-
-func (c *S3) GetBucketReplication(input *GetBucketReplicationInput) (*GetBucketReplicationOutput, error) {
- req, out := c.GetBucketReplicationRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketReplicationPresignedUrl(input *GetBucketReplicationInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketReplicationRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketReplication *aws.Operation
-
-// GetBucketRequestPaymentRequest generates a request for the GetBucketRequestPayment operation.
-func (c *S3) GetBucketRequestPaymentRequest(input *GetBucketRequestPaymentInput) (req *aws.Request, output *GetBucketRequestPaymentOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketRequestPayment == nil {
- opGetBucketRequestPayment = &aws.Operation{
- Name: "GetBucketRequestPayment",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?requestPayment",
- }
- }
-
- if input == nil {
- input = &GetBucketRequestPaymentInput{}
- }
-
- req = c.newRequest(opGetBucketRequestPayment, input, output)
- output = &GetBucketRequestPaymentOutput{}
- req.Data = output
- return
-}
-
-// Returns the request payment configuration of a bucket.
-func (c *S3) GetBucketRequestPayment(input *GetBucketRequestPaymentInput) (*GetBucketRequestPaymentOutput, error) {
- req, out := c.GetBucketRequestPaymentRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketRequestPaymentPresignedUrl(input *GetBucketRequestPaymentInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketRequestPaymentRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketRequestPayment *aws.Operation
-
-// GetBucketTaggingRequest generates a request for the GetBucketTagging operation.
-func (c *S3) GetBucketTaggingRequest(input *GetBucketTaggingInput) (req *aws.Request, output *GetBucketTaggingOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketTagging == nil {
- opGetBucketTagging = &aws.Operation{
- Name: "GetBucketTagging",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?tagging",
- }
- }
-
- if input == nil {
- input = &GetBucketTaggingInput{}
- }
-
- req = c.newRequest(opGetBucketTagging, input, output)
- output = &GetBucketTaggingOutput{}
- req.Data = output
- return
-}
-
-// Returns the tag set associated with the bucket.
-func (c *S3) GetBucketTagging(input *GetBucketTaggingInput) (*GetBucketTaggingOutput, error) {
- req, out := c.GetBucketTaggingRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketTaggingPresignedUrl(input *GetBucketTaggingInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketTaggingRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketTagging *aws.Operation
-
-// GetBucketVersioningRequest generates a request for the GetBucketVersioning operation.
-func (c *S3) GetBucketVersioningRequest(input *GetBucketVersioningInput) (req *aws.Request, output *GetBucketVersioningOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketVersioning == nil {
- opGetBucketVersioning = &aws.Operation{
- Name: "GetBucketVersioning",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?versioning",
- }
- }
-
- if input == nil {
- input = &GetBucketVersioningInput{}
- }
-
- req = c.newRequest(opGetBucketVersioning, input, output)
- output = &GetBucketVersioningOutput{}
- req.Data = output
- return
-}
-
-// Returns the versioning state of a bucket.
-func (c *S3) GetBucketVersioning(input *GetBucketVersioningInput) (*GetBucketVersioningOutput, error) {
- req, out := c.GetBucketVersioningRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketVersioningPresignedUrl(input *GetBucketVersioningInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketVersioningRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketVersioning *aws.Operation
-
-// GetBucketWebsiteRequest generates a request for the GetBucketWebsite operation.
-func (c *S3) GetBucketWebsiteRequest(input *GetBucketWebsiteInput) (req *aws.Request, output *GetBucketWebsiteOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetBucketWebsite == nil {
- opGetBucketWebsite = &aws.Operation{
- Name: "GetBucketWebsite",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?website",
- }
- }
-
- if input == nil {
- input = &GetBucketWebsiteInput{}
- }
-
- req = c.newRequest(opGetBucketWebsite, input, output)
- output = &GetBucketWebsiteOutput{}
- req.Data = output
- return
-}
-
-// Returns the website configuration for a bucket.
-func (c *S3) GetBucketWebsite(input *GetBucketWebsiteInput) (*GetBucketWebsiteOutput, error) {
- req, out := c.GetBucketWebsiteRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetBucketWebsitePresignedUrl(input *GetBucketWebsiteInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetBucketWebsiteRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetBucketWebsite *aws.Operation
-
-// GetObjectRequest generates a request for the GetObject operation.
-func (c *S3) GetObjectRequest(input *GetObjectInput) (req *aws.Request, output *GetObjectOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetObject == nil {
- opGetObject = &aws.Operation{
- Name: "GetObject",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}/{Key+}",
- }
- }
-
- if input == nil {
- input = &GetObjectInput{}
- }
-
- req = c.newRequest(opGetObject, input, output)
- output = &GetObjectOutput{}
- req.Data = output
- return
-}
-
-// Retrieves objects from Amazon S3.
-func (c *S3) GetObject(input *GetObjectInput) (*GetObjectOutput, error) {
- req, out := c.GetObjectRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetObjectToFile(bucket, objectKey, filePath, Range string) error {
- tempFilePath := filePath + TempFileSuffix
-
- getInput := &GetObjectInput{
- Bucket: aws.String(bucket),
- Key: aws.String(objectKey),
- Range: aws.String(Range),
- }
- // Calls the API to actually download the object. Returns the result instance.
- req, err := c.GetObject(getInput)
- if err != nil {
- return err
- }
- // If the local file does not exist, create a new one. If it exists, overwrite it.
- fd, err := os.OpenFile(tempFilePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, os.FileMode(0664))
- if err != nil {
- return err
- }
-
- // Copy the data to the local file path.
- _, err = io.Copy(fd, req.Body)
- fd.Close()
- if err != nil {
- return err
- }
-
- return os.Rename(tempFilePath, filePath)
-}
-func (c *S3) GetObjectPresignedUrl(input *GetObjectInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetObjectRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetObject *aws.Operation
-
-// GetObjectACLRequest generates a request for the GetObjectACL operation.
-func (c *S3) GetObjectACLRequest(input *GetObjectACLInput) (req *aws.Request, output *GetObjectACLOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetObjectACL == nil {
- opGetObjectACL = &aws.Operation{
- Name: "GetObjectAcl",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}/{Key+}?acl",
- }
- }
-
- if input == nil {
- input = &GetObjectACLInput{}
- }
-
- req = c.newRequest(opGetObjectACL, input, output)
- output = &GetObjectACLOutput{}
- req.Data = output
- return
-}
-
-// Returns the access control list (ACL) of an object.
-func (c *S3) GetObjectACL(input *GetObjectACLInput) (*GetObjectACLOutput, error) {
- req, out := c.GetObjectACLRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetObjectACLPresignedUrl(input *GetObjectACLInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetObjectACLRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetObjectACL *aws.Operation
-
-// GetObjectTorrentRequest generates a request for the GetObjectTorrent operation.
-func (c *S3) GetObjectTorrentRequest(input *GetObjectTorrentInput) (req *aws.Request, output *GetObjectTorrentOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetObjectTorrent == nil {
- opGetObjectTorrent = &aws.Operation{
- Name: "GetObjectTorrent",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}/{Key+}?torrent",
- }
- }
-
- if input == nil {
- input = &GetObjectTorrentInput{}
- }
-
- req = c.newRequest(opGetObjectTorrent, input, output)
- output = &GetObjectTorrentOutput{}
- req.Data = output
- return
-}
-
-// Return torrent files from a bucket.
-func (c *S3) GetObjectTorrent(input *GetObjectTorrentInput) (*GetObjectTorrentOutput, error) {
- req, out := c.GetObjectTorrentRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetObjectTorrentPresignedUrl(input *GetObjectTorrentInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetObjectTorrentRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetObjectTorrent *aws.Operation
-
-// HeadBucketRequest generates a request for the HeadBucket operation.
-func (c *S3) HeadBucketRequest(input *HeadBucketInput) (req *aws.Request, output *HeadBucketOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opHeadBucket == nil {
- opHeadBucket = &aws.Operation{
- Name: "HeadBucket",
- HTTPMethod: "HEAD",
- HTTPPath: "/{Bucket}",
- }
- }
-
- if input == nil {
- input = &HeadBucketInput{}
- }
-
- req = c.newRequest(opHeadBucket, input, output)
- output = &HeadBucketOutput{}
- req.Data = output
- return
-}
-
-// This operation is useful to determine if a bucket exists and you have permission
-// to access it.
-func (c *S3) HeadBucket(input *HeadBucketInput) (*HeadBucketOutput, error) {
- req, out := c.HeadBucketRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) HeadBucketPresignedUrl(input *HeadBucketInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.HeadBucketRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opHeadBucket *aws.Operation
-
-// HeadObjectRequest generates a request for the HeadObject operation.
-func (c *S3) HeadObjectRequest(input *HeadObjectInput) (req *aws.Request, output *HeadObjectOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opHeadObject == nil {
- opHeadObject = &aws.Operation{
- Name: "HeadObject",
- HTTPMethod: "HEAD",
- HTTPPath: "/{Bucket}/{Key+}",
- }
- }
-
- if input == nil {
- input = &HeadObjectInput{}
- }
-
- req = c.newRequest(opHeadObject, input, output)
- output = &HeadObjectOutput{}
- req.Data = output
- return
-}
-
-// The HEAD operation retrieves metadata from an object without returning the
-// object itself. This operation is useful if you're only interested in an object's
-// metadata. To use HEAD, you must have READ access to the object.
-func (c *S3) HeadObject(input *HeadObjectInput) (*HeadObjectOutput, error) {
- req, out := c.HeadObjectRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) HeadObjectPresignedUrl(input *HeadObjectInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.HeadObjectRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opHeadObject *aws.Operation
-
-// ListBucketsRequest generates a request for the ListBuckets operation.
-func (c *S3) ListBucketsRequest(input *ListBucketsInput) (req *aws.Request, output *ListBucketsOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opListBuckets == nil {
- opListBuckets = &aws.Operation{
- Name: "ListBuckets",
- HTTPMethod: "GET",
- HTTPPath: "/",
- }
- }
-
- if input == nil {
- input = &ListBucketsInput{}
- }
-
- req = c.newRequest(opListBuckets, input, output)
- output = &ListBucketsOutput{}
- req.Data = output
- return
-}
-
-// Returns a list of all buckets owned by the authenticated sender of the request.
-func (c *S3) ListBuckets(input *ListBucketsInput) (*ListBucketsOutput, error) {
- req, out := c.ListBucketsRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) ListBucketsPresignedUrl(input *ListBucketsInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.ListBucketsRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opListBuckets *aws.Operation
-
-// ListMultipartUploadsRequest generates a request for the ListMultipartUploads operation.
-func (c *S3) ListMultipartUploadsRequest(input *ListMultipartUploadsInput) (req *aws.Request, output *ListMultipartUploadsOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opListMultipartUploads == nil {
- opListMultipartUploads = &aws.Operation{
- Name: "ListMultipartUploads",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?uploads",
- Paginator: &aws.Paginator{
- InputTokens: []string{"KeyMarker", "UploadIdMarker"},
- OutputTokens: []string{"NextKeyMarker", "NextUploadIdMarker"},
- LimitToken: "MaxUploads",
- TruncationToken: "IsTruncated",
- },
- }
- }
-
- if input == nil {
- input = &ListMultipartUploadsInput{}
- }
-
- req = c.newRequest(opListMultipartUploads, input, output)
- output = &ListMultipartUploadsOutput{}
- req.Data = output
- return
-}
-
-// This operation lists in-progress multipart uploads.
-func (c *S3) ListMultipartUploads(input *ListMultipartUploadsInput) (*ListMultipartUploadsOutput, error) {
- req, out := c.ListMultipartUploadsRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) ListMultipartUploadsPresignedUrl(input *ListMultipartUploadsInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.ListMultipartUploadsRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-func (c *S3) ListMultipartUploadsPages(input *ListMultipartUploadsInput, fn func(p *ListMultipartUploadsOutput, lastPage bool) (shouldContinue bool)) error {
- page, _ := c.ListMultipartUploadsRequest(input)
- return page.EachPage(func(p interface{}, lastPage bool) bool {
- return fn(p.(*ListMultipartUploadsOutput), lastPage)
- })
-}
-
-var opListMultipartUploads *aws.Operation
-
-// ListObjectVersionsRequest generates a request for the ListObjectVersions operation.
-func (c *S3) ListObjectVersionsRequest(input *ListObjectVersionsInput) (req *aws.Request, output *ListObjectVersionsOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opListObjectVersions == nil {
- opListObjectVersions = &aws.Operation{
- Name: "ListObjectVersions",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}?versions",
- Paginator: &aws.Paginator{
- InputTokens: []string{"KeyMarker", "VersionIdMarker"},
- OutputTokens: []string{"NextKeyMarker", "NextVersionIdMarker"},
- LimitToken: "MaxKeys",
- TruncationToken: "IsTruncated",
- },
- }
- }
-
- if input == nil {
- input = &ListObjectVersionsInput{}
- }
-
- req = c.newRequest(opListObjectVersions, input, output)
- output = &ListObjectVersionsOutput{}
- req.Data = output
- return
-}
-
-// Returns metadata about all of the versions of objects in a bucket.
-func (c *S3) ListObjectVersions(input *ListObjectVersionsInput) (*ListObjectVersionsOutput, error) {
- req, out := c.ListObjectVersionsRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) ListObjectVersionsPresignedUrl(input *ListObjectVersionsInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.ListObjectVersionsRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-func (c *S3) ListObjectVersionsPages(input *ListObjectVersionsInput, fn func(p *ListObjectVersionsOutput, lastPage bool) (shouldContinue bool)) error {
- page, _ := c.ListObjectVersionsRequest(input)
- return page.EachPage(func(p interface{}, lastPage bool) bool {
- return fn(p.(*ListObjectVersionsOutput), lastPage)
- })
-}
-
-var opListObjectVersions *aws.Operation
-
-// ListObjectsRequest generates a request for the ListObjects operation.
-func (c *S3) ListObjectsRequest(input *ListObjectsInput) (req *aws.Request, output *ListObjectsOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opListObjects == nil {
- opListObjects = &aws.Operation{
- Name: "ListObjects",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}",
- Paginator: &aws.Paginator{
- InputTokens: []string{"Marker"},
- OutputTokens: []string{"NextMarker || Contents[-1].Key"},
- LimitToken: "MaxKeys",
- TruncationToken: "IsTruncated",
- },
- }
- }
-
- if input == nil {
- input = &ListObjectsInput{}
- }
-
- req = c.newRequest(opListObjects, input, output)
- output = &ListObjectsOutput{}
- req.Data = output
- return
-}
-
-// Returns some or all (up to 1000) of the objects in a bucket. You can use
-// the request parameters as selection criteria to return a subset of the objects
-// in a bucket.
-func (c *S3) ListObjects(input *ListObjectsInput) (*ListObjectsOutput, error) {
- req, out := c.ListObjectsRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) ListObjectsPresignedUrl(input *ListObjectsInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.ListObjectsRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-func (c *S3) ListObjectsPages(input *ListObjectsInput, fn func(p *ListObjectsOutput, lastPage bool) (shouldContinue bool)) error {
- page, _ := c.ListObjectsRequest(input)
- return page.EachPage(func(p interface{}, lastPage bool) bool {
- return fn(p.(*ListObjectsOutput), lastPage)
- })
-}
-
-var opListObjects *aws.Operation
-
-// ListPartsRequest generates a request for the ListParts operation.
-func (c *S3) ListPartsRequest(input *ListPartsInput) (req *aws.Request, output *ListPartsOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opListParts == nil {
- opListParts = &aws.Operation{
- Name: "ListParts",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}/{Key+}",
- Paginator: &aws.Paginator{
- InputTokens: []string{"PartNumberMarker"},
- OutputTokens: []string{"NextPartNumberMarker"},
- LimitToken: "MaxParts",
- TruncationToken: "IsTruncated",
- },
- }
- }
-
- if input == nil {
- input = &ListPartsInput{}
- }
-
- req = c.newRequest(opListParts, input, output)
- output = &ListPartsOutput{}
- req.Data = output
- return
-}
-
-// Lists the parts that have been uploaded for a specific multipart upload.
-func (c *S3) ListParts(input *ListPartsInput) (*ListPartsOutput, error) {
- req, out := c.ListPartsRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) ListPartsPresignedUrl(input *ListPartsInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.ListPartsRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-func (c *S3) ListPartsPages(input *ListPartsInput, fn func(p *ListPartsOutput, lastPage bool) (shouldContinue bool)) error {
- page, _ := c.ListPartsRequest(input)
- return page.EachPage(func(p interface{}, lastPage bool) bool {
- return fn(p.(*ListPartsOutput), lastPage)
- })
-}
-
-var opListParts *aws.Operation
-
-// PutBucketACLRequest generates a request for the PutBucketACL operation.
-func (c *S3) PutBucketACLRequest(input *PutBucketACLInput) (req *aws.Request, output *PutBucketACLOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutBucketACL == nil {
- opPutBucketACL = &aws.Operation{
- Name: "PutBucketAcl",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?acl",
- }
- }
-
- if input == nil {
- input = &PutBucketACLInput{}
- }
-
- req = c.newRequest(opPutBucketACL, input, output)
- output = &PutBucketACLOutput{}
- req.Data = output
- return
-}
-
-// Sets the permissions on a bucket using access control lists (ACL).
-func (c *S3) PutBucketACL(input *PutBucketACLInput) (*PutBucketACLOutput, error) {
- req, out := c.PutBucketACLRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutBucketACLPresignedUrl(input *PutBucketACLInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutBucketACLRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutBucketACL *aws.Operation
-
-// PutBucketCORSRequest generates a request for the PutBucketCORS operation.
-func (c *S3) PutBucketCORSRequest(input *PutBucketCORSInput) (req *aws.Request, output *PutBucketCORSOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutBucketCORS == nil {
- opPutBucketCORS = &aws.Operation{
- Name: "PutBucketCors",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?cors",
- }
- }
-
- if input == nil {
- input = &PutBucketCORSInput{}
- }
-
- req = c.newRequest(opPutBucketCORS, input, output)
- output = &PutBucketCORSOutput{}
- req.Data = output
- return
-}
-
-// Sets the cors configuration for a bucket.
-func (c *S3) PutBucketCORS(input *PutBucketCORSInput) (*PutBucketCORSOutput, error) {
- req, out := c.PutBucketCORSRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutBucketCORSPresignedUrl(input *PutBucketCORSInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutBucketCORSRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutBucketCORS *aws.Operation
-
-// PutBucketLifecycleRequest generates a request for the PutBucketLifecycle operation.
-func (c *S3) PutBucketLifecycleRequest(input *PutBucketLifecycleInput) (req *aws.Request, output *PutBucketLifecycleOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutBucketLifecycle == nil {
- opPutBucketLifecycle = &aws.Operation{
- Name: "PutBucketLifecycle",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?lifecycle",
- }
- }
-
- if input == nil {
- input = &PutBucketLifecycleInput{}
- }
-
- req = c.newRequest(opPutBucketLifecycle, input, output)
- output = &PutBucketLifecycleOutput{}
- req.Data = output
- return
-}
-
-// Sets lifecycle configuration for your bucket. If a lifecycle configuration
-// exists, it replaces it.
-func (c *S3) PutBucketLifecycle(input *PutBucketLifecycleInput) (*PutBucketLifecycleOutput, error) {
- req, out := c.PutBucketLifecycleRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutBucketLifecyclePresignedUrl(input *PutBucketLifecycleInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutBucketLifecycleRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutBucketLifecycle *aws.Operation
-
-// PutBucketLoggingRequest generates a request for the PutBucketLogging operation.
-func (c *S3) PutBucketLoggingRequest(input *PutBucketLoggingInput) (req *aws.Request, output *PutBucketLoggingOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutBucketLogging == nil {
- opPutBucketLogging = &aws.Operation{
- Name: "PutBucketLogging",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?logging",
- }
- }
-
- if input == nil {
- input = &PutBucketLoggingInput{}
- }
-
- req = c.newRequest(opPutBucketLogging, input, output)
- output = &PutBucketLoggingOutput{}
- req.Data = output
- return
-}
-
-// Set the logging parameters for a bucket and to specify permissions for who
-// can view and modify the logging parameters. To set the logging status of
-// a bucket, you must be the bucket owner.
-func (c *S3) PutBucketLogging(input *PutBucketLoggingInput) (*PutBucketLoggingOutput, error) {
- req, out := c.PutBucketLoggingRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutBucketLoggingPresignedUrl(input *PutBucketLoggingInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutBucketLoggingRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutBucketLogging *aws.Operation
-
-// PutBucketNotificationRequest generates a request for the PutBucketNotification operation.
-func (c *S3) PutBucketNotificationRequest(input *PutBucketNotificationInput) (req *aws.Request, output *PutBucketNotificationOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutBucketNotification == nil {
- opPutBucketNotification = &aws.Operation{
- Name: "PutBucketNotification",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?notification",
- }
- }
-
- if input == nil {
- input = &PutBucketNotificationInput{}
- }
-
- req = c.newRequest(opPutBucketNotification, input, output)
- output = &PutBucketNotificationOutput{}
- req.Data = output
- return
-}
-
-// Deprecated, see the PutBucketNotificationConfiguraiton operation.
-func (c *S3) PutBucketNotification(input *PutBucketNotificationInput) (*PutBucketNotificationOutput, error) {
- req, out := c.PutBucketNotificationRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutBucketNotificationPresignedUrl(input *PutBucketNotificationInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutBucketNotificationRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutBucketNotification *aws.Operation
-
-// PutBucketNotificationConfigurationRequest generates a request for the PutBucketNotificationConfiguration operation.
-func (c *S3) PutBucketNotificationConfigurationRequest(input *PutBucketNotificationConfigurationInput) (req *aws.Request, output *PutBucketNotificationConfigurationOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutBucketNotificationConfiguration == nil {
- opPutBucketNotificationConfiguration = &aws.Operation{
- Name: "PutBucketNotificationConfiguration",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?notification",
- }
- }
-
- if input == nil {
- input = &PutBucketNotificationConfigurationInput{}
- }
-
- req = c.newRequest(opPutBucketNotificationConfiguration, input, output)
- output = &PutBucketNotificationConfigurationOutput{}
- req.Data = output
- return
-}
-
-// Enables notifications of specified events for a bucket.
-func (c *S3) PutBucketNotificationConfiguration(input *PutBucketNotificationConfigurationInput) (*PutBucketNotificationConfigurationOutput, error) {
- req, out := c.PutBucketNotificationConfigurationRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutBucketNotificationConfigurationPresignedUrl(input *PutBucketNotificationConfigurationInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutBucketNotificationConfigurationRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutBucketNotificationConfiguration *aws.Operation
-
-// PutBucketPolicyRequest generates a request for the PutBucketPolicy operation.
-func (c *S3) PutBucketPolicyRequest(input *PutBucketPolicyInput) (req *aws.Request, output *PutBucketPolicyOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutBucketPolicy == nil {
- opPutBucketPolicy = &aws.Operation{
- Name: "PutBucketPolicy",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?policy",
- }
- }
-
- if input == nil {
- input = &PutBucketPolicyInput{}
- }
-
- req = c.newRequest(opPutBucketPolicy, input, output)
- output = &PutBucketPolicyOutput{}
- req.Data = output
- return
-}
-
-// Replaces a policy on a bucket. If the bucket already has a policy, the one
-// in this request completely replaces it.
-func (c *S3) PutBucketPolicy(input *PutBucketPolicyInput) (*PutBucketPolicyOutput, error) {
- req, out := c.PutBucketPolicyRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutBucketPolicyPresignedUrl(input *PutBucketPolicyInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutBucketPolicyRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutBucketPolicy *aws.Operation
-
-// PutBucketReplicationRequest generates a request for the PutBucketReplication operation.
-func (c *S3) PutBucketReplicationRequest(input *PutBucketReplicationInput) (req *aws.Request, output *PutBucketReplicationOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutBucketReplication == nil {
- opPutBucketReplication = &aws.Operation{
- Name: "PutBucketReplication",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?replication",
- }
- }
-
- if input == nil {
- input = &PutBucketReplicationInput{}
- }
-
- req = c.newRequest(opPutBucketReplication, input, output)
- output = &PutBucketReplicationOutput{}
- req.Data = output
- return
-}
-
-// Creates a new replication configuration (or replaces an existing one, if
-// present).
-func (c *S3) PutBucketReplication(input *PutBucketReplicationInput) (*PutBucketReplicationOutput, error) {
- req, out := c.PutBucketReplicationRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutBucketReplicationPresignedUrl(input *PutBucketReplicationInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutBucketReplicationRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutBucketReplication *aws.Operation
-
-// PutBucketRequestPaymentRequest generates a request for the PutBucketRequestPayment operation.
-func (c *S3) PutBucketRequestPaymentRequest(input *PutBucketRequestPaymentInput) (req *aws.Request, output *PutBucketRequestPaymentOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutBucketRequestPayment == nil {
- opPutBucketRequestPayment = &aws.Operation{
- Name: "PutBucketRequestPayment",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?requestPayment",
- }
- }
-
- if input == nil {
- input = &PutBucketRequestPaymentInput{}
- }
-
- req = c.newRequest(opPutBucketRequestPayment, input, output)
- output = &PutBucketRequestPaymentOutput{}
- req.Data = output
- return
-}
-
-// Sets the request payment configuration for a bucket. By default, the bucket
-// owner pays for downloads from the bucket. This configuration parameter enables
-// the bucket owner (only) to specify that the person requesting the download
-// will be charged for the download. Documentation on requester pays buckets
-// can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/RequesterPaysBuckets.html
-func (c *S3) PutBucketRequestPayment(input *PutBucketRequestPaymentInput) (*PutBucketRequestPaymentOutput, error) {
- req, out := c.PutBucketRequestPaymentRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutBucketRequestPaymentPresignedUrl(input *PutBucketRequestPaymentInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutBucketRequestPaymentRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutBucketRequestPayment *aws.Operation
-
-// PutBucketTaggingRequest generates a request for the PutBucketTagging operation.
-func (c *S3) PutBucketTaggingRequest(input *PutBucketTaggingInput) (req *aws.Request, output *PutBucketTaggingOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutBucketTagging == nil {
- opPutBucketTagging = &aws.Operation{
- Name: "PutBucketTagging",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?tagging",
- }
- }
-
- if input == nil {
- input = &PutBucketTaggingInput{}
- }
-
- req = c.newRequest(opPutBucketTagging, input, output)
- output = &PutBucketTaggingOutput{}
- req.Data = output
- return
-}
-
-// Sets the tags for a bucket.
-func (c *S3) PutBucketTagging(input *PutBucketTaggingInput) (*PutBucketTaggingOutput, error) {
- req, out := c.PutBucketTaggingRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutBucketTaggingPresignedUrl(input *PutBucketTaggingInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutBucketTaggingRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutBucketTagging *aws.Operation
-
-// PutBucketVersioningRequest generates a request for the PutBucketVersioning operation.
-func (c *S3) PutBucketVersioningRequest(input *PutBucketVersioningInput) (req *aws.Request, output *PutBucketVersioningOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutBucketVersioning == nil {
- opPutBucketVersioning = &aws.Operation{
- Name: "PutBucketVersioning",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?versioning",
- }
- }
-
- if input == nil {
- input = &PutBucketVersioningInput{}
- }
-
- req = c.newRequest(opPutBucketVersioning, input, output)
- output = &PutBucketVersioningOutput{}
- req.Data = output
- return
-}
-
-// Sets the versioning state of an existing bucket. To set the versioning state,
-// you must be the bucket owner.
-func (c *S3) PutBucketVersioning(input *PutBucketVersioningInput) (*PutBucketVersioningOutput, error) {
- req, out := c.PutBucketVersioningRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutBucketVersioningPresignedUrl(input *PutBucketVersioningInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutBucketVersioningRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutBucketVersioning *aws.Operation
-
-// PutBucketWebsiteRequest generates a request for the PutBucketWebsite operation.
-func (c *S3) PutBucketWebsiteRequest(input *PutBucketWebsiteInput) (req *aws.Request, output *PutBucketWebsiteOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutBucketWebsite == nil {
- opPutBucketWebsite = &aws.Operation{
- Name: "PutBucketWebsite",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}?website",
- }
- }
-
- if input == nil {
- input = &PutBucketWebsiteInput{}
- }
-
- req = c.newRequest(opPutBucketWebsite, input, output)
- output = &PutBucketWebsiteOutput{}
- req.Data = output
- return
-}
-
-// Set the website configuration for a bucket.
-func (c *S3) PutBucketWebsite(input *PutBucketWebsiteInput) (*PutBucketWebsiteOutput, error) {
- req, out := c.PutBucketWebsiteRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutBucketWebsitePresignedUrl(input *PutBucketWebsiteInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutBucketWebsiteRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutBucketWebsite *aws.Operation
-
-// PutObjectRequest generates a request for the PutObject operation.
-func (c *S3) PutObjectRequest(input *PutObjectInput) (req *aws.Request, output *PutObjectOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutObject == nil {
- opPutObject = &aws.Operation{
- Name: "PutObject",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}/{Key+}",
- }
- }
-
- if input == nil {
- input = &PutObjectInput{}
- }
-
- req = c.newRequest(opPutObject, input, output)
- output = &PutObjectOutput{}
- req.Data = output
- return
-}
-func (c *S3) PutReader(input *PutReaderRequest) (*PutObjectOutput, error) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutObject == nil {
- opPutObject = &aws.Operation{
- Name: "PutObject",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}/{Key+}",
- }
- }
-
- if input == nil {
- input = &PutReaderRequest{}
- }
- out := &PutObjectOutput{}
- req := c.newRequest(opPutObject, input, out)
- req.Data = out
- err := req.Send()
- return out, err
-}
-
-// Adds an object to a bucket.
-func (c *S3) PutObject(input *PutObjectInput) (*PutObjectOutput, error) {
- req, out := c.PutObjectRequest(input)
- err := req.Send()
- return out, err
-}
-
-//func (c *S3) PutObjectMD5Check(input *PutObjectInput) (*PutObjectOutput, error) {
-// req, out := c.PutObjectRequest(input)
-// req.Handlers.Build.PushBack(contentMD5)
-// err := req.Send()
-// return out, err
-//}
-
-func (c *S3) PutObjectPresignedUrl(input *PutObjectInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutObjectRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-func (c *S3) PutObjectPreassignedInput(input *PutObjectInput) (*http.Request, error) {
- req, _ := c.PutObjectRequest(input)
- err := req.Sign()
- return req.HTTPRequest, err
-}
-
-var opPutObject *aws.Operation
-
-// PutObjectACLRequest generates a request for the PutObjectACL operation.
-func (c *S3) PutObjectACLRequest(input *PutObjectACLInput) (req *aws.Request, output *PutObjectACLOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutObjectACL == nil {
- opPutObjectACL = &aws.Operation{
- Name: "PutObjectAcl",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}/{Key+}?acl",
- }
- }
-
- if input == nil {
- input = &PutObjectACLInput{}
- }
-
- req = c.newRequest(opPutObjectACL, input, output)
- output = &PutObjectACLOutput{}
- req.Data = output
- return
-}
-
-// uses the acl subresource to set the access control list (ACL) permissions
-// for an object that already exists in a bucket
-func (c *S3) PutObjectACL(input *PutObjectACLInput) (*PutObjectACLOutput, error) {
- req, out := c.PutObjectACLRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutObjectACLPresignedUrl(input *PutObjectACLInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutObjectACLRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutObjectACL *aws.Operation
-
-// RestoreObjectRequest generates a request for the RestoreObject operation.
-func (c *S3) RestoreObjectRequest(input *RestoreObjectInput) (req *aws.Request, output *RestoreObjectOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opRestoreObject == nil {
- opRestoreObject = &aws.Operation{
- Name: "RestoreObject",
- HTTPMethod: "POST",
- HTTPPath: "/{Bucket}/{Key+}?restore",
- }
- }
-
- if input == nil {
- input = &RestoreObjectInput{}
- }
-
- req = c.newRequest(opRestoreObject, input, output)
- output = &RestoreObjectOutput{}
- req.Data = output
- return
-}
-
-func (c *S3) RestoreObjectPresignedUrl(input *RestoreObjectInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.RestoreObjectRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opRestoreObject *aws.Operation
-
-// UploadPartRequest generates a request for the UploadPart operation.
-func (c *S3) UploadPartRequest(input *UploadPartInput) (req *aws.Request, output *UploadPartOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opUploadPart == nil {
- opUploadPart = &aws.Operation{
- Name: "UploadPart",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}/{Key+}",
- }
- }
-
- if input == nil {
- input = &UploadPartInput{}
- }
-
- req = c.newRequest(opUploadPart, input, output)
- output = &UploadPartOutput{}
- req.Data = output
- return
-}
-
-// Uploads a part in a multipart upload.
-//
-// Note: After you initiate multipart upload and upload one or more parts,
-// you must either complete or abort multipart upload in order to stop getting
-// charged for storage of the uploaded parts. Only after you either complete
-// or abort multipart upload, Amazon S3 frees up the parts storage and stops
-// charging you for the parts storage.
-func (c *S3) UploadPart(input *UploadPartInput) (*UploadPartOutput, error) {
- req, out := c.UploadPartRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) UploadPartPresignedUrl(input *UploadPartInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.UploadPartRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opUploadPart *aws.Operation
-
-// UploadPartCopyRequest generates a request for the UploadPartCopy operation.
-func (c *S3) UploadPartCopyRequest(input *UploadPartCopyInput) (req *aws.Request, output *UploadPartCopyOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opUploadPartCopy == nil {
- opUploadPartCopy = &aws.Operation{
- Name: "UploadPartCopy",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}/{Key+}",
- }
- }
-
- if input == nil {
- input = &UploadPartCopyInput{}
- }
-
- req = c.newRequest(opUploadPartCopy, input, output)
- output = &UploadPartCopyOutput{}
- req.Data = output
- return
-}
-
-// Uploads a part by copying data from an existing object as data source.
-func (c *S3) UploadPartCopy(input *UploadPartCopyInput) (*UploadPartCopyOutput, error) {
- req, out := c.UploadPartCopyRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) UploadPartCopyPresignedUrl(input *UploadPartCopyInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.UploadPartCopyRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opUploadPartCopy *aws.Operation
-
-type AbortMultipartUploadInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- UploadID *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataAbortMultipartUploadInput `json:"-" xml:"-"`
-}
-
-type metadataAbortMultipartUploadInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type AbortMultipartUploadOutput struct {
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- metadataAbortMultipartUploadOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataAbortMultipartUploadOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type AccessControlPolicy struct {
- // A list of grants.
- Grants []*Grant `locationName:"AccessControlList" locationNameList:"Grant" type:"list"`
-
- Owner *Owner `type:"structure"`
-
- metadataAccessControlPolicy `json:"-" xml:"-"`
-}
-
-type metadataAccessControlPolicy struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Bucket struct {
- // Date the bucket was created.
- CreationDate *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- // The name of the bucket.
- Name *string `type:"string"`
-
- Region *string `type:"string"`
-
- Type *string `type:"string"`
-
- metadataBucket `json:"-" xml:"-"`
-}
-
-type metadataBucket struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type BucketLoggingStatus struct {
- LoggingEnabled *LoggingEnabled `type:"structure"`
-
- metadataBucketLoggingStatus `json:"-" xml:"-"`
-}
-
-type metadataBucketLoggingStatus struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CORSConfiguration struct {
- CORSRules []*CORSRule `locationName:"CORSRule" type:"list" flattened:"true"`
-
- metadataCORSConfiguration `json:"-" xml:"-"`
-}
-
-type metadataCORSConfiguration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CORSRule struct {
- // Specifies which headers are allowed in a pre-flight OPTIONS request.
- AllowedHeaders []*string `locationName:"AllowedHeader" type:"list" flattened:"true"`
-
- // Identifies HTTP methods that the domain/origin specified in the rule is allowed
- // to execute.
- AllowedMethods []*string `locationName:"AllowedMethod" type:"list" flattened:"true"`
-
- // One or more origins you want customers to be able to access the bucket from.
- AllowedOrigins []*string `locationName:"AllowedOrigin" type:"list" flattened:"true"`
-
- // One or more headers in the response that you want customers to be able to
- // access from their applications (for example, from a JavaScript XMLHttpRequest
- // object).
- ExposeHeaders []*string `locationName:"ExposeHeader" type:"list" flattened:"true"`
-
- // The time in seconds that your browser is to cache the preflight response
- // for the specified resource.
- MaxAgeSeconds *int64 `type:"integer"`
-
- metadataCORSRule `json:"-" xml:"-"`
-}
-
-type metadataCORSRule struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CloudFunctionConfiguration struct {
- CloudFunction *string `type:"string"`
-
- // Bucket event for which to send notifications.
- Event *string `type:"string"`
-
- Events []*string `locationName:"Event" type:"list" flattened:"true"`
-
- // Optional unique identifier for configurations in a notification configuration.
- // If you don't provide one, Amazon S3 will assign an ID.
- ID *string `locationName:"Id" type:"string"`
-
- InvocationRole *string `type:"string"`
-
- metadataCloudFunctionConfiguration `json:"-" xml:"-"`
-}
-
-type metadataCloudFunctionConfiguration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CommonPrefix struct {
- Prefix *string `type:"string"`
-
- metadataCommonPrefix `json:"-" xml:"-"`
-}
-
-type metadataCommonPrefix struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CompleteMultipartUploadInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- MultipartUpload *CompletedMultipartUpload `locationName:"CompleteMultipartUpload" type:"structure"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- UploadID *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataCompleteMultipartUploadInput `json:"-" xml:"-"`
-}
-
-type metadataCompleteMultipartUploadInput struct {
- SDKShapeTraits bool `type:"structure" payload:"MultipartUpload"`
-}
-
-type CompleteMultipartUploadOutput struct {
- Bucket *string `type:"string"`
-
- // Entity tag of the object.
- ETag *string `type:"string"`
-
- // If the object expiration is configured, this will contain the expiration
- // date (expiry-date) and rule ID (rule-id). The value of rule-id is URL encoded.
- Expiration *string `location:"header" locationName:"x-amz-expiration" type:"string"`
-
- Key *string `type:"string"`
-
- Location *string `type:"string"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- // If present, specifies the ID of the AWS Key Management Service (KMS) master
- // encryption key that was used for the object.
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- // Version of the object.
- VersionID *string `location:"header" locationName:"x-amz-version-id" type:"string"`
-
- metadataCompleteMultipartUploadOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataCompleteMultipartUploadOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CompletedMultipartUpload struct {
- Parts []*CompletedPart `locationName:"Part" type:"list" flattened:"true"`
-
- metadataCompletedMultipartUpload `json:"-" xml:"-"`
-}
-
-type metadataCompletedMultipartUpload struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CompletedPart struct {
- // Entity tag returned when the part was uploaded.
- ETag *string `type:"string"`
-
- // Part number that identifies the part.
- PartNumber *int64 `type:"integer"`
-
- metadataCompletedPart `json:"-" xml:"-"`
-}
-
-type metadataCompletedPart struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Condition struct {
- // The HTTP error code when the redirect is applied. In the event of an error,
- // if the error code equals this value, then the specified redirect is applied.
- // Required when parent element Condition is specified and sibling KeyPrefixEquals
- // is not specified. If both are specified, then both must be true for the redirect
- // to be applied.
- HTTPErrorCodeReturnedEquals *string `locationName:"HttpErrorCodeReturnedEquals" type:"string"`
-
- // The object key name prefix when the redirect is applied. For example, to
- // redirect requests for ExamplePage.html, the key prefix will be ExamplePage.html.
- // To redirect request for all pages with the prefix docs/, the key prefix will
- // be /docs, which identifies all objects in the docs/ folder. Required when
- // the parent element Condition is specified and sibling HttpErrorCodeReturnedEquals
- // is not specified. If both conditions are specified, both must be true for
- // the redirect to be applied.
- KeyPrefixEquals *string `type:"string"`
-
- metadataCondition `json:"-" xml:"-"`
-}
-
-type metadataCondition struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CopyObjectInput struct {
- // The canned ACL to apply to the object.
- ACL *string `location:"header" locationName:"x-amz-acl" type:"string"`
-
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Specifies caching behavior along the request/reply chain.
- CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"`
-
- // Specifies presentational information for the object.
- ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"`
-
- // Specifies what content encodings have been applied to the object and thus
- // what decoding mechanisms must be applied to obtain the media-type referenced
- // by the Content-Type header field.
- ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"`
-
- // The language the content is in.
- ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"`
-
- // A standard MIME type describing the format of the object data.
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- // The name of the source bucket and key name of the source object, separated
- // by a slash (/). Must be URL-encoded.
- CopySource *string `location:"header" locationName:"x-amz-copy-source" type:"string" required:"true"`
-
- // Copies the object if its entity tag (ETag) matches the specified tag.
- CopySourceIfMatch *string `location:"header" locationName:"x-amz-copy-source-if-match" type:"string"`
-
- // Copies the object if it has been modified since the specified time.
- CopySourceIfModifiedSince *time.Time `location:"header" locationName:"x-amz-copy-source-if-modified-since" type:"timestamp" timestampFormat:"rfc822"`
-
- // Copies the object if its entity tag (ETag) is different than the specified
- // ETag.
- CopySourceIfNoneMatch *string `location:"header" locationName:"x-amz-copy-source-if-none-match" type:"string"`
-
- // Copies the object if it hasn't been modified since the specified time.
- CopySourceIfUnmodifiedSince *time.Time `location:"header" locationName:"x-amz-copy-source-if-unmodified-since" type:"timestamp" timestampFormat:"rfc822"`
-
- // Specifies the algorithm to use when decrypting the source object (e.g., AES256).
- CopySourceSSECustomerAlgorithm *string `location:"header" locationName:"x-amz-copy-source-server-side-encryption-customer-algorithm" type:"string"`
-
- // Specifies the customer-provided encryption key for Amazon S3 to use to decrypt
- // the source object. The encryption key provided in this header must be one
- // that was used when the source object was created.
- CopySourceSSECustomerKey *string `location:"header" locationName:"x-amz-copy-source-server-side-encryption-customer-key" type:"string"`
-
- // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321.
- // Amazon S3 uses this header for a message integrity check to ensure the encryption
- // key was transmitted without error.
- CopySourceSSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-copy-source-server-side-encryption-customer-key-MD5" type:"string"`
-
- // The date and time at which the object is no longer cacheable.
- Expires *time.Time `location:"header" locationName:"Expires" type:"timestamp" timestampFormat:"rfc822"`
-
- // Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
- GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"`
-
- // Allows grantee to read the object data and its metadata.
- GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"`
-
- // Allows grantee to read the object ACL.
- GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"`
-
- // Allows grantee to write the ACL for the applicable object.
- GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // A map of metadata to store with the object in S3.
- Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"`
-
- // Specifies whether the metadata is copied from the source object or replaced
- // with metadata provided in the request.
- MetadataDirective *string `location:"header" locationName:"x-amz-metadata-directive" type:"string"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- // Specifies the algorithm to use to when encrypting the object (e.g., AES256,
- // aws:kms).
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting
- // data. This value is used to store the object and then it is discarded; Amazon
- // does not store the encryption key. The key must be appropriate for use with
- // the algorithm specified in the x-amz-server-side-encryption-customer-algorithm
- // header.
- SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"`
-
- // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321.
- // Amazon S3 uses this header for a message integrity check to ensure the encryption
- // key was transmitted without error.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // Specifies the AWS KMS key ID to use for object encryption. All GET and PUT
- // requests for an object protected by AWS KMS will fail if not made via SSL
- // or using SigV4. Documentation on configuring any of the officially supported
- // AWS SDKs and CLI can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- // The type of storage to use for the object. Defaults to 'STANDARD'.
- StorageClass *string `location:"header" locationName:"x-amz-storage-class" type:"string"`
-
- // If the bucket is configured as a website, redirects requests for this object
- // to another object in the same bucket or to an external URL. Amazon S3 stores
- // the value of this header in the object metadata.
- WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"`
-
- XAmzTaggingDirective *string `location:"header" locationName:"x-kss-tagging-Directive" type:"string"`
-
- XAmzTagging *string `location:"header" locationName:"x-kss-tagging" type:"string"`
-
- metadataCopyObjectInput `json:"-" xml:"-"`
-}
-
-type metadataCopyObjectInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CopyObjectOutput struct {
- CopyObjectResult *CopyObjectResult `type:"structure"`
-
- CopySourceVersionID *string `location:"header" locationName:"x-amz-copy-source-version-id" type:"string"`
-
- // If the object expiration is configured, the response includes this header.
- Expiration *string `location:"header" locationName:"x-amz-expiration" type:"string"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header confirming the encryption algorithm
- // used.
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header to provide round trip message integrity
- // verification of the customer-provided encryption key.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // If present, specifies the ID of the AWS Key Management Service (KMS) master
- // encryption key that was used for the object.
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- metadataCopyObjectOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataCopyObjectOutput struct {
- SDKShapeTraits bool `type:"structure" payload:"CopyObjectResult"`
-}
-
-type CopyObjectResult struct {
- ETag *string `type:"string"`
-
- LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- metadataCopyObjectResult `json:"-" xml:"-"`
-}
-
-type metadataCopyObjectResult struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CopyPartResult struct {
- // Entity tag of the object.
- ETag *string `type:"string"`
-
- // Date and time at which the object was uploaded.
- LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- metadataCopyPartResult `json:"-" xml:"-"`
-}
-
-type metadataCopyPartResult struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CreateBucketConfiguration struct {
- // Specifies the region where the bucket will be created. If you don't specify
- // a region, the bucket will be created in US Standard.
- LocationConstraint *string `type:"string"`
-
- metadataCreateBucketConfiguration `json:"-" xml:"-"`
-}
-
-type metadataCreateBucketConfiguration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CreateBucketInput struct {
- // The canned ACL to apply to the bucket.
- ACL *string `location:"header" locationName:"x-amz-acl" type:"string"`
-
- ProjectId *string `location:"uri" locationName:"ProjectId" type:"string"`
-
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- CreateBucketConfiguration *CreateBucketConfiguration `locationName:"CreateBucketConfiguration" type:"structure" xmlURI:"http://s3.amazonaws.com/doc/2006-03-01/"`
-
- // Allows grantee the read, write, read ACP, and write ACP permissions on the
- // bucket.
- GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"`
-
- // Allows grantee to list the objects in the bucket.
- GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"`
-
- // Allows grantee to read the bucket ACL.
- GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"`
-
- // Allows grantee to create, overwrite, and delete any object in the bucket.
- GrantWrite *string `location:"header" locationName:"x-amz-grant-write" type:"string"`
-
- // Allows grantee to write the ACL for the applicable bucket.
- GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- BucketType *string `location:"header" locationName:"x-amz-bucket-type" type:"string"`
-
- MetadataCreateBucketInput `json:"-" xml:"-"`
-}
-
-type MetadataCreateBucketInput struct {
- SDKShapeTraits bool `type:"structure" payload:"CreateBucketConfiguration"`
-}
-
-type CreateBucketOutput struct {
- Location *string `location:"header" locationName:"Location" type:"string"`
-
- metadataCreateBucketOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataCreateBucketOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CreateMultipartUploadInput struct {
- // The canned ACL to apply to the object.
- ACL *string `location:"header" locationName:"x-amz-acl" type:"string"`
-
- XAmzTagging *string `location:"header" locationName:"x-amz-tagging" type:"string"`
-
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Specifies caching behavior along the request/reply chain.
- CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"`
-
- // Specifies presentational information for the object.
- ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"`
-
- // Specifies what content encodings have been applied to the object and thus
- // what decoding mechanisms must be applied to obtain the media-type referenced
- // by the Content-Type header field.
- ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"`
-
- // The language the content is in.
- ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"`
-
- // A standard MIME type describing the format of the object data.
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- // The date and time at which the object is no longer cacheable.
- Expires *time.Time `location:"header" locationName:"Expires" type:"timestamp" timestampFormat:"rfc822"`
-
- // Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
- GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"`
-
- // Allows grantee to read the object data and its metadata.
- GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"`
-
- // Allows grantee to read the object ACL.
- GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"`
-
- // Allows grantee to write the ACL for the applicable object.
- GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // A map of metadata to store with the object in S3.
- Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- // Specifies the algorithm to use to when encrypting the object (e.g., AES256,
- // aws:kms).
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting
- // data. This value is used to store the object and then it is discarded; Amazon
- // does not store the encryption key. The key must be appropriate for use with
- // the algorithm specified in the x-amz-server-side-encryption-customer-algorithm
- // header.
- SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"`
-
- // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321.
- // Amazon S3 uses this header for a message integrity check to ensure the encryption
- // key was transmitted without error.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // Specifies the AWS KMS key ID to use for object encryption. All GET and PUT
- // requests for an object protected by AWS KMS will fail if not made via SSL
- // or using SigV4. Documentation on configuring any of the officially supported
- // AWS SDKs and CLI can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- // The type of storage to use for the object. Defaults to 'STANDARD'.
- StorageClass *string `location:"header" locationName:"x-amz-storage-class" type:"string"`
-
- // If the bucket is configured as a website, redirects requests for this object
- // to another object in the same bucket or to an external URL. Amazon S3 stores
- // the value of this header in the object metadata.
- WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"`
-
- metadataCreateMultipartUploadInput `json:"-" xml:"-"`
-}
-
-type metadataCreateMultipartUploadInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type CreateMultipartUploadOutput struct {
- // Name of the bucket to which the multipart upload was initiated.
- Bucket *string `locationName:"Bucket" type:"string"`
-
- // Object key for which the multipart upload was initiated.
- Key *string `type:"string"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header confirming the encryption algorithm
- // used.
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header to provide round trip message integrity
- // verification of the customer-provided encryption key.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // If present, specifies the ID of the AWS Key Management Service (KMS) master
- // encryption key that was used for the object.
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- // ID for the initiated multipart upload.
- UploadID *string `locationName:"UploadId" type:"string"`
-
- metadataCreateMultipartUploadOutput `json:"-" xml:"-"`
-}
-
-type metadataCreateMultipartUploadOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Delete struct {
- Objects []*ObjectIdentifier `locationName:"Object" type:"list" flattened:"true" required:"true"`
-
- // Element to enable quiet mode for the request. When you add this element,
- // you must set its value to true.
- Quiet *bool `type:"boolean"`
-
- metadataDelete `json:"-" xml:"-"`
-}
-
-type metadataDelete struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketCORSInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataDeleteBucketCORSInput `json:"-" xml:"-"`
-}
-
-type metadataDeleteBucketCORSInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketCORSOutput struct {
- metadataDeleteBucketCORSOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataDeleteBucketCORSOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataDeleteBucketInput `json:"-" xml:"-"`
-}
-
-type metadataDeleteBucketInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketLifecycleInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataDeleteBucketLifecycleInput `json:"-" xml:"-"`
-}
-
-type metadataDeleteBucketLifecycleInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketLifecycleOutput struct {
- metadataDeleteBucketLifecycleOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataDeleteBucketLifecycleOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketOutput struct {
- metadataDeleteBucketOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataDeleteBucketOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketPolicyInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataDeleteBucketPolicyInput `json:"-" xml:"-"`
-}
-
-type metadataDeleteBucketPolicyInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketPolicyOutput struct {
- metadataDeleteBucketPolicyOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataDeleteBucketPolicyOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketReplicationInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataDeleteBucketReplicationInput `json:"-" xml:"-"`
-}
-
-type metadataDeleteBucketReplicationInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketReplicationOutput struct {
- metadataDeleteBucketReplicationOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataDeleteBucketReplicationOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketTaggingInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataDeleteBucketTaggingInput `json:"-" xml:"-"`
-}
-
-type metadataDeleteBucketTaggingInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketTaggingOutput struct {
- metadataDeleteBucketTaggingOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataDeleteBucketTaggingOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketWebsiteInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataDeleteBucketWebsiteInput `json:"-" xml:"-"`
-}
-
-type metadataDeleteBucketWebsiteInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteBucketWebsiteOutput struct {
- metadataDeleteBucketWebsiteOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataDeleteBucketWebsiteOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteMarkerEntry struct {
- // Specifies whether the object is (true) or is not (false) the latest version
- // of an object.
- IsLatest *bool `type:"boolean"`
-
- // The object key.
- Key *string `type:"string"`
-
- // Date and time the object was last modified.
- LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- Owner *Owner `type:"structure"`
-
- // Version ID of an object.
- VersionID *string `locationName:"VersionId" type:"string"`
-
- metadataDeleteMarkerEntry `json:"-" xml:"-"`
-}
-
-type metadataDeleteMarkerEntry struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteObjectInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // The concatenation of the authentication device's serial number, a space,
- // and the value that is displayed on your authentication device.
- MFA *string `location:"header" locationName:"x-amz-mfa" type:"string"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- // VersionId used to reference a specific version of the object.
- VersionID *string `location:"querystring" locationName:"versionId" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataDeleteObjectInput `json:"-" xml:"-"`
-}
-
-type DeleteBucketPrefixInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
- Prefix *string `type:"string" required:"true"`
- IsReTurnResults *bool `type:"boolean" required:"true"`
-}
-
-type metadataDeleteObjectInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteObjectOutput struct {
- // Specifies whether the versioned object that was permanently deleted was (true)
- // or was not (false) a delete marker.
- DeleteMarker *bool `location:"header" locationName:"x-amz-delete-marker" type:"boolean"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- // Returns the version ID of the delete marker created as a result of the DELETE
- // operation.
- VersionID *string `location:"header" locationName:"x-amz-version-id" type:"string"`
-
- metadataDeleteObjectOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataDeleteObjectOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteObjectsInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- Delete *Delete `locationName:"Delete" type:"structure" required:"true"`
-
- IsReTurnResults *bool `type:"boolean" required:"true"`
-
- // The concatenation of the authentication device's serial number, a space,
- // and the value that is displayed on your authentication device.
- MFA *string `location:"header" locationName:"x-amz-mfa" type:"string"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataDeleteObjectsInput `json:"-" xml:"-"`
-}
-
-type metadataDeleteObjectsInput struct {
- SDKShapeTraits bool `type:"structure" payload:"Delete"`
-}
-
-type DeleteObjectsOutput struct {
- Deleted []*DeletedObject `type:"list" flattened:"true"`
-
- Errors []*Error `locationName:"Error" type:"list" flattened:"true"`
-
- ErrorsCount *int64 `locationName:"ErrorsCount" type:"integer"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- metadataDeleteObjectsOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataDeleteObjectsOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeletedObject struct {
- DeleteMarker *bool `type:"boolean"`
-
- DeleteMarkerVersionID *string `locationName:"DeleteMarkerVersionId" type:"string"`
-
- Key *string `type:"string"`
-
- VersionID *string `locationName:"VersionId" type:"string"`
-
- metadataDeletedObject `json:"-" xml:"-"`
-}
-
-type metadataDeletedObject struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Destination struct {
- // Amazon resource name (ARN) of the bucket where you want Amazon S3 to store
- // replicas of the object identified by the rule.
- Bucket *string `type:"string" required:"true"`
-
- metadataDestination `json:"-" xml:"-"`
-}
-
-type metadataDestination struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Error struct {
- Code *string `type:"string"`
-
- Key *string `type:"string"`
-
- Message *string `type:"string"`
-
- VersionID *string `locationName:"VersionId" type:"string"`
-
- metadataError `json:"-" xml:"-"`
-}
-
-type metadataError struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ErrorDocument struct {
- // The object key name to use when a 4XX class error occurs.
- Key *string `type:"string" required:"true"`
-
- metadataErrorDocument `json:"-" xml:"-"`
-}
-
-type metadataErrorDocument struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketACLInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetBucketACLInput `json:"-" xml:"-"`
-}
-
-type metadataGetBucketACLInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketACLOutput struct {
- // A list of grants.
- Grants []*Grant `locationName:"AccessControlList" locationNameList:"Grant" type:"list"`
-
- Owner *Owner `type:"structure"`
-
- metadataGetBucketACLOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetBucketACLOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketCORSInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetBucketCORSInput `json:"-" xml:"-"`
-}
-
-type metadataGetBucketCORSInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketCORSOutput struct {
- CORSRules []*CORSRule `locationName:"CORSRule" type:"list" flattened:"true"`
-
- metadataGetBucketCORSOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetBucketCORSOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketLifecycleInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetBucketLifecycleInput `json:"-" xml:"-"`
-}
-
-type metadataGetBucketLifecycleInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-type LifecycleFilter struct {
- And *And `locationName:"And" type :"structure"`
- metadataLifecycleFilter `json:"-" xml:"-"`
-}
-type metadataLifecycleFilter struct {
- SDKShapeTraits bool `type:"structure"`
-}
-type And struct {
- Prefix *string `type:"string" required:"true"`
- Tag []*Tag `locationNameList:"Tag" type:"list" flattened:"true"`
- metadataAnd `json:"-" xml:"-"`
-}
-type metadataAnd struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketLifecycleOutput struct {
- Rules []*LifecycleRule `locationName:"Rule" type:"list" flattened:"true"`
-
- metadataGetBucketLifecycleOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetBucketLifecycleOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketLocationInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetBucketLocationInput `json:"-" xml:"-"`
-}
-
-type metadataGetBucketLocationInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketLocationOutput struct {
- LocationConstraint *string `type:"string"`
-
- metadataGetBucketLocationOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetBucketLocationOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketLoggingInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetBucketLoggingInput `json:"-" xml:"-"`
-}
-
-type metadataGetBucketLoggingInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketLoggingOutput struct {
- LoggingEnabled *LoggingEnabled `type:"structure"`
-
- metadataGetBucketLoggingOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetBucketLoggingOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketNotificationConfigurationRequest struct {
- // Name of the buket to get the notification configuration for.
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- metadataGetBucketNotificationConfigurationRequest `json:"-" xml:"-"`
-}
-
-type metadataGetBucketNotificationConfigurationRequest struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketPolicyInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetBucketPolicyInput `json:"-" xml:"-"`
-}
-
-type metadataGetBucketPolicyInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketPolicyOutput struct {
- // The bucket policy as a JSON document.
- Policy *string `type:"string"`
-
- metadataGetBucketPolicyOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetBucketPolicyOutput struct {
- SDKShapeTraits bool `type:"structure" payload:"Policy"`
-}
-
-type GetBucketReplicationInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetBucketReplicationInput `json:"-" xml:"-"`
-}
-
-type metadataGetBucketReplicationInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketReplicationOutput struct {
- // Container for replication rules. You can add as many as 1,000 rules. Total
- // replication configuration size can be up to 2 MB.
- ReplicationConfiguration *ReplicationConfiguration `type:"structure"`
-
- metadataGetBucketReplicationOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetBucketReplicationOutput struct {
- SDKShapeTraits bool `type:"structure" payload:"ReplicationConfiguration"`
-}
-
-type GetBucketRequestPaymentInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetBucketRequestPaymentInput `json:"-" xml:"-"`
-}
-
-type metadataGetBucketRequestPaymentInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketRequestPaymentOutput struct {
- // Specifies who pays for the download and request fees.
- Payer *string `type:"string"`
-
- metadataGetBucketRequestPaymentOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetBucketRequestPaymentOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketTaggingInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetBucketTaggingInput `json:"-" xml:"-"`
-}
-
-type metadataGetBucketTaggingInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketTaggingOutput struct {
- TagSet []*Tag `locationNameList:"Tag" type:"list" required:"true"`
-
- metadataGetBucketTaggingOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetBucketTaggingOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketVersioningInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetBucketVersioningInput `json:"-" xml:"-"`
-}
-
-type metadataGetBucketVersioningInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketVersioningOutput struct {
- // Specifies whether MFA delete is enabled in the bucket versioning configuration.
- // This element is only returned if the bucket has been configured with MFA
- // delete. If the bucket has never been so configured, this element is not returned.
- MFADelete *string `locationName:"MfaDelete" type:"string"`
-
- // The versioning state of the bucket.
- Status *string `type:"string"`
-
- metadataGetBucketVersioningOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetBucketVersioningOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketWebsiteInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetBucketWebsiteInput `json:"-" xml:"-"`
-}
-
-type metadataGetBucketWebsiteInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetBucketWebsiteOutput struct {
- ErrorDocument *ErrorDocument `type:"structure"`
-
- IndexDocument *IndexDocument `type:"structure"`
-
- RedirectAllRequestsTo *RedirectAllRequestsTo `type:"structure"`
-
- RoutingRules []*RoutingRule `locationNameList:"RoutingRule" type:"list"`
-
- metadataGetBucketWebsiteOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetBucketWebsiteOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetObjectACLInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- // VersionId used to reference a specific version of the object.
- VersionID *string `location:"querystring" locationName:"versionId" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetObjectACLInput `json:"-" xml:"-"`
-}
-
-type metadataGetObjectACLInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetObjectACLOutput struct {
- // A list of grants.
- Grants []*Grant `locationName:"AccessControlList" locationNameList:"Grant" type:"list"`
-
- Owner *Owner `type:"structure"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- metadataGetObjectACLOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetObjectACLOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetObjectInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Return the object only if its entity tag (ETag) is the same as the one specified,
- // otherwise return a 412 (precondition failed).
- IfMatch *string `location:"header" locationName:"If-Match" type:"string"`
-
- // Return the object only if it has been modified since the specified time,
- // otherwise return a 304 (not modified).
- IfModifiedSince *time.Time `location:"header" locationName:"If-Modified-Since" type:"timestamp" timestampFormat:"rfc822"`
-
- // Return the object only if its entity tag (ETag) is different from the one
- // specified, otherwise return a 304 (not modified).
- IfNoneMatch *string `location:"header" locationName:"If-None-Match" type:"string"`
-
- // Return the object only if it has not been modified since the specified time,
- // otherwise return a 412 (precondition failed).
- IfUnmodifiedSince *time.Time `location:"header" locationName:"If-Unmodified-Since" type:"timestamp" timestampFormat:"rfc822"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // Downloads the specified range bytes of an object. For more information about
- // the HTTP Range header, go to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.
- Range *string `location:"header" locationName:"Range" type:"string"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- // Sets the Cache-Control header of the response.
- ResponseCacheControl *string `location:"querystring" locationName:"response-cache-control" type:"string"`
-
- // Sets the Content-Disposition header of the response
- ResponseContentDisposition *string `location:"querystring" locationName:"response-content-disposition" type:"string"`
-
- // Sets the Content-Encoding header of the response.
- ResponseContentEncoding *string `location:"querystring" locationName:"response-content-encoding" type:"string"`
-
- // Sets the Content-Language header of the response.
- ResponseContentLanguage *string `location:"querystring" locationName:"response-content-language" type:"string"`
-
- // Sets the Content-Type header of the response.
- ResponseContentType *string `location:"querystring" locationName:"response-content-type" type:"string"`
-
- // Sets the Expires header of the response.
- ResponseExpires *time.Time `location:"querystring" locationName:"response-expires" type:"timestamp" timestampFormat:"iso8601"`
-
- // Specifies the algorithm to use to when encrypting the object (e.g., AES256,
- // aws:kms).
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting
- // data. This value is used to store the object and then it is discarded; Amazon
- // does not store the encryption key. The key must be appropriate for use with
- // the algorithm specified in the x-amz-server-side-encryption-customer-algorithm
- // header.
- SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"`
-
- // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321.
- // Amazon S3 uses this header for a message integrity check to ensure the encryption
- // key was transmitted without error.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // VersionId used to reference a specific version of the object.
- VersionID *string `location:"querystring" locationName:"versionId" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- TrafficLimit *int64 `location:"header" locationName:"x-kss-traffic-limit" type:"string"`
-
- metadataGetObjectInput `json:"-" xml:"-"`
-}
-
-type metadataGetObjectInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetObjectOutput struct {
- AcceptRanges *string `location:"header" locationName:"accept-ranges" type:"string"`
-
- // Object data.
- Body io.ReadCloser `type:"blob"`
-
- // Specifies caching behavior along the request/reply chain.
- CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"`
-
- // Specifies presentational information for the object.
- ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"`
-
- // Specifies what content encodings have been applied to the object and thus
- // what decoding mechanisms must be applied to obtain the media-type referenced
- // by the Content-Type header field.
- ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"`
-
- // The language the content is in.
- ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"`
-
- // Size of the body in bytes.
- ContentLength *int64 `location:"header" locationName:"Content-Length" type:"integer"`
-
- // The portion of the object returned in the response.
- ContentRange *string `location:"header" locationName:"Content-Range" type:"string"`
-
- // A standard MIME type describing the format of the object data.
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- // Specifies whether the object retrieved was (true) or was not (false) a Delete
- // Marker. If false, this response header does not appear in the response.
- DeleteMarker *bool `location:"header" locationName:"x-amz-delete-marker" type:"boolean"`
-
- // An ETag is an opaque identifier assigned by a web server to a specific version
- // of a resource found at a URL
- ETag *string `location:"header" locationName:"ETag" type:"string"`
-
- // If the object expiration is configured (see PUT Bucket lifecycle), the response
- // includes this header. It includes the expiry-date and rule-id key value pairs
- // providing object expiration information. The value of the rule-id is URL
- // encoded.
- Expiration *string `location:"header" locationName:"x-amz-expiration" type:"string"`
-
- // The date and time at which the object is no longer cacheable.
- Expires *time.Time `location:"header" locationName:"Expires" type:"timestamp" timestampFormat:"rfc822"`
-
- // Last modified date of the object
- LastModified *time.Time `location:"header" locationName:"Last-Modified" type:"timestamp" timestampFormat:"rfc822"`
-
- // This is set to the number of metadata entries not returned in x-amz-meta
- // headers. This can happen if you create metadata using an API like SOAP that
- // supports more flexible metadata than the REST API. For example, using SOAP,
- // you can create metadata whose values are not legal HTTP headers.
- MissingMeta *int64 `location:"header" locationName:"x-amz-missing-meta" type:"integer"`
-
- ReplicationStatus *string `location:"header" locationName:"x-amz-replication-status" type:"string"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- // Provides information about object restoration operation and expiration time
- // of the restored object copy.
- Restore *string `location:"header" locationName:"x-amz-restore" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header confirming the encryption algorithm
- // used.
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header to provide round trip message integrity
- // verification of the customer-provided encryption key.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // If present, specifies the ID of the AWS Key Management Service (KMS) master
- // encryption key that was used for the object.
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- // Version of the object.
- VersionID *string `location:"header" locationName:"x-amz-version-id" type:"string"`
-
- // If the bucket is configured as a website, redirects requests for this object
- // to another object in the same bucket or to an external URL. Amazon S3 stores
- // the value of this header in the object metadata.
- WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"`
-
- metadataGetObjectOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetObjectOutput struct {
- SDKShapeTraits bool `type:"structure" payload:"Body"`
-}
-
-type GetObjectTorrentInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetObjectTorrentInput `json:"-" xml:"-"`
-}
-
-type metadataGetObjectTorrentInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetObjectTorrentOutput struct {
- Body io.ReadCloser `type:"blob"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- metadataGetObjectTorrentOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetObjectTorrentOutput struct {
- SDKShapeTraits bool `type:"structure" payload:"Body"`
-}
-
-type Grant struct {
- Grantee *Grantee `type:"structure"`
-
- // Specifies the permission given to the grantee.
- Permission *string `type:"string"`
-
- metadataGrant `json:"-" xml:"-"`
-}
-
-type metadataGrant struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Grantee struct {
- // Screen name of the grantee.
- DisplayName *string `type:"string"`
-
- // Email address of the grantee.
- EmailAddress *string `type:"string"`
-
- // The canonical user ID of the grantee.
- ID *string `type:"string"`
-
- // Type of grantee
- Type *string `locationName:"xsi:type" type:"string" xmlAttribute:"true" required:"true"`
-
- // URI of the grantee group.
- URI *string `type:"string"`
-
- metadataGrantee `json:"-" xml:"-"`
-}
-
-type metadataGrantee struct {
- SDKShapeTraits bool `type:"structure" xmlPrefix:"xsi" xmlURI:"http://www.w3.org/2001/XMLSchema-instance"`
-}
-
-type HeadBucketInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataHeadBucketInput `json:"-" xml:"-"`
-}
-
-type metadataHeadBucketInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type HeadBucketOutput struct {
- metadataHeadBucketOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataHeadBucketOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type HeadObjectInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Return the object only if its entity tag (ETag) is the same as the one specified,
- // otherwise return a 412 (precondition failed).
- IfMatch *string `location:"header" locationName:"If-Match" type:"string"`
-
- // Return the object only if it has been modified since the specified time,
- // otherwise return a 304 (not modified).
- IfModifiedSince *time.Time `location:"header" locationName:"If-Modified-Since" type:"timestamp" timestampFormat:"rfc822"`
-
- // Return the object only if its entity tag (ETag) is different from the one
- // specified, otherwise return a 304 (not modified).
- IfNoneMatch *string `location:"header" locationName:"If-None-Match" type:"string"`
-
- // Return the object only if it has not been modified since the specified time,
- // otherwise return a 412 (precondition failed).
- IfUnmodifiedSince *time.Time `location:"header" locationName:"If-Unmodified-Since" type:"timestamp" timestampFormat:"rfc822"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // Downloads the specified range bytes of an object. For more information about
- // the HTTP Range header, go to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.
- Range *string `location:"header" locationName:"Range" type:"string"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- // Specifies the algorithm to use to when encrypting the object (e.g., AES256,
- // aws:kms).
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting
- // data. This value is used to store the object and then it is discarded; Amazon
- // does not store the encryption key. The key must be appropriate for use with
- // the algorithm specified in the x-amz-server-side-encryption-customer-algorithm
- // header.
- SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"`
-
- // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321.
- // Amazon S3 uses this header for a message integrity check to ensure the encryption
- // key was transmitted without error.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // VersionId used to reference a specific version of the object.
- VersionID *string `location:"querystring" locationName:"versionId" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataHeadObjectInput `json:"-" xml:"-"`
-}
-
-type metadataHeadObjectInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type HeadObjectOutput struct {
- AcceptRanges *string `location:"header" locationName:"accept-ranges" type:"string"`
-
- // Specifies caching behavior along the request/reply chain.
- CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"`
-
- // Specifies presentational information for the object.
- ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"`
-
- // Specifies what content encodings have been applied to the object and thus
- // what decoding mechanisms must be applied to obtain the media-type referenced
- // by the Content-Type header field.
- ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"`
-
- // The language the content is in.
- ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"`
-
- // Size of the body in bytes.
- ContentLength *int64 `location:"header" locationName:"Content-Length" type:"integer"`
-
- // A standard MIME type describing the format of the object data.
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- // Specifies whether the object retrieved was (true) or was not (false) a Delete
- // Marker. If false, this response header does not appear in the response.
- DeleteMarker *bool `location:"header" locationName:"x-amz-delete-marker" type:"boolean"`
-
- // An ETag is an opaque identifier assigned by a web server to a specific version
- // of a resource found at a URL
- ETag *string `location:"header" locationName:"ETag" type:"string"`
-
- // If the object expiration is configured (see PUT Bucket lifecycle), the response
- // includes this header. It includes the expiry-date and rule-id key value pairs
- // providing object expiration information. The value of the rule-id is URL
- // encoded.
- Expiration *string `location:"header" locationName:"x-amz-expiration" type:"string"`
-
- // The date and time at which the object is no longer cacheable.
- Expires *time.Time `location:"header" locationName:"Expires" type:"timestamp" timestampFormat:"rfc822"`
-
- // Last modified date of the object
- LastModified *time.Time `location:"header" locationName:"Last-Modified" type:"timestamp" timestampFormat:"rfc822"`
-
- // This is set to the number of metadata entries not returned in x-amz-meta
- // headers. This can happen if you create metadata using an API like SOAP that
- // supports more flexible metadata than the REST API. For example, using SOAP,
- // you can create metadata whose values are not legal HTTP headers.
- MissingMeta *int64 `location:"header" locationName:"x-amz-missing-meta" type:"integer"`
-
- ReplicationStatus *string `location:"header" locationName:"x-amz-replication-status" type:"string"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- // Provides information about object restoration operation and expiration time
- // of the restored object copy.
- Restore *string `location:"header" locationName:"x-amz-restore" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header confirming the encryption algorithm
- // used.
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header to provide round trip message integrity
- // verification of the customer-provided encryption key.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // If present, specifies the ID of the AWS Key Management Service (KMS) master
- // encryption key that was used for the object.
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- // Version of the object.
- VersionID *string `location:"header" locationName:"x-amz-version-id" type:"string"`
-
- // If the bucket is configured as a website, redirects requests for this object
- // to another object in the same bucket or to an external URL. Amazon S3 stores
- // the value of this header in the object metadata.
- WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"`
-
- metadataHeadObjectOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataHeadObjectOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type IndexDocument struct {
- // A suffix that is appended to a request that is for a directory on the website
- // endpoint (e.g. if the suffix is index.html and you make a request to samplebucket/images/
- // the data that is returned will be for the object with the key name images/index.html)
- // The suffix must not be empty and must not include a slash character.
- Suffix *string `type:"string" required:"true"`
-
- metadataIndexDocument `json:"-" xml:"-"`
-}
-
-type metadataIndexDocument struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Initiator struct {
- // Name of the Principal.
- DisplayName *string `type:"string"`
-
- // If the principal is an AWS account, it provides the Canonical User ID. If
- // the principal is an IAM User, it provides a user ARN value.
- ID *string `type:"string"`
-
- metadataInitiator `json:"-" xml:"-"`
-}
-
-type metadataInitiator struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// Container for specifying the AWS Lambda notification configuration.
-type LambdaFunctionConfiguration struct {
- Events []*string `locationName:"Event" type:"list" flattened:"true" required:"true"`
-
- // Optional unique identifier for configurations in a notification configuration.
- // If you don't provide one, Amazon S3 will assign an ID.
- ID *string `locationName:"Id" type:"string"`
-
- // Lambda cloud function ARN that Amazon S3 can invoke when it detects events
- // of the specified type.
- LambdaFunctionARN *string `locationName:"CloudFunction" type:"string" required:"true"`
-
- metadataLambdaFunctionConfiguration `json:"-" xml:"-"`
-}
-
-type metadataLambdaFunctionConfiguration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type LifecycleConfiguration struct {
- Rules []*LifecycleRule `locationName:"Rule" type:"list" flattened:"true" required:"true"`
-
- metadataLifecycleConfiguration `json:"-" xml:"-"`
-}
-
-type metadataLifecycleConfiguration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type LifecycleExpiration struct {
- // Indicates at what date the object is to be moved or deleted. Should be in
- // GMT ISO 8601 Format.
- Date *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- // Indicates the lifetime, in days, of the objects that are subject to the rule.
- // The value must be a non-zero positive integer.
- Days *int64 `type:"integer"`
-
- metadataLifecycleExpiration `json:"-" xml:"-"`
-}
-
-type metadataLifecycleExpiration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type LifecycleRule struct {
- Expiration *LifecycleExpiration `type:"structure"`
-
- // Unique identifier for the rule. The value cannot be longer than 255 characters.
- ID *string `type:"string"`
-
- // Specifies when noncurrent object versions expire. Upon expiration, Amazon
- // S3 permanently deletes the noncurrent object versions. You set this lifecycle
- // configuration action on a bucket that has versioning enabled (or suspended)
- // to request that Amazon S3 delete noncurrent object versions at a specific
- // period in the object's lifetime.
- NoncurrentVersionExpiration *NoncurrentVersionExpiration `type:"structure"`
-
- // Container for the transition rule that describes when noncurrent objects
- // transition to the GLACIER storage class. If your bucket is versioning-enabled
- // (or versioning is suspended), you can set this action to request that Amazon
- // S3 transition noncurrent object versions to the GLACIER storage class at
- // a specific period in the object's lifetime.
- NoncurrentVersionTransition *NoncurrentVersionTransition `type:"structure"`
-
- // Prefix identifying one or more objects to which the rule applies.
- Filter *LifecycleFilter `type:"structure"`
-
- // If 'Enabled', the rule is currently being applied. If 'Disabled', the rule
- // is not currently being applied.
- Status *string `type:"string" required:"true"`
-
- Transitions []*Transition `locationName:"Transition" type:"list" flattened:"true"`
-
- metadataLifecycleRule `json:"-" xml:"-"`
-}
-
-type metadataLifecycleRule struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ListBucketsInput struct {
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
- metadataListBucketsInput `json:"-" xml:"-"`
-}
-
-type metadataListBucketsInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ListBucketsOutput struct {
- Buckets []*Bucket `locationNameList:"Bucket" type:"list"`
-
- Owner *Owner `type:"structure"`
-
- metadataListBucketsOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataListBucketsOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ListMultipartUploadsInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Character you use to group keys.
- Delimiter *string `location:"querystring" locationName:"delimiter" type:"string"`
-
- // Requests Amazon S3 to encode the object keys in the response and specifies
- // the encoding method to use. An object key may contain any Unicode character;
- // however, XML 1.0 parser cannot parse some characters, such as characters
- // with an ASCII value from 0 to 10. For characters that are not supported in
- // XML 1.0, you can add this parameter to request that Amazon S3 encode the
- // keys in the response.
- EncodingType *string `location:"querystring" locationName:"encoding-type" type:"string"`
-
- // Together with upload-id-marker, this parameter specifies the multipart upload
- // after which listing should begin.
- KeyMarker *string `location:"querystring" locationName:"key-marker" type:"string"`
-
- // Sets the maximum number of multipart uploads, from 1 to 1,000, to return
- // in the response body. 1,000 is the maximum number of uploads that can be
- // returned in a response.
- MaxUploads *int64 `location:"querystring" locationName:"max-uploads" type:"integer"`
-
- // Lists in-progress uploads only for those keys that begin with the specified
- // prefix.
- Prefix *string `location:"querystring" locationName:"prefix" type:"string"`
-
- // Together with key-marker, specifies the multipart upload after which listing
- // should begin. If key-marker is not specified, the upload-id-marker parameter
- // is ignored.
- UploadIDMarker *string `location:"querystring" locationName:"upload-id-marker" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataListMultipartUploadsInput `json:"-" xml:"-"`
-}
-
-type metadataListMultipartUploadsInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ListMultipartUploadsOutput struct {
- // Name of the bucket to which the multipart upload was initiated.
- Bucket *string `type:"string"`
-
- CommonPrefixes []*CommonPrefix `type:"list" flattened:"true"`
-
- Delimiter *string `type:"string"`
-
- // Encoding type used by Amazon S3 to encode object keys in the response.
- EncodingType *string `type:"string"`
-
- // Indicates whether the returned list of multipart uploads is truncated. A
- // value of true indicates that the list was truncated. The list can be truncated
- // if the number of multipart uploads exceeds the limit allowed or specified
- // by max uploads.
- IsTruncated *bool `type:"boolean"`
-
- // The key at or after which the listing began.
- KeyMarker *string `type:"string"`
-
- // Maximum number of multipart uploads that could have been included in the
- // response.
- MaxUploads *int64 `type:"integer"`
-
- // When a list is truncated, this element specifies the value that should be
- // used for the key-marker request parameter in a subsequent request.
- NextKeyMarker *string `type:"string"`
-
- // When a list is truncated, this element specifies the value that should be
- // used for the upload-id-marker request parameter in a subsequent request.
- NextUploadIDMarker *string `locationName:"NextUploadIdMarker" type:"string"`
-
- // When a prefix is provided in the request, this field contains the specified
- // prefix. The result contains only keys starting with the specified prefix.
- Prefix *string `type:"string"`
-
- // Upload ID after which listing began.
- UploadIDMarker *string `locationName:"UploadIdMarker" type:"string"`
-
- Uploads []*MultipartUpload `locationName:"Upload" type:"list" flattened:"true"`
-
- metadataListMultipartUploadsOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataListMultipartUploadsOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ListObjectVersionsInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // A delimiter is a character you use to group keys.
- Delimiter *string `location:"querystring" locationName:"delimiter" type:"string"`
-
- // Requests Amazon S3 to encode the object keys in the response and specifies
- // the encoding method to use. An object key may contain any Unicode character;
- // however, XML 1.0 parser cannot parse some characters, such as characters
- // with an ASCII value from 0 to 10. For characters that are not supported in
- // XML 1.0, you can add this parameter to request that Amazon S3 encode the
- // keys in the response.
- EncodingType *string `location:"querystring" locationName:"encoding-type" type:"string"`
-
- // Specifies the key to start with when listing objects in a bucket.
- KeyMarker *string `location:"querystring" locationName:"key-marker" type:"string"`
-
- // Sets the maximum number of keys returned in the response. The response might
- // contain fewer keys but will never contain more.
- MaxKeys *int64 `location:"querystring" locationName:"max-keys" type:"integer"`
-
- // Limits the response to keys that begin with the specified prefix.
- Prefix *string `location:"querystring" locationName:"prefix" type:"string"`
-
- // Specifies the object version you want to start listing from.
- VersionIDMarker *string `location:"querystring" locationName:"version-id-marker" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataListObjectVersionsInput `json:"-" xml:"-"`
-}
-
-type metadataListObjectVersionsInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ListObjectVersionsOutput struct {
- CommonPrefixes []*CommonPrefix `type:"list" flattened:"true"`
-
- DeleteMarkers []*DeleteMarkerEntry `locationName:"DeleteMarker" type:"list" flattened:"true"`
-
- Delimiter *string `type:"string"`
-
- // Encoding type used by Amazon S3 to encode object keys in the response.
- EncodingType *string `type:"string"`
-
- // A flag that indicates whether or not Amazon S3 returned all of the results
- // that satisfied the search criteria. If your results were truncated, you can
- // make a follow-up paginated request using the NextKeyMarker and NextVersionIdMarker
- // response parameters as a starting place in another request to return the
- // rest of the results.
- IsTruncated *bool `type:"boolean"`
-
- // Marks the last Key returned in a truncated response.
- KeyMarker *string `type:"string"`
-
- MaxKeys *int64 `type:"integer"`
-
- Name *string `type:"string"`
-
- // Use this value for the key marker request parameter in a subsequent request.
- NextKeyMarker *string `type:"string"`
-
- // Use this value for the next version id marker parameter in a subsequent request.
- NextVersionIDMarker *string `locationName:"NextVersionIdMarker" type:"string"`
-
- Prefix *string `type:"string"`
-
- VersionIDMarker *string `locationName:"VersionIdMarker" type:"string"`
-
- Versions []*ObjectVersion `locationName:"Version" type:"list" flattened:"true"`
-
- metadataListObjectVersionsOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataListObjectVersionsOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ListObjectsInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // A delimiter is a character you use to group keys.
- Delimiter *string `location:"querystring" locationName:"delimiter" type:"string"`
-
- // Requests Amazon S3 to encode the object keys in the response and specifies
- // the encoding method to use. An object key may contain any Unicode character;
- // however, XML 1.0 parser cannot parse some characters, such as characters
- // with an ASCII value from 0 to 10. For characters that are not supported in
- // XML 1.0, you can add this parameter to request that Amazon S3 encode the
- // keys in the response.
- EncodingType *string `location:"querystring" locationName:"encoding-type" type:"string"`
-
- // Specifies the key to start with when listing objects in a bucket.
- Marker *string `location:"querystring" locationName:"marker" type:"string"`
-
- // Sets the maximum number of keys returned in the response. The response might
- // contain fewer keys but will never contain more.
- MaxKeys *int64 `location:"querystring" locationName:"max-keys" type:"integer"`
-
- // Limits the response to keys that begin with the specified prefix.
- Prefix *string `location:"querystring" locationName:"prefix" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataListObjectsInput `json:"-" xml:"-"`
-}
-
-type metadataListObjectsInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ListObjectsOutput struct {
- CommonPrefixes []*CommonPrefix `type:"list" flattened:"true"`
-
- Contents []*Object `type:"list" flattened:"true"`
-
- Delimiter *string `type:"string"`
-
- // Encoding type used by Amazon S3 to encode object keys in the response.
- EncodingType *string `type:"string"`
-
- // A flag that indicates whether or not Amazon S3 returned all of the results
- // that satisfied the search criteria.
- IsTruncated *bool `type:"boolean"`
-
- Marker *string `type:"string"`
-
- MaxKeys *int64 `type:"integer"`
-
- Name *string `type:"string"`
-
- // When response is truncated (the IsTruncated element value in the response
- // is true), you can use the key name in this field as marker in the subsequent
- // request to get next set of objects. Amazon S3 lists objects in alphabetical
- // order Note: This element is returned only if you have delimiter request parameter
- // specified. If response does not include the NextMaker and it is truncated,
- // you can use the value of the last Key in the response as the marker in the
- // subsequent request to get the next set of object keys.
- NextMarker *string `type:"string"`
-
- Prefix *string `type:"string"`
-
- metadataListObjectsOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataListObjectsOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ListPartsInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // Sets the maximum number of parts to return.
- MaxParts *int64 `location:"querystring" locationName:"max-parts" type:"integer"`
-
- // Specifies the part after which listing should begin. Only parts with higher
- // part numbers will be listed.
- PartNumberMarker *int64 `location:"querystring" locationName:"part-number-marker" type:"integer"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- // Upload ID identifying the multipart upload whose parts are being listed.
- UploadID *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataListPartsInput `json:"-" xml:"-"`
-}
-
-type metadataListPartsInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ListPartsOutput struct {
- // Name of the bucket to which the multipart upload was initiated.
- Bucket *string `type:"string"`
-
- // Identifies who initiated the multipart upload.
- Initiator *Initiator `type:"structure"`
-
- // Indicates whether the returned list of parts is truncated.
- IsTruncated *bool `type:"boolean"`
-
- // Object key for which the multipart upload was initiated.
- Key *string `type:"string"`
-
- // Maximum number of parts that were allowed in the response.
- MaxParts *int64 `type:"integer"`
-
- // When a list is truncated, this element specifies the last part in the list,
- // as well as the value to use for the part-number-marker request parameter
- // in a subsequent request.
- NextPartNumberMarker *int64 `type:"integer"`
-
- Owner *Owner `type:"structure"`
-
- // Part number after which listing begins.
- PartNumberMarker *int64 `type:"integer"`
-
- Parts []*Part `locationName:"Part" type:"list" flattened:"true"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- // The class of storage used to store the object.
- StorageClass *string `type:"string"`
-
- // Upload ID identifying the multipart upload whose parts are being listed.
- UploadID *string `locationName:"UploadId" type:"string"`
-
- metadataListPartsOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataListPartsOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type LoggingEnabled struct {
- // Specifies the bucket where you want Amazon S3 to store server access logs.
- // You can have your logs delivered to any bucket that you own, including the
- // same bucket that is being logged. You can also configure multiple buckets
- // to deliver their logs to the same target bucket. In this case you should
- // choose a different TargetPrefix for each source bucket so that the delivered
- // log files can be distinguished by key.
- TargetBucket *string `type:"string"`
-
- TargetGrants []*TargetGrant `locationNameList:"Grant" type:"list"`
-
- // This element lets you specify a prefix for the keys that the log files will
- // be stored under.
- TargetPrefix *string `type:"string"`
-
- metadataLoggingEnabled `json:"-" xml:"-"`
-}
-
-type metadataLoggingEnabled struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type MultipartUpload struct {
- // Date and time at which the multipart upload was initiated.
- Initiated *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- // Identifies who initiated the multipart upload.
- Initiator *Initiator `type:"structure"`
-
- // Key of the object for which the multipart upload was initiated.
- Key *string `type:"string"`
-
- Owner *Owner `type:"structure"`
-
- // The class of storage used to store the object.
- StorageClass *string `type:"string"`
-
- // Upload ID that identifies the multipart upload.
- UploadID *string `locationName:"UploadId" type:"string"`
-
- metadataMultipartUpload `json:"-" xml:"-"`
-}
-
-type metadataMultipartUpload struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// Specifies when noncurrent object versions expire. Upon expiration, Amazon
-// S3 permanently deletes the noncurrent object versions. You set this lifecycle
-// configuration action on a bucket that has versioning enabled (or suspended)
-// to request that Amazon S3 delete noncurrent object versions at a specific
-// period in the object's lifetime.
-type NoncurrentVersionExpiration struct {
- // Specifies the number of days an object is noncurrent before Amazon S3 can
- // perform the associated action. For information about the noncurrent days
- // calculations, see How Amazon S3 Calculates When an Object Became Noncurrent
- // (/AmazonS3/latest/dev/s3-access-control.html) in the Amazon Simple Storage
- // Service Developer Guide.
- NoncurrentDays *int64 `type:"integer"`
-
- metadataNoncurrentVersionExpiration `json:"-" xml:"-"`
-}
-
-type metadataNoncurrentVersionExpiration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// Container for the transition rule that describes when noncurrent objects
-// transition to the GLACIER storage class. If your bucket is versioning-enabled
-// (or versioning is suspended), you can set this action to request that Amazon
-// S3 transition noncurrent object versions to the GLACIER storage class at
-// a specific period in the object's lifetime.
-type NoncurrentVersionTransition struct {
- // Specifies the number of days an object is noncurrent before Amazon S3 can
- // perform the associated action. For information about the noncurrent days
- // calculations, see How Amazon S3 Calculates When an Object Became Noncurrent
- // (/AmazonS3/latest/dev/s3-access-control.html) in the Amazon Simple Storage
- // Service Developer Guide.
- NoncurrentDays *int64 `type:"integer"`
-
- // The class of storage used to store the object.
- StorageClass *string `type:"string"`
-
- metadataNoncurrentVersionTransition `json:"-" xml:"-"`
-}
-
-type metadataNoncurrentVersionTransition struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// Container for specifying the notification configuration of the bucket. If
-// this element is empty, notifications are turned off on the bucket.
-type NotificationConfiguration struct {
- LambdaFunctionConfigurations []*LambdaFunctionConfiguration `locationName:"CloudFunctionConfiguration" type:"list" flattened:"true"`
-
- QueueConfigurations []*QueueConfiguration `locationName:"QueueConfiguration" type:"list" flattened:"true"`
-
- TopicConfigurations []*TopicConfiguration `locationName:"TopicConfiguration" type:"list" flattened:"true"`
-
- metadataNotificationConfiguration `json:"-" xml:"-"`
-}
-
-type metadataNotificationConfiguration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type NotificationConfigurationDeprecated struct {
- CloudFunctionConfiguration *CloudFunctionConfiguration `type:"structure"`
-
- QueueConfiguration *QueueConfigurationDeprecated `type:"structure"`
-
- TopicConfiguration *TopicConfigurationDeprecated `type:"structure"`
-
- metadataNotificationConfigurationDeprecated `json:"-" xml:"-"`
-}
-
-type metadataNotificationConfigurationDeprecated struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Object struct {
- ETag *string `type:"string"`
-
- Key *string `type:"string"`
-
- LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- Owner *Owner `type:"structure"`
-
- Size *int64 `type:"integer"`
-
- // The class of storage used to store the object.
- StorageClass *string `type:"string"`
-
- metadataObject `json:"-" xml:"-"`
-}
-
-type metadataObject struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ObjectIdentifier struct {
- // Key name of the object to delete.
- Key *string `type:"string" required:"true"`
-
- // VersionId for the specific version of the object to delete.
- VersionID *string `locationName:"VersionId" type:"string"`
-
- metadataObjectIdentifier `json:"-" xml:"-"`
-}
-
-type metadataObjectIdentifier struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ObjectVersion struct {
- ETag *string `type:"string"`
-
- // Specifies whether the object is (true) or is not (false) the latest version
- // of an object.
- IsLatest *bool `type:"boolean"`
-
- // The object key.
- Key *string `type:"string"`
-
- // Date and time the object was last modified.
- LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- Owner *Owner `type:"structure"`
-
- // Size in bytes of the object.
- Size *int64 `type:"integer"`
-
- // The class of storage used to store the object.
- StorageClass *string `type:"string"`
-
- // Version ID of an object.
- VersionID *string `locationName:"VersionId" type:"string"`
-
- metadataObjectVersion `json:"-" xml:"-"`
-}
-
-type metadataObjectVersion struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Owner struct {
- DisplayName *string `type:"string"`
-
- ID *string `type:"string"`
-
- metadataOwner `json:"-" xml:"-"`
-}
-
-type metadataOwner struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Part struct {
- // Entity tag returned when the part was uploaded.
- ETag *string `type:"string"`
-
- // Date and time at which the part was uploaded.
- LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- // Part number identifying the part.
- PartNumber *int64 `type:"integer"`
-
- // Size of the uploaded part data.
- Size *int64 `type:"integer"`
-
- metadataPart `json:"-" xml:"-"`
-}
-
-type metadataPart struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutBucketACLInput struct {
- // The canned ACL to apply to the bucket.
- ACL *string `location:"header" locationName:"x-amz-acl" type:"string"`
-
- AccessControlPolicy *AccessControlPolicy `locationName:"AccessControlPolicy" type:"structure"`
-
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Allows grantee the read, write, read ACP, and write ACP permissions on the
- // bucket.
- GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"`
-
- // Allows grantee to list the objects in the bucket.
- GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"`
-
- // Allows grantee to read the bucket ACL.
- GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"`
-
- // Allows grantee to create, overwrite, and delete any object in the bucket.
- GrantWrite *string `location:"header" locationName:"x-amz-grant-write" type:"string"`
-
- // Allows grantee to write the ACL for the applicable bucket.
- GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutBucketACLInput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketACLInput struct {
- SDKShapeTraits bool `type:"structure" payload:"AccessControlPolicy"`
-}
-
-type PutBucketACLOutput struct {
- metadataPutBucketACLOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutBucketACLOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutBucketCORSInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- CORSConfiguration *CORSConfiguration `locationName:"CORSConfiguration" type:"structure" xmlURI:"http://s3.amazonaws.com/doc/2006-03-01/"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutBucketCORSInput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketCORSInput struct {
- SDKShapeTraits bool `type:"structure" payload:"CORSConfiguration"`
-}
-
-type PutBucketCORSOutput struct {
- metadataPutBucketCORSOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutBucketCORSOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutBucketLifecycleInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- LifecycleConfiguration *LifecycleConfiguration `locationName:"LifecycleConfiguration" type:"structure"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutBucketLifecycleInput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketLifecycleInput struct {
- SDKShapeTraits bool `type:"structure" payload:"LifecycleConfiguration"`
-}
-
-type PutBucketLifecycleOutput struct {
- metadataPutBucketLifecycleOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutBucketLifecycleOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutBucketLoggingInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- BucketLoggingStatus *BucketLoggingStatus `locationName:"BucketLoggingStatus" type:"structure" required:"true" xmlURI:"http://s3.amazonaws.com/doc/2006-03-01/"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutBucketLoggingInput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketLoggingInput struct {
- SDKShapeTraits bool `type:"structure" payload:"BucketLoggingStatus"`
-}
-
-type PutBucketLoggingOutput struct {
- metadataPutBucketLoggingOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutBucketLoggingOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutBucketNotificationConfigurationInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Container for specifying the notification configuration of the bucket. If
- // this element is empty, notifications are turned off on the bucket.
- NotificationConfiguration *NotificationConfiguration `locationName:"NotificationConfiguration" type:"structure" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutBucketNotificationConfigurationInput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketNotificationConfigurationInput struct {
- SDKShapeTraits bool `type:"structure" payload:"NotificationConfiguration"`
-}
-
-type PutBucketNotificationConfigurationOutput struct {
- metadataPutBucketNotificationConfigurationOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutBucketNotificationConfigurationOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutBucketNotificationInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- NotificationConfiguration *NotificationConfigurationDeprecated `locationName:"NotificationConfiguration" type:"structure" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutBucketNotificationInput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketNotificationInput struct {
- SDKShapeTraits bool `type:"structure" payload:"NotificationConfiguration"`
-}
-
-type PutBucketNotificationOutput struct {
- metadataPutBucketNotificationOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutBucketNotificationOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutBucketPolicyInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // The bucket policy as a JSON document.
- Policy *string `type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutBucketPolicyInput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketPolicyInput struct {
- SDKShapeTraits bool `type:"structure" payload:"Policy"`
-}
-
-type PutBucketPolicyOutput struct {
- metadataPutBucketPolicyOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutBucketPolicyOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutBucketReplicationInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Container for replication rules. You can add as many as 1,000 rules. Total
- // replication configuration size can be up to 2 MB.
- ReplicationConfiguration *ReplicationConfiguration `locationName:"ReplicationConfiguration" type:"structure" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutBucketReplicationInput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketReplicationInput struct {
- SDKShapeTraits bool `type:"structure" payload:"ReplicationConfiguration"`
-}
-
-type PutBucketReplicationOutput struct {
- metadataPutBucketReplicationOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutBucketReplicationOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutBucketRequestPaymentInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- RequestPaymentConfiguration *RequestPaymentConfiguration `locationName:"RequestPaymentConfiguration" type:"structure" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutBucketRequestPaymentInput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketRequestPaymentInput struct {
- SDKShapeTraits bool `type:"structure" payload:"RequestPaymentConfiguration"`
-}
-
-type PutBucketRequestPaymentOutput struct {
- metadataPutBucketRequestPaymentOutput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketRequestPaymentOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutBucketTaggingInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- Tagging *Tagging `locationName:"Tagging" type:"structure" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutBucketTaggingInput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketTaggingInput struct {
- SDKShapeTraits bool `type:"structure" payload:"Tagging"`
-}
-
-type PutBucketTaggingOutput struct {
- metadataPutBucketTaggingOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutBucketTaggingOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutBucketVersioningInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // The concatenation of the authentication device's serial number, a space,
- // and the value that is displayed on your authentication device.
- MFA *string `location:"header" locationName:"x-amz-mfa" type:"string"`
-
- VersioningConfiguration *VersioningConfiguration `locationName:"VersioningConfiguration" type:"structure" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutBucketVersioningInput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketVersioningInput struct {
- SDKShapeTraits bool `type:"structure" payload:"VersioningConfiguration"`
-}
-
-type PutBucketVersioningOutput struct {
- metadataPutBucketVersioningOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutBucketVersioningOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutBucketWebsiteInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- WebsiteConfiguration *WebsiteConfiguration `locationName:"WebsiteConfiguration" type:"structure" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutBucketWebsiteInput `json:"-" xml:"-"`
-}
-
-type metadataPutBucketWebsiteInput struct {
- SDKShapeTraits bool `type:"structure" payload:"WebsiteConfiguration"`
-}
-
-type PutBucketWebsiteOutput struct {
- metadataPutBucketWebsiteOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutBucketWebsiteOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutObjectACLInput struct {
- // The canned ACL to apply to the object.
- ACL *string `location:"header" locationName:"x-amz-acl" type:"string"`
-
- AccessControlPolicy *AccessControlPolicy `locationName:"AccessControlPolicy" type:"structure"`
-
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Allows grantee the read, write, read ACP, and write ACP permissions on the
- // bucket.
- GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"`
-
- // Allows grantee to list the objects in the bucket.
- GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"`
-
- // Allows grantee to read the bucket ACL.
- GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"`
-
- // Allows grantee to create, overwrite, and delete any object in the bucket.
- GrantWrite *string `location:"header" locationName:"x-amz-grant-write" type:"string"`
-
- // Allows grantee to write the ACL for the applicable bucket.
- GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutObjectACLInput `json:"-" xml:"-"`
-}
-
-type metadataPutObjectACLInput struct {
- SDKShapeTraits bool `type:"structure" payload:"AccessControlPolicy"`
-}
-
-type PutObjectACLOutput struct {
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- metadataPutObjectACLOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutObjectACLOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type PutObjectInput struct {
- // The canned ACL to apply to the object.
- ACL *string `location:"header" locationName:"x-amz-acl" type:"string"`
-
- // Object data.
- Body io.ReadSeeker `type:"blob"`
-
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Specifies caching behavior along the request/reply chain.
- CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"`
-
- // Specifies presentational information for the object.
- ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"`
-
- // Specifies what content encodings have been applied to the object and thus
- // what decoding mechanisms must be applied to obtain the media-type referenced
- // by the Content-Type header field.
- ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"`
-
- // The language the content is in.
- ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"`
-
- // Size of the body in bytes. This parameter is useful when the size of the
- // body cannot be determined automatically.
- ContentLength *int64 `location:"header" locationName:"Content-Length" type:"integer"`
-
- // A standard MIME type describing the format of the object data.
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- // The date and time at which the object is no longer cacheable.
- Expires *time.Time `location:"header" locationName:"Expires" type:"timestamp" timestampFormat:"rfc822"`
-
- // Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
- GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"`
-
- // Allows grantee to read the object data and its metadata.
- GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"`
-
- // Allows grantee to read the object ACL.
- GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"`
-
- // Allows grantee to write the ACL for the applicable object.
- GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // A map of metadata to store with the object in S3.
- Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"`
-
- XAmzTagging *string `location:"header" locationName:"X-Amz-Tagging" type:"string"`
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- // Specifies the algorithm to use to when encrypting the object (e.g., AES256,
- // aws:kms).
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting
- // data. This value is used to store the object and then it is discarded; Amazon
- // does not store the encryption key. The key must be appropriate for use with
- // the algorithm specified in the x-amz-server-side-encryption-customer-algorithm
- // header.
- SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"`
-
- // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321.
- // Amazon S3 uses this header for a message integrity check to ensure the encryption
- // key was transmitted without error.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // Specifies the AWS KMS key ID to use for object encryption. All GET and PUT
- // requests for an object protected by AWS KMS will fail if not made via SSL
- // or using SigV4. Documentation on configuring any of the officially supported
- // AWS SDKs and CLI can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- // The type of storage to use for the object. Defaults to 'STANDARD'.
- StorageClass *string `location:"header" locationName:"x-amz-storage-class" type:"string"`
-
- // If the bucket is configured as a website, redirects requests for this object
- // to another object in the same bucket or to an external URL. Amazon S3 stores
- // the value of this header in the object metadata.
- WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"`
-
- ContentMaxLength *int64 `location:"header" locationName:"x-amz-content-maxlength" type:"integer"`
-
- CallbackUrl *string `location:"header" locationName:"x-kss-callbackurl" type:"string"`
- CallbackBody *string `location:"header" locationName:"x-kss-callbackbody" type:"string"`
-
- TrafficLimit *int64 `location:"header" locationName:"x-kss-traffic-limit" type:"string"`
-
- metadataPutObjectInput `json:"-" xml:"-"`
-}
-type PutReaderRequest struct {
- // The canned ACL to apply to the object.
- ACL *string `location:"header" locationName:"x-amz-acl" type:"string"`
-
- // Object data.
- Body io.Reader `type:"blob"`
-
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Specifies caching behavior along the request/reply chain.
- CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"`
-
- // Specifies presentational information for the object.
- ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"`
-
- // Specifies what content encodings have been applied to the object and thus
- // what decoding mechanisms must be applied to obtain the media-type referenced
- // by the Content-Type header field.
- ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"`
-
- // The language the content is in.
- ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"`
-
- // Size of the body in bytes. This parameter is useful when the size of the
- // body cannot be determined automatically.
- ContentLength *int64 `location:"header" locationName:"Content-Length" type:"integer"`
-
- // A standard MIME type describing the format of the object data.
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- // The date and time at which the object is no longer cacheable.
- Expires *time.Time `location:"header" locationName:"Expires" type:"timestamp" timestampFormat:"rfc822"`
-
- // Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
- GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"`
-
- // Allows grantee to read the object data and its metadata.
- GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"`
-
- // Allows grantee to read the object ACL.
- GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"`
-
- // Allows grantee to write the ACL for the applicable object.
- GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // A map of metadata to store with the object in S3.
- Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- // Specifies the algorithm to use to when encrypting the object (e.g., AES256,
- // aws:kms).
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting
- // data. This value is used to store the object and then it is discarded; Amazon
- // does not store the encryption key. The key must be appropriate for use with
- // the algorithm specified in the x-amz-server-side-encryption-customer-algorithm
- // header.
- SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"`
-
- // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321.
- // Amazon S3 uses this header for a message integrity check to ensure the encryption
- // key was transmitted without error.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // Specifies the AWS KMS key ID to use for object encryption. All GET and PUT
- // requests for an object protected by AWS KMS will fail if not made via SSL
- // or using SigV4. Documentation on configuring any of the officially supported
- // AWS SDKs and CLI can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- // The type of storage to use for the object. Defaults to 'STANDARD'.
- StorageClass *string `location:"header" locationName:"x-amz-storage-class" type:"string"`
-
- // If the bucket is configured as a website, redirects requests for this object
- // to another object in the same bucket or to an external URL. Amazon S3 stores
- // the value of this header in the object metadata.
- WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"`
-
- ContentMaxLength *int64 `location:"header" locationName:"x-amz-content-maxlength" type:"integer"`
-
- CallbackUrl *string `location:"header" locationName:"x-kss-callbackurl" type:"string"`
- CallbackBody *string `location:"header" locationName:"x-kss-callbackbody" type:"string"`
-
- metadataPutObjectInput `json:"-" xml:"-"`
-}
-
-type metadataPutObjectInput struct {
- SDKShapeTraits bool `type:"structure" payload:"Body"`
-}
-
-type PutObjectOutput struct {
- // Entity tag for the uploaded object.
- ETag *string `location:"header" locationName:"ETag" type:"string"`
-
- // If the object expiration is configured, this will contain the expiration
- // date (expiry-date) and rule ID (rule-id). The value of rule-id is URL encoded.
- Expiration *string `location:"header" locationName:"x-amz-expiration" type:"string"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header confirming the encryption algorithm
- // used.
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header to provide round trip message integrity
- // verification of the customer-provided encryption key.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // If present, specifies the ID of the AWS Key Management Service (KMS) master
- // encryption key that was used for the object.
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- // Version of the object.
- VersionID *string `location:"header" locationName:"x-amz-version-id" type:"string"`
-
- NewFileName *string `location:"header" locationName:"newfilename" type:"string"`
-
- metadataPutObjectOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutObjectOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// Container for specifying an configuration when you want Amazon S3 to publish
-// events to an Amazon Simple Queue Service (Amazon SQS) queue.
-type QueueConfiguration struct {
- Events []*string `locationName:"Event" type:"list" flattened:"true" required:"true"`
-
- // Optional unique identifier for configurations in a notification configuration.
- // If you don't provide one, Amazon S3 will assign an ID.
- ID *string `locationName:"Id" type:"string"`
-
- // Amazon SQS queue ARN to which Amazon S3 will publish a message when it detects
- // events of specified type.
- QueueARN *string `locationName:"Queue" type:"string" required:"true"`
-
- metadataQueueConfiguration `json:"-" xml:"-"`
-}
-
-type metadataQueueConfiguration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type QueueConfigurationDeprecated struct {
- // Bucket event for which to send notifications.
- Event *string `type:"string"`
-
- Events []*string `locationName:"Event" type:"list" flattened:"true"`
-
- // Optional unique identifier for configurations in a notification configuration.
- // If you don't provide one, Amazon S3 will assign an ID.
- ID *string `locationName:"Id" type:"string"`
-
- Queue *string `type:"string"`
-
- metadataQueueConfigurationDeprecated `json:"-" xml:"-"`
-}
-
-type metadataQueueConfigurationDeprecated struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Redirect struct {
- // The HTTP redirect code to use on the response. Not required if one of the
- // siblings is present.
- HTTPRedirectCode *string `locationName:"HttpRedirectCode" type:"string"`
-
- // The host name to use in the redirect request.
- HostName *string `type:"string"`
-
- // Protocol to use (http, https) when redirecting requests. The default is the
- // protocol that is used in the original request.
- Protocol *string `type:"string"`
-
- // The object key prefix to use in the redirect request. For example, to redirect
- // requests for all pages with prefix docs/ (objects in the docs/ folder) to
- // documents/, you can set a condition block with KeyPrefixEquals set to docs/
- // and in the Redirect set ReplaceKeyPrefixWith to /documents. Not required
- // if one of the siblings is present. Can be present only if ReplaceKeyWith
- // is not provided.
- ReplaceKeyPrefixWith *string `type:"string"`
-
- // The specific object key to use in the redirect request. For example, redirect
- // request to error.html. Not required if one of the sibling is present. Can
- // be present only if ReplaceKeyPrefixWith is not provided.
- ReplaceKeyWith *string `type:"string"`
-
- metadataRedirect `json:"-" xml:"-"`
-}
-
-type metadataRedirect struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type RedirectAllRequestsTo struct {
- // Name of the host where requests will be redirected.
- HostName *string `type:"string" required:"true"`
-
- // Protocol to use (http, https) when redirecting requests. The default is the
- // protocol that is used in the original request.
- Protocol *string `type:"string"`
-
- metadataRedirectAllRequestsTo `json:"-" xml:"-"`
-}
-
-type metadataRedirectAllRequestsTo struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// Container for replication rules. You can add as many as 1,000 rules. Total
-// replication configuration size can be up to 2 MB.
-type ReplicationConfiguration struct {
- // Amazon Resource Name (ARN) of an IAM role for Amazon S3 to assume when replicating
- // the objects.
- Role *string `type:"string" required:"true"`
-
- // Container for information about a particular replication rule. Replication
- // configuration must have at least one rule and can contain up to 1,000 rules.
- Rules []*ReplicationRule `locationName:"Rule" type:"list" flattened:"true" required:"true"`
-
- metadataReplicationConfiguration `json:"-" xml:"-"`
-}
-
-type metadataReplicationConfiguration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type ReplicationRule struct {
- Destination *Destination `type:"structure" required:"true"`
-
- // Unique identifier for the rule. The value cannot be longer than 255 characters.
- ID *string `type:"string"`
-
- // Object keyname prefix identifying one or more objects to which the rule applies.
- // Maximum prefix length can be up to 1,024 characters. Overlapping prefixes
- // are not supported.
- Prefix *string `type:"string" required:"true"`
-
- // The rule is ignored if status is not Enabled.
- Status *string `type:"string" required:"true"`
-
- metadataReplicationRule `json:"-" xml:"-"`
-}
-
-type metadataReplicationRule struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type RequestPaymentConfiguration struct {
- // Specifies who pays for the download and request fees.
- Payer *string `type:"string" required:"true"`
-
- metadataRequestPaymentConfiguration `json:"-" xml:"-"`
-}
-
-type metadataRequestPaymentConfiguration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type RestoreObjectInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- RestoreRequest *RestoreRequest `locationName:"RestoreRequest" type:"structure"`
-
- VersionID *string `location:"querystring" locationName:"versionId" type:"string"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataRestoreObjectInput `json:"-" xml:"-"`
-}
-
-type metadataRestoreObjectInput struct {
- SDKShapeTraits bool `type:"structure" payload:"RestoreRequest"`
-}
-
-type RestoreObjectOutput struct {
- Ks3WebServiceResponse
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type RestoreRequest struct {
- // Lifetime of the active copy in days
- Days *int64 `type:"integer" required:"true"`
-
- metadataRestoreRequest `json:"-" xml:"-"`
-}
-
-type metadataRestoreRequest struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type RoutingRule struct {
- // A container for describing a condition that must be met for the specified
- // redirect to apply. For example, 1. If request is for pages in the /docs folder,
- // redirect to the /documents folder. 2. If request results in HTTP error 4xx,
- // redirect request to another host where you might process the error.
- Condition *Condition `type:"structure"`
-
- // Container for redirect information. You can redirect requests to another
- // host, to another page, or with another protocol. In the event of an error,
- // you can can specify a different error code to return.
- Redirect *Redirect `type:"structure" required:"true"`
-
- metadataRoutingRule `json:"-" xml:"-"`
-}
-
-type metadataRoutingRule struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Tag struct {
- // Name of the tag.
- Key *string `type:"string" required:"true"`
-
- // Value of the tag.
- Value *string `type:"string" required:"true"`
-
- metadataTag `json:"-" xml:"-"`
-}
-
-type metadataTag struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Tagging struct {
- TagSet []*Tag `locationNameList:"Tag" type:"list" required:"true"`
-
- metadataTagging `json:"-" xml:"-"`
-}
-
-type metadataTagging struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type TargetGrant struct {
- Grantee *Grantee `type:"structure"`
-
- // Logging permissions assigned to the Grantee for the bucket.
- Permission *string `type:"string"`
-
- metadataTargetGrant `json:"-" xml:"-"`
-}
-
-type metadataTargetGrant struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-// Container for specifying the configuration when you want Amazon S3 to publish
-// events to an Amazon Simple Notification Service (Amazon SNS) topic.
-type TopicConfiguration struct {
- Events []*string `locationName:"Event" type:"list" flattened:"true" required:"true"`
-
- // Optional unique identifier for configurations in a notification configuration.
- // If you don't provide one, Amazon S3 will assign an ID.
- ID *string `locationName:"Id" type:"string"`
-
- // Amazon SNS topic ARN to which Amazon S3 will publish a message when it detects
- // events of specified type.
- TopicARN *string `locationName:"Topic" type:"string" required:"true"`
-
- metadataTopicConfiguration `json:"-" xml:"-"`
-}
-
-type metadataTopicConfiguration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type TopicConfigurationDeprecated struct {
- // Bucket event for which to send notifications.
- Event *string `type:"string"`
-
- Events []*string `locationName:"Event" type:"list" flattened:"true"`
-
- // Optional unique identifier for configurations in a notification configuration.
- // If you don't provide one, Amazon S3 will assign an ID.
- ID *string `locationName:"Id" type:"string"`
-
- // Amazon SNS topic to which Amazon S3 will publish a message to report the
- // specified events for the bucket.
- Topic *string `type:"string"`
-
- metadataTopicConfigurationDeprecated `json:"-" xml:"-"`
-}
-
-type metadataTopicConfigurationDeprecated struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Transition struct {
- // Indicates at what date the object is to be moved or deleted. Should be in
- // GMT ISO 8601 Format.
- Date *time.Time `type:"timestamp" timestampFormat:"iso8601"`
-
- // Indicates the lifetime, in days, of the objects that are subject to the rule.
- // The value must be a non-zero positive integer.
- Days *int64 `type:"integer"`
-
- // The class of storage used to store the object.
- StorageClass *string `type:"string"`
-
- metadataTransition `json:"-" xml:"-"`
-}
-
-type metadataTransition struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type UploadPartCopyInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // The name of the source bucket and key name of the source object, separated
- // by a slash (/). Must be URL-encoded.
- CopySource *string `location:"header" locationName:"x-amz-copy-source" type:"string" required:"true"`
-
- // Copies the object if its entity tag (ETag) matches the specified tag.
- CopySourceIfMatch *string `location:"header" locationName:"x-amz-copy-source-if-match" type:"string"`
-
- // Copies the object if it has been modified since the specified time.
- CopySourceIfModifiedSince *time.Time `location:"header" locationName:"x-amz-copy-source-if-modified-since" type:"timestamp" timestampFormat:"rfc822"`
-
- // Copies the object if its entity tag (ETag) is different than the specified
- // ETag.
- CopySourceIfNoneMatch *string `location:"header" locationName:"x-amz-copy-source-if-none-match" type:"string"`
-
- // Copies the object if it hasn't been modified since the specified time.
- CopySourceIfUnmodifiedSince *time.Time `location:"header" locationName:"x-amz-copy-source-if-unmodified-since" type:"timestamp" timestampFormat:"rfc822"`
-
- // The range of bytes to copy from the source object. The range value must use
- // the form bytes=first-last, where the first and last are the zero-based byte
- // offsets to copy. For example, bytes=0-9 indicates that you want to copy the
- // first ten bytes of the source. You can copy a range only if the source object
- // is greater than 5 GB.
- CopySourceRange *string `location:"header" locationName:"x-amz-copy-source-range" type:"string"`
-
- // Specifies the algorithm to use when decrypting the source object (e.g., AES256).
- CopySourceSSECustomerAlgorithm *string `location:"header" locationName:"x-amz-copy-source-server-side-encryption-customer-algorithm" type:"string"`
-
- // Specifies the customer-provided encryption key for Amazon S3 to use to decrypt
- // the source object. The encryption key provided in this header must be one
- // that was used when the source object was created.
- CopySourceSSECustomerKey *string `location:"header" locationName:"x-amz-copy-source-server-side-encryption-customer-key" type:"string"`
-
- // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321.
- // Amazon S3 uses this header for a message integrity check to ensure the encryption
- // key was transmitted without error.
- CopySourceSSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-copy-source-server-side-encryption-customer-key-MD5" type:"string"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // Part number of part being copied.
- PartNumber *int64 `location:"querystring" locationName:"partNumber" type:"integer" required:"true"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- // Specifies the algorithm to use to when encrypting the object (e.g., AES256,
- // aws:kms).
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting
- // data. This value is used to store the object and then it is discarded; Amazon
- // does not store the encryption key. The key must be appropriate for use with
- // the algorithm specified in the x-amz-server-side-encryption-customer-algorithm
- // header. This must be the same encryption key specified in the initiate multipart
- // upload request.
- SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"`
-
- // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321.
- // Amazon S3 uses this header for a message integrity check to ensure the encryption
- // key was transmitted without error.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // Upload ID identifying the multipart upload whose part is being copied.
- UploadID *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataUploadPartCopyInput `json:"-" xml:"-"`
-}
-
-type metadataUploadPartCopyInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type UploadPartCopyOutput struct {
- CopyPartResult *CopyPartResult `type:"structure"`
-
- // The version of the source object that was copied, if you have enabled versioning
- // on the source bucket.
- CopySourceVersionID *string `location:"header" locationName:"x-amz-copy-source-version-id" type:"string"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header confirming the encryption algorithm
- // used.
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header to provide round trip message integrity
- // verification of the customer-provided encryption key.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // If present, specifies the ID of the AWS Key Management Service (KMS) master
- // encryption key that was used for the object.
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- metadataUploadPartCopyOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataUploadPartCopyOutput struct {
- SDKShapeTraits bool `type:"structure" payload:"CopyPartResult"`
-}
-
-type UploadPartInput struct {
- Body io.ReadSeeker `type:"blob"`
-
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Size of the body in bytes. This parameter is useful when the size of the
- // body cannot be determined automatically.
- ContentLength *int64 `location:"header" locationName:"Content-Length" type:"integer"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // Part number of part being uploaded.
- PartNumber *int64 `location:"querystring" locationName:"partNumber" type:"integer" required:"true"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- // Specifies the algorithm to use to when encrypting the object (e.g., AES256,
- // aws:kms).
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting
- // data. This value is used to store the object and then it is discarded; Amazon
- // does not store the encryption key. The key must be appropriate for use with
- // the algorithm specified in the x-amz-server-side-encryption-customer-algorithm
- // header. This must be the same encryption key specified in the initiate multipart
- // upload request.
- SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"`
-
- // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321.
- // Amazon S3 uses this header for a message integrity check to ensure the encryption
- // key was transmitted without error.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // Upload ID identifying the multipart upload whose part is being uploaded.
- UploadID *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataUploadPartInput `json:"-" xml:"-"`
-}
-
-type metadataUploadPartInput struct {
- SDKShapeTraits bool `type:"structure" payload:"Body"`
-}
-
-type UploadPartOutput struct {
- // Entity tag for the uploaded object.
- ETag *string `location:"header" locationName:"ETag" type:"string"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header confirming the encryption algorithm
- // used.
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header to provide round trip message integrity
- // verification of the customer-provided encryption key.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // If present, specifies the ID of the AWS Key Management Service (KMS) master
- // encryption key that was used for the object.
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- metadataUploadPartOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataUploadPartOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type VersioningConfiguration struct {
- // Specifies whether MFA delete is enabled in the bucket versioning configuration.
- // This element is only returned if the bucket has been configured with MFA
- // delete. If the bucket has never been so configured, this element is not returned.
- MFADelete *string `locationName:"MfaDelete" type:"string"`
-
- // The versioning state of the bucket.
- Status *string `type:"string"`
-
- metadataVersioningConfiguration `json:"-" xml:"-"`
-}
-
-type metadataVersioningConfiguration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type WebsiteConfiguration struct {
- ErrorDocument *ErrorDocument `type:"structure"`
-
- IndexDocument *IndexDocument `type:"structure"`
-
- RedirectAllRequestsTo *RedirectAllRequestsTo `type:"structure"`
-
- RoutingRules []*RoutingRule `locationNameList:"RoutingRule" type:"list"`
-
- metadataWebsiteConfiguration `json:"-" xml:"-"`
-}
-
-type metadataWebsiteConfiguration struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type Header map[string][]string
-
-type Ks3WebServiceResponse struct {
- HttpCode int `xml:"HttpCode"`
- Code string `xml:"Code"`
- Message string `xml:"Message"`
- Resource string `xml:"Resource"`
- RequestId string `xml:"RequestId"`
- Header Header
- Body []byte
-}
-
-func (c *S3) SignedReq(req *http.Request, canonicalizedResource string) {
-
- ossHeadersMap := make(map[string]string)
- for k, v := range req.Header {
- if strings.HasPrefix(strings.ToLower(k), "x-kss-") {
- ossHeadersMap[strings.ToLower(k)] = v[0]
- }
- }
- hs := newHeaderSorter(ossHeadersMap)
- hs.Sort()
- canonicalizedKS3Headers := ""
- for i := range hs.Keys {
- canonicalizedKS3Headers += hs.Keys[i] + ":" + hs.Vals[i] + "\n"
- }
- date := req.Header.Get(HTTPHeaderDate)
- contentType := req.Header.Get(HTTPHeaderContentType)
- contentMd5 := req.Header.Get(HTTPHeaderContentMD5)
- signStr := req.Method + "\n" + contentMd5 + "\n" + contentType + "\n" + date + "\n" + canonicalizedKS3Headers + canonicalizedResource
- if c.Config.LogHTTPBody {
- fmt.Print("signStr : ", signStr+"\n")
- }
- config, _ := c.Config.Credentials.Get()
- h := hmac.New(func() hash.Hash { return sha1.New() }, []byte(config.SecretAccessKey))
- io.WriteString(h, signStr)
- signedStr := "KSS " + config.AccessKeyID + ":" + base64.StdEncoding.EncodeToString(h.Sum(nil))
- if c.Config.LogHTTPBody {
- fmt.Print("signedStr : ", signedStr+"\n")
- }
- req.Header.Set(HTTPHeaderAuthorization, signedStr)
-
-}
-
-// headerSorter defines the key-value structure for storing the sorted data in signHeader.
-type headerSorter struct {
- Keys []string
- Vals []string
-}
-
-// Sort is an additional function for function SignHeader.
-func (hs *headerSorter) Sort() {
- sort.Sort(hs)
-}
-
-// Len is an additional function for function SignHeader.
-func (hs *headerSorter) Len() int {
- return len(hs.Vals)
-}
-
-// Less is an additional function for function SignHeader.
-func (hs *headerSorter) Less(i, j int) bool {
- return bytes.Compare([]byte(hs.Keys[i]), []byte(hs.Keys[j])) < 0
-}
-
-// Swap is an additional function for function SignHeader.
-func (hs *headerSorter) Swap(i, j int) {
- hs.Vals[i], hs.Vals[j] = hs.Vals[j], hs.Vals[i]
- hs.Keys[i], hs.Keys[j] = hs.Keys[j], hs.Keys[i]
-}
-
-// newHeaderSorter is an additional function for function SignHeader.
-func newHeaderSorter(m map[string]string) *headerSorter {
- hs := &headerSorter{
- Keys: make([]string, 0, len(m)),
- Vals: make([]string, 0, len(m)),
- }
-
- for k, v := range m {
- hs.Keys = append(hs.Keys, k)
- hs.Vals = append(hs.Vals, v)
- }
- return hs
-}
-
-/**
- ACL类型
-*/
-const AllUsersUri = "http://acs.amazonaws.com/groups/global/AllUsers"
-
-type CannedAccessControlType int32
-
-const (
- PublicReadWrite CannedAccessControlType = 0
- PublicRead CannedAccessControlType = 1
- Private CannedAccessControlType = 2
-)
-
-func GetAcl(resp GetObjectACLOutput) CannedAccessControlType {
-
- allUsersPermissions := map[string]*string{}
- for _, value := range resp.Grants {
- if value.Grantee.URI != nil && *value.Grantee.URI == AllUsersUri {
- allUsersPermissions[*value.Permission] = value.Permission
- }
- }
- _, read := allUsersPermissions["READ"]
- _, write := allUsersPermissions["WRITE"]
- if read && write {
- return PublicReadWrite
- } else if read {
- return PublicRead
- } else {
- return Private
- }
-}
-
-func (c *S3) RestoreObject(input *RestoreObjectInput) (*RestoreObjectOutput, error) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if input == nil {
- input = &RestoreObjectInput{}
- }
- out := &RestoreObjectOutput{}
-
- date := time.Now().UTC().Format(http.TimeFormat)
- client := &http.Client{}
- objectKey := *input.Key + "?restore"
- resource := "/" + *input.Bucket + "/" + objectKey
- url := c.Endpoint + resource
- req, err := http.NewRequest("POST", url, nil)
- req.Header.Set(HTTPHeaderDate, date)
- req.Header.Set(HTTPHeaderHost, c.Endpoint)
- c.SignedReq(req, resource)
- res, err := client.Do(req)
- if res != nil {
- defer res.Body.Close()
- body, _ := ioutil.ReadAll(res.Body)
- xml.Unmarshal((body), &out)
- if err != nil {
- fmt.Println(err)
- }
- if res.Header != nil {
- out.Header = Header(res.Header)
- out.HttpCode = res.StatusCode
- }
- if body != nil {
- out.Body = body
- }
- }
- return out, err
-
-}
-
-//----obj tag start--
-
-func (c *S3) DeleteObjectTaggingRequest(input *DeleteObjectTaggingInput) (req *aws.Request, output *DeleteObjectTaggingOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opDeleteObjectTagging == nil {
- opDeleteObjectTagging = &aws.Operation{
- Name: "DeleteObjectTagging",
- HTTPMethod: "DELETE",
- HTTPPath: "/{Bucket}/{Key+}?tagging",
- }
- }
-
- if input == nil {
- input = &DeleteObjectTaggingInput{}
- }
-
- req = c.newRequest(opDeleteObjectTagging, input, output)
- output = &DeleteObjectTaggingOutput{}
- req.Data = output
- return
-}
-
-func (c *S3) DeleteObjectTagging(input *DeleteObjectTaggingInput) (*DeleteObjectTaggingOutput, error) {
- req, out := c.DeleteObjectTaggingRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) DeleteObjectTaggingPresignedUrl(input *DeleteObjectTaggingInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.DeleteObjectTaggingRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opDeleteObjectTagging *aws.Operation
-
-type DeleteObjectTaggingInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataDeleteObjectTaggingInput `json:"-" xml:"-"`
-}
-
-type metadataDeleteObjectTaggingInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type DeleteObjectTaggingOutput struct {
- metadataDeleteObjectTaggingOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataDeleteObjectTaggingOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-//get 对象标签
-func (c *S3) GetObjectTaggingRequest(input *GetObjectTaggingInput) (req *aws.Request, output *GetObjectTaggingOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opGetObjectTagging == nil {
- opGetObjectTagging = &aws.Operation{
- Name: "GetObjectTagging",
- HTTPMethod: "GET",
- HTTPPath: "/{Bucket}/{Key+}?tagging",
- }
- }
-
- if input == nil {
- input = &GetObjectTaggingInput{}
- }
-
- req = c.newRequest(opGetObjectTagging, input, output)
- output = &GetObjectTaggingOutput{}
- req.Data = output
- return
-}
-
-func (c *S3) GetObjectTagging(input *GetObjectTaggingInput) (*GetObjectTaggingOutput, error) {
- req, out := c.GetObjectTaggingRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) GetObjectTaggingPresignedUrl(input *GetObjectTaggingInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.GetObjectTaggingRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opGetObjectTagging *aws.Operation
-
-//
-type GetObjectTaggingInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataGetObjectTaggingInput `json:"-" xml:"-"`
-}
-
-type metadataGetObjectTaggingInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type GetObjectTaggingOutput struct {
- Tagging *Tagging `locationName:"Tagging" type:"structure"`
-
- metadataGetObjectTaggingOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataGetObjectTaggingOutput struct {
- SDKShapeTraits bool `type:"structure" payload:"Tagging"`
-}
-
-//对象标签 put
-func (c *S3) PutObjectTaggingRequest(input *PutObjectTaggingInput) (req *aws.Request, output *PutObjectTaggingOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opPutObjectTagging == nil {
- opPutObjectTagging = &aws.Operation{
- Name: "PutObjectTagging",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}/{Key+}?tagging",
- }
- }
-
- if input == nil {
- input = &PutObjectTaggingInput{}
- }
- req = c.newRequest(opPutObjectTagging, input, output)
- output = &PutObjectTaggingOutput{}
- req.Data = output
- return
-}
-
-func (c *S3) PutObjectTagging(input *PutObjectTaggingInput) (*PutObjectTaggingOutput, error) {
- input.ContentType = aws.String("application/xml")
- req, out := c.PutObjectTaggingRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) PutObjectTaggingPresignedUrl(input *PutObjectTaggingInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.PutObjectTaggingRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opPutObjectTagging *aws.Operation
-
-type PutObjectTaggingInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- Tagging *Tagging `locationName:"Tagging" type:"structure"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- metadataPutObjectTaggingInput `json:"-" xml:"-"`
-}
-
-type metadataPutObjectTaggingInput struct {
- SDKShapeTraits bool `type:"structure" payload:"Tagging"`
-}
-
-type PutObjectTaggingOutput struct {
- metadataPutObjectTaggingOutput `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type metadataPutObjectTaggingOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-//----obj tag end--
-
-// FetchObjectRequest generates a request for the FetchObject operation.
-func (c *S3) FetchObjectRequest(input *FetchObjectInput) (req *aws.Request, output *FetchObjectOutput) {
- oprw.Lock()
- defer oprw.Unlock()
-
- if opFetchObject == nil {
- opFetchObject = &aws.Operation{
- Name: "FetchObject",
- HTTPMethod: "PUT",
- HTTPPath: "/{Bucket}/{Key+}?fetch",
- }
- }
-
- if input == nil {
- input = &FetchObjectInput{}
- }
-
- req = c.newRequest(opFetchObject, input, output)
- output = &FetchObjectOutput{}
- req.Data = output
- return
-}
-
-func (c *S3) FetchObject(input *FetchObjectInput) (*FetchObjectOutput, error) {
- req, out := c.FetchObjectRequest(input)
- err := req.Send()
- return out, err
-}
-func (c *S3) FetchObjectPresignedUrl(input *FetchObjectInput, expires time.Duration) (*url.URL, error) {
- req, _ := c.FetchObjectRequest(input)
- req.ExpireTime = expires
- err := req.Sign()
- return req.HTTPRequest.URL, err
-}
-
-var opFetchObject *aws.Operation
-
-type FetchObjectInput struct {
- // The canned ACL to apply to the object.
- ACL *string `location:"header" locationName:"x-kss-acl" type:"string"`
-
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- // Specifies caching behavior along the request/reply chain.
- CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"`
-
- // Specifies presentational information for the object.
- ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"`
-
- // Specifies what content encodings have been applied to the object and thus
- // what decoding mechanisms must be applied to obtain the media-type referenced
- // by the Content-Type header field.
- ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"`
-
- // The language the content is in.
- ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"`
-
- // A standard MIME type describing the format of the object data.
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-
- // The name of the source bucket and key name of the source object, separated
- // by a slash (/). Must be URL-encoded.
- SourceUrl *string `location:"header" locationName:"x-kss-sourceurl" type:"string" required:"true"`
-
- CallbackUrl *string `location:"header" locationName:"x-kss-callbackurl" type:"string"`
-
- // The date and time at which the object is no longer cacheable.
- Expires *time.Time `location:"header" locationName:"Expires" type:"timestamp" timestampFormat:"rfc822"`
-
- // Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
- GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"`
-
- // Allows grantee to read the object data and its metadata.
- GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"`
-
- // Allows grantee to read the object ACL.
- GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"`
-
- // Allows grantee to write the ACL for the applicable object.
- GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"`
-
- Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
-
- // A map of metadata to store with the object in S3.
- Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"`
-
- // Specifies whether the metadata is copied from the source object or replaced
- // with metadata provided in the request.
- MetadataDirective *string `location:"header" locationName:"x-amz-metadata-directive" type:"string"`
-
- // Confirms that the requester knows that she or he will be charged for the
- // request. Bucket owners need not specify this parameter in their requests.
- // Documentation on downloading objects from requester pays buckets can be found
- // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
- RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string"`
-
- // Specifies the algorithm to use to when encrypting the object (e.g., AES256,
- // aws:kms).
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting
- // data. This value is used to store the object and then it is discarded; Amazon
- // does not store the encryption key. The key must be appropriate for use with
- // the algorithm specified in the x-amz-server-side-encryption-customer-algorithm
- // header.
- SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"`
-
- // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321.
- // Amazon S3 uses this header for a message integrity check to ensure the encryption
- // key was transmitted without error.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // Specifies the AWS KMS key ID to use for object encryption. All GET and PUT
- // requests for an object protected by AWS KMS will fail if not made via SSL
- // or using SigV4. Documentation on configuring any of the officially supported
- // AWS SDKs and CLI can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- // The type of storage to use for the object. Defaults to 'STANDARD'.
- StorageClass *string `location:"header" locationName:"x-amz-storage-class" type:"string"`
-
- // If the bucket is configured as a website, redirects requests for this object
- // to another object in the same bucket or to an external URL. Amazon S3 stores
- // the value of this header in the object metadata.
- WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"`
-
- XAmzTagging *string `location:"header" locationName:"X-Amz-Tagging" type:"string"`
-
- metadataFetchObjectInput `json:"-" xml:"-"`
-}
-
-type metadataFetchObjectInput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-type FetchObjectOutput struct {
-
- // If the object expiration is configured, the response includes this header.
- Expiration *string `location:"header" locationName:"x-amz-expiration" type:"string"`
-
- // If present, indicates that the requester was successfully charged for the
- // request.
- RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header confirming the encryption algorithm
- // used.
- SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
-
- // If server-side encryption with a customer-provided encryption key was requested,
- // the response will include this header to provide round trip message integrity
- // verification of the customer-provided encryption key.
- SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
-
- // If present, specifies the ID of the AWS Key Management Service (KMS) master
- // encryption key that was used for the object.
- SSEKMSKeyID *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"`
-
- // The Server-side encryption algorithm used when storing this object in S3
- // (e.g., AES256, aws:kms).
- ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
-
- metadataFetchObjectOutput `json:"-" xml:"-"`
-}
-
-type metadataFetchObjectOutput struct {
- SDKShapeTraits bool `type:"structure"`
-}
-
-//--------fetch object end-------
-
-//--------镜像回源-------
-type BucketMirror struct {
- Version *string `json:"version"`
- UseDefaultRobots *bool `json:"use_default_robots"`
- AsyncMirrorRule *AsyncMirrorRule `json:"async_mirror_rule,omitempty"`
- SyncMirrorRules []*SyncMirrorRules `json:"sync_mirror_rules,omitempty"`
-}
-type SavingSetting struct {
- ACL *string `json:"acl,omitempty" required:"true"`
-}
-type AsyncMirrorRule struct {
- MirrorUrls []*string `json:"mirror_urls,omitempty" required:"true"`
- SavingSetting *SavingSetting `json:"saving_setting,omitempty" required:"true"`
-}
-type MatchCondition struct {
- HTTPCodes []*string `json:"http_codes,omitempty"`
- KeyPrefixes []*string `json:"key_prefixes,omitempty"`
-}
-type SetHeaders struct {
- Key *string `json:"key,omitempty"`
- Value *string `json:"value,omitempty"`
-}
-type RemoveHeaders struct {
- Key *string `json:"key,omitempty"`
-}
-type PassHeaders struct {
- Key *string `json:"key,omitempty"`
-}
-type HeaderSetting struct {
- SetHeaders []*SetHeaders `json:"set_headers,omitempty"`
- RemoveHeaders []*RemoveHeaders `json:"remove_headers,omitempty"`
- PassAll *bool `json:"pass_all,omitempty"`
- PassHeaders []*PassHeaders `json:"pass_headers,omitempty"`
-}
-type MirrorRequestSetting struct {
- PassQueryString *bool `json:"pass_query_string,omitempty"`
- Follow3Xx *bool `json:"follow3xx,omitempty"`
- HeaderSetting *HeaderSetting `json:"header_setting,omitempty"`
-}
-type SyncMirrorRules struct {
- MatchCondition MatchCondition `json:"match_condition"`
- MirrorURL *string `json:"mirror_url,omitempty"`
- MirrorRequestSetting *MirrorRequestSetting `json:"mirror_request_setting,omitempty"`
- SavingSetting *SavingSetting `json:"saving_setting,omitempty"`
-}
-
-func (c *S3) PutBucketMirror(input *PutBucketMirrorInput) (*PutBucketMirrorOutput, error) {
-
- oprw.Lock()
- defer oprw.Unlock()
-
- if input == nil {
- input = &PutBucketMirrorInput{}
- }
- out := &PutBucketMirrorOutput{}
- date := time.Now().UTC().Format(http.TimeFormat)
- resource := "/" + *input.Bucket + "?mirror"
- signResource := "/" + *input.Bucket + "/?mirror"
- url := c.Endpoint + resource
- data, err := json.Marshal(input.BucketMirror)
- if err != nil {
- return nil, errors.New("error:" + string(data))
- }
- request, _ := http.NewRequest("PUT", url, bytes.NewReader(data))
- request.Header.Set(HTTPHeaderContentType, "application/json")
- request.Header.Set(HTTPHeaderDate, date)
- request.Header.Set(HTTPHeaderHost, c.Endpoint)
- c.SignedReq(request, signResource)
- client := &http.Client{}
- res, err := client.Do(request)
- if res != nil {
- defer res.Body.Close()
- body, _ := ioutil.ReadAll(res.Body)
- xml.Unmarshal((body), &out)
- if err != nil {
- fmt.Println(err)
- }
- if res.Header != nil {
- out.Header = Header(res.Header)
- out.HttpCode = res.StatusCode
- }
- if body != nil {
- out.Body = body
- }
- }
- return out, err
-
-}
-
-var opPutBucketMirror *aws.Operation
-
-type PutBucketMirrorInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
-
- BucketMirror *BucketMirror `locationName:"Mirror" type:"structure"`
-
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-}
-
-type PutBucketMirrorOutput struct {
- Ks3WebServiceResponse `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-type GetBucketMirrorInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-}
-type GetBucketMirrorOutput struct {
- Ks3WebServiceResponse `json:"-" xml:"-"`
- BucketMirror *BucketMirror `locationName:"Mirror" type:"structure"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-func (c *S3) GetBucketMirror(input *GetBucketMirrorInput) (*GetBucketMirrorOutput, error) {
-
- oprw.Lock()
- defer oprw.Unlock()
-
- if input == nil {
- input = &GetBucketMirrorInput{}
- }
- out := &GetBucketMirrorOutput{}
- date := time.Now().UTC().Format(http.TimeFormat)
- resource := "/" + *input.Bucket + "?mirror"
- signResource := "/" + *input.Bucket + "/?mirror"
- url := c.Endpoint + resource
- request, _ := http.NewRequest("GET", url, nil)
- request.Header.Set(HTTPHeaderContentType, "application/json")
- request.Header.Set(HTTPHeaderDate, date)
- request.Header.Set(HTTPHeaderHost, c.Endpoint)
- c.SignedReq(request, signResource)
- client := &http.Client{}
- res, err := client.Do(request)
- if res != nil {
- defer res.Body.Close()
- body, _ := ioutil.ReadAll(res.Body)
- xml.Unmarshal((body), &out)
- if err != nil {
- fmt.Println(err)
- }
- if res.Header != nil {
- out.Header = Header(res.Header)
- out.HttpCode = res.StatusCode
- if res.StatusCode == 200 {
- json.Unmarshal(out.Body, &out.BucketMirror)
- }
- }
- if body != nil {
- out.Body = body
- }
- }
- return out, err
-
-}
-
-type DeleteBucketMirrorInput struct {
- Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
- ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
-}
-type DeleteBucketMirrorOutput struct {
- Ks3WebServiceResponse `json:"-" xml:"-"`
-
- Metadata map[string]*string `location:"headers" type:"map"`
-}
-
-func (c *S3) DeleteBucketMirror(input *DeleteBucketMirrorInput) (*DeleteBucketMirrorOutput, error) {
-
- oprw.Lock()
- defer oprw.Unlock()
-
- if input == nil {
- input = &DeleteBucketMirrorInput{}
- }
- out := &DeleteBucketMirrorOutput{}
- date := time.Now().UTC().Format(http.TimeFormat)
- resource := "/" + *input.Bucket + "?mirror"
- signResource := "/" + *input.Bucket + "/?mirror"
- url := c.Endpoint + resource
- request, _ := http.NewRequest("DELETE", url, nil)
- request.Header.Set(HTTPHeaderContentType, "application/json")
- request.Header.Set(HTTPHeaderDate, date)
- request.Header.Set(HTTPHeaderHost, c.Endpoint)
- c.SignedReq(request, signResource)
- client := &http.Client{}
- res, err := client.Do(request)
- if res != nil {
- defer res.Body.Close()
- body, _ := ioutil.ReadAll(res.Body)
- xml.Unmarshal((body), &out)
- if err != nil {
- fmt.Println(err)
- }
- if res.Header != nil {
- out.Header = Header(res.Header)
- out.HttpCode = res.StatusCode
- }
- if body != nil {
- out.Body = body
- }
- }
- return out, err
-
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/const.go b/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/const.go
deleted file mode 100644
index af18957d..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/const.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package s3
-
-// HTTP headers
-const (
- HTTPHeaderAcceptEncoding string = "Accept-Encoding"
- HTTPHeaderAuthorization = "Authorization"
- HTTPHeaderCacheControl = "Cache-Control"
- HTTPHeaderContentDisposition = "Content-Disposition"
- HTTPHeaderContentEncoding = "Content-Encoding"
- HTTPHeaderContentLength = "Content-Length"
- HTTPHeaderContentMD5 = "Content-MD5"
- HTTPHeaderContentType = "Content-Type"
- HTTPHeaderContentLanguage = "Content-Language"
- HTTPHeaderDate = "Date"
- HTTPHeaderEtag = "ETag"
- HTTPHeaderExpires = "Expires"
- HTTPHeaderHost = "Host"
- HTTPHeaderkssACL = "X-kss-Acl"
-)
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/errors.go b/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/errors.go
deleted file mode 100644
index 6d3e726c..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/errors.go
+++ /dev/null
@@ -1,60 +0,0 @@
-// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
-
-package s3
-
-const (
-
- // ErrCodeBucketAlreadyExists for service response error code
- // "BucketAlreadyExists".
- //
- // The requested bucket name is not available. The bucket namespace is shared
- // by all users of the system. Select a different name and try again.
- ErrCodeBucketAlreadyExists = "BucketAlreadyExists"
-
- // ErrCodeBucketAlreadyOwnedByYou for service response error code
- // "BucketAlreadyOwnedByYou".
- //
- // The bucket you tried to create already exists, and you own it. Amazon S3
- // returns this error in all AWS Regions except in the North Virginia Region.
- // For legacy compatibility, if you re-create an existing bucket that you already
- // own in the North Virginia Region, Amazon S3 returns 200 OK and resets the
- // bucket access control lists (ACLs).
- ErrCodeBucketAlreadyOwnedByYou = "BucketAlreadyOwnedByYou"
-
- // ErrCodeInvalidObjectState for service response error code
- // "InvalidObjectState".
- //
- // Object is archived and inaccessible until restored.
- ErrCodeInvalidObjectState = "InvalidObjectState"
-
- // ErrCodeNoSuchBucket for service response error code
- // "NoSuchBucket".
- //
- // The specified bucket does not exist.
- ErrCodeNoSuchBucket = "NoSuchBucket"
-
- // ErrCodeNoSuchKey for service response error code
- // "NoSuchKey".
- //
- // The specified key does not exist.
- ErrCodeNoSuchKey = "NoSuchKey"
-
- // ErrCodeNoSuchUpload for service response error code
- // "NoSuchUpload".
- //
- // The specified multipart upload does not exist.
- ErrCodeNoSuchUpload = "NoSuchUpload"
-
- // ErrCodeObjectAlreadyInActiveTierError for service response error code
- // "ObjectAlreadyInActiveTierError".
- //
- // This action is not allowed against this storage tier.
- ErrCodeObjectAlreadyInActiveTierError = "ObjectAlreadyInActiveTierError"
-
- // ErrCodeObjectNotInActiveTierError for service response error code
- // "ObjectNotInActiveTierError".
- //
- // The source object of the COPY action is not in the active tier and is only
- // stored in Amazon S3 Glacier.
- ErrCodeObjectNotInActiveTierError = "ObjectNotInActiveTierError"
-)
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/host_style_bucket.go b/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/host_style_bucket.go
deleted file mode 100644
index c1b53947..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/host_style_bucket.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package s3
-
-import (
- "regexp"
- "strings"
-
- "github.com/ks3sdklib/aws-sdk-go/aws"
- "github.com/ks3sdklib/aws-sdk-go/aws/awsutil"
-)
-
-var reDomain = regexp.MustCompile(`^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$`)
-var reIPAddress = regexp.MustCompile(`^(\d+\.){3}\d+$`)
-
-// dnsCompatibleBucketName returns true if the bucket name is DNS compatible.
-// Buckets created outside of the classic region MUST be DNS compatible.
-func dnsCompatibleBucketName(bucket string) bool {
- return reDomain.MatchString(bucket) &&
- !reIPAddress.MatchString(bucket) &&
- !strings.Contains(bucket, "..")
-}
-
-// hostStyleBucketName returns true if the request should put the bucket in
-// the host. This is false if S3ForcePathStyle is explicitly set or if the
-// bucket is not DNS compatible.
-func hostStyleBucketName(r *aws.Request, bucket string) bool {
- if r.Config.S3ForcePathStyle {
- return false
- }
-
- // Bucket might be DNS compatible but dots in the hostname will fail
- // certificate validation, so do not use host-style.
- if r.HTTPRequest.URL.Scheme == "https" && strings.Contains(bucket, ".") {
- return false
- }
-
- // Use host-style if the bucket is DNS compatible
- return dnsCompatibleBucketName(bucket)
-}
-
-func updateHostWithBucket(r *aws.Request) {
- b := awsutil.ValuesAtPath(r.Params, "Bucket")
- if len(b) == 0 {
- return
- }
-
- if bucket := b[0].(string); bucket != "" && hostStyleBucketName(r, bucket) {
- r.HTTPRequest.URL.Host = bucket + "." + r.HTTPRequest.URL.Host
- r.HTTPRequest.URL.Path = strings.Replace(r.HTTPRequest.URL.Path, "/{Bucket}", "", -1)
- if r.HTTPRequest.URL.Path == "" {
- r.HTTPRequest.URL.Path = "/"
- }
- }
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/service.go b/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/service.go
deleted file mode 100644
index 014b045e..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/service.go
+++ /dev/null
@@ -1,74 +0,0 @@
-// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
-
-package s3
-
-import (
- "github.com/ks3sdklib/aws-sdk-go/aws"
- "github.com/ks3sdklib/aws-sdk-go/internal/protocol/restxml"
- v2 "github.com/ks3sdklib/aws-sdk-go/internal/signer/v2"
- v4 "github.com/ks3sdklib/aws-sdk-go/internal/signer/v4"
- "strings"
-)
-
-// S3 is a client for Amazon S3.
-type S3 struct {
- *aws.Service
-}
-
-// Used for custom service initialization logic
-var initService func(*aws.Service)
-
-// Used for custom request initialization logic
-var initRequest func(*aws.Request)
-
-// New returns a new S3 client.
-func New(config *aws.Config) *S3 {
- service := &aws.Service{
- Config: aws.DefaultConfig.Merge(config),
- ServiceName: "s3",
- APIVersion: "2006-03-01",
- }
- service.Initialize()
-
- // Handlers
- if config.SignerVersion == "V4" {
- service.Handlers.Sign.PushBack(v4.Sign)
- } else if config.SignerVersion == "V4_UNSIGNED_PAYLOAD_SIGNER" {
- service.Handlers.Sign.PushBack(v4.Sign)
- } else {
- service.Handlers.Sign.PushBack(v2.Sign)
- }
-
- service.Handlers.Build.PushBack(restxml.Build)
- //service.Handlers.Build.PushBack(aws.ContentTypeHandler)
- service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)
- service.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)
- service.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)
-
- // Run custom service initialization if present
- if initService != nil {
- initService(service)
- }
-
- return &S3{service}
-}
-
-// newRequest creates a new request for a S3 operation and runs any
-// custom request initialization.
-func (c *S3) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {
- r := aws.NewRequest(c.Service, op, params, data)
- if r.Config.DomainMode {
- r.HTTPRequest.URL.Host = r.HTTPRequest.URL.Host
- r.HTTPRequest.URL.Path = strings.Replace(r.HTTPRequest.URL.Path, "/{Bucket}", "", -1)
- if r.HTTPRequest.URL.Path == "" {
- r.HTTPRequest.URL.Path = "/"
- }
- } else {
- updateHostWithBucket(r)
- }
- // Run custom request initialization if present
- if initRequest != nil {
- initRequest(r)
- }
- return r
-}
diff --git a/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/try.go b/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/try.go
deleted file mode 100644
index d2ba553c..00000000
--- a/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/try.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package s3
-import "errors"
-
-// MaxRetries is the maximum number of retries before bailing.
-var MaxRetries = 10
-
-var errMaxRetriesReached = errors.New("exceeded retry limit")
-
-// Func represents functions that can be retried.
-type Func func(attempt int) (retry bool, err error)
-
-// Do keeps trying the function until the second argument
-// returns false, or no error is returned.
-func Do(fn Func) error {
- var err error
- var cont bool
- attempt := 1
- for {
- cont, err = fn(attempt)
- if !cont || err == nil {
- break
- }
- attempt++
- if attempt > MaxRetries {
- return errMaxRetriesReached
- }
- }
- return err
-}
-
-// IsMaxRetries checks whether the error is due to hitting the
-// maximum number of retries or not.
-func IsMaxRetries(err error) bool {
- return err == errMaxRetriesReached
-}
diff --git a/vendor/github.com/pmezard/go-difflib/LICENSE b/vendor/github.com/pmezard/go-difflib/LICENSE
deleted file mode 100644
index c67dad61..00000000
--- a/vendor/github.com/pmezard/go-difflib/LICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-Copyright (c) 2013, Patrick Mezard
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
- The names of its contributors may not be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/github.com/pmezard/go-difflib/difflib/difflib.go b/vendor/github.com/pmezard/go-difflib/difflib/difflib.go
deleted file mode 100644
index 003e99fa..00000000
--- a/vendor/github.com/pmezard/go-difflib/difflib/difflib.go
+++ /dev/null
@@ -1,772 +0,0 @@
-// Package difflib is a partial port of Python difflib module.
-//
-// It provides tools to compare sequences of strings and generate textual diffs.
-//
-// The following class and functions have been ported:
-//
-// - SequenceMatcher
-//
-// - unified_diff
-//
-// - context_diff
-//
-// Getting unified diffs was the main goal of the port. Keep in mind this code
-// is mostly suitable to output text differences in a human friendly way, there
-// are no guarantees generated diffs are consumable by patch(1).
-package difflib
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strings"
-)
-
-func min(a, b int) int {
- if a < b {
- return a
- }
- return b
-}
-
-func max(a, b int) int {
- if a > b {
- return a
- }
- return b
-}
-
-func calculateRatio(matches, length int) float64 {
- if length > 0 {
- return 2.0 * float64(matches) / float64(length)
- }
- return 1.0
-}
-
-type Match struct {
- A int
- B int
- Size int
-}
-
-type OpCode struct {
- Tag byte
- I1 int
- I2 int
- J1 int
- J2 int
-}
-
-// SequenceMatcher compares sequence of strings. The basic
-// algorithm predates, and is a little fancier than, an algorithm
-// published in the late 1980's by Ratcliff and Obershelp under the
-// hyperbolic name "gestalt pattern matching". The basic idea is to find
-// the longest contiguous matching subsequence that contains no "junk"
-// elements (R-O doesn't address junk). The same idea is then applied
-// recursively to the pieces of the sequences to the left and to the right
-// of the matching subsequence. This does not yield minimal edit
-// sequences, but does tend to yield matches that "look right" to people.
-//
-// SequenceMatcher tries to compute a "human-friendly diff" between two
-// sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the
-// longest *contiguous* & junk-free matching subsequence. That's what
-// catches peoples' eyes. The Windows(tm) windiff has another interesting
-// notion, pairing up elements that appear uniquely in each sequence.
-// That, and the method here, appear to yield more intuitive difference
-// reports than does diff. This method appears to be the least vulnerable
-// to synching up on blocks of "junk lines", though (like blank lines in
-// ordinary text files, or maybe "" lines in HTML files). That may be
-// because this is the only method of the 3 that has a *concept* of
-// "junk" .
-//
-// Timing: Basic R-O is cubic time worst case and quadratic time expected
-// case. SequenceMatcher is quadratic time for the worst case and has
-// expected-case behavior dependent in a complicated way on how many
-// elements the sequences have in common; best case time is linear.
-type SequenceMatcher struct {
- a []string
- b []string
- b2j map[string][]int
- IsJunk func(string) bool
- autoJunk bool
- bJunk map[string]struct{}
- matchingBlocks []Match
- fullBCount map[string]int
- bPopular map[string]struct{}
- opCodes []OpCode
-}
-
-func NewMatcher(a, b []string) *SequenceMatcher {
- m := SequenceMatcher{autoJunk: true}
- m.SetSeqs(a, b)
- return &m
-}
-
-func NewMatcherWithJunk(a, b []string, autoJunk bool,
- isJunk func(string) bool) *SequenceMatcher {
-
- m := SequenceMatcher{IsJunk: isJunk, autoJunk: autoJunk}
- m.SetSeqs(a, b)
- return &m
-}
-
-// Set two sequences to be compared.
-func (m *SequenceMatcher) SetSeqs(a, b []string) {
- m.SetSeq1(a)
- m.SetSeq2(b)
-}
-
-// Set the first sequence to be compared. The second sequence to be compared is
-// not changed.
-//
-// SequenceMatcher computes and caches detailed information about the second
-// sequence, so if you want to compare one sequence S against many sequences,
-// use .SetSeq2(s) once and call .SetSeq1(x) repeatedly for each of the other
-// sequences.
-//
-// See also SetSeqs() and SetSeq2().
-func (m *SequenceMatcher) SetSeq1(a []string) {
- if &a == &m.a {
- return
- }
- m.a = a
- m.matchingBlocks = nil
- m.opCodes = nil
-}
-
-// Set the second sequence to be compared. The first sequence to be compared is
-// not changed.
-func (m *SequenceMatcher) SetSeq2(b []string) {
- if &b == &m.b {
- return
- }
- m.b = b
- m.matchingBlocks = nil
- m.opCodes = nil
- m.fullBCount = nil
- m.chainB()
-}
-
-func (m *SequenceMatcher) chainB() {
- // Populate line -> index mapping
- b2j := map[string][]int{}
- for i, s := range m.b {
- indices := b2j[s]
- indices = append(indices, i)
- b2j[s] = indices
- }
-
- // Purge junk elements
- m.bJunk = map[string]struct{}{}
- if m.IsJunk != nil {
- junk := m.bJunk
- for s, _ := range b2j {
- if m.IsJunk(s) {
- junk[s] = struct{}{}
- }
- }
- for s, _ := range junk {
- delete(b2j, s)
- }
- }
-
- // Purge remaining popular elements
- popular := map[string]struct{}{}
- n := len(m.b)
- if m.autoJunk && n >= 200 {
- ntest := n/100 + 1
- for s, indices := range b2j {
- if len(indices) > ntest {
- popular[s] = struct{}{}
- }
- }
- for s, _ := range popular {
- delete(b2j, s)
- }
- }
- m.bPopular = popular
- m.b2j = b2j
-}
-
-func (m *SequenceMatcher) isBJunk(s string) bool {
- _, ok := m.bJunk[s]
- return ok
-}
-
-// Find longest matching block in a[alo:ahi] and b[blo:bhi].
-//
-// If IsJunk is not defined:
-//
-// Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where
-// alo <= i <= i+k <= ahi
-// blo <= j <= j+k <= bhi
-// and for all (i',j',k') meeting those conditions,
-// k >= k'
-// i <= i'
-// and if i == i', j <= j'
-//
-// In other words, of all maximal matching blocks, return one that
-// starts earliest in a, and of all those maximal matching blocks that
-// start earliest in a, return the one that starts earliest in b.
-//
-// If IsJunk is defined, first the longest matching block is
-// determined as above, but with the additional restriction that no
-// junk element appears in the block. Then that block is extended as
-// far as possible by matching (only) junk elements on both sides. So
-// the resulting block never matches on junk except as identical junk
-// happens to be adjacent to an "interesting" match.
-//
-// If no blocks match, return (alo, blo, 0).
-func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Match {
- // CAUTION: stripping common prefix or suffix would be incorrect.
- // E.g.,
- // ab
- // acab
- // Longest matching block is "ab", but if common prefix is
- // stripped, it's "a" (tied with "b"). UNIX(tm) diff does so
- // strip, so ends up claiming that ab is changed to acab by
- // inserting "ca" in the middle. That's minimal but unintuitive:
- // "it's obvious" that someone inserted "ac" at the front.
- // Windiff ends up at the same place as diff, but by pairing up
- // the unique 'b's and then matching the first two 'a's.
- besti, bestj, bestsize := alo, blo, 0
-
- // find longest junk-free match
- // during an iteration of the loop, j2len[j] = length of longest
- // junk-free match ending with a[i-1] and b[j]
- j2len := map[int]int{}
- for i := alo; i != ahi; i++ {
- // look at all instances of a[i] in b; note that because
- // b2j has no junk keys, the loop is skipped if a[i] is junk
- newj2len := map[int]int{}
- for _, j := range m.b2j[m.a[i]] {
- // a[i] matches b[j]
- if j < blo {
- continue
- }
- if j >= bhi {
- break
- }
- k := j2len[j-1] + 1
- newj2len[j] = k
- if k > bestsize {
- besti, bestj, bestsize = i-k+1, j-k+1, k
- }
- }
- j2len = newj2len
- }
-
- // Extend the best by non-junk elements on each end. In particular,
- // "popular" non-junk elements aren't in b2j, which greatly speeds
- // the inner loop above, but also means "the best" match so far
- // doesn't contain any junk *or* popular non-junk elements.
- for besti > alo && bestj > blo && !m.isBJunk(m.b[bestj-1]) &&
- m.a[besti-1] == m.b[bestj-1] {
- besti, bestj, bestsize = besti-1, bestj-1, bestsize+1
- }
- for besti+bestsize < ahi && bestj+bestsize < bhi &&
- !m.isBJunk(m.b[bestj+bestsize]) &&
- m.a[besti+bestsize] == m.b[bestj+bestsize] {
- bestsize += 1
- }
-
- // Now that we have a wholly interesting match (albeit possibly
- // empty!), we may as well suck up the matching junk on each
- // side of it too. Can't think of a good reason not to, and it
- // saves post-processing the (possibly considerable) expense of
- // figuring out what to do with it. In the case of an empty
- // interesting match, this is clearly the right thing to do,
- // because no other kind of match is possible in the regions.
- for besti > alo && bestj > blo && m.isBJunk(m.b[bestj-1]) &&
- m.a[besti-1] == m.b[bestj-1] {
- besti, bestj, bestsize = besti-1, bestj-1, bestsize+1
- }
- for besti+bestsize < ahi && bestj+bestsize < bhi &&
- m.isBJunk(m.b[bestj+bestsize]) &&
- m.a[besti+bestsize] == m.b[bestj+bestsize] {
- bestsize += 1
- }
-
- return Match{A: besti, B: bestj, Size: bestsize}
-}
-
-// Return list of triples describing matching subsequences.
-//
-// Each triple is of the form (i, j, n), and means that
-// a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in
-// i and in j. It's also guaranteed that if (i, j, n) and (i', j', n') are
-// adjacent triples in the list, and the second is not the last triple in the
-// list, then i+n != i' or j+n != j'. IOW, adjacent triples never describe
-// adjacent equal blocks.
-//
-// The last triple is a dummy, (len(a), len(b), 0), and is the only
-// triple with n==0.
-func (m *SequenceMatcher) GetMatchingBlocks() []Match {
- if m.matchingBlocks != nil {
- return m.matchingBlocks
- }
-
- var matchBlocks func(alo, ahi, blo, bhi int, matched []Match) []Match
- matchBlocks = func(alo, ahi, blo, bhi int, matched []Match) []Match {
- match := m.findLongestMatch(alo, ahi, blo, bhi)
- i, j, k := match.A, match.B, match.Size
- if match.Size > 0 {
- if alo < i && blo < j {
- matched = matchBlocks(alo, i, blo, j, matched)
- }
- matched = append(matched, match)
- if i+k < ahi && j+k < bhi {
- matched = matchBlocks(i+k, ahi, j+k, bhi, matched)
- }
- }
- return matched
- }
- matched := matchBlocks(0, len(m.a), 0, len(m.b), nil)
-
- // It's possible that we have adjacent equal blocks in the
- // matching_blocks list now.
- nonAdjacent := []Match{}
- i1, j1, k1 := 0, 0, 0
- for _, b := range matched {
- // Is this block adjacent to i1, j1, k1?
- i2, j2, k2 := b.A, b.B, b.Size
- if i1+k1 == i2 && j1+k1 == j2 {
- // Yes, so collapse them -- this just increases the length of
- // the first block by the length of the second, and the first
- // block so lengthened remains the block to compare against.
- k1 += k2
- } else {
- // Not adjacent. Remember the first block (k1==0 means it's
- // the dummy we started with), and make the second block the
- // new block to compare against.
- if k1 > 0 {
- nonAdjacent = append(nonAdjacent, Match{i1, j1, k1})
- }
- i1, j1, k1 = i2, j2, k2
- }
- }
- if k1 > 0 {
- nonAdjacent = append(nonAdjacent, Match{i1, j1, k1})
- }
-
- nonAdjacent = append(nonAdjacent, Match{len(m.a), len(m.b), 0})
- m.matchingBlocks = nonAdjacent
- return m.matchingBlocks
-}
-
-// Return list of 5-tuples describing how to turn a into b.
-//
-// Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple
-// has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the
-// tuple preceding it, and likewise for j1 == the previous j2.
-//
-// The tags are characters, with these meanings:
-//
-// 'r' (replace): a[i1:i2] should be replaced by b[j1:j2]
-//
-// 'd' (delete): a[i1:i2] should be deleted, j1==j2 in this case.
-//
-// 'i' (insert): b[j1:j2] should be inserted at a[i1:i1], i1==i2 in this case.
-//
-// 'e' (equal): a[i1:i2] == b[j1:j2]
-func (m *SequenceMatcher) GetOpCodes() []OpCode {
- if m.opCodes != nil {
- return m.opCodes
- }
- i, j := 0, 0
- matching := m.GetMatchingBlocks()
- opCodes := make([]OpCode, 0, len(matching))
- for _, m := range matching {
- // invariant: we've pumped out correct diffs to change
- // a[:i] into b[:j], and the next matching block is
- // a[ai:ai+size] == b[bj:bj+size]. So we need to pump
- // out a diff to change a[i:ai] into b[j:bj], pump out
- // the matching block, and move (i,j) beyond the match
- ai, bj, size := m.A, m.B, m.Size
- tag := byte(0)
- if i < ai && j < bj {
- tag = 'r'
- } else if i < ai {
- tag = 'd'
- } else if j < bj {
- tag = 'i'
- }
- if tag > 0 {
- opCodes = append(opCodes, OpCode{tag, i, ai, j, bj})
- }
- i, j = ai+size, bj+size
- // the list of matching blocks is terminated by a
- // sentinel with size 0
- if size > 0 {
- opCodes = append(opCodes, OpCode{'e', ai, i, bj, j})
- }
- }
- m.opCodes = opCodes
- return m.opCodes
-}
-
-// Isolate change clusters by eliminating ranges with no changes.
-//
-// Return a generator of groups with up to n lines of context.
-// Each group is in the same format as returned by GetOpCodes().
-func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode {
- if n < 0 {
- n = 3
- }
- codes := m.GetOpCodes()
- if len(codes) == 0 {
- codes = []OpCode{OpCode{'e', 0, 1, 0, 1}}
- }
- // Fixup leading and trailing groups if they show no changes.
- if codes[0].Tag == 'e' {
- c := codes[0]
- i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
- codes[0] = OpCode{c.Tag, max(i1, i2-n), i2, max(j1, j2-n), j2}
- }
- if codes[len(codes)-1].Tag == 'e' {
- c := codes[len(codes)-1]
- i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
- codes[len(codes)-1] = OpCode{c.Tag, i1, min(i2, i1+n), j1, min(j2, j1+n)}
- }
- nn := n + n
- groups := [][]OpCode{}
- group := []OpCode{}
- for _, c := range codes {
- i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
- // End the current group and start a new one whenever
- // there is a large range with no changes.
- if c.Tag == 'e' && i2-i1 > nn {
- group = append(group, OpCode{c.Tag, i1, min(i2, i1+n),
- j1, min(j2, j1+n)})
- groups = append(groups, group)
- group = []OpCode{}
- i1, j1 = max(i1, i2-n), max(j1, j2-n)
- }
- group = append(group, OpCode{c.Tag, i1, i2, j1, j2})
- }
- if len(group) > 0 && !(len(group) == 1 && group[0].Tag == 'e') {
- groups = append(groups, group)
- }
- return groups
-}
-
-// Return a measure of the sequences' similarity (float in [0,1]).
-//
-// Where T is the total number of elements in both sequences, and
-// M is the number of matches, this is 2.0*M / T.
-// Note that this is 1 if the sequences are identical, and 0 if
-// they have nothing in common.
-//
-// .Ratio() is expensive to compute if you haven't already computed
-// .GetMatchingBlocks() or .GetOpCodes(), in which case you may
-// want to try .QuickRatio() or .RealQuickRation() first to get an
-// upper bound.
-func (m *SequenceMatcher) Ratio() float64 {
- matches := 0
- for _, m := range m.GetMatchingBlocks() {
- matches += m.Size
- }
- return calculateRatio(matches, len(m.a)+len(m.b))
-}
-
-// Return an upper bound on ratio() relatively quickly.
-//
-// This isn't defined beyond that it is an upper bound on .Ratio(), and
-// is faster to compute.
-func (m *SequenceMatcher) QuickRatio() float64 {
- // viewing a and b as multisets, set matches to the cardinality
- // of their intersection; this counts the number of matches
- // without regard to order, so is clearly an upper bound
- if m.fullBCount == nil {
- m.fullBCount = map[string]int{}
- for _, s := range m.b {
- m.fullBCount[s] = m.fullBCount[s] + 1
- }
- }
-
- // avail[x] is the number of times x appears in 'b' less the
- // number of times we've seen it in 'a' so far ... kinda
- avail := map[string]int{}
- matches := 0
- for _, s := range m.a {
- n, ok := avail[s]
- if !ok {
- n = m.fullBCount[s]
- }
- avail[s] = n - 1
- if n > 0 {
- matches += 1
- }
- }
- return calculateRatio(matches, len(m.a)+len(m.b))
-}
-
-// Return an upper bound on ratio() very quickly.
-//
-// This isn't defined beyond that it is an upper bound on .Ratio(), and
-// is faster to compute than either .Ratio() or .QuickRatio().
-func (m *SequenceMatcher) RealQuickRatio() float64 {
- la, lb := len(m.a), len(m.b)
- return calculateRatio(min(la, lb), la+lb)
-}
-
-// Convert range to the "ed" format
-func formatRangeUnified(start, stop int) string {
- // Per the diff spec at http://www.unix.org/single_unix_specification/
- beginning := start + 1 // lines start numbering with one
- length := stop - start
- if length == 1 {
- return fmt.Sprintf("%d", beginning)
- }
- if length == 0 {
- beginning -= 1 // empty ranges begin at line just before the range
- }
- return fmt.Sprintf("%d,%d", beginning, length)
-}
-
-// Unified diff parameters
-type UnifiedDiff struct {
- A []string // First sequence lines
- FromFile string // First file name
- FromDate string // First file time
- B []string // Second sequence lines
- ToFile string // Second file name
- ToDate string // Second file time
- Eol string // Headers end of line, defaults to LF
- Context int // Number of context lines
-}
-
-// Compare two sequences of lines; generate the delta as a unified diff.
-//
-// Unified diffs are a compact way of showing line changes and a few
-// lines of context. The number of context lines is set by 'n' which
-// defaults to three.
-//
-// By default, the diff control lines (those with ---, +++, or @@) are
-// created with a trailing newline. This is helpful so that inputs
-// created from file.readlines() result in diffs that are suitable for
-// file.writelines() since both the inputs and outputs have trailing
-// newlines.
-//
-// For inputs that do not have trailing newlines, set the lineterm
-// argument to "" so that the output will be uniformly newline free.
-//
-// The unidiff format normally has a header for filenames and modification
-// times. Any or all of these may be specified using strings for
-// 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
-// The modification times are normally expressed in the ISO 8601 format.
-func WriteUnifiedDiff(writer io.Writer, diff UnifiedDiff) error {
- buf := bufio.NewWriter(writer)
- defer buf.Flush()
- wf := func(format string, args ...interface{}) error {
- _, err := buf.WriteString(fmt.Sprintf(format, args...))
- return err
- }
- ws := func(s string) error {
- _, err := buf.WriteString(s)
- return err
- }
-
- if len(diff.Eol) == 0 {
- diff.Eol = "\n"
- }
-
- started := false
- m := NewMatcher(diff.A, diff.B)
- for _, g := range m.GetGroupedOpCodes(diff.Context) {
- if !started {
- started = true
- fromDate := ""
- if len(diff.FromDate) > 0 {
- fromDate = "\t" + diff.FromDate
- }
- toDate := ""
- if len(diff.ToDate) > 0 {
- toDate = "\t" + diff.ToDate
- }
- if diff.FromFile != "" || diff.ToFile != "" {
- err := wf("--- %s%s%s", diff.FromFile, fromDate, diff.Eol)
- if err != nil {
- return err
- }
- err = wf("+++ %s%s%s", diff.ToFile, toDate, diff.Eol)
- if err != nil {
- return err
- }
- }
- }
- first, last := g[0], g[len(g)-1]
- range1 := formatRangeUnified(first.I1, last.I2)
- range2 := formatRangeUnified(first.J1, last.J2)
- if err := wf("@@ -%s +%s @@%s", range1, range2, diff.Eol); err != nil {
- return err
- }
- for _, c := range g {
- i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
- if c.Tag == 'e' {
- for _, line := range diff.A[i1:i2] {
- if err := ws(" " + line); err != nil {
- return err
- }
- }
- continue
- }
- if c.Tag == 'r' || c.Tag == 'd' {
- for _, line := range diff.A[i1:i2] {
- if err := ws("-" + line); err != nil {
- return err
- }
- }
- }
- if c.Tag == 'r' || c.Tag == 'i' {
- for _, line := range diff.B[j1:j2] {
- if err := ws("+" + line); err != nil {
- return err
- }
- }
- }
- }
- }
- return nil
-}
-
-// Like WriteUnifiedDiff but returns the diff a string.
-func GetUnifiedDiffString(diff UnifiedDiff) (string, error) {
- w := &bytes.Buffer{}
- err := WriteUnifiedDiff(w, diff)
- return string(w.Bytes()), err
-}
-
-// Convert range to the "ed" format.
-func formatRangeContext(start, stop int) string {
- // Per the diff spec at http://www.unix.org/single_unix_specification/
- beginning := start + 1 // lines start numbering with one
- length := stop - start
- if length == 0 {
- beginning -= 1 // empty ranges begin at line just before the range
- }
- if length <= 1 {
- return fmt.Sprintf("%d", beginning)
- }
- return fmt.Sprintf("%d,%d", beginning, beginning+length-1)
-}
-
-type ContextDiff UnifiedDiff
-
-// Compare two sequences of lines; generate the delta as a context diff.
-//
-// Context diffs are a compact way of showing line changes and a few
-// lines of context. The number of context lines is set by diff.Context
-// which defaults to three.
-//
-// By default, the diff control lines (those with *** or ---) are
-// created with a trailing newline.
-//
-// For inputs that do not have trailing newlines, set the diff.Eol
-// argument to "" so that the output will be uniformly newline free.
-//
-// The context diff format normally has a header for filenames and
-// modification times. Any or all of these may be specified using
-// strings for diff.FromFile, diff.ToFile, diff.FromDate, diff.ToDate.
-// The modification times are normally expressed in the ISO 8601 format.
-// If not specified, the strings default to blanks.
-func WriteContextDiff(writer io.Writer, diff ContextDiff) error {
- buf := bufio.NewWriter(writer)
- defer buf.Flush()
- var diffErr error
- wf := func(format string, args ...interface{}) {
- _, err := buf.WriteString(fmt.Sprintf(format, args...))
- if diffErr == nil && err != nil {
- diffErr = err
- }
- }
- ws := func(s string) {
- _, err := buf.WriteString(s)
- if diffErr == nil && err != nil {
- diffErr = err
- }
- }
-
- if len(diff.Eol) == 0 {
- diff.Eol = "\n"
- }
-
- prefix := map[byte]string{
- 'i': "+ ",
- 'd': "- ",
- 'r': "! ",
- 'e': " ",
- }
-
- started := false
- m := NewMatcher(diff.A, diff.B)
- for _, g := range m.GetGroupedOpCodes(diff.Context) {
- if !started {
- started = true
- fromDate := ""
- if len(diff.FromDate) > 0 {
- fromDate = "\t" + diff.FromDate
- }
- toDate := ""
- if len(diff.ToDate) > 0 {
- toDate = "\t" + diff.ToDate
- }
- if diff.FromFile != "" || diff.ToFile != "" {
- wf("*** %s%s%s", diff.FromFile, fromDate, diff.Eol)
- wf("--- %s%s%s", diff.ToFile, toDate, diff.Eol)
- }
- }
-
- first, last := g[0], g[len(g)-1]
- ws("***************" + diff.Eol)
-
- range1 := formatRangeContext(first.I1, last.I2)
- wf("*** %s ****%s", range1, diff.Eol)
- for _, c := range g {
- if c.Tag == 'r' || c.Tag == 'd' {
- for _, cc := range g {
- if cc.Tag == 'i' {
- continue
- }
- for _, line := range diff.A[cc.I1:cc.I2] {
- ws(prefix[cc.Tag] + line)
- }
- }
- break
- }
- }
-
- range2 := formatRangeContext(first.J1, last.J2)
- wf("--- %s ----%s", range2, diff.Eol)
- for _, c := range g {
- if c.Tag == 'r' || c.Tag == 'i' {
- for _, cc := range g {
- if cc.Tag == 'd' {
- continue
- }
- for _, line := range diff.B[cc.J1:cc.J2] {
- ws(prefix[cc.Tag] + line)
- }
- }
- break
- }
- }
- }
- return diffErr
-}
-
-// Like WriteContextDiff but returns the diff a string.
-func GetContextDiffString(diff ContextDiff) (string, error) {
- w := &bytes.Buffer{}
- err := WriteContextDiff(w, diff)
- return string(w.Bytes()), err
-}
-
-// Split a string on "\n" while preserving them. The output can be used
-// as input for UnifiedDiff and ContextDiff structures.
-func SplitLines(s string) []string {
- lines := strings.SplitAfter(s, "\n")
- lines[len(lines)-1] += "\n"
- return lines
-}
diff --git a/vendor/github.com/stretchr/testify/LICENSE b/vendor/github.com/stretchr/testify/LICENSE
deleted file mode 100644
index 4b0421cf..00000000
--- a/vendor/github.com/stretchr/testify/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2012-2020 Mat Ryer, Tyler Bunnell and contributors.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/vendor/github.com/stretchr/testify/assert/assertion_compare.go b/vendor/github.com/stretchr/testify/assert/assertion_compare.go
deleted file mode 100644
index 95d8e59d..00000000
--- a/vendor/github.com/stretchr/testify/assert/assertion_compare.go
+++ /dev/null
@@ -1,458 +0,0 @@
-package assert
-
-import (
- "bytes"
- "fmt"
- "reflect"
- "time"
-)
-
-type CompareType int
-
-const (
- compareLess CompareType = iota - 1
- compareEqual
- compareGreater
-)
-
-var (
- intType = reflect.TypeOf(int(1))
- int8Type = reflect.TypeOf(int8(1))
- int16Type = reflect.TypeOf(int16(1))
- int32Type = reflect.TypeOf(int32(1))
- int64Type = reflect.TypeOf(int64(1))
-
- uintType = reflect.TypeOf(uint(1))
- uint8Type = reflect.TypeOf(uint8(1))
- uint16Type = reflect.TypeOf(uint16(1))
- uint32Type = reflect.TypeOf(uint32(1))
- uint64Type = reflect.TypeOf(uint64(1))
-
- float32Type = reflect.TypeOf(float32(1))
- float64Type = reflect.TypeOf(float64(1))
-
- stringType = reflect.TypeOf("")
-
- timeType = reflect.TypeOf(time.Time{})
- bytesType = reflect.TypeOf([]byte{})
-)
-
-func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
- obj1Value := reflect.ValueOf(obj1)
- obj2Value := reflect.ValueOf(obj2)
-
- // throughout this switch we try and avoid calling .Convert() if possible,
- // as this has a pretty big performance impact
- switch kind {
- case reflect.Int:
- {
- intobj1, ok := obj1.(int)
- if !ok {
- intobj1 = obj1Value.Convert(intType).Interface().(int)
- }
- intobj2, ok := obj2.(int)
- if !ok {
- intobj2 = obj2Value.Convert(intType).Interface().(int)
- }
- if intobj1 > intobj2 {
- return compareGreater, true
- }
- if intobj1 == intobj2 {
- return compareEqual, true
- }
- if intobj1 < intobj2 {
- return compareLess, true
- }
- }
- case reflect.Int8:
- {
- int8obj1, ok := obj1.(int8)
- if !ok {
- int8obj1 = obj1Value.Convert(int8Type).Interface().(int8)
- }
- int8obj2, ok := obj2.(int8)
- if !ok {
- int8obj2 = obj2Value.Convert(int8Type).Interface().(int8)
- }
- if int8obj1 > int8obj2 {
- return compareGreater, true
- }
- if int8obj1 == int8obj2 {
- return compareEqual, true
- }
- if int8obj1 < int8obj2 {
- return compareLess, true
- }
- }
- case reflect.Int16:
- {
- int16obj1, ok := obj1.(int16)
- if !ok {
- int16obj1 = obj1Value.Convert(int16Type).Interface().(int16)
- }
- int16obj2, ok := obj2.(int16)
- if !ok {
- int16obj2 = obj2Value.Convert(int16Type).Interface().(int16)
- }
- if int16obj1 > int16obj2 {
- return compareGreater, true
- }
- if int16obj1 == int16obj2 {
- return compareEqual, true
- }
- if int16obj1 < int16obj2 {
- return compareLess, true
- }
- }
- case reflect.Int32:
- {
- int32obj1, ok := obj1.(int32)
- if !ok {
- int32obj1 = obj1Value.Convert(int32Type).Interface().(int32)
- }
- int32obj2, ok := obj2.(int32)
- if !ok {
- int32obj2 = obj2Value.Convert(int32Type).Interface().(int32)
- }
- if int32obj1 > int32obj2 {
- return compareGreater, true
- }
- if int32obj1 == int32obj2 {
- return compareEqual, true
- }
- if int32obj1 < int32obj2 {
- return compareLess, true
- }
- }
- case reflect.Int64:
- {
- int64obj1, ok := obj1.(int64)
- if !ok {
- int64obj1 = obj1Value.Convert(int64Type).Interface().(int64)
- }
- int64obj2, ok := obj2.(int64)
- if !ok {
- int64obj2 = obj2Value.Convert(int64Type).Interface().(int64)
- }
- if int64obj1 > int64obj2 {
- return compareGreater, true
- }
- if int64obj1 == int64obj2 {
- return compareEqual, true
- }
- if int64obj1 < int64obj2 {
- return compareLess, true
- }
- }
- case reflect.Uint:
- {
- uintobj1, ok := obj1.(uint)
- if !ok {
- uintobj1 = obj1Value.Convert(uintType).Interface().(uint)
- }
- uintobj2, ok := obj2.(uint)
- if !ok {
- uintobj2 = obj2Value.Convert(uintType).Interface().(uint)
- }
- if uintobj1 > uintobj2 {
- return compareGreater, true
- }
- if uintobj1 == uintobj2 {
- return compareEqual, true
- }
- if uintobj1 < uintobj2 {
- return compareLess, true
- }
- }
- case reflect.Uint8:
- {
- uint8obj1, ok := obj1.(uint8)
- if !ok {
- uint8obj1 = obj1Value.Convert(uint8Type).Interface().(uint8)
- }
- uint8obj2, ok := obj2.(uint8)
- if !ok {
- uint8obj2 = obj2Value.Convert(uint8Type).Interface().(uint8)
- }
- if uint8obj1 > uint8obj2 {
- return compareGreater, true
- }
- if uint8obj1 == uint8obj2 {
- return compareEqual, true
- }
- if uint8obj1 < uint8obj2 {
- return compareLess, true
- }
- }
- case reflect.Uint16:
- {
- uint16obj1, ok := obj1.(uint16)
- if !ok {
- uint16obj1 = obj1Value.Convert(uint16Type).Interface().(uint16)
- }
- uint16obj2, ok := obj2.(uint16)
- if !ok {
- uint16obj2 = obj2Value.Convert(uint16Type).Interface().(uint16)
- }
- if uint16obj1 > uint16obj2 {
- return compareGreater, true
- }
- if uint16obj1 == uint16obj2 {
- return compareEqual, true
- }
- if uint16obj1 < uint16obj2 {
- return compareLess, true
- }
- }
- case reflect.Uint32:
- {
- uint32obj1, ok := obj1.(uint32)
- if !ok {
- uint32obj1 = obj1Value.Convert(uint32Type).Interface().(uint32)
- }
- uint32obj2, ok := obj2.(uint32)
- if !ok {
- uint32obj2 = obj2Value.Convert(uint32Type).Interface().(uint32)
- }
- if uint32obj1 > uint32obj2 {
- return compareGreater, true
- }
- if uint32obj1 == uint32obj2 {
- return compareEqual, true
- }
- if uint32obj1 < uint32obj2 {
- return compareLess, true
- }
- }
- case reflect.Uint64:
- {
- uint64obj1, ok := obj1.(uint64)
- if !ok {
- uint64obj1 = obj1Value.Convert(uint64Type).Interface().(uint64)
- }
- uint64obj2, ok := obj2.(uint64)
- if !ok {
- uint64obj2 = obj2Value.Convert(uint64Type).Interface().(uint64)
- }
- if uint64obj1 > uint64obj2 {
- return compareGreater, true
- }
- if uint64obj1 == uint64obj2 {
- return compareEqual, true
- }
- if uint64obj1 < uint64obj2 {
- return compareLess, true
- }
- }
- case reflect.Float32:
- {
- float32obj1, ok := obj1.(float32)
- if !ok {
- float32obj1 = obj1Value.Convert(float32Type).Interface().(float32)
- }
- float32obj2, ok := obj2.(float32)
- if !ok {
- float32obj2 = obj2Value.Convert(float32Type).Interface().(float32)
- }
- if float32obj1 > float32obj2 {
- return compareGreater, true
- }
- if float32obj1 == float32obj2 {
- return compareEqual, true
- }
- if float32obj1 < float32obj2 {
- return compareLess, true
- }
- }
- case reflect.Float64:
- {
- float64obj1, ok := obj1.(float64)
- if !ok {
- float64obj1 = obj1Value.Convert(float64Type).Interface().(float64)
- }
- float64obj2, ok := obj2.(float64)
- if !ok {
- float64obj2 = obj2Value.Convert(float64Type).Interface().(float64)
- }
- if float64obj1 > float64obj2 {
- return compareGreater, true
- }
- if float64obj1 == float64obj2 {
- return compareEqual, true
- }
- if float64obj1 < float64obj2 {
- return compareLess, true
- }
- }
- case reflect.String:
- {
- stringobj1, ok := obj1.(string)
- if !ok {
- stringobj1 = obj1Value.Convert(stringType).Interface().(string)
- }
- stringobj2, ok := obj2.(string)
- if !ok {
- stringobj2 = obj2Value.Convert(stringType).Interface().(string)
- }
- if stringobj1 > stringobj2 {
- return compareGreater, true
- }
- if stringobj1 == stringobj2 {
- return compareEqual, true
- }
- if stringobj1 < stringobj2 {
- return compareLess, true
- }
- }
- // Check for known struct types we can check for compare results.
- case reflect.Struct:
- {
- // All structs enter here. We're not interested in most types.
- if !canConvert(obj1Value, timeType) {
- break
- }
-
- // time.Time can compared!
- timeObj1, ok := obj1.(time.Time)
- if !ok {
- timeObj1 = obj1Value.Convert(timeType).Interface().(time.Time)
- }
-
- timeObj2, ok := obj2.(time.Time)
- if !ok {
- timeObj2 = obj2Value.Convert(timeType).Interface().(time.Time)
- }
-
- return compare(timeObj1.UnixNano(), timeObj2.UnixNano(), reflect.Int64)
- }
- case reflect.Slice:
- {
- // We only care about the []byte type.
- if !canConvert(obj1Value, bytesType) {
- break
- }
-
- // []byte can be compared!
- bytesObj1, ok := obj1.([]byte)
- if !ok {
- bytesObj1 = obj1Value.Convert(bytesType).Interface().([]byte)
-
- }
- bytesObj2, ok := obj2.([]byte)
- if !ok {
- bytesObj2 = obj2Value.Convert(bytesType).Interface().([]byte)
- }
-
- return CompareType(bytes.Compare(bytesObj1, bytesObj2)), true
- }
- }
-
- return compareEqual, false
-}
-
-// Greater asserts that the first element is greater than the second
-//
-// assert.Greater(t, 2, 1)
-// assert.Greater(t, float64(2), float64(1))
-// assert.Greater(t, "b", "a")
-func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return compareTwoValues(t, e1, e2, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
-}
-
-// GreaterOrEqual asserts that the first element is greater than or equal to the second
-//
-// assert.GreaterOrEqual(t, 2, 1)
-// assert.GreaterOrEqual(t, 2, 2)
-// assert.GreaterOrEqual(t, "b", "a")
-// assert.GreaterOrEqual(t, "b", "b")
-func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return compareTwoValues(t, e1, e2, []CompareType{compareGreater, compareEqual}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
-}
-
-// Less asserts that the first element is less than the second
-//
-// assert.Less(t, 1, 2)
-// assert.Less(t, float64(1), float64(2))
-// assert.Less(t, "a", "b")
-func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return compareTwoValues(t, e1, e2, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
-}
-
-// LessOrEqual asserts that the first element is less than or equal to the second
-//
-// assert.LessOrEqual(t, 1, 2)
-// assert.LessOrEqual(t, 2, 2)
-// assert.LessOrEqual(t, "a", "b")
-// assert.LessOrEqual(t, "b", "b")
-func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return compareTwoValues(t, e1, e2, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
-}
-
-// Positive asserts that the specified element is positive
-//
-// assert.Positive(t, 1)
-// assert.Positive(t, 1.23)
-func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- zero := reflect.Zero(reflect.TypeOf(e))
- return compareTwoValues(t, e, zero.Interface(), []CompareType{compareGreater}, "\"%v\" is not positive", msgAndArgs...)
-}
-
-// Negative asserts that the specified element is negative
-//
-// assert.Negative(t, -1)
-// assert.Negative(t, -1.23)
-func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- zero := reflect.Zero(reflect.TypeOf(e))
- return compareTwoValues(t, e, zero.Interface(), []CompareType{compareLess}, "\"%v\" is not negative", msgAndArgs...)
-}
-
-func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- e1Kind := reflect.ValueOf(e1).Kind()
- e2Kind := reflect.ValueOf(e2).Kind()
- if e1Kind != e2Kind {
- return Fail(t, "Elements should be the same type", msgAndArgs...)
- }
-
- compareResult, isComparable := compare(e1, e2, e1Kind)
- if !isComparable {
- return Fail(t, fmt.Sprintf("Can not compare type \"%s\"", reflect.TypeOf(e1)), msgAndArgs...)
- }
-
- if !containsValue(allowedComparesResults, compareResult) {
- return Fail(t, fmt.Sprintf(failMessage, e1, e2), msgAndArgs...)
- }
-
- return true
-}
-
-func containsValue(values []CompareType, value CompareType) bool {
- for _, v := range values {
- if v == value {
- return true
- }
- }
-
- return false
-}
diff --git a/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go b/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go
deleted file mode 100644
index da867903..00000000
--- a/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go
+++ /dev/null
@@ -1,16 +0,0 @@
-//go:build go1.17
-// +build go1.17
-
-// TODO: once support for Go 1.16 is dropped, this file can be
-// merged/removed with assertion_compare_go1.17_test.go and
-// assertion_compare_legacy.go
-
-package assert
-
-import "reflect"
-
-// Wrapper around reflect.Value.CanConvert, for compatibility
-// reasons.
-func canConvert(value reflect.Value, to reflect.Type) bool {
- return value.CanConvert(to)
-}
diff --git a/vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go b/vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go
deleted file mode 100644
index 1701af2a..00000000
--- a/vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go
+++ /dev/null
@@ -1,16 +0,0 @@
-//go:build !go1.17
-// +build !go1.17
-
-// TODO: once support for Go 1.16 is dropped, this file can be
-// merged/removed with assertion_compare_go1.17_test.go and
-// assertion_compare_can_convert.go
-
-package assert
-
-import "reflect"
-
-// Older versions of Go does not have the reflect.Value.CanConvert
-// method.
-func canConvert(value reflect.Value, to reflect.Type) bool {
- return false
-}
diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go b/vendor/github.com/stretchr/testify/assert/assertion_format.go
deleted file mode 100644
index 7880b8f9..00000000
--- a/vendor/github.com/stretchr/testify/assert/assertion_format.go
+++ /dev/null
@@ -1,763 +0,0 @@
-/*
-* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
-* THIS FILE MUST NOT BE EDITED BY HAND
- */
-
-package assert
-
-import (
- http "net/http"
- url "net/url"
- time "time"
-)
-
-// Conditionf uses a Comparison to assert a complex condition.
-func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Condition(t, comp, append([]interface{}{msg}, args...)...)
-}
-
-// Containsf asserts that the specified string, list(array, slice...) or map contains the
-// specified substring or element.
-//
-// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
-// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
-// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
-func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Contains(t, s, contains, append([]interface{}{msg}, args...)...)
-}
-
-// DirExistsf checks whether a directory exists in the given path. It also fails
-// if the path is a file rather a directory or there is an error checking whether it exists.
-func DirExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return DirExists(t, path, append([]interface{}{msg}, args...)...)
-}
-
-// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
-// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
-// the number of appearances of each of them in both lists should match.
-//
-// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
-func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return ElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...)
-}
-
-// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// assert.Emptyf(t, obj, "error message %s", "formatted")
-func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Empty(t, object, append([]interface{}{msg}, args...)...)
-}
-
-// Equalf asserts that two objects are equal.
-//
-// assert.Equalf(t, 123, 123, "error message %s", "formatted")
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses). Function equality
-// cannot be determined and will always fail.
-func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Equal(t, expected, actual, append([]interface{}{msg}, args...)...)
-}
-
-// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
-// and that it is equal to the provided error.
-//
-// actualObj, err := SomeFunction()
-// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
-func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...)
-}
-
-// EqualValuesf asserts that two objects are equal or convertable to the same types
-// and equal.
-//
-// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
-func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
-}
-
-// Errorf asserts that a function returned an error (i.e. not `nil`).
-//
-// actualObj, err := SomeFunction()
-// if assert.Errorf(t, err, "error message %s", "formatted") {
-// assert.Equal(t, expectedErrorf, err)
-// }
-func Errorf(t TestingT, err error, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Error(t, err, append([]interface{}{msg}, args...)...)
-}
-
-// ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
-// This is a wrapper for errors.As.
-func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return ErrorAs(t, err, target, append([]interface{}{msg}, args...)...)
-}
-
-// ErrorContainsf asserts that a function returned an error (i.e. not `nil`)
-// and that the error contains the specified substring.
-//
-// actualObj, err := SomeFunction()
-// assert.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted")
-func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return ErrorContains(t, theError, contains, append([]interface{}{msg}, args...)...)
-}
-
-// ErrorIsf asserts that at least one of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return ErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
-}
-
-// Eventuallyf asserts that given condition will be met in waitFor time,
-// periodically checking target function each tick.
-//
-// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
-func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Eventually(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
-}
-
-// Exactlyf asserts that two objects are equal in value and type.
-//
-// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted")
-func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...)
-}
-
-// Failf reports a failure through
-func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Fail(t, failureMessage, append([]interface{}{msg}, args...)...)
-}
-
-// FailNowf fails test
-func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...)
-}
-
-// Falsef asserts that the specified value is false.
-//
-// assert.Falsef(t, myBool, "error message %s", "formatted")
-func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return False(t, value, append([]interface{}{msg}, args...)...)
-}
-
-// FileExistsf checks whether a file exists in the given path. It also fails if
-// the path points to a directory or there is an error when trying to check the file.
-func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return FileExists(t, path, append([]interface{}{msg}, args...)...)
-}
-
-// Greaterf asserts that the first element is greater than the second
-//
-// assert.Greaterf(t, 2, 1, "error message %s", "formatted")
-// assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted")
-// assert.Greaterf(t, "b", "a", "error message %s", "formatted")
-func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Greater(t, e1, e2, append([]interface{}{msg}, args...)...)
-}
-
-// GreaterOrEqualf asserts that the first element is greater than or equal to the second
-//
-// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted")
-// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted")
-// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted")
-// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted")
-func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return GreaterOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...)
-}
-
-// HTTPBodyContainsf asserts that a specified handler returns a
-// body that contains a string.
-//
-// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return HTTPBodyContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...)
-}
-
-// HTTPBodyNotContainsf asserts that a specified handler returns a
-// body that does not contain a string.
-//
-// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return HTTPBodyNotContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...)
-}
-
-// HTTPErrorf asserts that a specified handler returns an error status code.
-//
-// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return HTTPError(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
-}
-
-// HTTPRedirectf asserts that a specified handler returns a redirect status code.
-//
-// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return HTTPRedirect(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
-}
-
-// HTTPStatusCodef asserts that a specified handler returns a specified status code.
-//
-// assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return HTTPStatusCode(t, handler, method, url, values, statuscode, append([]interface{}{msg}, args...)...)
-}
-
-// HTTPSuccessf asserts that a specified handler returns a success status code.
-//
-// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return HTTPSuccess(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
-}
-
-// Implementsf asserts that an object is implemented by the specified interface.
-//
-// assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
-func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
-}
-
-// InDeltaf asserts that the two numerals are within delta of each other.
-//
-// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
-func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
-}
-
-// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
-func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return InDeltaMapValues(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
-}
-
-// InDeltaSlicef is the same as InDelta, except it compares two slices.
-func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
-}
-
-// InEpsilonf asserts that expected and actual have a relative error less than epsilon
-func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
-}
-
-// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
-func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
-}
-
-// IsDecreasingf asserts that the collection is decreasing
-//
-// assert.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted")
-// assert.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted")
-// assert.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
-func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return IsDecreasing(t, object, append([]interface{}{msg}, args...)...)
-}
-
-// IsIncreasingf asserts that the collection is increasing
-//
-// assert.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted")
-// assert.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted")
-// assert.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
-func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return IsIncreasing(t, object, append([]interface{}{msg}, args...)...)
-}
-
-// IsNonDecreasingf asserts that the collection is not decreasing
-//
-// assert.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted")
-// assert.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted")
-// assert.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
-func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return IsNonDecreasing(t, object, append([]interface{}{msg}, args...)...)
-}
-
-// IsNonIncreasingf asserts that the collection is not increasing
-//
-// assert.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted")
-// assert.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted")
-// assert.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
-func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return IsNonIncreasing(t, object, append([]interface{}{msg}, args...)...)
-}
-
-// IsTypef asserts that the specified objects are of the same type.
-func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...)
-}
-
-// JSONEqf asserts that two JSON strings are equivalent.
-//
-// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
-func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...)
-}
-
-// Lenf asserts that the specified object has specific length.
-// Lenf also fails if the object has a type that len() not accept.
-//
-// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
-func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Len(t, object, length, append([]interface{}{msg}, args...)...)
-}
-
-// Lessf asserts that the first element is less than the second
-//
-// assert.Lessf(t, 1, 2, "error message %s", "formatted")
-// assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted")
-// assert.Lessf(t, "a", "b", "error message %s", "formatted")
-func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Less(t, e1, e2, append([]interface{}{msg}, args...)...)
-}
-
-// LessOrEqualf asserts that the first element is less than or equal to the second
-//
-// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted")
-// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted")
-// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted")
-// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted")
-func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return LessOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...)
-}
-
-// Negativef asserts that the specified element is negative
-//
-// assert.Negativef(t, -1, "error message %s", "formatted")
-// assert.Negativef(t, -1.23, "error message %s", "formatted")
-func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Negative(t, e, append([]interface{}{msg}, args...)...)
-}
-
-// Neverf asserts that the given condition doesn't satisfy in waitFor time,
-// periodically checking the target function each tick.
-//
-// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
-func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Never(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
-}
-
-// Nilf asserts that the specified object is nil.
-//
-// assert.Nilf(t, err, "error message %s", "formatted")
-func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Nil(t, object, append([]interface{}{msg}, args...)...)
-}
-
-// NoDirExistsf checks whether a directory does not exist in the given path.
-// It fails if the path points to an existing _directory_ only.
-func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NoDirExists(t, path, append([]interface{}{msg}, args...)...)
-}
-
-// NoErrorf asserts that a function returned no error (i.e. `nil`).
-//
-// actualObj, err := SomeFunction()
-// if assert.NoErrorf(t, err, "error message %s", "formatted") {
-// assert.Equal(t, expectedObj, actualObj)
-// }
-func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NoError(t, err, append([]interface{}{msg}, args...)...)
-}
-
-// NoFileExistsf checks whether a file does not exist in a given path. It fails
-// if the path points to an existing _file_ only.
-func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NoFileExists(t, path, append([]interface{}{msg}, args...)...)
-}
-
-// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
-// specified substring or element.
-//
-// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
-// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
-// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
-func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NotContains(t, s, contains, append([]interface{}{msg}, args...)...)
-}
-
-// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
-// assert.Equal(t, "two", obj[1])
-// }
-func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NotEmpty(t, object, append([]interface{}{msg}, args...)...)
-}
-
-// NotEqualf asserts that the specified values are NOT equal.
-//
-// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses).
-func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...)
-}
-
-// NotEqualValuesf asserts that two objects are not equal even when converted to the same type
-//
-// assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted")
-func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NotEqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
-}
-
-// NotErrorIsf asserts that at none of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NotErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
-}
-
-// NotNilf asserts that the specified object is not nil.
-//
-// assert.NotNilf(t, err, "error message %s", "formatted")
-func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NotNil(t, object, append([]interface{}{msg}, args...)...)
-}
-
-// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
-//
-// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
-func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NotPanics(t, f, append([]interface{}{msg}, args...)...)
-}
-
-// NotRegexpf asserts that a specified regexp does not match a string.
-//
-// assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
-// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
-func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...)
-}
-
-// NotSamef asserts that two pointers do not reference the same object.
-//
-// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted")
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NotSame(t, expected, actual, append([]interface{}{msg}, args...)...)
-}
-
-// NotSubsetf asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
-//
-// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
-func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...)
-}
-
-// NotZerof asserts that i is not the zero value for its type.
-func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return NotZero(t, i, append([]interface{}{msg}, args...)...)
-}
-
-// Panicsf asserts that the code inside the specified PanicTestFunc panics.
-//
-// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
-func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Panics(t, f, append([]interface{}{msg}, args...)...)
-}
-
-// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc
-// panics, and that the recovered panic value is an error that satisfies the
-// EqualError comparison.
-//
-// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
-func PanicsWithErrorf(t TestingT, errString string, f PanicTestFunc, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return PanicsWithError(t, errString, f, append([]interface{}{msg}, args...)...)
-}
-
-// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
-// the recovered panic value equals the expected panic value.
-//
-// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
-func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return PanicsWithValue(t, expected, f, append([]interface{}{msg}, args...)...)
-}
-
-// Positivef asserts that the specified element is positive
-//
-// assert.Positivef(t, 1, "error message %s", "formatted")
-// assert.Positivef(t, 1.23, "error message %s", "formatted")
-func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Positive(t, e, append([]interface{}{msg}, args...)...)
-}
-
-// Regexpf asserts that a specified regexp matches a string.
-//
-// assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
-// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
-func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Regexp(t, rx, str, append([]interface{}{msg}, args...)...)
-}
-
-// Samef asserts that two pointers reference the same object.
-//
-// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted")
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Same(t, expected, actual, append([]interface{}{msg}, args...)...)
-}
-
-// Subsetf asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
-//
-// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
-func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Subset(t, list, subset, append([]interface{}{msg}, args...)...)
-}
-
-// Truef asserts that the specified value is true.
-//
-// assert.Truef(t, myBool, "error message %s", "formatted")
-func Truef(t TestingT, value bool, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return True(t, value, append([]interface{}{msg}, args...)...)
-}
-
-// WithinDurationf asserts that the two times are within duration delta of each other.
-//
-// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
-func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
-}
-
-// WithinRangef asserts that a time is within a time range (inclusive).
-//
-// assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
-func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return WithinRange(t, actual, start, end, append([]interface{}{msg}, args...)...)
-}
-
-// YAMLEqf asserts that two YAML strings are equivalent.
-func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return YAMLEq(t, expected, actual, append([]interface{}{msg}, args...)...)
-}
-
-// Zerof asserts that i is the zero value for its type.
-func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Zero(t, i, append([]interface{}{msg}, args...)...)
-}
diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl b/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl
deleted file mode 100644
index d2bb0b81..00000000
--- a/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl
+++ /dev/null
@@ -1,5 +0,0 @@
-{{.CommentFormat}}
-func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool {
- if h, ok := t.(tHelper); ok { h.Helper() }
- return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}})
-}
diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go b/vendor/github.com/stretchr/testify/assert/assertion_forward.go
deleted file mode 100644
index 339515b8..00000000
--- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go
+++ /dev/null
@@ -1,1514 +0,0 @@
-/*
-* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
-* THIS FILE MUST NOT BE EDITED BY HAND
- */
-
-package assert
-
-import (
- http "net/http"
- url "net/url"
- time "time"
-)
-
-// Condition uses a Comparison to assert a complex condition.
-func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Condition(a.t, comp, msgAndArgs...)
-}
-
-// Conditionf uses a Comparison to assert a complex condition.
-func (a *Assertions) Conditionf(comp Comparison, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Conditionf(a.t, comp, msg, args...)
-}
-
-// Contains asserts that the specified string, list(array, slice...) or map contains the
-// specified substring or element.
-//
-// a.Contains("Hello World", "World")
-// a.Contains(["Hello", "World"], "World")
-// a.Contains({"Hello": "World"}, "Hello")
-func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Contains(a.t, s, contains, msgAndArgs...)
-}
-
-// Containsf asserts that the specified string, list(array, slice...) or map contains the
-// specified substring or element.
-//
-// a.Containsf("Hello World", "World", "error message %s", "formatted")
-// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted")
-// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted")
-func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Containsf(a.t, s, contains, msg, args...)
-}
-
-// DirExists checks whether a directory exists in the given path. It also fails
-// if the path is a file rather a directory or there is an error checking whether it exists.
-func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return DirExists(a.t, path, msgAndArgs...)
-}
-
-// DirExistsf checks whether a directory exists in the given path. It also fails
-// if the path is a file rather a directory or there is an error checking whether it exists.
-func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return DirExistsf(a.t, path, msg, args...)
-}
-
-// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
-// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
-// the number of appearances of each of them in both lists should match.
-//
-// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2])
-func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return ElementsMatch(a.t, listA, listB, msgAndArgs...)
-}
-
-// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
-// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
-// the number of appearances of each of them in both lists should match.
-//
-// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
-func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return ElementsMatchf(a.t, listA, listB, msg, args...)
-}
-
-// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// a.Empty(obj)
-func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Empty(a.t, object, msgAndArgs...)
-}
-
-// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// a.Emptyf(obj, "error message %s", "formatted")
-func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Emptyf(a.t, object, msg, args...)
-}
-
-// Equal asserts that two objects are equal.
-//
-// a.Equal(123, 123)
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses). Function equality
-// cannot be determined and will always fail.
-func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Equal(a.t, expected, actual, msgAndArgs...)
-}
-
-// EqualError asserts that a function returned an error (i.e. not `nil`)
-// and that it is equal to the provided error.
-//
-// actualObj, err := SomeFunction()
-// a.EqualError(err, expectedErrorString)
-func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return EqualError(a.t, theError, errString, msgAndArgs...)
-}
-
-// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
-// and that it is equal to the provided error.
-//
-// actualObj, err := SomeFunction()
-// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted")
-func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return EqualErrorf(a.t, theError, errString, msg, args...)
-}
-
-// EqualValues asserts that two objects are equal or convertable to the same types
-// and equal.
-//
-// a.EqualValues(uint32(123), int32(123))
-func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return EqualValues(a.t, expected, actual, msgAndArgs...)
-}
-
-// EqualValuesf asserts that two objects are equal or convertable to the same types
-// and equal.
-//
-// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
-func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return EqualValuesf(a.t, expected, actual, msg, args...)
-}
-
-// Equalf asserts that two objects are equal.
-//
-// a.Equalf(123, 123, "error message %s", "formatted")
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses). Function equality
-// cannot be determined and will always fail.
-func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Equalf(a.t, expected, actual, msg, args...)
-}
-
-// Error asserts that a function returned an error (i.e. not `nil`).
-//
-// actualObj, err := SomeFunction()
-// if a.Error(err) {
-// assert.Equal(t, expectedError, err)
-// }
-func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Error(a.t, err, msgAndArgs...)
-}
-
-// ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
-// This is a wrapper for errors.As.
-func (a *Assertions) ErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return ErrorAs(a.t, err, target, msgAndArgs...)
-}
-
-// ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
-// This is a wrapper for errors.As.
-func (a *Assertions) ErrorAsf(err error, target interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return ErrorAsf(a.t, err, target, msg, args...)
-}
-
-// ErrorContains asserts that a function returned an error (i.e. not `nil`)
-// and that the error contains the specified substring.
-//
-// actualObj, err := SomeFunction()
-// a.ErrorContains(err, expectedErrorSubString)
-func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return ErrorContains(a.t, theError, contains, msgAndArgs...)
-}
-
-// ErrorContainsf asserts that a function returned an error (i.e. not `nil`)
-// and that the error contains the specified substring.
-//
-// actualObj, err := SomeFunction()
-// a.ErrorContainsf(err, expectedErrorSubString, "error message %s", "formatted")
-func (a *Assertions) ErrorContainsf(theError error, contains string, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return ErrorContainsf(a.t, theError, contains, msg, args...)
-}
-
-// ErrorIs asserts that at least one of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func (a *Assertions) ErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return ErrorIs(a.t, err, target, msgAndArgs...)
-}
-
-// ErrorIsf asserts that at least one of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return ErrorIsf(a.t, err, target, msg, args...)
-}
-
-// Errorf asserts that a function returned an error (i.e. not `nil`).
-//
-// actualObj, err := SomeFunction()
-// if a.Errorf(err, "error message %s", "formatted") {
-// assert.Equal(t, expectedErrorf, err)
-// }
-func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Errorf(a.t, err, msg, args...)
-}
-
-// Eventually asserts that given condition will be met in waitFor time,
-// periodically checking target function each tick.
-//
-// a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond)
-func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Eventually(a.t, condition, waitFor, tick, msgAndArgs...)
-}
-
-// Eventuallyf asserts that given condition will be met in waitFor time,
-// periodically checking target function each tick.
-//
-// a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
-func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Eventuallyf(a.t, condition, waitFor, tick, msg, args...)
-}
-
-// Exactly asserts that two objects are equal in value and type.
-//
-// a.Exactly(int32(123), int64(123))
-func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Exactly(a.t, expected, actual, msgAndArgs...)
-}
-
-// Exactlyf asserts that two objects are equal in value and type.
-//
-// a.Exactlyf(int32(123), int64(123), "error message %s", "formatted")
-func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Exactlyf(a.t, expected, actual, msg, args...)
-}
-
-// Fail reports a failure through
-func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Fail(a.t, failureMessage, msgAndArgs...)
-}
-
-// FailNow fails test
-func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return FailNow(a.t, failureMessage, msgAndArgs...)
-}
-
-// FailNowf fails test
-func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return FailNowf(a.t, failureMessage, msg, args...)
-}
-
-// Failf reports a failure through
-func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Failf(a.t, failureMessage, msg, args...)
-}
-
-// False asserts that the specified value is false.
-//
-// a.False(myBool)
-func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return False(a.t, value, msgAndArgs...)
-}
-
-// Falsef asserts that the specified value is false.
-//
-// a.Falsef(myBool, "error message %s", "formatted")
-func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Falsef(a.t, value, msg, args...)
-}
-
-// FileExists checks whether a file exists in the given path. It also fails if
-// the path points to a directory or there is an error when trying to check the file.
-func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return FileExists(a.t, path, msgAndArgs...)
-}
-
-// FileExistsf checks whether a file exists in the given path. It also fails if
-// the path points to a directory or there is an error when trying to check the file.
-func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return FileExistsf(a.t, path, msg, args...)
-}
-
-// Greater asserts that the first element is greater than the second
-//
-// a.Greater(2, 1)
-// a.Greater(float64(2), float64(1))
-// a.Greater("b", "a")
-func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Greater(a.t, e1, e2, msgAndArgs...)
-}
-
-// GreaterOrEqual asserts that the first element is greater than or equal to the second
-//
-// a.GreaterOrEqual(2, 1)
-// a.GreaterOrEqual(2, 2)
-// a.GreaterOrEqual("b", "a")
-// a.GreaterOrEqual("b", "b")
-func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return GreaterOrEqual(a.t, e1, e2, msgAndArgs...)
-}
-
-// GreaterOrEqualf asserts that the first element is greater than or equal to the second
-//
-// a.GreaterOrEqualf(2, 1, "error message %s", "formatted")
-// a.GreaterOrEqualf(2, 2, "error message %s", "formatted")
-// a.GreaterOrEqualf("b", "a", "error message %s", "formatted")
-// a.GreaterOrEqualf("b", "b", "error message %s", "formatted")
-func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return GreaterOrEqualf(a.t, e1, e2, msg, args...)
-}
-
-// Greaterf asserts that the first element is greater than the second
-//
-// a.Greaterf(2, 1, "error message %s", "formatted")
-// a.Greaterf(float64(2), float64(1), "error message %s", "formatted")
-// a.Greaterf("b", "a", "error message %s", "formatted")
-func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Greaterf(a.t, e1, e2, msg, args...)
-}
-
-// HTTPBodyContains asserts that a specified handler returns a
-// body that contains a string.
-//
-// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...)
-}
-
-// HTTPBodyContainsf asserts that a specified handler returns a
-// body that contains a string.
-//
-// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...)
-}
-
-// HTTPBodyNotContains asserts that a specified handler returns a
-// body that does not contain a string.
-//
-// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...)
-}
-
-// HTTPBodyNotContainsf asserts that a specified handler returns a
-// body that does not contain a string.
-//
-// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...)
-}
-
-// HTTPError asserts that a specified handler returns an error status code.
-//
-// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return HTTPError(a.t, handler, method, url, values, msgAndArgs...)
-}
-
-// HTTPErrorf asserts that a specified handler returns an error status code.
-//
-// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return HTTPErrorf(a.t, handler, method, url, values, msg, args...)
-}
-
-// HTTPRedirect asserts that a specified handler returns a redirect status code.
-//
-// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...)
-}
-
-// HTTPRedirectf asserts that a specified handler returns a redirect status code.
-//
-// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return HTTPRedirectf(a.t, handler, method, url, values, msg, args...)
-}
-
-// HTTPStatusCode asserts that a specified handler returns a specified status code.
-//
-// a.HTTPStatusCode(myHandler, "GET", "/notImplemented", nil, 501)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return HTTPStatusCode(a.t, handler, method, url, values, statuscode, msgAndArgs...)
-}
-
-// HTTPStatusCodef asserts that a specified handler returns a specified status code.
-//
-// a.HTTPStatusCodef(myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return HTTPStatusCodef(a.t, handler, method, url, values, statuscode, msg, args...)
-}
-
-// HTTPSuccess asserts that a specified handler returns a success status code.
-//
-// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...)
-}
-
-// HTTPSuccessf asserts that a specified handler returns a success status code.
-//
-// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return HTTPSuccessf(a.t, handler, method, url, values, msg, args...)
-}
-
-// Implements asserts that an object is implemented by the specified interface.
-//
-// a.Implements((*MyInterface)(nil), new(MyObject))
-func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Implements(a.t, interfaceObject, object, msgAndArgs...)
-}
-
-// Implementsf asserts that an object is implemented by the specified interface.
-//
-// a.Implementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
-func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Implementsf(a.t, interfaceObject, object, msg, args...)
-}
-
-// InDelta asserts that the two numerals are within delta of each other.
-//
-// a.InDelta(math.Pi, 22/7.0, 0.01)
-func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return InDelta(a.t, expected, actual, delta, msgAndArgs...)
-}
-
-// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
-func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...)
-}
-
-// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
-func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...)
-}
-
-// InDeltaSlice is the same as InDelta, except it compares two slices.
-func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
-}
-
-// InDeltaSlicef is the same as InDelta, except it compares two slices.
-func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
-}
-
-// InDeltaf asserts that the two numerals are within delta of each other.
-//
-// a.InDeltaf(math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
-func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return InDeltaf(a.t, expected, actual, delta, msg, args...)
-}
-
-// InEpsilon asserts that expected and actual have a relative error less than epsilon
-func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
-}
-
-// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
-func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
-}
-
-// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
-func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
-}
-
-// InEpsilonf asserts that expected and actual have a relative error less than epsilon
-func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return InEpsilonf(a.t, expected, actual, epsilon, msg, args...)
-}
-
-// IsDecreasing asserts that the collection is decreasing
-//
-// a.IsDecreasing([]int{2, 1, 0})
-// a.IsDecreasing([]float{2, 1})
-// a.IsDecreasing([]string{"b", "a"})
-func (a *Assertions) IsDecreasing(object interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return IsDecreasing(a.t, object, msgAndArgs...)
-}
-
-// IsDecreasingf asserts that the collection is decreasing
-//
-// a.IsDecreasingf([]int{2, 1, 0}, "error message %s", "formatted")
-// a.IsDecreasingf([]float{2, 1}, "error message %s", "formatted")
-// a.IsDecreasingf([]string{"b", "a"}, "error message %s", "formatted")
-func (a *Assertions) IsDecreasingf(object interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return IsDecreasingf(a.t, object, msg, args...)
-}
-
-// IsIncreasing asserts that the collection is increasing
-//
-// a.IsIncreasing([]int{1, 2, 3})
-// a.IsIncreasing([]float{1, 2})
-// a.IsIncreasing([]string{"a", "b"})
-func (a *Assertions) IsIncreasing(object interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return IsIncreasing(a.t, object, msgAndArgs...)
-}
-
-// IsIncreasingf asserts that the collection is increasing
-//
-// a.IsIncreasingf([]int{1, 2, 3}, "error message %s", "formatted")
-// a.IsIncreasingf([]float{1, 2}, "error message %s", "formatted")
-// a.IsIncreasingf([]string{"a", "b"}, "error message %s", "formatted")
-func (a *Assertions) IsIncreasingf(object interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return IsIncreasingf(a.t, object, msg, args...)
-}
-
-// IsNonDecreasing asserts that the collection is not decreasing
-//
-// a.IsNonDecreasing([]int{1, 1, 2})
-// a.IsNonDecreasing([]float{1, 2})
-// a.IsNonDecreasing([]string{"a", "b"})
-func (a *Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return IsNonDecreasing(a.t, object, msgAndArgs...)
-}
-
-// IsNonDecreasingf asserts that the collection is not decreasing
-//
-// a.IsNonDecreasingf([]int{1, 1, 2}, "error message %s", "formatted")
-// a.IsNonDecreasingf([]float{1, 2}, "error message %s", "formatted")
-// a.IsNonDecreasingf([]string{"a", "b"}, "error message %s", "formatted")
-func (a *Assertions) IsNonDecreasingf(object interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return IsNonDecreasingf(a.t, object, msg, args...)
-}
-
-// IsNonIncreasing asserts that the collection is not increasing
-//
-// a.IsNonIncreasing([]int{2, 1, 1})
-// a.IsNonIncreasing([]float{2, 1})
-// a.IsNonIncreasing([]string{"b", "a"})
-func (a *Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return IsNonIncreasing(a.t, object, msgAndArgs...)
-}
-
-// IsNonIncreasingf asserts that the collection is not increasing
-//
-// a.IsNonIncreasingf([]int{2, 1, 1}, "error message %s", "formatted")
-// a.IsNonIncreasingf([]float{2, 1}, "error message %s", "formatted")
-// a.IsNonIncreasingf([]string{"b", "a"}, "error message %s", "formatted")
-func (a *Assertions) IsNonIncreasingf(object interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return IsNonIncreasingf(a.t, object, msg, args...)
-}
-
-// IsType asserts that the specified objects are of the same type.
-func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return IsType(a.t, expectedType, object, msgAndArgs...)
-}
-
-// IsTypef asserts that the specified objects are of the same type.
-func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return IsTypef(a.t, expectedType, object, msg, args...)
-}
-
-// JSONEq asserts that two JSON strings are equivalent.
-//
-// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
-func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return JSONEq(a.t, expected, actual, msgAndArgs...)
-}
-
-// JSONEqf asserts that two JSON strings are equivalent.
-//
-// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
-func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return JSONEqf(a.t, expected, actual, msg, args...)
-}
-
-// Len asserts that the specified object has specific length.
-// Len also fails if the object has a type that len() not accept.
-//
-// a.Len(mySlice, 3)
-func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Len(a.t, object, length, msgAndArgs...)
-}
-
-// Lenf asserts that the specified object has specific length.
-// Lenf also fails if the object has a type that len() not accept.
-//
-// a.Lenf(mySlice, 3, "error message %s", "formatted")
-func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Lenf(a.t, object, length, msg, args...)
-}
-
-// Less asserts that the first element is less than the second
-//
-// a.Less(1, 2)
-// a.Less(float64(1), float64(2))
-// a.Less("a", "b")
-func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Less(a.t, e1, e2, msgAndArgs...)
-}
-
-// LessOrEqual asserts that the first element is less than or equal to the second
-//
-// a.LessOrEqual(1, 2)
-// a.LessOrEqual(2, 2)
-// a.LessOrEqual("a", "b")
-// a.LessOrEqual("b", "b")
-func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return LessOrEqual(a.t, e1, e2, msgAndArgs...)
-}
-
-// LessOrEqualf asserts that the first element is less than or equal to the second
-//
-// a.LessOrEqualf(1, 2, "error message %s", "formatted")
-// a.LessOrEqualf(2, 2, "error message %s", "formatted")
-// a.LessOrEqualf("a", "b", "error message %s", "formatted")
-// a.LessOrEqualf("b", "b", "error message %s", "formatted")
-func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return LessOrEqualf(a.t, e1, e2, msg, args...)
-}
-
-// Lessf asserts that the first element is less than the second
-//
-// a.Lessf(1, 2, "error message %s", "formatted")
-// a.Lessf(float64(1), float64(2), "error message %s", "formatted")
-// a.Lessf("a", "b", "error message %s", "formatted")
-func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Lessf(a.t, e1, e2, msg, args...)
-}
-
-// Negative asserts that the specified element is negative
-//
-// a.Negative(-1)
-// a.Negative(-1.23)
-func (a *Assertions) Negative(e interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Negative(a.t, e, msgAndArgs...)
-}
-
-// Negativef asserts that the specified element is negative
-//
-// a.Negativef(-1, "error message %s", "formatted")
-// a.Negativef(-1.23, "error message %s", "formatted")
-func (a *Assertions) Negativef(e interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Negativef(a.t, e, msg, args...)
-}
-
-// Never asserts that the given condition doesn't satisfy in waitFor time,
-// periodically checking the target function each tick.
-//
-// a.Never(func() bool { return false; }, time.Second, 10*time.Millisecond)
-func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Never(a.t, condition, waitFor, tick, msgAndArgs...)
-}
-
-// Neverf asserts that the given condition doesn't satisfy in waitFor time,
-// periodically checking the target function each tick.
-//
-// a.Neverf(func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
-func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Neverf(a.t, condition, waitFor, tick, msg, args...)
-}
-
-// Nil asserts that the specified object is nil.
-//
-// a.Nil(err)
-func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Nil(a.t, object, msgAndArgs...)
-}
-
-// Nilf asserts that the specified object is nil.
-//
-// a.Nilf(err, "error message %s", "formatted")
-func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Nilf(a.t, object, msg, args...)
-}
-
-// NoDirExists checks whether a directory does not exist in the given path.
-// It fails if the path points to an existing _directory_ only.
-func (a *Assertions) NoDirExists(path string, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NoDirExists(a.t, path, msgAndArgs...)
-}
-
-// NoDirExistsf checks whether a directory does not exist in the given path.
-// It fails if the path points to an existing _directory_ only.
-func (a *Assertions) NoDirExistsf(path string, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NoDirExistsf(a.t, path, msg, args...)
-}
-
-// NoError asserts that a function returned no error (i.e. `nil`).
-//
-// actualObj, err := SomeFunction()
-// if a.NoError(err) {
-// assert.Equal(t, expectedObj, actualObj)
-// }
-func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NoError(a.t, err, msgAndArgs...)
-}
-
-// NoErrorf asserts that a function returned no error (i.e. `nil`).
-//
-// actualObj, err := SomeFunction()
-// if a.NoErrorf(err, "error message %s", "formatted") {
-// assert.Equal(t, expectedObj, actualObj)
-// }
-func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NoErrorf(a.t, err, msg, args...)
-}
-
-// NoFileExists checks whether a file does not exist in a given path. It fails
-// if the path points to an existing _file_ only.
-func (a *Assertions) NoFileExists(path string, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NoFileExists(a.t, path, msgAndArgs...)
-}
-
-// NoFileExistsf checks whether a file does not exist in a given path. It fails
-// if the path points to an existing _file_ only.
-func (a *Assertions) NoFileExistsf(path string, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NoFileExistsf(a.t, path, msg, args...)
-}
-
-// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
-// specified substring or element.
-//
-// a.NotContains("Hello World", "Earth")
-// a.NotContains(["Hello", "World"], "Earth")
-// a.NotContains({"Hello": "World"}, "Earth")
-func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotContains(a.t, s, contains, msgAndArgs...)
-}
-
-// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
-// specified substring or element.
-//
-// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted")
-// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted")
-// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted")
-func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotContainsf(a.t, s, contains, msg, args...)
-}
-
-// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// if a.NotEmpty(obj) {
-// assert.Equal(t, "two", obj[1])
-// }
-func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotEmpty(a.t, object, msgAndArgs...)
-}
-
-// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// if a.NotEmptyf(obj, "error message %s", "formatted") {
-// assert.Equal(t, "two", obj[1])
-// }
-func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotEmptyf(a.t, object, msg, args...)
-}
-
-// NotEqual asserts that the specified values are NOT equal.
-//
-// a.NotEqual(obj1, obj2)
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses).
-func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotEqual(a.t, expected, actual, msgAndArgs...)
-}
-
-// NotEqualValues asserts that two objects are not equal even when converted to the same type
-//
-// a.NotEqualValues(obj1, obj2)
-func (a *Assertions) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotEqualValues(a.t, expected, actual, msgAndArgs...)
-}
-
-// NotEqualValuesf asserts that two objects are not equal even when converted to the same type
-//
-// a.NotEqualValuesf(obj1, obj2, "error message %s", "formatted")
-func (a *Assertions) NotEqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotEqualValuesf(a.t, expected, actual, msg, args...)
-}
-
-// NotEqualf asserts that the specified values are NOT equal.
-//
-// a.NotEqualf(obj1, obj2, "error message %s", "formatted")
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses).
-func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotEqualf(a.t, expected, actual, msg, args...)
-}
-
-// NotErrorIs asserts that at none of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotErrorIs(a.t, err, target, msgAndArgs...)
-}
-
-// NotErrorIsf asserts that at none of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotErrorIsf(a.t, err, target, msg, args...)
-}
-
-// NotNil asserts that the specified object is not nil.
-//
-// a.NotNil(err)
-func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotNil(a.t, object, msgAndArgs...)
-}
-
-// NotNilf asserts that the specified object is not nil.
-//
-// a.NotNilf(err, "error message %s", "formatted")
-func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotNilf(a.t, object, msg, args...)
-}
-
-// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
-//
-// a.NotPanics(func(){ RemainCalm() })
-func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotPanics(a.t, f, msgAndArgs...)
-}
-
-// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
-//
-// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted")
-func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotPanicsf(a.t, f, msg, args...)
-}
-
-// NotRegexp asserts that a specified regexp does not match a string.
-//
-// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
-// a.NotRegexp("^start", "it's not starting")
-func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotRegexp(a.t, rx, str, msgAndArgs...)
-}
-
-// NotRegexpf asserts that a specified regexp does not match a string.
-//
-// a.NotRegexpf(regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
-// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted")
-func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotRegexpf(a.t, rx, str, msg, args...)
-}
-
-// NotSame asserts that two pointers do not reference the same object.
-//
-// a.NotSame(ptr1, ptr2)
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func (a *Assertions) NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotSame(a.t, expected, actual, msgAndArgs...)
-}
-
-// NotSamef asserts that two pointers do not reference the same object.
-//
-// a.NotSamef(ptr1, ptr2, "error message %s", "formatted")
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func (a *Assertions) NotSamef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotSamef(a.t, expected, actual, msg, args...)
-}
-
-// NotSubset asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
-//
-// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
-func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotSubset(a.t, list, subset, msgAndArgs...)
-}
-
-// NotSubsetf asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
-//
-// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
-func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotSubsetf(a.t, list, subset, msg, args...)
-}
-
-// NotZero asserts that i is not the zero value for its type.
-func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotZero(a.t, i, msgAndArgs...)
-}
-
-// NotZerof asserts that i is not the zero value for its type.
-func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return NotZerof(a.t, i, msg, args...)
-}
-
-// Panics asserts that the code inside the specified PanicTestFunc panics.
-//
-// a.Panics(func(){ GoCrazy() })
-func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Panics(a.t, f, msgAndArgs...)
-}
-
-// PanicsWithError asserts that the code inside the specified PanicTestFunc
-// panics, and that the recovered panic value is an error that satisfies the
-// EqualError comparison.
-//
-// a.PanicsWithError("crazy error", func(){ GoCrazy() })
-func (a *Assertions) PanicsWithError(errString string, f PanicTestFunc, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return PanicsWithError(a.t, errString, f, msgAndArgs...)
-}
-
-// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc
-// panics, and that the recovered panic value is an error that satisfies the
-// EqualError comparison.
-//
-// a.PanicsWithErrorf("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
-func (a *Assertions) PanicsWithErrorf(errString string, f PanicTestFunc, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return PanicsWithErrorf(a.t, errString, f, msg, args...)
-}
-
-// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
-// the recovered panic value equals the expected panic value.
-//
-// a.PanicsWithValue("crazy error", func(){ GoCrazy() })
-func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return PanicsWithValue(a.t, expected, f, msgAndArgs...)
-}
-
-// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
-// the recovered panic value equals the expected panic value.
-//
-// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
-func (a *Assertions) PanicsWithValuef(expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return PanicsWithValuef(a.t, expected, f, msg, args...)
-}
-
-// Panicsf asserts that the code inside the specified PanicTestFunc panics.
-//
-// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted")
-func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Panicsf(a.t, f, msg, args...)
-}
-
-// Positive asserts that the specified element is positive
-//
-// a.Positive(1)
-// a.Positive(1.23)
-func (a *Assertions) Positive(e interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Positive(a.t, e, msgAndArgs...)
-}
-
-// Positivef asserts that the specified element is positive
-//
-// a.Positivef(1, "error message %s", "formatted")
-// a.Positivef(1.23, "error message %s", "formatted")
-func (a *Assertions) Positivef(e interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Positivef(a.t, e, msg, args...)
-}
-
-// Regexp asserts that a specified regexp matches a string.
-//
-// a.Regexp(regexp.MustCompile("start"), "it's starting")
-// a.Regexp("start...$", "it's not starting")
-func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Regexp(a.t, rx, str, msgAndArgs...)
-}
-
-// Regexpf asserts that a specified regexp matches a string.
-//
-// a.Regexpf(regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
-// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
-func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Regexpf(a.t, rx, str, msg, args...)
-}
-
-// Same asserts that two pointers reference the same object.
-//
-// a.Same(ptr1, ptr2)
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func (a *Assertions) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Same(a.t, expected, actual, msgAndArgs...)
-}
-
-// Samef asserts that two pointers reference the same object.
-//
-// a.Samef(ptr1, ptr2, "error message %s", "formatted")
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Samef(a.t, expected, actual, msg, args...)
-}
-
-// Subset asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
-//
-// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
-func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Subset(a.t, list, subset, msgAndArgs...)
-}
-
-// Subsetf asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
-//
-// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
-func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Subsetf(a.t, list, subset, msg, args...)
-}
-
-// True asserts that the specified value is true.
-//
-// a.True(myBool)
-func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return True(a.t, value, msgAndArgs...)
-}
-
-// Truef asserts that the specified value is true.
-//
-// a.Truef(myBool, "error message %s", "formatted")
-func (a *Assertions) Truef(value bool, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Truef(a.t, value, msg, args...)
-}
-
-// WithinDuration asserts that the two times are within duration delta of each other.
-//
-// a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
-func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
-}
-
-// WithinDurationf asserts that the two times are within duration delta of each other.
-//
-// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
-func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return WithinDurationf(a.t, expected, actual, delta, msg, args...)
-}
-
-// WithinRange asserts that a time is within a time range (inclusive).
-//
-// a.WithinRange(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
-func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return WithinRange(a.t, actual, start, end, msgAndArgs...)
-}
-
-// WithinRangef asserts that a time is within a time range (inclusive).
-//
-// a.WithinRangef(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
-func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return WithinRangef(a.t, actual, start, end, msg, args...)
-}
-
-// YAMLEq asserts that two YAML strings are equivalent.
-func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return YAMLEq(a.t, expected, actual, msgAndArgs...)
-}
-
-// YAMLEqf asserts that two YAML strings are equivalent.
-func (a *Assertions) YAMLEqf(expected string, actual string, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return YAMLEqf(a.t, expected, actual, msg, args...)
-}
-
-// Zero asserts that i is the zero value for its type.
-func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Zero(a.t, i, msgAndArgs...)
-}
-
-// Zerof asserts that i is the zero value for its type.
-func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) bool {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- return Zerof(a.t, i, msg, args...)
-}
diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl b/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl
deleted file mode 100644
index 188bb9e1..00000000
--- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl
+++ /dev/null
@@ -1,5 +0,0 @@
-{{.CommentWithoutT "a"}}
-func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool {
- if h, ok := a.t.(tHelper); ok { h.Helper() }
- return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
-}
diff --git a/vendor/github.com/stretchr/testify/assert/assertion_order.go b/vendor/github.com/stretchr/testify/assert/assertion_order.go
deleted file mode 100644
index 75944878..00000000
--- a/vendor/github.com/stretchr/testify/assert/assertion_order.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package assert
-
-import (
- "fmt"
- "reflect"
-)
-
-// isOrdered checks that collection contains orderable elements.
-func isOrdered(t TestingT, object interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool {
- objKind := reflect.TypeOf(object).Kind()
- if objKind != reflect.Slice && objKind != reflect.Array {
- return false
- }
-
- objValue := reflect.ValueOf(object)
- objLen := objValue.Len()
-
- if objLen <= 1 {
- return true
- }
-
- value := objValue.Index(0)
- valueInterface := value.Interface()
- firstValueKind := value.Kind()
-
- for i := 1; i < objLen; i++ {
- prevValue := value
- prevValueInterface := valueInterface
-
- value = objValue.Index(i)
- valueInterface = value.Interface()
-
- compareResult, isComparable := compare(prevValueInterface, valueInterface, firstValueKind)
-
- if !isComparable {
- return Fail(t, fmt.Sprintf("Can not compare type \"%s\" and \"%s\"", reflect.TypeOf(value), reflect.TypeOf(prevValue)), msgAndArgs...)
- }
-
- if !containsValue(allowedComparesResults, compareResult) {
- return Fail(t, fmt.Sprintf(failMessage, prevValue, value), msgAndArgs...)
- }
- }
-
- return true
-}
-
-// IsIncreasing asserts that the collection is increasing
-//
-// assert.IsIncreasing(t, []int{1, 2, 3})
-// assert.IsIncreasing(t, []float{1, 2})
-// assert.IsIncreasing(t, []string{"a", "b"})
-func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
- return isOrdered(t, object, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
-}
-
-// IsNonIncreasing asserts that the collection is not increasing
-//
-// assert.IsNonIncreasing(t, []int{2, 1, 1})
-// assert.IsNonIncreasing(t, []float{2, 1})
-// assert.IsNonIncreasing(t, []string{"b", "a"})
-func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
- return isOrdered(t, object, []CompareType{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
-}
-
-// IsDecreasing asserts that the collection is decreasing
-//
-// assert.IsDecreasing(t, []int{2, 1, 0})
-// assert.IsDecreasing(t, []float{2, 1})
-// assert.IsDecreasing(t, []string{"b", "a"})
-func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
- return isOrdered(t, object, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
-}
-
-// IsNonDecreasing asserts that the collection is not decreasing
-//
-// assert.IsNonDecreasing(t, []int{1, 1, 2})
-// assert.IsNonDecreasing(t, []float{1, 2})
-// assert.IsNonDecreasing(t, []string{"a", "b"})
-func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
- return isOrdered(t, object, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
-}
diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go
deleted file mode 100644
index fa1245b1..00000000
--- a/vendor/github.com/stretchr/testify/assert/assertions.go
+++ /dev/null
@@ -1,1868 +0,0 @@
-package assert
-
-import (
- "bufio"
- "bytes"
- "encoding/json"
- "errors"
- "fmt"
- "math"
- "os"
- "path/filepath"
- "reflect"
- "regexp"
- "runtime"
- "runtime/debug"
- "strings"
- "time"
- "unicode"
- "unicode/utf8"
-
- "github.com/davecgh/go-spew/spew"
- "github.com/pmezard/go-difflib/difflib"
- yaml "gopkg.in/yaml.v3"
-)
-
-//go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_format.go.tmpl"
-
-// TestingT is an interface wrapper around *testing.T
-type TestingT interface {
- Errorf(format string, args ...interface{})
-}
-
-// ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful
-// for table driven tests.
-type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) bool
-
-// ValueAssertionFunc is a common function prototype when validating a single value. Can be useful
-// for table driven tests.
-type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) bool
-
-// BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful
-// for table driven tests.
-type BoolAssertionFunc func(TestingT, bool, ...interface{}) bool
-
-// ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful
-// for table driven tests.
-type ErrorAssertionFunc func(TestingT, error, ...interface{}) bool
-
-// Comparison is a custom function that returns true on success and false on failure
-type Comparison func() (success bool)
-
-/*
- Helper functions
-*/
-
-// ObjectsAreEqual determines if two objects are considered equal.
-//
-// This function does no assertion of any kind.
-func ObjectsAreEqual(expected, actual interface{}) bool {
- if expected == nil || actual == nil {
- return expected == actual
- }
-
- exp, ok := expected.([]byte)
- if !ok {
- return reflect.DeepEqual(expected, actual)
- }
-
- act, ok := actual.([]byte)
- if !ok {
- return false
- }
- if exp == nil || act == nil {
- return exp == nil && act == nil
- }
- return bytes.Equal(exp, act)
-}
-
-// ObjectsAreEqualValues gets whether two objects are equal, or if their
-// values are equal.
-func ObjectsAreEqualValues(expected, actual interface{}) bool {
- if ObjectsAreEqual(expected, actual) {
- return true
- }
-
- actualType := reflect.TypeOf(actual)
- if actualType == nil {
- return false
- }
- expectedValue := reflect.ValueOf(expected)
- if expectedValue.IsValid() && expectedValue.Type().ConvertibleTo(actualType) {
- // Attempt comparison after type conversion
- return reflect.DeepEqual(expectedValue.Convert(actualType).Interface(), actual)
- }
-
- return false
-}
-
-/* CallerInfo is necessary because the assert functions use the testing object
-internally, causing it to print the file:line of the assert method, rather than where
-the problem actually occurred in calling code.*/
-
-// CallerInfo returns an array of strings containing the file and line number
-// of each stack frame leading from the current test to the assert call that
-// failed.
-func CallerInfo() []string {
-
- var pc uintptr
- var ok bool
- var file string
- var line int
- var name string
-
- callers := []string{}
- for i := 0; ; i++ {
- pc, file, line, ok = runtime.Caller(i)
- if !ok {
- // The breaks below failed to terminate the loop, and we ran off the
- // end of the call stack.
- break
- }
-
- // This is a huge edge case, but it will panic if this is the case, see #180
- if file == "" {
- break
- }
-
- f := runtime.FuncForPC(pc)
- if f == nil {
- break
- }
- name = f.Name()
-
- // testing.tRunner is the standard library function that calls
- // tests. Subtests are called directly by tRunner, without going through
- // the Test/Benchmark/Example function that contains the t.Run calls, so
- // with subtests we should break when we hit tRunner, without adding it
- // to the list of callers.
- if name == "testing.tRunner" {
- break
- }
-
- parts := strings.Split(file, "/")
- file = parts[len(parts)-1]
- if len(parts) > 1 {
- dir := parts[len(parts)-2]
- if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" {
- path, _ := filepath.Abs(file)
- callers = append(callers, fmt.Sprintf("%s:%d", path, line))
- }
- }
-
- // Drop the package
- segments := strings.Split(name, ".")
- name = segments[len(segments)-1]
- if isTest(name, "Test") ||
- isTest(name, "Benchmark") ||
- isTest(name, "Example") {
- break
- }
- }
-
- return callers
-}
-
-// Stolen from the `go test` tool.
-// isTest tells whether name looks like a test (or benchmark, according to prefix).
-// It is a Test (say) if there is a character after Test that is not a lower-case letter.
-// We don't want TesticularCancer.
-func isTest(name, prefix string) bool {
- if !strings.HasPrefix(name, prefix) {
- return false
- }
- if len(name) == len(prefix) { // "Test" is ok
- return true
- }
- r, _ := utf8.DecodeRuneInString(name[len(prefix):])
- return !unicode.IsLower(r)
-}
-
-func messageFromMsgAndArgs(msgAndArgs ...interface{}) string {
- if len(msgAndArgs) == 0 || msgAndArgs == nil {
- return ""
- }
- if len(msgAndArgs) == 1 {
- msg := msgAndArgs[0]
- if msgAsStr, ok := msg.(string); ok {
- return msgAsStr
- }
- return fmt.Sprintf("%+v", msg)
- }
- if len(msgAndArgs) > 1 {
- return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...)
- }
- return ""
-}
-
-// Aligns the provided message so that all lines after the first line start at the same location as the first line.
-// Assumes that the first line starts at the correct location (after carriage return, tab, label, spacer and tab).
-// The longestLabelLen parameter specifies the length of the longest label in the output (required becaues this is the
-// basis on which the alignment occurs).
-func indentMessageLines(message string, longestLabelLen int) string {
- outBuf := new(bytes.Buffer)
-
- for i, scanner := 0, bufio.NewScanner(strings.NewReader(message)); scanner.Scan(); i++ {
- // no need to align first line because it starts at the correct location (after the label)
- if i != 0 {
- // append alignLen+1 spaces to align with "{{longestLabel}}:" before adding tab
- outBuf.WriteString("\n\t" + strings.Repeat(" ", longestLabelLen+1) + "\t")
- }
- outBuf.WriteString(scanner.Text())
- }
-
- return outBuf.String()
-}
-
-type failNower interface {
- FailNow()
-}
-
-// FailNow fails test
-func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- Fail(t, failureMessage, msgAndArgs...)
-
- // We cannot extend TestingT with FailNow() and
- // maintain backwards compatibility, so we fallback
- // to panicking when FailNow is not available in
- // TestingT.
- // See issue #263
-
- if t, ok := t.(failNower); ok {
- t.FailNow()
- } else {
- panic("test failed and t is missing `FailNow()`")
- }
- return false
-}
-
-// Fail reports a failure through
-func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- content := []labeledContent{
- {"Error Trace", strings.Join(CallerInfo(), "\n\t\t\t")},
- {"Error", failureMessage},
- }
-
- // Add test name if the Go version supports it
- if n, ok := t.(interface {
- Name() string
- }); ok {
- content = append(content, labeledContent{"Test", n.Name()})
- }
-
- message := messageFromMsgAndArgs(msgAndArgs...)
- if len(message) > 0 {
- content = append(content, labeledContent{"Messages", message})
- }
-
- t.Errorf("\n%s", ""+labeledOutput(content...))
-
- return false
-}
-
-type labeledContent struct {
- label string
- content string
-}
-
-// labeledOutput returns a string consisting of the provided labeledContent. Each labeled output is appended in the following manner:
-//
-// \t{{label}}:{{align_spaces}}\t{{content}}\n
-//
-// The initial carriage return is required to undo/erase any padding added by testing.T.Errorf. The "\t{{label}}:" is for the label.
-// If a label is shorter than the longest label provided, padding spaces are added to make all the labels match in length. Once this
-// alignment is achieved, "\t{{content}}\n" is added for the output.
-//
-// If the content of the labeledOutput contains line breaks, the subsequent lines are aligned so that they start at the same location as the first line.
-func labeledOutput(content ...labeledContent) string {
- longestLabel := 0
- for _, v := range content {
- if len(v.label) > longestLabel {
- longestLabel = len(v.label)
- }
- }
- var output string
- for _, v := range content {
- output += "\t" + v.label + ":" + strings.Repeat(" ", longestLabel-len(v.label)) + "\t" + indentMessageLines(v.content, longestLabel) + "\n"
- }
- return output
-}
-
-// Implements asserts that an object is implemented by the specified interface.
-//
-// assert.Implements(t, (*MyInterface)(nil), new(MyObject))
-func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- interfaceType := reflect.TypeOf(interfaceObject).Elem()
-
- if object == nil {
- return Fail(t, fmt.Sprintf("Cannot check if nil implements %v", interfaceType), msgAndArgs...)
- }
- if !reflect.TypeOf(object).Implements(interfaceType) {
- return Fail(t, fmt.Sprintf("%T must implement %v", object, interfaceType), msgAndArgs...)
- }
-
- return true
-}
-
-// IsType asserts that the specified objects are of the same type.
-func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- if !ObjectsAreEqual(reflect.TypeOf(object), reflect.TypeOf(expectedType)) {
- return Fail(t, fmt.Sprintf("Object expected to be of type %v, but was %v", reflect.TypeOf(expectedType), reflect.TypeOf(object)), msgAndArgs...)
- }
-
- return true
-}
-
-// Equal asserts that two objects are equal.
-//
-// assert.Equal(t, 123, 123)
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses). Function equality
-// cannot be determined and will always fail.
-func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if err := validateEqualArgs(expected, actual); err != nil {
- return Fail(t, fmt.Sprintf("Invalid operation: %#v == %#v (%s)",
- expected, actual, err), msgAndArgs...)
- }
-
- if !ObjectsAreEqual(expected, actual) {
- diff := diff(expected, actual)
- expected, actual = formatUnequalValues(expected, actual)
- return Fail(t, fmt.Sprintf("Not equal: \n"+
- "expected: %s\n"+
- "actual : %s%s", expected, actual, diff), msgAndArgs...)
- }
-
- return true
-
-}
-
-// validateEqualArgs checks whether provided arguments can be safely used in the
-// Equal/NotEqual functions.
-func validateEqualArgs(expected, actual interface{}) error {
- if expected == nil && actual == nil {
- return nil
- }
-
- if isFunction(expected) || isFunction(actual) {
- return errors.New("cannot take func type as argument")
- }
- return nil
-}
-
-// Same asserts that two pointers reference the same object.
-//
-// assert.Same(t, ptr1, ptr2)
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func Same(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- if !samePointers(expected, actual) {
- return Fail(t, fmt.Sprintf("Not same: \n"+
- "expected: %p %#v\n"+
- "actual : %p %#v", expected, expected, actual, actual), msgAndArgs...)
- }
-
- return true
-}
-
-// NotSame asserts that two pointers do not reference the same object.
-//
-// assert.NotSame(t, ptr1, ptr2)
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- if samePointers(expected, actual) {
- return Fail(t, fmt.Sprintf(
- "Expected and actual point to the same object: %p %#v",
- expected, expected), msgAndArgs...)
- }
- return true
-}
-
-// samePointers compares two generic interface objects and returns whether
-// they point to the same object
-func samePointers(first, second interface{}) bool {
- firstPtr, secondPtr := reflect.ValueOf(first), reflect.ValueOf(second)
- if firstPtr.Kind() != reflect.Ptr || secondPtr.Kind() != reflect.Ptr {
- return false
- }
-
- firstType, secondType := reflect.TypeOf(first), reflect.TypeOf(second)
- if firstType != secondType {
- return false
- }
-
- // compare pointer addresses
- return first == second
-}
-
-// formatUnequalValues takes two values of arbitrary types and returns string
-// representations appropriate to be presented to the user.
-//
-// If the values are not of like type, the returned strings will be prefixed
-// with the type name, and the value will be enclosed in parenthesis similar
-// to a type conversion in the Go grammar.
-func formatUnequalValues(expected, actual interface{}) (e string, a string) {
- if reflect.TypeOf(expected) != reflect.TypeOf(actual) {
- return fmt.Sprintf("%T(%s)", expected, truncatingFormat(expected)),
- fmt.Sprintf("%T(%s)", actual, truncatingFormat(actual))
- }
- switch expected.(type) {
- case time.Duration:
- return fmt.Sprintf("%v", expected), fmt.Sprintf("%v", actual)
- }
- return truncatingFormat(expected), truncatingFormat(actual)
-}
-
-// truncatingFormat formats the data and truncates it if it's too long.
-//
-// This helps keep formatted error messages lines from exceeding the
-// bufio.MaxScanTokenSize max line length that the go testing framework imposes.
-func truncatingFormat(data interface{}) string {
- value := fmt.Sprintf("%#v", data)
- max := bufio.MaxScanTokenSize - 100 // Give us some space the type info too if needed.
- if len(value) > max {
- value = value[0:max] + "<... truncated>"
- }
- return value
-}
-
-// EqualValues asserts that two objects are equal or convertable to the same types
-// and equal.
-//
-// assert.EqualValues(t, uint32(123), int32(123))
-func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- if !ObjectsAreEqualValues(expected, actual) {
- diff := diff(expected, actual)
- expected, actual = formatUnequalValues(expected, actual)
- return Fail(t, fmt.Sprintf("Not equal: \n"+
- "expected: %s\n"+
- "actual : %s%s", expected, actual, diff), msgAndArgs...)
- }
-
- return true
-
-}
-
-// Exactly asserts that two objects are equal in value and type.
-//
-// assert.Exactly(t, int32(123), int64(123))
-func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- aType := reflect.TypeOf(expected)
- bType := reflect.TypeOf(actual)
-
- if aType != bType {
- return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...)
- }
-
- return Equal(t, expected, actual, msgAndArgs...)
-
-}
-
-// NotNil asserts that the specified object is not nil.
-//
-// assert.NotNil(t, err)
-func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
- if !isNil(object) {
- return true
- }
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Fail(t, "Expected value not to be nil.", msgAndArgs...)
-}
-
-// containsKind checks if a specified kind in the slice of kinds.
-func containsKind(kinds []reflect.Kind, kind reflect.Kind) bool {
- for i := 0; i < len(kinds); i++ {
- if kind == kinds[i] {
- return true
- }
- }
-
- return false
-}
-
-// isNil checks if a specified object is nil or not, without Failing.
-func isNil(object interface{}) bool {
- if object == nil {
- return true
- }
-
- value := reflect.ValueOf(object)
- kind := value.Kind()
- isNilableKind := containsKind(
- []reflect.Kind{
- reflect.Chan, reflect.Func,
- reflect.Interface, reflect.Map,
- reflect.Ptr, reflect.Slice},
- kind)
-
- if isNilableKind && value.IsNil() {
- return true
- }
-
- return false
-}
-
-// Nil asserts that the specified object is nil.
-//
-// assert.Nil(t, err)
-func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
- if isNil(object) {
- return true
- }
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Fail(t, fmt.Sprintf("Expected nil, but got: %#v", object), msgAndArgs...)
-}
-
-// isEmpty gets whether the specified object is considered empty or not.
-func isEmpty(object interface{}) bool {
-
- // get nil case out of the way
- if object == nil {
- return true
- }
-
- objValue := reflect.ValueOf(object)
-
- switch objValue.Kind() {
- // collection types are empty when they have no element
- case reflect.Chan, reflect.Map, reflect.Slice:
- return objValue.Len() == 0
- // pointers are empty if nil or if the value they point to is empty
- case reflect.Ptr:
- if objValue.IsNil() {
- return true
- }
- deref := objValue.Elem().Interface()
- return isEmpty(deref)
- // for all other types, compare against the zero value
- // array types are empty when they match their zero-initialized state
- default:
- zero := reflect.Zero(objValue.Type())
- return reflect.DeepEqual(object, zero.Interface())
- }
-}
-
-// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// assert.Empty(t, obj)
-func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
- pass := isEmpty(object)
- if !pass {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- Fail(t, fmt.Sprintf("Should be empty, but was %v", object), msgAndArgs...)
- }
-
- return pass
-
-}
-
-// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// if assert.NotEmpty(t, obj) {
-// assert.Equal(t, "two", obj[1])
-// }
-func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
- pass := !isEmpty(object)
- if !pass {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- Fail(t, fmt.Sprintf("Should NOT be empty, but was %v", object), msgAndArgs...)
- }
-
- return pass
-
-}
-
-// getLen try to get length of object.
-// return (false, 0) if impossible.
-func getLen(x interface{}) (ok bool, length int) {
- v := reflect.ValueOf(x)
- defer func() {
- if e := recover(); e != nil {
- ok = false
- }
- }()
- return true, v.Len()
-}
-
-// Len asserts that the specified object has specific length.
-// Len also fails if the object has a type that len() not accept.
-//
-// assert.Len(t, mySlice, 3)
-func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- ok, l := getLen(object)
- if !ok {
- return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", object), msgAndArgs...)
- }
-
- if l != length {
- return Fail(t, fmt.Sprintf("\"%s\" should have %d item(s), but has %d", object, length, l), msgAndArgs...)
- }
- return true
-}
-
-// True asserts that the specified value is true.
-//
-// assert.True(t, myBool)
-func True(t TestingT, value bool, msgAndArgs ...interface{}) bool {
- if !value {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Fail(t, "Should be true", msgAndArgs...)
- }
-
- return true
-
-}
-
-// False asserts that the specified value is false.
-//
-// assert.False(t, myBool)
-func False(t TestingT, value bool, msgAndArgs ...interface{}) bool {
- if value {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Fail(t, "Should be false", msgAndArgs...)
- }
-
- return true
-
-}
-
-// NotEqual asserts that the specified values are NOT equal.
-//
-// assert.NotEqual(t, obj1, obj2)
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses).
-func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if err := validateEqualArgs(expected, actual); err != nil {
- return Fail(t, fmt.Sprintf("Invalid operation: %#v != %#v (%s)",
- expected, actual, err), msgAndArgs...)
- }
-
- if ObjectsAreEqual(expected, actual) {
- return Fail(t, fmt.Sprintf("Should not be: %#v\n", actual), msgAndArgs...)
- }
-
- return true
-
-}
-
-// NotEqualValues asserts that two objects are not equal even when converted to the same type
-//
-// assert.NotEqualValues(t, obj1, obj2)
-func NotEqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- if ObjectsAreEqualValues(expected, actual) {
- return Fail(t, fmt.Sprintf("Should not be: %#v\n", actual), msgAndArgs...)
- }
-
- return true
-}
-
-// containsElement try loop over the list check if the list includes the element.
-// return (false, false) if impossible.
-// return (true, false) if element was not found.
-// return (true, true) if element was found.
-func containsElement(list interface{}, element interface{}) (ok, found bool) {
-
- listValue := reflect.ValueOf(list)
- listType := reflect.TypeOf(list)
- if listType == nil {
- return false, false
- }
- listKind := listType.Kind()
- defer func() {
- if e := recover(); e != nil {
- ok = false
- found = false
- }
- }()
-
- if listKind == reflect.String {
- elementValue := reflect.ValueOf(element)
- return true, strings.Contains(listValue.String(), elementValue.String())
- }
-
- if listKind == reflect.Map {
- mapKeys := listValue.MapKeys()
- for i := 0; i < len(mapKeys); i++ {
- if ObjectsAreEqual(mapKeys[i].Interface(), element) {
- return true, true
- }
- }
- return true, false
- }
-
- for i := 0; i < listValue.Len(); i++ {
- if ObjectsAreEqual(listValue.Index(i).Interface(), element) {
- return true, true
- }
- }
- return true, false
-
-}
-
-// Contains asserts that the specified string, list(array, slice...) or map contains the
-// specified substring or element.
-//
-// assert.Contains(t, "Hello World", "World")
-// assert.Contains(t, ["Hello", "World"], "World")
-// assert.Contains(t, {"Hello": "World"}, "Hello")
-func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- ok, found := containsElement(s, contains)
- if !ok {
- return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", s), msgAndArgs...)
- }
- if !found {
- return Fail(t, fmt.Sprintf("%#v does not contain %#v", s, contains), msgAndArgs...)
- }
-
- return true
-
-}
-
-// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
-// specified substring or element.
-//
-// assert.NotContains(t, "Hello World", "Earth")
-// assert.NotContains(t, ["Hello", "World"], "Earth")
-// assert.NotContains(t, {"Hello": "World"}, "Earth")
-func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- ok, found := containsElement(s, contains)
- if !ok {
- return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...)
- }
- if found {
- return Fail(t, fmt.Sprintf("\"%s\" should not contain \"%s\"", s, contains), msgAndArgs...)
- }
-
- return true
-
-}
-
-// Subset asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
-//
-// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
-func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if subset == nil {
- return true // we consider nil to be equal to the nil set
- }
-
- defer func() {
- if e := recover(); e != nil {
- ok = false
- }
- }()
-
- listKind := reflect.TypeOf(list).Kind()
- subsetKind := reflect.TypeOf(subset).Kind()
-
- if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map {
- return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...)
- }
-
- if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map {
- return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...)
- }
-
- subsetValue := reflect.ValueOf(subset)
- if subsetKind == reflect.Map && listKind == reflect.Map {
- listValue := reflect.ValueOf(list)
- subsetKeys := subsetValue.MapKeys()
-
- for i := 0; i < len(subsetKeys); i++ {
- subsetKey := subsetKeys[i]
- subsetElement := subsetValue.MapIndex(subsetKey).Interface()
- listElement := listValue.MapIndex(subsetKey).Interface()
-
- if !ObjectsAreEqual(subsetElement, listElement) {
- return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, subsetElement), msgAndArgs...)
- }
- }
-
- return true
- }
-
- for i := 0; i < subsetValue.Len(); i++ {
- element := subsetValue.Index(i).Interface()
- ok, found := containsElement(list, element)
- if !ok {
- return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...)
- }
- if !found {
- return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, element), msgAndArgs...)
- }
- }
-
- return true
-}
-
-// NotSubset asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
-//
-// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
-func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if subset == nil {
- return Fail(t, "nil is the empty set which is a subset of every set", msgAndArgs...)
- }
-
- defer func() {
- if e := recover(); e != nil {
- ok = false
- }
- }()
-
- listKind := reflect.TypeOf(list).Kind()
- subsetKind := reflect.TypeOf(subset).Kind()
-
- if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map {
- return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...)
- }
-
- if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map {
- return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...)
- }
-
- subsetValue := reflect.ValueOf(subset)
- if subsetKind == reflect.Map && listKind == reflect.Map {
- listValue := reflect.ValueOf(list)
- subsetKeys := subsetValue.MapKeys()
-
- for i := 0; i < len(subsetKeys); i++ {
- subsetKey := subsetKeys[i]
- subsetElement := subsetValue.MapIndex(subsetKey).Interface()
- listElement := listValue.MapIndex(subsetKey).Interface()
-
- if !ObjectsAreEqual(subsetElement, listElement) {
- return true
- }
- }
-
- return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...)
- }
-
- for i := 0; i < subsetValue.Len(); i++ {
- element := subsetValue.Index(i).Interface()
- ok, found := containsElement(list, element)
- if !ok {
- return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...)
- }
- if !found {
- return true
- }
- }
-
- return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...)
-}
-
-// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
-// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
-// the number of appearances of each of them in both lists should match.
-//
-// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
-func ElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if isEmpty(listA) && isEmpty(listB) {
- return true
- }
-
- if !isList(t, listA, msgAndArgs...) || !isList(t, listB, msgAndArgs...) {
- return false
- }
-
- extraA, extraB := diffLists(listA, listB)
-
- if len(extraA) == 0 && len(extraB) == 0 {
- return true
- }
-
- return Fail(t, formatListDiff(listA, listB, extraA, extraB), msgAndArgs...)
-}
-
-// isList checks that the provided value is array or slice.
-func isList(t TestingT, list interface{}, msgAndArgs ...interface{}) (ok bool) {
- kind := reflect.TypeOf(list).Kind()
- if kind != reflect.Array && kind != reflect.Slice {
- return Fail(t, fmt.Sprintf("%q has an unsupported type %s, expecting array or slice", list, kind),
- msgAndArgs...)
- }
- return true
-}
-
-// diffLists diffs two arrays/slices and returns slices of elements that are only in A and only in B.
-// If some element is present multiple times, each instance is counted separately (e.g. if something is 2x in A and
-// 5x in B, it will be 0x in extraA and 3x in extraB). The order of items in both lists is ignored.
-func diffLists(listA, listB interface{}) (extraA, extraB []interface{}) {
- aValue := reflect.ValueOf(listA)
- bValue := reflect.ValueOf(listB)
-
- aLen := aValue.Len()
- bLen := bValue.Len()
-
- // Mark indexes in bValue that we already used
- visited := make([]bool, bLen)
- for i := 0; i < aLen; i++ {
- element := aValue.Index(i).Interface()
- found := false
- for j := 0; j < bLen; j++ {
- if visited[j] {
- continue
- }
- if ObjectsAreEqual(bValue.Index(j).Interface(), element) {
- visited[j] = true
- found = true
- break
- }
- }
- if !found {
- extraA = append(extraA, element)
- }
- }
-
- for j := 0; j < bLen; j++ {
- if visited[j] {
- continue
- }
- extraB = append(extraB, bValue.Index(j).Interface())
- }
-
- return
-}
-
-func formatListDiff(listA, listB interface{}, extraA, extraB []interface{}) string {
- var msg bytes.Buffer
-
- msg.WriteString("elements differ")
- if len(extraA) > 0 {
- msg.WriteString("\n\nextra elements in list A:\n")
- msg.WriteString(spewConfig.Sdump(extraA))
- }
- if len(extraB) > 0 {
- msg.WriteString("\n\nextra elements in list B:\n")
- msg.WriteString(spewConfig.Sdump(extraB))
- }
- msg.WriteString("\n\nlistA:\n")
- msg.WriteString(spewConfig.Sdump(listA))
- msg.WriteString("\n\nlistB:\n")
- msg.WriteString(spewConfig.Sdump(listB))
-
- return msg.String()
-}
-
-// Condition uses a Comparison to assert a complex condition.
-func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- result := comp()
- if !result {
- Fail(t, "Condition failed!", msgAndArgs...)
- }
- return result
-}
-
-// PanicTestFunc defines a func that should be passed to the assert.Panics and assert.NotPanics
-// methods, and represents a simple func that takes no arguments, and returns nothing.
-type PanicTestFunc func()
-
-// didPanic returns true if the function passed to it panics. Otherwise, it returns false.
-func didPanic(f PanicTestFunc) (didPanic bool, message interface{}, stack string) {
- didPanic = true
-
- defer func() {
- message = recover()
- if didPanic {
- stack = string(debug.Stack())
- }
- }()
-
- // call the target function
- f()
- didPanic = false
-
- return
-}
-
-// Panics asserts that the code inside the specified PanicTestFunc panics.
-//
-// assert.Panics(t, func(){ GoCrazy() })
-func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- if funcDidPanic, panicValue, _ := didPanic(f); !funcDidPanic {
- return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...)
- }
-
- return true
-}
-
-// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
-// the recovered panic value equals the expected panic value.
-//
-// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
-func PanicsWithValue(t TestingT, expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- funcDidPanic, panicValue, panickedStack := didPanic(f)
- if !funcDidPanic {
- return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...)
- }
- if panicValue != expected {
- return Fail(t, fmt.Sprintf("func %#v should panic with value:\t%#v\n\tPanic value:\t%#v\n\tPanic stack:\t%s", f, expected, panicValue, panickedStack), msgAndArgs...)
- }
-
- return true
-}
-
-// PanicsWithError asserts that the code inside the specified PanicTestFunc
-// panics, and that the recovered panic value is an error that satisfies the
-// EqualError comparison.
-//
-// assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() })
-func PanicsWithError(t TestingT, errString string, f PanicTestFunc, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- funcDidPanic, panicValue, panickedStack := didPanic(f)
- if !funcDidPanic {
- return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...)
- }
- panicErr, ok := panicValue.(error)
- if !ok || panicErr.Error() != errString {
- return Fail(t, fmt.Sprintf("func %#v should panic with error message:\t%#v\n\tPanic value:\t%#v\n\tPanic stack:\t%s", f, errString, panicValue, panickedStack), msgAndArgs...)
- }
-
- return true
-}
-
-// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
-//
-// assert.NotPanics(t, func(){ RemainCalm() })
-func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- if funcDidPanic, panicValue, panickedStack := didPanic(f); funcDidPanic {
- return Fail(t, fmt.Sprintf("func %#v should not panic\n\tPanic value:\t%v\n\tPanic stack:\t%s", f, panicValue, panickedStack), msgAndArgs...)
- }
-
- return true
-}
-
-// WithinDuration asserts that the two times are within duration delta of each other.
-//
-// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
-func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- dt := expected.Sub(actual)
- if dt < -delta || dt > delta {
- return Fail(t, fmt.Sprintf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, delta, dt), msgAndArgs...)
- }
-
- return true
-}
-
-// WithinRange asserts that a time is within a time range (inclusive).
-//
-// assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
-func WithinRange(t TestingT, actual, start, end time.Time, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- if end.Before(start) {
- return Fail(t, "Start should be before end", msgAndArgs...)
- }
-
- if actual.Before(start) {
- return Fail(t, fmt.Sprintf("Time %v expected to be in time range %v to %v, but is before the range", actual, start, end), msgAndArgs...)
- } else if actual.After(end) {
- return Fail(t, fmt.Sprintf("Time %v expected to be in time range %v to %v, but is after the range", actual, start, end), msgAndArgs...)
- }
-
- return true
-}
-
-func toFloat(x interface{}) (float64, bool) {
- var xf float64
- xok := true
-
- switch xn := x.(type) {
- case uint:
- xf = float64(xn)
- case uint8:
- xf = float64(xn)
- case uint16:
- xf = float64(xn)
- case uint32:
- xf = float64(xn)
- case uint64:
- xf = float64(xn)
- case int:
- xf = float64(xn)
- case int8:
- xf = float64(xn)
- case int16:
- xf = float64(xn)
- case int32:
- xf = float64(xn)
- case int64:
- xf = float64(xn)
- case float32:
- xf = float64(xn)
- case float64:
- xf = xn
- case time.Duration:
- xf = float64(xn)
- default:
- xok = false
- }
-
- return xf, xok
-}
-
-// InDelta asserts that the two numerals are within delta of each other.
-//
-// assert.InDelta(t, math.Pi, 22/7.0, 0.01)
-func InDelta(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- af, aok := toFloat(expected)
- bf, bok := toFloat(actual)
-
- if !aok || !bok {
- return Fail(t, "Parameters must be numerical", msgAndArgs...)
- }
-
- if math.IsNaN(af) && math.IsNaN(bf) {
- return true
- }
-
- if math.IsNaN(af) {
- return Fail(t, "Expected must not be NaN", msgAndArgs...)
- }
-
- if math.IsNaN(bf) {
- return Fail(t, fmt.Sprintf("Expected %v with delta %v, but was NaN", expected, delta), msgAndArgs...)
- }
-
- dt := af - bf
- if dt < -delta || dt > delta {
- return Fail(t, fmt.Sprintf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, delta, dt), msgAndArgs...)
- }
-
- return true
-}
-
-// InDeltaSlice is the same as InDelta, except it compares two slices.
-func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if expected == nil || actual == nil ||
- reflect.TypeOf(actual).Kind() != reflect.Slice ||
- reflect.TypeOf(expected).Kind() != reflect.Slice {
- return Fail(t, "Parameters must be slice", msgAndArgs...)
- }
-
- actualSlice := reflect.ValueOf(actual)
- expectedSlice := reflect.ValueOf(expected)
-
- for i := 0; i < actualSlice.Len(); i++ {
- result := InDelta(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), delta, msgAndArgs...)
- if !result {
- return result
- }
- }
-
- return true
-}
-
-// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
-func InDeltaMapValues(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if expected == nil || actual == nil ||
- reflect.TypeOf(actual).Kind() != reflect.Map ||
- reflect.TypeOf(expected).Kind() != reflect.Map {
- return Fail(t, "Arguments must be maps", msgAndArgs...)
- }
-
- expectedMap := reflect.ValueOf(expected)
- actualMap := reflect.ValueOf(actual)
-
- if expectedMap.Len() != actualMap.Len() {
- return Fail(t, "Arguments must have the same number of keys", msgAndArgs...)
- }
-
- for _, k := range expectedMap.MapKeys() {
- ev := expectedMap.MapIndex(k)
- av := actualMap.MapIndex(k)
-
- if !ev.IsValid() {
- return Fail(t, fmt.Sprintf("missing key %q in expected map", k), msgAndArgs...)
- }
-
- if !av.IsValid() {
- return Fail(t, fmt.Sprintf("missing key %q in actual map", k), msgAndArgs...)
- }
-
- if !InDelta(
- t,
- ev.Interface(),
- av.Interface(),
- delta,
- msgAndArgs...,
- ) {
- return false
- }
- }
-
- return true
-}
-
-func calcRelativeError(expected, actual interface{}) (float64, error) {
- af, aok := toFloat(expected)
- bf, bok := toFloat(actual)
- if !aok || !bok {
- return 0, fmt.Errorf("Parameters must be numerical")
- }
- if math.IsNaN(af) && math.IsNaN(bf) {
- return 0, nil
- }
- if math.IsNaN(af) {
- return 0, errors.New("expected value must not be NaN")
- }
- if af == 0 {
- return 0, fmt.Errorf("expected value must have a value other than zero to calculate the relative error")
- }
- if math.IsNaN(bf) {
- return 0, errors.New("actual value must not be NaN")
- }
-
- return math.Abs(af-bf) / math.Abs(af), nil
-}
-
-// InEpsilon asserts that expected and actual have a relative error less than epsilon
-func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if math.IsNaN(epsilon) {
- return Fail(t, "epsilon must not be NaN")
- }
- actualEpsilon, err := calcRelativeError(expected, actual)
- if err != nil {
- return Fail(t, err.Error(), msgAndArgs...)
- }
- if actualEpsilon > epsilon {
- return Fail(t, fmt.Sprintf("Relative error is too high: %#v (expected)\n"+
- " < %#v (actual)", epsilon, actualEpsilon), msgAndArgs...)
- }
-
- return true
-}
-
-// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
-func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if expected == nil || actual == nil ||
- reflect.TypeOf(actual).Kind() != reflect.Slice ||
- reflect.TypeOf(expected).Kind() != reflect.Slice {
- return Fail(t, "Parameters must be slice", msgAndArgs...)
- }
-
- actualSlice := reflect.ValueOf(actual)
- expectedSlice := reflect.ValueOf(expected)
-
- for i := 0; i < actualSlice.Len(); i++ {
- result := InEpsilon(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), epsilon)
- if !result {
- return result
- }
- }
-
- return true
-}
-
-/*
- Errors
-*/
-
-// NoError asserts that a function returned no error (i.e. `nil`).
-//
-// actualObj, err := SomeFunction()
-// if assert.NoError(t, err) {
-// assert.Equal(t, expectedObj, actualObj)
-// }
-func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool {
- if err != nil {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Fail(t, fmt.Sprintf("Received unexpected error:\n%+v", err), msgAndArgs...)
- }
-
- return true
-}
-
-// Error asserts that a function returned an error (i.e. not `nil`).
-//
-// actualObj, err := SomeFunction()
-// if assert.Error(t, err) {
-// assert.Equal(t, expectedError, err)
-// }
-func Error(t TestingT, err error, msgAndArgs ...interface{}) bool {
- if err == nil {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- return Fail(t, "An error is expected but got nil.", msgAndArgs...)
- }
-
- return true
-}
-
-// EqualError asserts that a function returned an error (i.e. not `nil`)
-// and that it is equal to the provided error.
-//
-// actualObj, err := SomeFunction()
-// assert.EqualError(t, err, expectedErrorString)
-func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if !Error(t, theError, msgAndArgs...) {
- return false
- }
- expected := errString
- actual := theError.Error()
- // don't need to use deep equals here, we know they are both strings
- if expected != actual {
- return Fail(t, fmt.Sprintf("Error message not equal:\n"+
- "expected: %q\n"+
- "actual : %q", expected, actual), msgAndArgs...)
- }
- return true
-}
-
-// ErrorContains asserts that a function returned an error (i.e. not `nil`)
-// and that the error contains the specified substring.
-//
-// actualObj, err := SomeFunction()
-// assert.ErrorContains(t, err, expectedErrorSubString)
-func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if !Error(t, theError, msgAndArgs...) {
- return false
- }
-
- actual := theError.Error()
- if !strings.Contains(actual, contains) {
- return Fail(t, fmt.Sprintf("Error %#v does not contain %#v", actual, contains), msgAndArgs...)
- }
-
- return true
-}
-
-// matchRegexp return true if a specified regexp matches a string.
-func matchRegexp(rx interface{}, str interface{}) bool {
-
- var r *regexp.Regexp
- if rr, ok := rx.(*regexp.Regexp); ok {
- r = rr
- } else {
- r = regexp.MustCompile(fmt.Sprint(rx))
- }
-
- return (r.FindStringIndex(fmt.Sprint(str)) != nil)
-
-}
-
-// Regexp asserts that a specified regexp matches a string.
-//
-// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
-// assert.Regexp(t, "start...$", "it's not starting")
-func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- match := matchRegexp(rx, str)
-
- if !match {
- Fail(t, fmt.Sprintf("Expect \"%v\" to match \"%v\"", str, rx), msgAndArgs...)
- }
-
- return match
-}
-
-// NotRegexp asserts that a specified regexp does not match a string.
-//
-// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
-// assert.NotRegexp(t, "^start", "it's not starting")
-func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- match := matchRegexp(rx, str)
-
- if match {
- Fail(t, fmt.Sprintf("Expect \"%v\" to NOT match \"%v\"", str, rx), msgAndArgs...)
- }
-
- return !match
-
-}
-
-// Zero asserts that i is the zero value for its type.
-func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if i != nil && !reflect.DeepEqual(i, reflect.Zero(reflect.TypeOf(i)).Interface()) {
- return Fail(t, fmt.Sprintf("Should be zero, but was %v", i), msgAndArgs...)
- }
- return true
-}
-
-// NotZero asserts that i is not the zero value for its type.
-func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if i == nil || reflect.DeepEqual(i, reflect.Zero(reflect.TypeOf(i)).Interface()) {
- return Fail(t, fmt.Sprintf("Should not be zero, but was %v", i), msgAndArgs...)
- }
- return true
-}
-
-// FileExists checks whether a file exists in the given path. It also fails if
-// the path points to a directory or there is an error when trying to check the file.
-func FileExists(t TestingT, path string, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- info, err := os.Lstat(path)
- if err != nil {
- if os.IsNotExist(err) {
- return Fail(t, fmt.Sprintf("unable to find file %q", path), msgAndArgs...)
- }
- return Fail(t, fmt.Sprintf("error when running os.Lstat(%q): %s", path, err), msgAndArgs...)
- }
- if info.IsDir() {
- return Fail(t, fmt.Sprintf("%q is a directory", path), msgAndArgs...)
- }
- return true
-}
-
-// NoFileExists checks whether a file does not exist in a given path. It fails
-// if the path points to an existing _file_ only.
-func NoFileExists(t TestingT, path string, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- info, err := os.Lstat(path)
- if err != nil {
- return true
- }
- if info.IsDir() {
- return true
- }
- return Fail(t, fmt.Sprintf("file %q exists", path), msgAndArgs...)
-}
-
-// DirExists checks whether a directory exists in the given path. It also fails
-// if the path is a file rather a directory or there is an error checking whether it exists.
-func DirExists(t TestingT, path string, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- info, err := os.Lstat(path)
- if err != nil {
- if os.IsNotExist(err) {
- return Fail(t, fmt.Sprintf("unable to find file %q", path), msgAndArgs...)
- }
- return Fail(t, fmt.Sprintf("error when running os.Lstat(%q): %s", path, err), msgAndArgs...)
- }
- if !info.IsDir() {
- return Fail(t, fmt.Sprintf("%q is a file", path), msgAndArgs...)
- }
- return true
-}
-
-// NoDirExists checks whether a directory does not exist in the given path.
-// It fails if the path points to an existing _directory_ only.
-func NoDirExists(t TestingT, path string, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- info, err := os.Lstat(path)
- if err != nil {
- if os.IsNotExist(err) {
- return true
- }
- return true
- }
- if !info.IsDir() {
- return true
- }
- return Fail(t, fmt.Sprintf("directory %q exists", path), msgAndArgs...)
-}
-
-// JSONEq asserts that two JSON strings are equivalent.
-//
-// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
-func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- var expectedJSONAsInterface, actualJSONAsInterface interface{}
-
- if err := json.Unmarshal([]byte(expected), &expectedJSONAsInterface); err != nil {
- return Fail(t, fmt.Sprintf("Expected value ('%s') is not valid json.\nJSON parsing error: '%s'", expected, err.Error()), msgAndArgs...)
- }
-
- if err := json.Unmarshal([]byte(actual), &actualJSONAsInterface); err != nil {
- return Fail(t, fmt.Sprintf("Input ('%s') needs to be valid json.\nJSON parsing error: '%s'", actual, err.Error()), msgAndArgs...)
- }
-
- return Equal(t, expectedJSONAsInterface, actualJSONAsInterface, msgAndArgs...)
-}
-
-// YAMLEq asserts that two YAML strings are equivalent.
-func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- var expectedYAMLAsInterface, actualYAMLAsInterface interface{}
-
- if err := yaml.Unmarshal([]byte(expected), &expectedYAMLAsInterface); err != nil {
- return Fail(t, fmt.Sprintf("Expected value ('%s') is not valid yaml.\nYAML parsing error: '%s'", expected, err.Error()), msgAndArgs...)
- }
-
- if err := yaml.Unmarshal([]byte(actual), &actualYAMLAsInterface); err != nil {
- return Fail(t, fmt.Sprintf("Input ('%s') needs to be valid yaml.\nYAML error: '%s'", actual, err.Error()), msgAndArgs...)
- }
-
- return Equal(t, expectedYAMLAsInterface, actualYAMLAsInterface, msgAndArgs...)
-}
-
-func typeAndKind(v interface{}) (reflect.Type, reflect.Kind) {
- t := reflect.TypeOf(v)
- k := t.Kind()
-
- if k == reflect.Ptr {
- t = t.Elem()
- k = t.Kind()
- }
- return t, k
-}
-
-// diff returns a diff of both values as long as both are of the same type and
-// are a struct, map, slice, array or string. Otherwise it returns an empty string.
-func diff(expected interface{}, actual interface{}) string {
- if expected == nil || actual == nil {
- return ""
- }
-
- et, ek := typeAndKind(expected)
- at, _ := typeAndKind(actual)
-
- if et != at {
- return ""
- }
-
- if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array && ek != reflect.String {
- return ""
- }
-
- var e, a string
-
- switch et {
- case reflect.TypeOf(""):
- e = reflect.ValueOf(expected).String()
- a = reflect.ValueOf(actual).String()
- case reflect.TypeOf(time.Time{}):
- e = spewConfigStringerEnabled.Sdump(expected)
- a = spewConfigStringerEnabled.Sdump(actual)
- default:
- e = spewConfig.Sdump(expected)
- a = spewConfig.Sdump(actual)
- }
-
- diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
- A: difflib.SplitLines(e),
- B: difflib.SplitLines(a),
- FromFile: "Expected",
- FromDate: "",
- ToFile: "Actual",
- ToDate: "",
- Context: 1,
- })
-
- return "\n\nDiff:\n" + diff
-}
-
-func isFunction(arg interface{}) bool {
- if arg == nil {
- return false
- }
- return reflect.TypeOf(arg).Kind() == reflect.Func
-}
-
-var spewConfig = spew.ConfigState{
- Indent: " ",
- DisablePointerAddresses: true,
- DisableCapacities: true,
- SortKeys: true,
- DisableMethods: true,
- MaxDepth: 10,
-}
-
-var spewConfigStringerEnabled = spew.ConfigState{
- Indent: " ",
- DisablePointerAddresses: true,
- DisableCapacities: true,
- SortKeys: true,
- MaxDepth: 10,
-}
-
-type tHelper interface {
- Helper()
-}
-
-// Eventually asserts that given condition will be met in waitFor time,
-// periodically checking target function each tick.
-//
-// assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond)
-func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- ch := make(chan bool, 1)
-
- timer := time.NewTimer(waitFor)
- defer timer.Stop()
-
- ticker := time.NewTicker(tick)
- defer ticker.Stop()
-
- for tick := ticker.C; ; {
- select {
- case <-timer.C:
- return Fail(t, "Condition never satisfied", msgAndArgs...)
- case <-tick:
- tick = nil
- go func() { ch <- condition() }()
- case v := <-ch:
- if v {
- return true
- }
- tick = ticker.C
- }
- }
-}
-
-// Never asserts that the given condition doesn't satisfy in waitFor time,
-// periodically checking the target function each tick.
-//
-// assert.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond)
-func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
-
- ch := make(chan bool, 1)
-
- timer := time.NewTimer(waitFor)
- defer timer.Stop()
-
- ticker := time.NewTicker(tick)
- defer ticker.Stop()
-
- for tick := ticker.C; ; {
- select {
- case <-timer.C:
- return true
- case <-tick:
- tick = nil
- go func() { ch <- condition() }()
- case v := <-ch:
- if v {
- return Fail(t, "Condition satisfied", msgAndArgs...)
- }
- tick = ticker.C
- }
- }
-}
-
-// ErrorIs asserts that at least one of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func ErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if errors.Is(err, target) {
- return true
- }
-
- var expectedText string
- if target != nil {
- expectedText = target.Error()
- }
-
- chain := buildErrorChainString(err)
-
- return Fail(t, fmt.Sprintf("Target error should be in err chain:\n"+
- "expected: %q\n"+
- "in chain: %s", expectedText, chain,
- ), msgAndArgs...)
-}
-
-// NotErrorIs asserts that at none of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if !errors.Is(err, target) {
- return true
- }
-
- var expectedText string
- if target != nil {
- expectedText = target.Error()
- }
-
- chain := buildErrorChainString(err)
-
- return Fail(t, fmt.Sprintf("Target error should not be in err chain:\n"+
- "found: %q\n"+
- "in chain: %s", expectedText, chain,
- ), msgAndArgs...)
-}
-
-// ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
-// This is a wrapper for errors.As.
-func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if errors.As(err, target) {
- return true
- }
-
- chain := buildErrorChainString(err)
-
- return Fail(t, fmt.Sprintf("Should be in error chain:\n"+
- "expected: %q\n"+
- "in chain: %s", target, chain,
- ), msgAndArgs...)
-}
-
-func buildErrorChainString(err error) string {
- if err == nil {
- return ""
- }
-
- e := errors.Unwrap(err)
- chain := fmt.Sprintf("%q", err.Error())
- for e != nil {
- chain += fmt.Sprintf("\n\t%q", e.Error())
- e = errors.Unwrap(e)
- }
- return chain
-}
diff --git a/vendor/github.com/stretchr/testify/assert/doc.go b/vendor/github.com/stretchr/testify/assert/doc.go
deleted file mode 100644
index c9dccc4d..00000000
--- a/vendor/github.com/stretchr/testify/assert/doc.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
-//
-// Example Usage
-//
-// The following is a complete example using assert in a standard test function:
-// import (
-// "testing"
-// "github.com/stretchr/testify/assert"
-// )
-//
-// func TestSomething(t *testing.T) {
-//
-// var a string = "Hello"
-// var b string = "Hello"
-//
-// assert.Equal(t, a, b, "The two words should be the same.")
-//
-// }
-//
-// if you assert many times, use the format below:
-//
-// import (
-// "testing"
-// "github.com/stretchr/testify/assert"
-// )
-//
-// func TestSomething(t *testing.T) {
-// assert := assert.New(t)
-//
-// var a string = "Hello"
-// var b string = "Hello"
-//
-// assert.Equal(a, b, "The two words should be the same.")
-// }
-//
-// Assertions
-//
-// Assertions allow you to easily write test code, and are global funcs in the `assert` package.
-// All assertion functions take, as the first argument, the `*testing.T` object provided by the
-// testing framework. This allows the assertion funcs to write the failings and other details to
-// the correct place.
-//
-// Every assertion function also takes an optional string message as the final argument,
-// allowing custom error messages to be appended to the message the assertion method outputs.
-package assert
diff --git a/vendor/github.com/stretchr/testify/assert/errors.go b/vendor/github.com/stretchr/testify/assert/errors.go
deleted file mode 100644
index ac9dc9d1..00000000
--- a/vendor/github.com/stretchr/testify/assert/errors.go
+++ /dev/null
@@ -1,10 +0,0 @@
-package assert
-
-import (
- "errors"
-)
-
-// AnError is an error instance useful for testing. If the code does not care
-// about error specifics, and only needs to return the error for example, this
-// error should be used to make the test code more readable.
-var AnError = errors.New("assert.AnError general error for testing")
diff --git a/vendor/github.com/stretchr/testify/assert/forward_assertions.go b/vendor/github.com/stretchr/testify/assert/forward_assertions.go
deleted file mode 100644
index df189d23..00000000
--- a/vendor/github.com/stretchr/testify/assert/forward_assertions.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package assert
-
-// Assertions provides assertion methods around the
-// TestingT interface.
-type Assertions struct {
- t TestingT
-}
-
-// New makes a new Assertions object for the specified TestingT.
-func New(t TestingT) *Assertions {
- return &Assertions{
- t: t,
- }
-}
-
-//go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs"
diff --git a/vendor/github.com/stretchr/testify/assert/http_assertions.go b/vendor/github.com/stretchr/testify/assert/http_assertions.go
deleted file mode 100644
index 4ed341dd..00000000
--- a/vendor/github.com/stretchr/testify/assert/http_assertions.go
+++ /dev/null
@@ -1,162 +0,0 @@
-package assert
-
-import (
- "fmt"
- "net/http"
- "net/http/httptest"
- "net/url"
- "strings"
-)
-
-// httpCode is a helper that returns HTTP code of the response. It returns -1 and
-// an error if building a new request fails.
-func httpCode(handler http.HandlerFunc, method, url string, values url.Values) (int, error) {
- w := httptest.NewRecorder()
- req, err := http.NewRequest(method, url, nil)
- if err != nil {
- return -1, err
- }
- req.URL.RawQuery = values.Encode()
- handler(w, req)
- return w.Code, nil
-}
-
-// HTTPSuccess asserts that a specified handler returns a success status code.
-//
-// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- code, err := httpCode(handler, method, url, values)
- if err != nil {
- Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err))
- }
-
- isSuccessCode := code >= http.StatusOK && code <= http.StatusPartialContent
- if !isSuccessCode {
- Fail(t, fmt.Sprintf("Expected HTTP success status code for %q but received %d", url+"?"+values.Encode(), code))
- }
-
- return isSuccessCode
-}
-
-// HTTPRedirect asserts that a specified handler returns a redirect status code.
-//
-// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- code, err := httpCode(handler, method, url, values)
- if err != nil {
- Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err))
- }
-
- isRedirectCode := code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect
- if !isRedirectCode {
- Fail(t, fmt.Sprintf("Expected HTTP redirect status code for %q but received %d", url+"?"+values.Encode(), code))
- }
-
- return isRedirectCode
-}
-
-// HTTPError asserts that a specified handler returns an error status code.
-//
-// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- code, err := httpCode(handler, method, url, values)
- if err != nil {
- Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err))
- }
-
- isErrorCode := code >= http.StatusBadRequest
- if !isErrorCode {
- Fail(t, fmt.Sprintf("Expected HTTP error status code for %q but received %d", url+"?"+values.Encode(), code))
- }
-
- return isErrorCode
-}
-
-// HTTPStatusCode asserts that a specified handler returns a specified status code.
-//
-// assert.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- code, err := httpCode(handler, method, url, values)
- if err != nil {
- Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err))
- }
-
- successful := code == statuscode
- if !successful {
- Fail(t, fmt.Sprintf("Expected HTTP status code %d for %q but received %d", statuscode, url+"?"+values.Encode(), code))
- }
-
- return successful
-}
-
-// HTTPBody is a helper that returns HTTP body of the response. It returns
-// empty string if building a new request fails.
-func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string {
- w := httptest.NewRecorder()
- req, err := http.NewRequest(method, url+"?"+values.Encode(), nil)
- if err != nil {
- return ""
- }
- handler(w, req)
- return w.Body.String()
-}
-
-// HTTPBodyContains asserts that a specified handler returns a
-// body that contains a string.
-//
-// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- body := HTTPBody(handler, method, url, values)
-
- contains := strings.Contains(body, fmt.Sprint(str))
- if !contains {
- Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body))
- }
-
- return contains
-}
-
-// HTTPBodyNotContains asserts that a specified handler returns a
-// body that does not contain a string.
-//
-// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- body := HTTPBody(handler, method, url, values)
-
- contains := strings.Contains(body, fmt.Sprint(str))
- if contains {
- Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body))
- }
-
- return !contains
-}
diff --git a/vendor/github.com/stretchr/testify/require/doc.go b/vendor/github.com/stretchr/testify/require/doc.go
deleted file mode 100644
index 169de392..00000000
--- a/vendor/github.com/stretchr/testify/require/doc.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Package require implements the same assertions as the `assert` package but
-// stops test execution when a test fails.
-//
-// Example Usage
-//
-// The following is a complete example using require in a standard test function:
-// import (
-// "testing"
-// "github.com/stretchr/testify/require"
-// )
-//
-// func TestSomething(t *testing.T) {
-//
-// var a string = "Hello"
-// var b string = "Hello"
-//
-// require.Equal(t, a, b, "The two words should be the same.")
-//
-// }
-//
-// Assertions
-//
-// The `require` package have same global functions as in the `assert` package,
-// but instead of returning a boolean result they call `t.FailNow()`.
-//
-// Every assertion function also takes an optional string message as the final argument,
-// allowing custom error messages to be appended to the message the assertion method outputs.
-package require
diff --git a/vendor/github.com/stretchr/testify/require/forward_requirements.go b/vendor/github.com/stretchr/testify/require/forward_requirements.go
deleted file mode 100644
index 1dcb2338..00000000
--- a/vendor/github.com/stretchr/testify/require/forward_requirements.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package require
-
-// Assertions provides assertion methods around the
-// TestingT interface.
-type Assertions struct {
- t TestingT
-}
-
-// New makes a new Assertions object for the specified TestingT.
-func New(t TestingT) *Assertions {
- return &Assertions{
- t: t,
- }
-}
-
-//go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require_forward.go.tmpl -include-format-funcs"
diff --git a/vendor/github.com/stretchr/testify/require/require.go b/vendor/github.com/stretchr/testify/require/require.go
deleted file mode 100644
index 880853f5..00000000
--- a/vendor/github.com/stretchr/testify/require/require.go
+++ /dev/null
@@ -1,1935 +0,0 @@
-/*
-* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
-* THIS FILE MUST NOT BE EDITED BY HAND
- */
-
-package require
-
-import (
- assert "github.com/stretchr/testify/assert"
- http "net/http"
- url "net/url"
- time "time"
-)
-
-// Condition uses a Comparison to assert a complex condition.
-func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Condition(t, comp, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Conditionf uses a Comparison to assert a complex condition.
-func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Conditionf(t, comp, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Contains asserts that the specified string, list(array, slice...) or map contains the
-// specified substring or element.
-//
-// assert.Contains(t, "Hello World", "World")
-// assert.Contains(t, ["Hello", "World"], "World")
-// assert.Contains(t, {"Hello": "World"}, "Hello")
-func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Contains(t, s, contains, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Containsf asserts that the specified string, list(array, slice...) or map contains the
-// specified substring or element.
-//
-// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
-// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
-// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
-func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Containsf(t, s, contains, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// DirExists checks whether a directory exists in the given path. It also fails
-// if the path is a file rather a directory or there is an error checking whether it exists.
-func DirExists(t TestingT, path string, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.DirExists(t, path, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// DirExistsf checks whether a directory exists in the given path. It also fails
-// if the path is a file rather a directory or there is an error checking whether it exists.
-func DirExistsf(t TestingT, path string, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.DirExistsf(t, path, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
-// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
-// the number of appearances of each of them in both lists should match.
-//
-// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
-func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.ElementsMatch(t, listA, listB, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
-// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
-// the number of appearances of each of them in both lists should match.
-//
-// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
-func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.ElementsMatchf(t, listA, listB, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// assert.Empty(t, obj)
-func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Empty(t, object, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// assert.Emptyf(t, obj, "error message %s", "formatted")
-func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Emptyf(t, object, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Equal asserts that two objects are equal.
-//
-// assert.Equal(t, 123, 123)
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses). Function equality
-// cannot be determined and will always fail.
-func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Equal(t, expected, actual, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// EqualError asserts that a function returned an error (i.e. not `nil`)
-// and that it is equal to the provided error.
-//
-// actualObj, err := SomeFunction()
-// assert.EqualError(t, err, expectedErrorString)
-func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.EqualError(t, theError, errString, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
-// and that it is equal to the provided error.
-//
-// actualObj, err := SomeFunction()
-// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
-func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.EqualErrorf(t, theError, errString, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// EqualValues asserts that two objects are equal or convertable to the same types
-// and equal.
-//
-// assert.EqualValues(t, uint32(123), int32(123))
-func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.EqualValues(t, expected, actual, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// EqualValuesf asserts that two objects are equal or convertable to the same types
-// and equal.
-//
-// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
-func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.EqualValuesf(t, expected, actual, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Equalf asserts that two objects are equal.
-//
-// assert.Equalf(t, 123, 123, "error message %s", "formatted")
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses). Function equality
-// cannot be determined and will always fail.
-func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Equalf(t, expected, actual, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Error asserts that a function returned an error (i.e. not `nil`).
-//
-// actualObj, err := SomeFunction()
-// if assert.Error(t, err) {
-// assert.Equal(t, expectedError, err)
-// }
-func Error(t TestingT, err error, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Error(t, err, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
-// This is a wrapper for errors.As.
-func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.ErrorAs(t, err, target, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
-// This is a wrapper for errors.As.
-func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.ErrorAsf(t, err, target, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// ErrorContains asserts that a function returned an error (i.e. not `nil`)
-// and that the error contains the specified substring.
-//
-// actualObj, err := SomeFunction()
-// assert.ErrorContains(t, err, expectedErrorSubString)
-func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.ErrorContains(t, theError, contains, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// ErrorContainsf asserts that a function returned an error (i.e. not `nil`)
-// and that the error contains the specified substring.
-//
-// actualObj, err := SomeFunction()
-// assert.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted")
-func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.ErrorContainsf(t, theError, contains, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// ErrorIs asserts that at least one of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func ErrorIs(t TestingT, err error, target error, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.ErrorIs(t, err, target, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// ErrorIsf asserts that at least one of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.ErrorIsf(t, err, target, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Errorf asserts that a function returned an error (i.e. not `nil`).
-//
-// actualObj, err := SomeFunction()
-// if assert.Errorf(t, err, "error message %s", "formatted") {
-// assert.Equal(t, expectedErrorf, err)
-// }
-func Errorf(t TestingT, err error, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Errorf(t, err, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Eventually asserts that given condition will be met in waitFor time,
-// periodically checking target function each tick.
-//
-// assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond)
-func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Eventually(t, condition, waitFor, tick, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Eventuallyf asserts that given condition will be met in waitFor time,
-// periodically checking target function each tick.
-//
-// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
-func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Eventuallyf(t, condition, waitFor, tick, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Exactly asserts that two objects are equal in value and type.
-//
-// assert.Exactly(t, int32(123), int64(123))
-func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Exactly(t, expected, actual, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Exactlyf asserts that two objects are equal in value and type.
-//
-// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted")
-func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Exactlyf(t, expected, actual, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Fail reports a failure through
-func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Fail(t, failureMessage, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// FailNow fails test
-func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.FailNow(t, failureMessage, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// FailNowf fails test
-func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.FailNowf(t, failureMessage, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Failf reports a failure through
-func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Failf(t, failureMessage, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// False asserts that the specified value is false.
-//
-// assert.False(t, myBool)
-func False(t TestingT, value bool, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.False(t, value, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Falsef asserts that the specified value is false.
-//
-// assert.Falsef(t, myBool, "error message %s", "formatted")
-func Falsef(t TestingT, value bool, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Falsef(t, value, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// FileExists checks whether a file exists in the given path. It also fails if
-// the path points to a directory or there is an error when trying to check the file.
-func FileExists(t TestingT, path string, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.FileExists(t, path, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// FileExistsf checks whether a file exists in the given path. It also fails if
-// the path points to a directory or there is an error when trying to check the file.
-func FileExistsf(t TestingT, path string, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.FileExistsf(t, path, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Greater asserts that the first element is greater than the second
-//
-// assert.Greater(t, 2, 1)
-// assert.Greater(t, float64(2), float64(1))
-// assert.Greater(t, "b", "a")
-func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Greater(t, e1, e2, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// GreaterOrEqual asserts that the first element is greater than or equal to the second
-//
-// assert.GreaterOrEqual(t, 2, 1)
-// assert.GreaterOrEqual(t, 2, 2)
-// assert.GreaterOrEqual(t, "b", "a")
-// assert.GreaterOrEqual(t, "b", "b")
-func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.GreaterOrEqual(t, e1, e2, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// GreaterOrEqualf asserts that the first element is greater than or equal to the second
-//
-// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted")
-// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted")
-// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted")
-// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted")
-func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.GreaterOrEqualf(t, e1, e2, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Greaterf asserts that the first element is greater than the second
-//
-// assert.Greaterf(t, 2, 1, "error message %s", "formatted")
-// assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted")
-// assert.Greaterf(t, "b", "a", "error message %s", "formatted")
-func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Greaterf(t, e1, e2, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// HTTPBodyContains asserts that a specified handler returns a
-// body that contains a string.
-//
-// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.HTTPBodyContains(t, handler, method, url, values, str, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// HTTPBodyContainsf asserts that a specified handler returns a
-// body that contains a string.
-//
-// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.HTTPBodyContainsf(t, handler, method, url, values, str, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// HTTPBodyNotContains asserts that a specified handler returns a
-// body that does not contain a string.
-//
-// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.HTTPBodyNotContains(t, handler, method, url, values, str, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// HTTPBodyNotContainsf asserts that a specified handler returns a
-// body that does not contain a string.
-//
-// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.HTTPBodyNotContainsf(t, handler, method, url, values, str, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// HTTPError asserts that a specified handler returns an error status code.
-//
-// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.HTTPError(t, handler, method, url, values, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// HTTPErrorf asserts that a specified handler returns an error status code.
-//
-// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.HTTPErrorf(t, handler, method, url, values, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// HTTPRedirect asserts that a specified handler returns a redirect status code.
-//
-// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.HTTPRedirect(t, handler, method, url, values, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// HTTPRedirectf asserts that a specified handler returns a redirect status code.
-//
-// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.HTTPRedirectf(t, handler, method, url, values, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// HTTPStatusCode asserts that a specified handler returns a specified status code.
-//
-// assert.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.HTTPStatusCode(t, handler, method, url, values, statuscode, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// HTTPStatusCodef asserts that a specified handler returns a specified status code.
-//
-// assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.HTTPStatusCodef(t, handler, method, url, values, statuscode, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// HTTPSuccess asserts that a specified handler returns a success status code.
-//
-// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.HTTPSuccess(t, handler, method, url, values, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// HTTPSuccessf asserts that a specified handler returns a success status code.
-//
-// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.HTTPSuccessf(t, handler, method, url, values, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Implements asserts that an object is implemented by the specified interface.
-//
-// assert.Implements(t, (*MyInterface)(nil), new(MyObject))
-func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Implements(t, interfaceObject, object, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Implementsf asserts that an object is implemented by the specified interface.
-//
-// assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
-func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Implementsf(t, interfaceObject, object, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// InDelta asserts that the two numerals are within delta of each other.
-//
-// assert.InDelta(t, math.Pi, 22/7.0, 0.01)
-func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.InDelta(t, expected, actual, delta, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
-func InDeltaMapValues(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.InDeltaMapValues(t, expected, actual, delta, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
-func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.InDeltaMapValuesf(t, expected, actual, delta, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// InDeltaSlice is the same as InDelta, except it compares two slices.
-func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// InDeltaSlicef is the same as InDelta, except it compares two slices.
-func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.InDeltaSlicef(t, expected, actual, delta, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// InDeltaf asserts that the two numerals are within delta of each other.
-//
-// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
-func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.InDeltaf(t, expected, actual, delta, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// InEpsilon asserts that expected and actual have a relative error less than epsilon
-func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
-func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.InEpsilonSlice(t, expected, actual, epsilon, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
-func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.InEpsilonSlicef(t, expected, actual, epsilon, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// InEpsilonf asserts that expected and actual have a relative error less than epsilon
-func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.InEpsilonf(t, expected, actual, epsilon, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// IsDecreasing asserts that the collection is decreasing
-//
-// assert.IsDecreasing(t, []int{2, 1, 0})
-// assert.IsDecreasing(t, []float{2, 1})
-// assert.IsDecreasing(t, []string{"b", "a"})
-func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.IsDecreasing(t, object, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// IsDecreasingf asserts that the collection is decreasing
-//
-// assert.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted")
-// assert.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted")
-// assert.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
-func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.IsDecreasingf(t, object, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// IsIncreasing asserts that the collection is increasing
-//
-// assert.IsIncreasing(t, []int{1, 2, 3})
-// assert.IsIncreasing(t, []float{1, 2})
-// assert.IsIncreasing(t, []string{"a", "b"})
-func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.IsIncreasing(t, object, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// IsIncreasingf asserts that the collection is increasing
-//
-// assert.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted")
-// assert.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted")
-// assert.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
-func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.IsIncreasingf(t, object, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// IsNonDecreasing asserts that the collection is not decreasing
-//
-// assert.IsNonDecreasing(t, []int{1, 1, 2})
-// assert.IsNonDecreasing(t, []float{1, 2})
-// assert.IsNonDecreasing(t, []string{"a", "b"})
-func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.IsNonDecreasing(t, object, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// IsNonDecreasingf asserts that the collection is not decreasing
-//
-// assert.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted")
-// assert.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted")
-// assert.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
-func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.IsNonDecreasingf(t, object, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// IsNonIncreasing asserts that the collection is not increasing
-//
-// assert.IsNonIncreasing(t, []int{2, 1, 1})
-// assert.IsNonIncreasing(t, []float{2, 1})
-// assert.IsNonIncreasing(t, []string{"b", "a"})
-func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.IsNonIncreasing(t, object, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// IsNonIncreasingf asserts that the collection is not increasing
-//
-// assert.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted")
-// assert.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted")
-// assert.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
-func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.IsNonIncreasingf(t, object, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// IsType asserts that the specified objects are of the same type.
-func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.IsType(t, expectedType, object, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// IsTypef asserts that the specified objects are of the same type.
-func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.IsTypef(t, expectedType, object, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// JSONEq asserts that two JSON strings are equivalent.
-//
-// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
-func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.JSONEq(t, expected, actual, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// JSONEqf asserts that two JSON strings are equivalent.
-//
-// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
-func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.JSONEqf(t, expected, actual, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Len asserts that the specified object has specific length.
-// Len also fails if the object has a type that len() not accept.
-//
-// assert.Len(t, mySlice, 3)
-func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Len(t, object, length, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Lenf asserts that the specified object has specific length.
-// Lenf also fails if the object has a type that len() not accept.
-//
-// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
-func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Lenf(t, object, length, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Less asserts that the first element is less than the second
-//
-// assert.Less(t, 1, 2)
-// assert.Less(t, float64(1), float64(2))
-// assert.Less(t, "a", "b")
-func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Less(t, e1, e2, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// LessOrEqual asserts that the first element is less than or equal to the second
-//
-// assert.LessOrEqual(t, 1, 2)
-// assert.LessOrEqual(t, 2, 2)
-// assert.LessOrEqual(t, "a", "b")
-// assert.LessOrEqual(t, "b", "b")
-func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.LessOrEqual(t, e1, e2, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// LessOrEqualf asserts that the first element is less than or equal to the second
-//
-// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted")
-// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted")
-// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted")
-// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted")
-func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.LessOrEqualf(t, e1, e2, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Lessf asserts that the first element is less than the second
-//
-// assert.Lessf(t, 1, 2, "error message %s", "formatted")
-// assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted")
-// assert.Lessf(t, "a", "b", "error message %s", "formatted")
-func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Lessf(t, e1, e2, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Negative asserts that the specified element is negative
-//
-// assert.Negative(t, -1)
-// assert.Negative(t, -1.23)
-func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Negative(t, e, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Negativef asserts that the specified element is negative
-//
-// assert.Negativef(t, -1, "error message %s", "formatted")
-// assert.Negativef(t, -1.23, "error message %s", "formatted")
-func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Negativef(t, e, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Never asserts that the given condition doesn't satisfy in waitFor time,
-// periodically checking the target function each tick.
-//
-// assert.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond)
-func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Never(t, condition, waitFor, tick, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Neverf asserts that the given condition doesn't satisfy in waitFor time,
-// periodically checking the target function each tick.
-//
-// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
-func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Neverf(t, condition, waitFor, tick, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Nil asserts that the specified object is nil.
-//
-// assert.Nil(t, err)
-func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Nil(t, object, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Nilf asserts that the specified object is nil.
-//
-// assert.Nilf(t, err, "error message %s", "formatted")
-func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Nilf(t, object, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NoDirExists checks whether a directory does not exist in the given path.
-// It fails if the path points to an existing _directory_ only.
-func NoDirExists(t TestingT, path string, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NoDirExists(t, path, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NoDirExistsf checks whether a directory does not exist in the given path.
-// It fails if the path points to an existing _directory_ only.
-func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NoDirExistsf(t, path, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NoError asserts that a function returned no error (i.e. `nil`).
-//
-// actualObj, err := SomeFunction()
-// if assert.NoError(t, err) {
-// assert.Equal(t, expectedObj, actualObj)
-// }
-func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NoError(t, err, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NoErrorf asserts that a function returned no error (i.e. `nil`).
-//
-// actualObj, err := SomeFunction()
-// if assert.NoErrorf(t, err, "error message %s", "formatted") {
-// assert.Equal(t, expectedObj, actualObj)
-// }
-func NoErrorf(t TestingT, err error, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NoErrorf(t, err, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NoFileExists checks whether a file does not exist in a given path. It fails
-// if the path points to an existing _file_ only.
-func NoFileExists(t TestingT, path string, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NoFileExists(t, path, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NoFileExistsf checks whether a file does not exist in a given path. It fails
-// if the path points to an existing _file_ only.
-func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NoFileExistsf(t, path, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
-// specified substring or element.
-//
-// assert.NotContains(t, "Hello World", "Earth")
-// assert.NotContains(t, ["Hello", "World"], "Earth")
-// assert.NotContains(t, {"Hello": "World"}, "Earth")
-func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotContains(t, s, contains, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
-// specified substring or element.
-//
-// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
-// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
-// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
-func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotContainsf(t, s, contains, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// if assert.NotEmpty(t, obj) {
-// assert.Equal(t, "two", obj[1])
-// }
-func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotEmpty(t, object, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
-// assert.Equal(t, "two", obj[1])
-// }
-func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotEmptyf(t, object, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NotEqual asserts that the specified values are NOT equal.
-//
-// assert.NotEqual(t, obj1, obj2)
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses).
-func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotEqual(t, expected, actual, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NotEqualValues asserts that two objects are not equal even when converted to the same type
-//
-// assert.NotEqualValues(t, obj1, obj2)
-func NotEqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotEqualValues(t, expected, actual, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NotEqualValuesf asserts that two objects are not equal even when converted to the same type
-//
-// assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted")
-func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotEqualValuesf(t, expected, actual, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NotEqualf asserts that the specified values are NOT equal.
-//
-// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses).
-func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotEqualf(t, expected, actual, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NotErrorIs asserts that at none of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func NotErrorIs(t TestingT, err error, target error, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotErrorIs(t, err, target, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NotErrorIsf asserts that at none of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotErrorIsf(t, err, target, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NotNil asserts that the specified object is not nil.
-//
-// assert.NotNil(t, err)
-func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotNil(t, object, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NotNilf asserts that the specified object is not nil.
-//
-// assert.NotNilf(t, err, "error message %s", "formatted")
-func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotNilf(t, object, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
-//
-// assert.NotPanics(t, func(){ RemainCalm() })
-func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotPanics(t, f, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
-//
-// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
-func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotPanicsf(t, f, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NotRegexp asserts that a specified regexp does not match a string.
-//
-// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
-// assert.NotRegexp(t, "^start", "it's not starting")
-func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotRegexp(t, rx, str, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NotRegexpf asserts that a specified regexp does not match a string.
-//
-// assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
-// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
-func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotRegexpf(t, rx, str, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NotSame asserts that two pointers do not reference the same object.
-//
-// assert.NotSame(t, ptr1, ptr2)
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func NotSame(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotSame(t, expected, actual, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NotSamef asserts that two pointers do not reference the same object.
-//
-// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted")
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotSamef(t, expected, actual, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NotSubset asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
-//
-// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
-func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotSubset(t, list, subset, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NotSubsetf asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
-//
-// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
-func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotSubsetf(t, list, subset, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// NotZero asserts that i is not the zero value for its type.
-func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotZero(t, i, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// NotZerof asserts that i is not the zero value for its type.
-func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.NotZerof(t, i, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Panics asserts that the code inside the specified PanicTestFunc panics.
-//
-// assert.Panics(t, func(){ GoCrazy() })
-func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Panics(t, f, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// PanicsWithError asserts that the code inside the specified PanicTestFunc
-// panics, and that the recovered panic value is an error that satisfies the
-// EqualError comparison.
-//
-// assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() })
-func PanicsWithError(t TestingT, errString string, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.PanicsWithError(t, errString, f, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc
-// panics, and that the recovered panic value is an error that satisfies the
-// EqualError comparison.
-//
-// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
-func PanicsWithErrorf(t TestingT, errString string, f assert.PanicTestFunc, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.PanicsWithErrorf(t, errString, f, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
-// the recovered panic value equals the expected panic value.
-//
-// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
-func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.PanicsWithValue(t, expected, f, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
-// the recovered panic value equals the expected panic value.
-//
-// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
-func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.PanicsWithValuef(t, expected, f, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Panicsf asserts that the code inside the specified PanicTestFunc panics.
-//
-// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
-func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Panicsf(t, f, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Positive asserts that the specified element is positive
-//
-// assert.Positive(t, 1)
-// assert.Positive(t, 1.23)
-func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Positive(t, e, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Positivef asserts that the specified element is positive
-//
-// assert.Positivef(t, 1, "error message %s", "formatted")
-// assert.Positivef(t, 1.23, "error message %s", "formatted")
-func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Positivef(t, e, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Regexp asserts that a specified regexp matches a string.
-//
-// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
-// assert.Regexp(t, "start...$", "it's not starting")
-func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Regexp(t, rx, str, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Regexpf asserts that a specified regexp matches a string.
-//
-// assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
-// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
-func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Regexpf(t, rx, str, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Same asserts that two pointers reference the same object.
-//
-// assert.Same(t, ptr1, ptr2)
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func Same(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Same(t, expected, actual, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Samef asserts that two pointers reference the same object.
-//
-// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted")
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Samef(t, expected, actual, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Subset asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
-//
-// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
-func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Subset(t, list, subset, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Subsetf asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
-//
-// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
-func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Subsetf(t, list, subset, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// True asserts that the specified value is true.
-//
-// assert.True(t, myBool)
-func True(t TestingT, value bool, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.True(t, value, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Truef asserts that the specified value is true.
-//
-// assert.Truef(t, myBool, "error message %s", "formatted")
-func Truef(t TestingT, value bool, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Truef(t, value, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// WithinDuration asserts that the two times are within duration delta of each other.
-//
-// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
-func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// WithinDurationf asserts that the two times are within duration delta of each other.
-//
-// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
-func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.WithinDurationf(t, expected, actual, delta, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// WithinRange asserts that a time is within a time range (inclusive).
-//
-// assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
-func WithinRange(t TestingT, actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.WithinRange(t, actual, start, end, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// WithinRangef asserts that a time is within a time range (inclusive).
-//
-// assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
-func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.WithinRangef(t, actual, start, end, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// YAMLEq asserts that two YAML strings are equivalent.
-func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.YAMLEq(t, expected, actual, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// YAMLEqf asserts that two YAML strings are equivalent.
-func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.YAMLEqf(t, expected, actual, msg, args...) {
- return
- }
- t.FailNow()
-}
-
-// Zero asserts that i is the zero value for its type.
-func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Zero(t, i, msgAndArgs...) {
- return
- }
- t.FailNow()
-}
-
-// Zerof asserts that i is the zero value for its type.
-func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) {
- if h, ok := t.(tHelper); ok {
- h.Helper()
- }
- if assert.Zerof(t, i, msg, args...) {
- return
- }
- t.FailNow()
-}
diff --git a/vendor/github.com/stretchr/testify/require/require.go.tmpl b/vendor/github.com/stretchr/testify/require/require.go.tmpl
deleted file mode 100644
index 55e42dde..00000000
--- a/vendor/github.com/stretchr/testify/require/require.go.tmpl
+++ /dev/null
@@ -1,6 +0,0 @@
-{{.Comment}}
-func {{.DocInfo.Name}}(t TestingT, {{.Params}}) {
- if h, ok := t.(tHelper); ok { h.Helper() }
- if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return }
- t.FailNow()
-}
diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go b/vendor/github.com/stretchr/testify/require/require_forward.go
deleted file mode 100644
index 960bf6f2..00000000
--- a/vendor/github.com/stretchr/testify/require/require_forward.go
+++ /dev/null
@@ -1,1515 +0,0 @@
-/*
-* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
-* THIS FILE MUST NOT BE EDITED BY HAND
- */
-
-package require
-
-import (
- assert "github.com/stretchr/testify/assert"
- http "net/http"
- url "net/url"
- time "time"
-)
-
-// Condition uses a Comparison to assert a complex condition.
-func (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Condition(a.t, comp, msgAndArgs...)
-}
-
-// Conditionf uses a Comparison to assert a complex condition.
-func (a *Assertions) Conditionf(comp assert.Comparison, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Conditionf(a.t, comp, msg, args...)
-}
-
-// Contains asserts that the specified string, list(array, slice...) or map contains the
-// specified substring or element.
-//
-// a.Contains("Hello World", "World")
-// a.Contains(["Hello", "World"], "World")
-// a.Contains({"Hello": "World"}, "Hello")
-func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Contains(a.t, s, contains, msgAndArgs...)
-}
-
-// Containsf asserts that the specified string, list(array, slice...) or map contains the
-// specified substring or element.
-//
-// a.Containsf("Hello World", "World", "error message %s", "formatted")
-// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted")
-// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted")
-func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Containsf(a.t, s, contains, msg, args...)
-}
-
-// DirExists checks whether a directory exists in the given path. It also fails
-// if the path is a file rather a directory or there is an error checking whether it exists.
-func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- DirExists(a.t, path, msgAndArgs...)
-}
-
-// DirExistsf checks whether a directory exists in the given path. It also fails
-// if the path is a file rather a directory or there is an error checking whether it exists.
-func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- DirExistsf(a.t, path, msg, args...)
-}
-
-// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
-// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
-// the number of appearances of each of them in both lists should match.
-//
-// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2])
-func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- ElementsMatch(a.t, listA, listB, msgAndArgs...)
-}
-
-// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
-// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
-// the number of appearances of each of them in both lists should match.
-//
-// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
-func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- ElementsMatchf(a.t, listA, listB, msg, args...)
-}
-
-// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// a.Empty(obj)
-func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Empty(a.t, object, msgAndArgs...)
-}
-
-// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// a.Emptyf(obj, "error message %s", "formatted")
-func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Emptyf(a.t, object, msg, args...)
-}
-
-// Equal asserts that two objects are equal.
-//
-// a.Equal(123, 123)
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses). Function equality
-// cannot be determined and will always fail.
-func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Equal(a.t, expected, actual, msgAndArgs...)
-}
-
-// EqualError asserts that a function returned an error (i.e. not `nil`)
-// and that it is equal to the provided error.
-//
-// actualObj, err := SomeFunction()
-// a.EqualError(err, expectedErrorString)
-func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- EqualError(a.t, theError, errString, msgAndArgs...)
-}
-
-// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
-// and that it is equal to the provided error.
-//
-// actualObj, err := SomeFunction()
-// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted")
-func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- EqualErrorf(a.t, theError, errString, msg, args...)
-}
-
-// EqualValues asserts that two objects are equal or convertable to the same types
-// and equal.
-//
-// a.EqualValues(uint32(123), int32(123))
-func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- EqualValues(a.t, expected, actual, msgAndArgs...)
-}
-
-// EqualValuesf asserts that two objects are equal or convertable to the same types
-// and equal.
-//
-// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
-func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- EqualValuesf(a.t, expected, actual, msg, args...)
-}
-
-// Equalf asserts that two objects are equal.
-//
-// a.Equalf(123, 123, "error message %s", "formatted")
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses). Function equality
-// cannot be determined and will always fail.
-func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Equalf(a.t, expected, actual, msg, args...)
-}
-
-// Error asserts that a function returned an error (i.e. not `nil`).
-//
-// actualObj, err := SomeFunction()
-// if a.Error(err) {
-// assert.Equal(t, expectedError, err)
-// }
-func (a *Assertions) Error(err error, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Error(a.t, err, msgAndArgs...)
-}
-
-// ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
-// This is a wrapper for errors.As.
-func (a *Assertions) ErrorAs(err error, target interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- ErrorAs(a.t, err, target, msgAndArgs...)
-}
-
-// ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
-// This is a wrapper for errors.As.
-func (a *Assertions) ErrorAsf(err error, target interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- ErrorAsf(a.t, err, target, msg, args...)
-}
-
-// ErrorContains asserts that a function returned an error (i.e. not `nil`)
-// and that the error contains the specified substring.
-//
-// actualObj, err := SomeFunction()
-// a.ErrorContains(err, expectedErrorSubString)
-func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- ErrorContains(a.t, theError, contains, msgAndArgs...)
-}
-
-// ErrorContainsf asserts that a function returned an error (i.e. not `nil`)
-// and that the error contains the specified substring.
-//
-// actualObj, err := SomeFunction()
-// a.ErrorContainsf(err, expectedErrorSubString, "error message %s", "formatted")
-func (a *Assertions) ErrorContainsf(theError error, contains string, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- ErrorContainsf(a.t, theError, contains, msg, args...)
-}
-
-// ErrorIs asserts that at least one of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func (a *Assertions) ErrorIs(err error, target error, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- ErrorIs(a.t, err, target, msgAndArgs...)
-}
-
-// ErrorIsf asserts that at least one of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- ErrorIsf(a.t, err, target, msg, args...)
-}
-
-// Errorf asserts that a function returned an error (i.e. not `nil`).
-//
-// actualObj, err := SomeFunction()
-// if a.Errorf(err, "error message %s", "formatted") {
-// assert.Equal(t, expectedErrorf, err)
-// }
-func (a *Assertions) Errorf(err error, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Errorf(a.t, err, msg, args...)
-}
-
-// Eventually asserts that given condition will be met in waitFor time,
-// periodically checking target function each tick.
-//
-// a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond)
-func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Eventually(a.t, condition, waitFor, tick, msgAndArgs...)
-}
-
-// Eventuallyf asserts that given condition will be met in waitFor time,
-// periodically checking target function each tick.
-//
-// a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
-func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Eventuallyf(a.t, condition, waitFor, tick, msg, args...)
-}
-
-// Exactly asserts that two objects are equal in value and type.
-//
-// a.Exactly(int32(123), int64(123))
-func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Exactly(a.t, expected, actual, msgAndArgs...)
-}
-
-// Exactlyf asserts that two objects are equal in value and type.
-//
-// a.Exactlyf(int32(123), int64(123), "error message %s", "formatted")
-func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Exactlyf(a.t, expected, actual, msg, args...)
-}
-
-// Fail reports a failure through
-func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Fail(a.t, failureMessage, msgAndArgs...)
-}
-
-// FailNow fails test
-func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- FailNow(a.t, failureMessage, msgAndArgs...)
-}
-
-// FailNowf fails test
-func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- FailNowf(a.t, failureMessage, msg, args...)
-}
-
-// Failf reports a failure through
-func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Failf(a.t, failureMessage, msg, args...)
-}
-
-// False asserts that the specified value is false.
-//
-// a.False(myBool)
-func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- False(a.t, value, msgAndArgs...)
-}
-
-// Falsef asserts that the specified value is false.
-//
-// a.Falsef(myBool, "error message %s", "formatted")
-func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Falsef(a.t, value, msg, args...)
-}
-
-// FileExists checks whether a file exists in the given path. It also fails if
-// the path points to a directory or there is an error when trying to check the file.
-func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- FileExists(a.t, path, msgAndArgs...)
-}
-
-// FileExistsf checks whether a file exists in the given path. It also fails if
-// the path points to a directory or there is an error when trying to check the file.
-func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- FileExistsf(a.t, path, msg, args...)
-}
-
-// Greater asserts that the first element is greater than the second
-//
-// a.Greater(2, 1)
-// a.Greater(float64(2), float64(1))
-// a.Greater("b", "a")
-func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Greater(a.t, e1, e2, msgAndArgs...)
-}
-
-// GreaterOrEqual asserts that the first element is greater than or equal to the second
-//
-// a.GreaterOrEqual(2, 1)
-// a.GreaterOrEqual(2, 2)
-// a.GreaterOrEqual("b", "a")
-// a.GreaterOrEqual("b", "b")
-func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- GreaterOrEqual(a.t, e1, e2, msgAndArgs...)
-}
-
-// GreaterOrEqualf asserts that the first element is greater than or equal to the second
-//
-// a.GreaterOrEqualf(2, 1, "error message %s", "formatted")
-// a.GreaterOrEqualf(2, 2, "error message %s", "formatted")
-// a.GreaterOrEqualf("b", "a", "error message %s", "formatted")
-// a.GreaterOrEqualf("b", "b", "error message %s", "formatted")
-func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- GreaterOrEqualf(a.t, e1, e2, msg, args...)
-}
-
-// Greaterf asserts that the first element is greater than the second
-//
-// a.Greaterf(2, 1, "error message %s", "formatted")
-// a.Greaterf(float64(2), float64(1), "error message %s", "formatted")
-// a.Greaterf("b", "a", "error message %s", "formatted")
-func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Greaterf(a.t, e1, e2, msg, args...)
-}
-
-// HTTPBodyContains asserts that a specified handler returns a
-// body that contains a string.
-//
-// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...)
-}
-
-// HTTPBodyContainsf asserts that a specified handler returns a
-// body that contains a string.
-//
-// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...)
-}
-
-// HTTPBodyNotContains asserts that a specified handler returns a
-// body that does not contain a string.
-//
-// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...)
-}
-
-// HTTPBodyNotContainsf asserts that a specified handler returns a
-// body that does not contain a string.
-//
-// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...)
-}
-
-// HTTPError asserts that a specified handler returns an error status code.
-//
-// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- HTTPError(a.t, handler, method, url, values, msgAndArgs...)
-}
-
-// HTTPErrorf asserts that a specified handler returns an error status code.
-//
-// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- HTTPErrorf(a.t, handler, method, url, values, msg, args...)
-}
-
-// HTTPRedirect asserts that a specified handler returns a redirect status code.
-//
-// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...)
-}
-
-// HTTPRedirectf asserts that a specified handler returns a redirect status code.
-//
-// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- HTTPRedirectf(a.t, handler, method, url, values, msg, args...)
-}
-
-// HTTPStatusCode asserts that a specified handler returns a specified status code.
-//
-// a.HTTPStatusCode(myHandler, "GET", "/notImplemented", nil, 501)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- HTTPStatusCode(a.t, handler, method, url, values, statuscode, msgAndArgs...)
-}
-
-// HTTPStatusCodef asserts that a specified handler returns a specified status code.
-//
-// a.HTTPStatusCodef(myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- HTTPStatusCodef(a.t, handler, method, url, values, statuscode, msg, args...)
-}
-
-// HTTPSuccess asserts that a specified handler returns a success status code.
-//
-// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...)
-}
-
-// HTTPSuccessf asserts that a specified handler returns a success status code.
-//
-// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- HTTPSuccessf(a.t, handler, method, url, values, msg, args...)
-}
-
-// Implements asserts that an object is implemented by the specified interface.
-//
-// a.Implements((*MyInterface)(nil), new(MyObject))
-func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Implements(a.t, interfaceObject, object, msgAndArgs...)
-}
-
-// Implementsf asserts that an object is implemented by the specified interface.
-//
-// a.Implementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
-func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Implementsf(a.t, interfaceObject, object, msg, args...)
-}
-
-// InDelta asserts that the two numerals are within delta of each other.
-//
-// a.InDelta(math.Pi, 22/7.0, 0.01)
-func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- InDelta(a.t, expected, actual, delta, msgAndArgs...)
-}
-
-// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
-func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...)
-}
-
-// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
-func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...)
-}
-
-// InDeltaSlice is the same as InDelta, except it compares two slices.
-func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
-}
-
-// InDeltaSlicef is the same as InDelta, except it compares two slices.
-func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
-}
-
-// InDeltaf asserts that the two numerals are within delta of each other.
-//
-// a.InDeltaf(math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
-func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- InDeltaf(a.t, expected, actual, delta, msg, args...)
-}
-
-// InEpsilon asserts that expected and actual have a relative error less than epsilon
-func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
-}
-
-// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
-func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
-}
-
-// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
-func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
-}
-
-// InEpsilonf asserts that expected and actual have a relative error less than epsilon
-func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- InEpsilonf(a.t, expected, actual, epsilon, msg, args...)
-}
-
-// IsDecreasing asserts that the collection is decreasing
-//
-// a.IsDecreasing([]int{2, 1, 0})
-// a.IsDecreasing([]float{2, 1})
-// a.IsDecreasing([]string{"b", "a"})
-func (a *Assertions) IsDecreasing(object interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- IsDecreasing(a.t, object, msgAndArgs...)
-}
-
-// IsDecreasingf asserts that the collection is decreasing
-//
-// a.IsDecreasingf([]int{2, 1, 0}, "error message %s", "formatted")
-// a.IsDecreasingf([]float{2, 1}, "error message %s", "formatted")
-// a.IsDecreasingf([]string{"b", "a"}, "error message %s", "formatted")
-func (a *Assertions) IsDecreasingf(object interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- IsDecreasingf(a.t, object, msg, args...)
-}
-
-// IsIncreasing asserts that the collection is increasing
-//
-// a.IsIncreasing([]int{1, 2, 3})
-// a.IsIncreasing([]float{1, 2})
-// a.IsIncreasing([]string{"a", "b"})
-func (a *Assertions) IsIncreasing(object interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- IsIncreasing(a.t, object, msgAndArgs...)
-}
-
-// IsIncreasingf asserts that the collection is increasing
-//
-// a.IsIncreasingf([]int{1, 2, 3}, "error message %s", "formatted")
-// a.IsIncreasingf([]float{1, 2}, "error message %s", "formatted")
-// a.IsIncreasingf([]string{"a", "b"}, "error message %s", "formatted")
-func (a *Assertions) IsIncreasingf(object interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- IsIncreasingf(a.t, object, msg, args...)
-}
-
-// IsNonDecreasing asserts that the collection is not decreasing
-//
-// a.IsNonDecreasing([]int{1, 1, 2})
-// a.IsNonDecreasing([]float{1, 2})
-// a.IsNonDecreasing([]string{"a", "b"})
-func (a *Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- IsNonDecreasing(a.t, object, msgAndArgs...)
-}
-
-// IsNonDecreasingf asserts that the collection is not decreasing
-//
-// a.IsNonDecreasingf([]int{1, 1, 2}, "error message %s", "formatted")
-// a.IsNonDecreasingf([]float{1, 2}, "error message %s", "formatted")
-// a.IsNonDecreasingf([]string{"a", "b"}, "error message %s", "formatted")
-func (a *Assertions) IsNonDecreasingf(object interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- IsNonDecreasingf(a.t, object, msg, args...)
-}
-
-// IsNonIncreasing asserts that the collection is not increasing
-//
-// a.IsNonIncreasing([]int{2, 1, 1})
-// a.IsNonIncreasing([]float{2, 1})
-// a.IsNonIncreasing([]string{"b", "a"})
-func (a *Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- IsNonIncreasing(a.t, object, msgAndArgs...)
-}
-
-// IsNonIncreasingf asserts that the collection is not increasing
-//
-// a.IsNonIncreasingf([]int{2, 1, 1}, "error message %s", "formatted")
-// a.IsNonIncreasingf([]float{2, 1}, "error message %s", "formatted")
-// a.IsNonIncreasingf([]string{"b", "a"}, "error message %s", "formatted")
-func (a *Assertions) IsNonIncreasingf(object interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- IsNonIncreasingf(a.t, object, msg, args...)
-}
-
-// IsType asserts that the specified objects are of the same type.
-func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- IsType(a.t, expectedType, object, msgAndArgs...)
-}
-
-// IsTypef asserts that the specified objects are of the same type.
-func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- IsTypef(a.t, expectedType, object, msg, args...)
-}
-
-// JSONEq asserts that two JSON strings are equivalent.
-//
-// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
-func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- JSONEq(a.t, expected, actual, msgAndArgs...)
-}
-
-// JSONEqf asserts that two JSON strings are equivalent.
-//
-// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
-func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- JSONEqf(a.t, expected, actual, msg, args...)
-}
-
-// Len asserts that the specified object has specific length.
-// Len also fails if the object has a type that len() not accept.
-//
-// a.Len(mySlice, 3)
-func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Len(a.t, object, length, msgAndArgs...)
-}
-
-// Lenf asserts that the specified object has specific length.
-// Lenf also fails if the object has a type that len() not accept.
-//
-// a.Lenf(mySlice, 3, "error message %s", "formatted")
-func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Lenf(a.t, object, length, msg, args...)
-}
-
-// Less asserts that the first element is less than the second
-//
-// a.Less(1, 2)
-// a.Less(float64(1), float64(2))
-// a.Less("a", "b")
-func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Less(a.t, e1, e2, msgAndArgs...)
-}
-
-// LessOrEqual asserts that the first element is less than or equal to the second
-//
-// a.LessOrEqual(1, 2)
-// a.LessOrEqual(2, 2)
-// a.LessOrEqual("a", "b")
-// a.LessOrEqual("b", "b")
-func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- LessOrEqual(a.t, e1, e2, msgAndArgs...)
-}
-
-// LessOrEqualf asserts that the first element is less than or equal to the second
-//
-// a.LessOrEqualf(1, 2, "error message %s", "formatted")
-// a.LessOrEqualf(2, 2, "error message %s", "formatted")
-// a.LessOrEqualf("a", "b", "error message %s", "formatted")
-// a.LessOrEqualf("b", "b", "error message %s", "formatted")
-func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- LessOrEqualf(a.t, e1, e2, msg, args...)
-}
-
-// Lessf asserts that the first element is less than the second
-//
-// a.Lessf(1, 2, "error message %s", "formatted")
-// a.Lessf(float64(1), float64(2), "error message %s", "formatted")
-// a.Lessf("a", "b", "error message %s", "formatted")
-func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Lessf(a.t, e1, e2, msg, args...)
-}
-
-// Negative asserts that the specified element is negative
-//
-// a.Negative(-1)
-// a.Negative(-1.23)
-func (a *Assertions) Negative(e interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Negative(a.t, e, msgAndArgs...)
-}
-
-// Negativef asserts that the specified element is negative
-//
-// a.Negativef(-1, "error message %s", "formatted")
-// a.Negativef(-1.23, "error message %s", "formatted")
-func (a *Assertions) Negativef(e interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Negativef(a.t, e, msg, args...)
-}
-
-// Never asserts that the given condition doesn't satisfy in waitFor time,
-// periodically checking the target function each tick.
-//
-// a.Never(func() bool { return false; }, time.Second, 10*time.Millisecond)
-func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Never(a.t, condition, waitFor, tick, msgAndArgs...)
-}
-
-// Neverf asserts that the given condition doesn't satisfy in waitFor time,
-// periodically checking the target function each tick.
-//
-// a.Neverf(func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
-func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Neverf(a.t, condition, waitFor, tick, msg, args...)
-}
-
-// Nil asserts that the specified object is nil.
-//
-// a.Nil(err)
-func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Nil(a.t, object, msgAndArgs...)
-}
-
-// Nilf asserts that the specified object is nil.
-//
-// a.Nilf(err, "error message %s", "formatted")
-func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Nilf(a.t, object, msg, args...)
-}
-
-// NoDirExists checks whether a directory does not exist in the given path.
-// It fails if the path points to an existing _directory_ only.
-func (a *Assertions) NoDirExists(path string, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NoDirExists(a.t, path, msgAndArgs...)
-}
-
-// NoDirExistsf checks whether a directory does not exist in the given path.
-// It fails if the path points to an existing _directory_ only.
-func (a *Assertions) NoDirExistsf(path string, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NoDirExistsf(a.t, path, msg, args...)
-}
-
-// NoError asserts that a function returned no error (i.e. `nil`).
-//
-// actualObj, err := SomeFunction()
-// if a.NoError(err) {
-// assert.Equal(t, expectedObj, actualObj)
-// }
-func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NoError(a.t, err, msgAndArgs...)
-}
-
-// NoErrorf asserts that a function returned no error (i.e. `nil`).
-//
-// actualObj, err := SomeFunction()
-// if a.NoErrorf(err, "error message %s", "formatted") {
-// assert.Equal(t, expectedObj, actualObj)
-// }
-func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NoErrorf(a.t, err, msg, args...)
-}
-
-// NoFileExists checks whether a file does not exist in a given path. It fails
-// if the path points to an existing _file_ only.
-func (a *Assertions) NoFileExists(path string, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NoFileExists(a.t, path, msgAndArgs...)
-}
-
-// NoFileExistsf checks whether a file does not exist in a given path. It fails
-// if the path points to an existing _file_ only.
-func (a *Assertions) NoFileExistsf(path string, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NoFileExistsf(a.t, path, msg, args...)
-}
-
-// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
-// specified substring or element.
-//
-// a.NotContains("Hello World", "Earth")
-// a.NotContains(["Hello", "World"], "Earth")
-// a.NotContains({"Hello": "World"}, "Earth")
-func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotContains(a.t, s, contains, msgAndArgs...)
-}
-
-// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
-// specified substring or element.
-//
-// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted")
-// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted")
-// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted")
-func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotContainsf(a.t, s, contains, msg, args...)
-}
-
-// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// if a.NotEmpty(obj) {
-// assert.Equal(t, "two", obj[1])
-// }
-func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotEmpty(a.t, object, msgAndArgs...)
-}
-
-// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// if a.NotEmptyf(obj, "error message %s", "formatted") {
-// assert.Equal(t, "two", obj[1])
-// }
-func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotEmptyf(a.t, object, msg, args...)
-}
-
-// NotEqual asserts that the specified values are NOT equal.
-//
-// a.NotEqual(obj1, obj2)
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses).
-func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotEqual(a.t, expected, actual, msgAndArgs...)
-}
-
-// NotEqualValues asserts that two objects are not equal even when converted to the same type
-//
-// a.NotEqualValues(obj1, obj2)
-func (a *Assertions) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotEqualValues(a.t, expected, actual, msgAndArgs...)
-}
-
-// NotEqualValuesf asserts that two objects are not equal even when converted to the same type
-//
-// a.NotEqualValuesf(obj1, obj2, "error message %s", "formatted")
-func (a *Assertions) NotEqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotEqualValuesf(a.t, expected, actual, msg, args...)
-}
-
-// NotEqualf asserts that the specified values are NOT equal.
-//
-// a.NotEqualf(obj1, obj2, "error message %s", "formatted")
-//
-// Pointer variable equality is determined based on the equality of the
-// referenced values (as opposed to the memory addresses).
-func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotEqualf(a.t, expected, actual, msg, args...)
-}
-
-// NotErrorIs asserts that at none of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotErrorIs(a.t, err, target, msgAndArgs...)
-}
-
-// NotErrorIsf asserts that at none of the errors in err's chain matches target.
-// This is a wrapper for errors.Is.
-func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotErrorIsf(a.t, err, target, msg, args...)
-}
-
-// NotNil asserts that the specified object is not nil.
-//
-// a.NotNil(err)
-func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotNil(a.t, object, msgAndArgs...)
-}
-
-// NotNilf asserts that the specified object is not nil.
-//
-// a.NotNilf(err, "error message %s", "formatted")
-func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotNilf(a.t, object, msg, args...)
-}
-
-// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
-//
-// a.NotPanics(func(){ RemainCalm() })
-func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotPanics(a.t, f, msgAndArgs...)
-}
-
-// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
-//
-// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted")
-func (a *Assertions) NotPanicsf(f assert.PanicTestFunc, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotPanicsf(a.t, f, msg, args...)
-}
-
-// NotRegexp asserts that a specified regexp does not match a string.
-//
-// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
-// a.NotRegexp("^start", "it's not starting")
-func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotRegexp(a.t, rx, str, msgAndArgs...)
-}
-
-// NotRegexpf asserts that a specified regexp does not match a string.
-//
-// a.NotRegexpf(regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
-// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted")
-func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotRegexpf(a.t, rx, str, msg, args...)
-}
-
-// NotSame asserts that two pointers do not reference the same object.
-//
-// a.NotSame(ptr1, ptr2)
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func (a *Assertions) NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotSame(a.t, expected, actual, msgAndArgs...)
-}
-
-// NotSamef asserts that two pointers do not reference the same object.
-//
-// a.NotSamef(ptr1, ptr2, "error message %s", "formatted")
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func (a *Assertions) NotSamef(expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotSamef(a.t, expected, actual, msg, args...)
-}
-
-// NotSubset asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
-//
-// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
-func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotSubset(a.t, list, subset, msgAndArgs...)
-}
-
-// NotSubsetf asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
-//
-// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
-func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotSubsetf(a.t, list, subset, msg, args...)
-}
-
-// NotZero asserts that i is not the zero value for its type.
-func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotZero(a.t, i, msgAndArgs...)
-}
-
-// NotZerof asserts that i is not the zero value for its type.
-func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- NotZerof(a.t, i, msg, args...)
-}
-
-// Panics asserts that the code inside the specified PanicTestFunc panics.
-//
-// a.Panics(func(){ GoCrazy() })
-func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Panics(a.t, f, msgAndArgs...)
-}
-
-// PanicsWithError asserts that the code inside the specified PanicTestFunc
-// panics, and that the recovered panic value is an error that satisfies the
-// EqualError comparison.
-//
-// a.PanicsWithError("crazy error", func(){ GoCrazy() })
-func (a *Assertions) PanicsWithError(errString string, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- PanicsWithError(a.t, errString, f, msgAndArgs...)
-}
-
-// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc
-// panics, and that the recovered panic value is an error that satisfies the
-// EqualError comparison.
-//
-// a.PanicsWithErrorf("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
-func (a *Assertions) PanicsWithErrorf(errString string, f assert.PanicTestFunc, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- PanicsWithErrorf(a.t, errString, f, msg, args...)
-}
-
-// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
-// the recovered panic value equals the expected panic value.
-//
-// a.PanicsWithValue("crazy error", func(){ GoCrazy() })
-func (a *Assertions) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- PanicsWithValue(a.t, expected, f, msgAndArgs...)
-}
-
-// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
-// the recovered panic value equals the expected panic value.
-//
-// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
-func (a *Assertions) PanicsWithValuef(expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- PanicsWithValuef(a.t, expected, f, msg, args...)
-}
-
-// Panicsf asserts that the code inside the specified PanicTestFunc panics.
-//
-// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted")
-func (a *Assertions) Panicsf(f assert.PanicTestFunc, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Panicsf(a.t, f, msg, args...)
-}
-
-// Positive asserts that the specified element is positive
-//
-// a.Positive(1)
-// a.Positive(1.23)
-func (a *Assertions) Positive(e interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Positive(a.t, e, msgAndArgs...)
-}
-
-// Positivef asserts that the specified element is positive
-//
-// a.Positivef(1, "error message %s", "formatted")
-// a.Positivef(1.23, "error message %s", "formatted")
-func (a *Assertions) Positivef(e interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Positivef(a.t, e, msg, args...)
-}
-
-// Regexp asserts that a specified regexp matches a string.
-//
-// a.Regexp(regexp.MustCompile("start"), "it's starting")
-// a.Regexp("start...$", "it's not starting")
-func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Regexp(a.t, rx, str, msgAndArgs...)
-}
-
-// Regexpf asserts that a specified regexp matches a string.
-//
-// a.Regexpf(regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
-// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
-func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Regexpf(a.t, rx, str, msg, args...)
-}
-
-// Same asserts that two pointers reference the same object.
-//
-// a.Same(ptr1, ptr2)
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func (a *Assertions) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Same(a.t, expected, actual, msgAndArgs...)
-}
-
-// Samef asserts that two pointers reference the same object.
-//
-// a.Samef(ptr1, ptr2, "error message %s", "formatted")
-//
-// Both arguments must be pointer variables. Pointer variable sameness is
-// determined based on the equality of both type and value.
-func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Samef(a.t, expected, actual, msg, args...)
-}
-
-// Subset asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
-//
-// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
-func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Subset(a.t, list, subset, msgAndArgs...)
-}
-
-// Subsetf asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
-//
-// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
-func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Subsetf(a.t, list, subset, msg, args...)
-}
-
-// True asserts that the specified value is true.
-//
-// a.True(myBool)
-func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- True(a.t, value, msgAndArgs...)
-}
-
-// Truef asserts that the specified value is true.
-//
-// a.Truef(myBool, "error message %s", "formatted")
-func (a *Assertions) Truef(value bool, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Truef(a.t, value, msg, args...)
-}
-
-// WithinDuration asserts that the two times are within duration delta of each other.
-//
-// a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
-func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
-}
-
-// WithinDurationf asserts that the two times are within duration delta of each other.
-//
-// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
-func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- WithinDurationf(a.t, expected, actual, delta, msg, args...)
-}
-
-// WithinRange asserts that a time is within a time range (inclusive).
-//
-// a.WithinRange(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
-func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- WithinRange(a.t, actual, start, end, msgAndArgs...)
-}
-
-// WithinRangef asserts that a time is within a time range (inclusive).
-//
-// a.WithinRangef(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
-func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- WithinRangef(a.t, actual, start, end, msg, args...)
-}
-
-// YAMLEq asserts that two YAML strings are equivalent.
-func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- YAMLEq(a.t, expected, actual, msgAndArgs...)
-}
-
-// YAMLEqf asserts that two YAML strings are equivalent.
-func (a *Assertions) YAMLEqf(expected string, actual string, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- YAMLEqf(a.t, expected, actual, msg, args...)
-}
-
-// Zero asserts that i is the zero value for its type.
-func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Zero(a.t, i, msgAndArgs...)
-}
-
-// Zerof asserts that i is the zero value for its type.
-func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) {
- if h, ok := a.t.(tHelper); ok {
- h.Helper()
- }
- Zerof(a.t, i, msg, args...)
-}
diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl b/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl
deleted file mode 100644
index 54124df1..00000000
--- a/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl
+++ /dev/null
@@ -1,5 +0,0 @@
-{{.CommentWithoutT "a"}}
-func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) {
- if h, ok := a.t.(tHelper); ok { h.Helper() }
- {{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
-}
diff --git a/vendor/github.com/stretchr/testify/require/requirements.go b/vendor/github.com/stretchr/testify/require/requirements.go
deleted file mode 100644
index 91772dfe..00000000
--- a/vendor/github.com/stretchr/testify/require/requirements.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package require
-
-// TestingT is an interface wrapper around *testing.T
-type TestingT interface {
- Errorf(format string, args ...interface{})
- FailNow()
-}
-
-type tHelper interface {
- Helper()
-}
-
-// ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful
-// for table driven tests.
-type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{})
-
-// ValueAssertionFunc is a common function prototype when validating a single value. Can be useful
-// for table driven tests.
-type ValueAssertionFunc func(TestingT, interface{}, ...interface{})
-
-// BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful
-// for table driven tests.
-type BoolAssertionFunc func(TestingT, bool, ...interface{})
-
-// ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful
-// for table driven tests.
-type ErrorAssertionFunc func(TestingT, error, ...interface{})
-
-//go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require.go.tmpl -include-format-funcs"
diff --git a/vendor/gopkg.in/yaml.v3/LICENSE b/vendor/gopkg.in/yaml.v3/LICENSE
deleted file mode 100644
index 2683e4bb..00000000
--- a/vendor/gopkg.in/yaml.v3/LICENSE
+++ /dev/null
@@ -1,50 +0,0 @@
-
-This project is covered by two different licenses: MIT and Apache.
-
-#### MIT License ####
-
-The following files were ported to Go from C files of libyaml, and thus
-are still covered by their original MIT license, with the additional
-copyright staring in 2011 when the project was ported over:
-
- apic.go emitterc.go parserc.go readerc.go scannerc.go
- writerc.go yamlh.go yamlprivateh.go
-
-Copyright (c) 2006-2010 Kirill Simonov
-Copyright (c) 2006-2011 Kirill Simonov
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
-### Apache License ###
-
-All the remaining project files are covered by the Apache license:
-
-Copyright (c) 2011-2019 Canonical Ltd
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/vendor/gopkg.in/yaml.v3/NOTICE b/vendor/gopkg.in/yaml.v3/NOTICE
deleted file mode 100644
index 866d74a7..00000000
--- a/vendor/gopkg.in/yaml.v3/NOTICE
+++ /dev/null
@@ -1,13 +0,0 @@
-Copyright 2011-2016 Canonical Ltd.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/vendor/gopkg.in/yaml.v3/README.md b/vendor/gopkg.in/yaml.v3/README.md
deleted file mode 100644
index 08eb1bab..00000000
--- a/vendor/gopkg.in/yaml.v3/README.md
+++ /dev/null
@@ -1,150 +0,0 @@
-# YAML support for the Go language
-
-Introduction
-------------
-
-The yaml package enables Go programs to comfortably encode and decode YAML
-values. It was developed within [Canonical](https://www.canonical.com) as
-part of the [juju](https://juju.ubuntu.com) project, and is based on a
-pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML)
-C library to parse and generate YAML data quickly and reliably.
-
-Compatibility
--------------
-
-The yaml package supports most of YAML 1.2, but preserves some behavior
-from 1.1 for backwards compatibility.
-
-Specifically, as of v3 of the yaml package:
-
- - YAML 1.1 bools (_yes/no, on/off_) are supported as long as they are being
- decoded into a typed bool value. Otherwise they behave as a string. Booleans
- in YAML 1.2 are _true/false_ only.
- - Octals encode and decode as _0777_ per YAML 1.1, rather than _0o777_
- as specified in YAML 1.2, because most parsers still use the old format.
- Octals in the _0o777_ format are supported though, so new files work.
- - Does not support base-60 floats. These are gone from YAML 1.2, and were
- actually never supported by this package as it's clearly a poor choice.
-
-and offers backwards
-compatibility with YAML 1.1 in some cases.
-1.2, including support for
-anchors, tags, map merging, etc. Multi-document unmarshalling is not yet
-implemented, and base-60 floats from YAML 1.1 are purposefully not
-supported since they're a poor design and are gone in YAML 1.2.
-
-Installation and usage
-----------------------
-
-The import path for the package is *gopkg.in/yaml.v3*.
-
-To install it, run:
-
- go get gopkg.in/yaml.v3
-
-API documentation
------------------
-
-If opened in a browser, the import path itself leads to the API documentation:
-
- - [https://gopkg.in/yaml.v3](https://gopkg.in/yaml.v3)
-
-API stability
--------------
-
-The package API for yaml v3 will remain stable as described in [gopkg.in](https://gopkg.in).
-
-
-License
--------
-
-The yaml package is licensed under the MIT and Apache License 2.0 licenses.
-Please see the LICENSE file for details.
-
-
-Example
--------
-
-```Go
-package main
-
-import (
- "fmt"
- "log"
-
- "gopkg.in/yaml.v3"
-)
-
-var data = `
-a: Easy!
-b:
- c: 2
- d: [3, 4]
-`
-
-// Note: struct fields must be public in order for unmarshal to
-// correctly populate the data.
-type T struct {
- A string
- B struct {
- RenamedC int `yaml:"c"`
- D []int `yaml:",flow"`
- }
-}
-
-func main() {
- t := T{}
-
- err := yaml.Unmarshal([]byte(data), &t)
- if err != nil {
- log.Fatalf("error: %v", err)
- }
- fmt.Printf("--- t:\n%v\n\n", t)
-
- d, err := yaml.Marshal(&t)
- if err != nil {
- log.Fatalf("error: %v", err)
- }
- fmt.Printf("--- t dump:\n%s\n\n", string(d))
-
- m := make(map[interface{}]interface{})
-
- err = yaml.Unmarshal([]byte(data), &m)
- if err != nil {
- log.Fatalf("error: %v", err)
- }
- fmt.Printf("--- m:\n%v\n\n", m)
-
- d, err = yaml.Marshal(&m)
- if err != nil {
- log.Fatalf("error: %v", err)
- }
- fmt.Printf("--- m dump:\n%s\n\n", string(d))
-}
-```
-
-This example will generate the following output:
-
-```
---- t:
-{Easy! {2 [3 4]}}
-
---- t dump:
-a: Easy!
-b:
- c: 2
- d: [3, 4]
-
-
---- m:
-map[a:Easy! b:map[c:2 d:[3 4]]]
-
---- m dump:
-a: Easy!
-b:
- c: 2
- d:
- - 3
- - 4
-```
-
diff --git a/vendor/gopkg.in/yaml.v3/apic.go b/vendor/gopkg.in/yaml.v3/apic.go
deleted file mode 100644
index ae7d049f..00000000
--- a/vendor/gopkg.in/yaml.v3/apic.go
+++ /dev/null
@@ -1,747 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-// Copyright (c) 2006-2010 Kirill Simonov
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-package yaml
-
-import (
- "io"
-)
-
-func yaml_insert_token(parser *yaml_parser_t, pos int, token *yaml_token_t) {
- //fmt.Println("yaml_insert_token", "pos:", pos, "typ:", token.typ, "head:", parser.tokens_head, "len:", len(parser.tokens))
-
- // Check if we can move the queue at the beginning of the buffer.
- if parser.tokens_head > 0 && len(parser.tokens) == cap(parser.tokens) {
- if parser.tokens_head != len(parser.tokens) {
- copy(parser.tokens, parser.tokens[parser.tokens_head:])
- }
- parser.tokens = parser.tokens[:len(parser.tokens)-parser.tokens_head]
- parser.tokens_head = 0
- }
- parser.tokens = append(parser.tokens, *token)
- if pos < 0 {
- return
- }
- copy(parser.tokens[parser.tokens_head+pos+1:], parser.tokens[parser.tokens_head+pos:])
- parser.tokens[parser.tokens_head+pos] = *token
-}
-
-// Create a new parser object.
-func yaml_parser_initialize(parser *yaml_parser_t) bool {
- *parser = yaml_parser_t{
- raw_buffer: make([]byte, 0, input_raw_buffer_size),
- buffer: make([]byte, 0, input_buffer_size),
- }
- return true
-}
-
-// Destroy a parser object.
-func yaml_parser_delete(parser *yaml_parser_t) {
- *parser = yaml_parser_t{}
-}
-
-// String read handler.
-func yaml_string_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) {
- if parser.input_pos == len(parser.input) {
- return 0, io.EOF
- }
- n = copy(buffer, parser.input[parser.input_pos:])
- parser.input_pos += n
- return n, nil
-}
-
-// Reader read handler.
-func yaml_reader_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) {
- return parser.input_reader.Read(buffer)
-}
-
-// Set a string input.
-func yaml_parser_set_input_string(parser *yaml_parser_t, input []byte) {
- if parser.read_handler != nil {
- panic("must set the input source only once")
- }
- parser.read_handler = yaml_string_read_handler
- parser.input = input
- parser.input_pos = 0
-}
-
-// Set a file input.
-func yaml_parser_set_input_reader(parser *yaml_parser_t, r io.Reader) {
- if parser.read_handler != nil {
- panic("must set the input source only once")
- }
- parser.read_handler = yaml_reader_read_handler
- parser.input_reader = r
-}
-
-// Set the source encoding.
-func yaml_parser_set_encoding(parser *yaml_parser_t, encoding yaml_encoding_t) {
- if parser.encoding != yaml_ANY_ENCODING {
- panic("must set the encoding only once")
- }
- parser.encoding = encoding
-}
-
-// Create a new emitter object.
-func yaml_emitter_initialize(emitter *yaml_emitter_t) {
- *emitter = yaml_emitter_t{
- buffer: make([]byte, output_buffer_size),
- raw_buffer: make([]byte, 0, output_raw_buffer_size),
- states: make([]yaml_emitter_state_t, 0, initial_stack_size),
- events: make([]yaml_event_t, 0, initial_queue_size),
- best_width: -1,
- }
-}
-
-// Destroy an emitter object.
-func yaml_emitter_delete(emitter *yaml_emitter_t) {
- *emitter = yaml_emitter_t{}
-}
-
-// String write handler.
-func yaml_string_write_handler(emitter *yaml_emitter_t, buffer []byte) error {
- *emitter.output_buffer = append(*emitter.output_buffer, buffer...)
- return nil
-}
-
-// yaml_writer_write_handler uses emitter.output_writer to write the
-// emitted text.
-func yaml_writer_write_handler(emitter *yaml_emitter_t, buffer []byte) error {
- _, err := emitter.output_writer.Write(buffer)
- return err
-}
-
-// Set a string output.
-func yaml_emitter_set_output_string(emitter *yaml_emitter_t, output_buffer *[]byte) {
- if emitter.write_handler != nil {
- panic("must set the output target only once")
- }
- emitter.write_handler = yaml_string_write_handler
- emitter.output_buffer = output_buffer
-}
-
-// Set a file output.
-func yaml_emitter_set_output_writer(emitter *yaml_emitter_t, w io.Writer) {
- if emitter.write_handler != nil {
- panic("must set the output target only once")
- }
- emitter.write_handler = yaml_writer_write_handler
- emitter.output_writer = w
-}
-
-// Set the output encoding.
-func yaml_emitter_set_encoding(emitter *yaml_emitter_t, encoding yaml_encoding_t) {
- if emitter.encoding != yaml_ANY_ENCODING {
- panic("must set the output encoding only once")
- }
- emitter.encoding = encoding
-}
-
-// Set the canonical output style.
-func yaml_emitter_set_canonical(emitter *yaml_emitter_t, canonical bool) {
- emitter.canonical = canonical
-}
-
-// Set the indentation increment.
-func yaml_emitter_set_indent(emitter *yaml_emitter_t, indent int) {
- if indent < 2 || indent > 9 {
- indent = 2
- }
- emitter.best_indent = indent
-}
-
-// Set the preferred line width.
-func yaml_emitter_set_width(emitter *yaml_emitter_t, width int) {
- if width < 0 {
- width = -1
- }
- emitter.best_width = width
-}
-
-// Set if unescaped non-ASCII characters are allowed.
-func yaml_emitter_set_unicode(emitter *yaml_emitter_t, unicode bool) {
- emitter.unicode = unicode
-}
-
-// Set the preferred line break character.
-func yaml_emitter_set_break(emitter *yaml_emitter_t, line_break yaml_break_t) {
- emitter.line_break = line_break
-}
-
-///*
-// * Destroy a token object.
-// */
-//
-//YAML_DECLARE(void)
-//yaml_token_delete(yaml_token_t *token)
-//{
-// assert(token); // Non-NULL token object expected.
-//
-// switch (token.type)
-// {
-// case YAML_TAG_DIRECTIVE_TOKEN:
-// yaml_free(token.data.tag_directive.handle);
-// yaml_free(token.data.tag_directive.prefix);
-// break;
-//
-// case YAML_ALIAS_TOKEN:
-// yaml_free(token.data.alias.value);
-// break;
-//
-// case YAML_ANCHOR_TOKEN:
-// yaml_free(token.data.anchor.value);
-// break;
-//
-// case YAML_TAG_TOKEN:
-// yaml_free(token.data.tag.handle);
-// yaml_free(token.data.tag.suffix);
-// break;
-//
-// case YAML_SCALAR_TOKEN:
-// yaml_free(token.data.scalar.value);
-// break;
-//
-// default:
-// break;
-// }
-//
-// memset(token, 0, sizeof(yaml_token_t));
-//}
-//
-///*
-// * Check if a string is a valid UTF-8 sequence.
-// *
-// * Check 'reader.c' for more details on UTF-8 encoding.
-// */
-//
-//static int
-//yaml_check_utf8(yaml_char_t *start, size_t length)
-//{
-// yaml_char_t *end = start+length;
-// yaml_char_t *pointer = start;
-//
-// while (pointer < end) {
-// unsigned char octet;
-// unsigned int width;
-// unsigned int value;
-// size_t k;
-//
-// octet = pointer[0];
-// width = (octet & 0x80) == 0x00 ? 1 :
-// (octet & 0xE0) == 0xC0 ? 2 :
-// (octet & 0xF0) == 0xE0 ? 3 :
-// (octet & 0xF8) == 0xF0 ? 4 : 0;
-// value = (octet & 0x80) == 0x00 ? octet & 0x7F :
-// (octet & 0xE0) == 0xC0 ? octet & 0x1F :
-// (octet & 0xF0) == 0xE0 ? octet & 0x0F :
-// (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;
-// if (!width) return 0;
-// if (pointer+width > end) return 0;
-// for (k = 1; k < width; k ++) {
-// octet = pointer[k];
-// if ((octet & 0xC0) != 0x80) return 0;
-// value = (value << 6) + (octet & 0x3F);
-// }
-// if (!((width == 1) ||
-// (width == 2 && value >= 0x80) ||
-// (width == 3 && value >= 0x800) ||
-// (width == 4 && value >= 0x10000))) return 0;
-//
-// pointer += width;
-// }
-//
-// return 1;
-//}
-//
-
-// Create STREAM-START.
-func yaml_stream_start_event_initialize(event *yaml_event_t, encoding yaml_encoding_t) {
- *event = yaml_event_t{
- typ: yaml_STREAM_START_EVENT,
- encoding: encoding,
- }
-}
-
-// Create STREAM-END.
-func yaml_stream_end_event_initialize(event *yaml_event_t) {
- *event = yaml_event_t{
- typ: yaml_STREAM_END_EVENT,
- }
-}
-
-// Create DOCUMENT-START.
-func yaml_document_start_event_initialize(
- event *yaml_event_t,
- version_directive *yaml_version_directive_t,
- tag_directives []yaml_tag_directive_t,
- implicit bool,
-) {
- *event = yaml_event_t{
- typ: yaml_DOCUMENT_START_EVENT,
- version_directive: version_directive,
- tag_directives: tag_directives,
- implicit: implicit,
- }
-}
-
-// Create DOCUMENT-END.
-func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) {
- *event = yaml_event_t{
- typ: yaml_DOCUMENT_END_EVENT,
- implicit: implicit,
- }
-}
-
-// Create ALIAS.
-func yaml_alias_event_initialize(event *yaml_event_t, anchor []byte) bool {
- *event = yaml_event_t{
- typ: yaml_ALIAS_EVENT,
- anchor: anchor,
- }
- return true
-}
-
-// Create SCALAR.
-func yaml_scalar_event_initialize(event *yaml_event_t, anchor, tag, value []byte, plain_implicit, quoted_implicit bool, style yaml_scalar_style_t) bool {
- *event = yaml_event_t{
- typ: yaml_SCALAR_EVENT,
- anchor: anchor,
- tag: tag,
- value: value,
- implicit: plain_implicit,
- quoted_implicit: quoted_implicit,
- style: yaml_style_t(style),
- }
- return true
-}
-
-// Create SEQUENCE-START.
-func yaml_sequence_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_sequence_style_t) bool {
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_START_EVENT,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(style),
- }
- return true
-}
-
-// Create SEQUENCE-END.
-func yaml_sequence_end_event_initialize(event *yaml_event_t) bool {
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_END_EVENT,
- }
- return true
-}
-
-// Create MAPPING-START.
-func yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_mapping_style_t) {
- *event = yaml_event_t{
- typ: yaml_MAPPING_START_EVENT,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(style),
- }
-}
-
-// Create MAPPING-END.
-func yaml_mapping_end_event_initialize(event *yaml_event_t) {
- *event = yaml_event_t{
- typ: yaml_MAPPING_END_EVENT,
- }
-}
-
-// Destroy an event object.
-func yaml_event_delete(event *yaml_event_t) {
- *event = yaml_event_t{}
-}
-
-///*
-// * Create a document object.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_document_initialize(document *yaml_document_t,
-// version_directive *yaml_version_directive_t,
-// tag_directives_start *yaml_tag_directive_t,
-// tag_directives_end *yaml_tag_directive_t,
-// start_implicit int, end_implicit int)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-// struct {
-// start *yaml_node_t
-// end *yaml_node_t
-// top *yaml_node_t
-// } nodes = { NULL, NULL, NULL }
-// version_directive_copy *yaml_version_directive_t = NULL
-// struct {
-// start *yaml_tag_directive_t
-// end *yaml_tag_directive_t
-// top *yaml_tag_directive_t
-// } tag_directives_copy = { NULL, NULL, NULL }
-// value yaml_tag_directive_t = { NULL, NULL }
-// mark yaml_mark_t = { 0, 0, 0 }
-//
-// assert(document) // Non-NULL document object is expected.
-// assert((tag_directives_start && tag_directives_end) ||
-// (tag_directives_start == tag_directives_end))
-// // Valid tag directives are expected.
-//
-// if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error
-//
-// if (version_directive) {
-// version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t))
-// if (!version_directive_copy) goto error
-// version_directive_copy.major = version_directive.major
-// version_directive_copy.minor = version_directive.minor
-// }
-//
-// if (tag_directives_start != tag_directives_end) {
-// tag_directive *yaml_tag_directive_t
-// if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE))
-// goto error
-// for (tag_directive = tag_directives_start
-// tag_directive != tag_directives_end; tag_directive ++) {
-// assert(tag_directive.handle)
-// assert(tag_directive.prefix)
-// if (!yaml_check_utf8(tag_directive.handle,
-// strlen((char *)tag_directive.handle)))
-// goto error
-// if (!yaml_check_utf8(tag_directive.prefix,
-// strlen((char *)tag_directive.prefix)))
-// goto error
-// value.handle = yaml_strdup(tag_directive.handle)
-// value.prefix = yaml_strdup(tag_directive.prefix)
-// if (!value.handle || !value.prefix) goto error
-// if (!PUSH(&context, tag_directives_copy, value))
-// goto error
-// value.handle = NULL
-// value.prefix = NULL
-// }
-// }
-//
-// DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy,
-// tag_directives_copy.start, tag_directives_copy.top,
-// start_implicit, end_implicit, mark, mark)
-//
-// return 1
-//
-//error:
-// STACK_DEL(&context, nodes)
-// yaml_free(version_directive_copy)
-// while (!STACK_EMPTY(&context, tag_directives_copy)) {
-// value yaml_tag_directive_t = POP(&context, tag_directives_copy)
-// yaml_free(value.handle)
-// yaml_free(value.prefix)
-// }
-// STACK_DEL(&context, tag_directives_copy)
-// yaml_free(value.handle)
-// yaml_free(value.prefix)
-//
-// return 0
-//}
-//
-///*
-// * Destroy a document object.
-// */
-//
-//YAML_DECLARE(void)
-//yaml_document_delete(document *yaml_document_t)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-// tag_directive *yaml_tag_directive_t
-//
-// context.error = YAML_NO_ERROR // Eliminate a compiler warning.
-//
-// assert(document) // Non-NULL document object is expected.
-//
-// while (!STACK_EMPTY(&context, document.nodes)) {
-// node yaml_node_t = POP(&context, document.nodes)
-// yaml_free(node.tag)
-// switch (node.type) {
-// case YAML_SCALAR_NODE:
-// yaml_free(node.data.scalar.value)
-// break
-// case YAML_SEQUENCE_NODE:
-// STACK_DEL(&context, node.data.sequence.items)
-// break
-// case YAML_MAPPING_NODE:
-// STACK_DEL(&context, node.data.mapping.pairs)
-// break
-// default:
-// assert(0) // Should not happen.
-// }
-// }
-// STACK_DEL(&context, document.nodes)
-//
-// yaml_free(document.version_directive)
-// for (tag_directive = document.tag_directives.start
-// tag_directive != document.tag_directives.end
-// tag_directive++) {
-// yaml_free(tag_directive.handle)
-// yaml_free(tag_directive.prefix)
-// }
-// yaml_free(document.tag_directives.start)
-//
-// memset(document, 0, sizeof(yaml_document_t))
-//}
-//
-///**
-// * Get a document node.
-// */
-//
-//YAML_DECLARE(yaml_node_t *)
-//yaml_document_get_node(document *yaml_document_t, index int)
-//{
-// assert(document) // Non-NULL document object is expected.
-//
-// if (index > 0 && document.nodes.start + index <= document.nodes.top) {
-// return document.nodes.start + index - 1
-// }
-// return NULL
-//}
-//
-///**
-// * Get the root object.
-// */
-//
-//YAML_DECLARE(yaml_node_t *)
-//yaml_document_get_root_node(document *yaml_document_t)
-//{
-// assert(document) // Non-NULL document object is expected.
-//
-// if (document.nodes.top != document.nodes.start) {
-// return document.nodes.start
-// }
-// return NULL
-//}
-//
-///*
-// * Add a scalar node to a document.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_document_add_scalar(document *yaml_document_t,
-// tag *yaml_char_t, value *yaml_char_t, length int,
-// style yaml_scalar_style_t)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-// mark yaml_mark_t = { 0, 0, 0 }
-// tag_copy *yaml_char_t = NULL
-// value_copy *yaml_char_t = NULL
-// node yaml_node_t
-//
-// assert(document) // Non-NULL document object is expected.
-// assert(value) // Non-NULL value is expected.
-//
-// if (!tag) {
-// tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG
-// }
-//
-// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error
-// tag_copy = yaml_strdup(tag)
-// if (!tag_copy) goto error
-//
-// if (length < 0) {
-// length = strlen((char *)value)
-// }
-//
-// if (!yaml_check_utf8(value, length)) goto error
-// value_copy = yaml_malloc(length+1)
-// if (!value_copy) goto error
-// memcpy(value_copy, value, length)
-// value_copy[length] = '\0'
-//
-// SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark)
-// if (!PUSH(&context, document.nodes, node)) goto error
-//
-// return document.nodes.top - document.nodes.start
-//
-//error:
-// yaml_free(tag_copy)
-// yaml_free(value_copy)
-//
-// return 0
-//}
-//
-///*
-// * Add a sequence node to a document.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_document_add_sequence(document *yaml_document_t,
-// tag *yaml_char_t, style yaml_sequence_style_t)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-// mark yaml_mark_t = { 0, 0, 0 }
-// tag_copy *yaml_char_t = NULL
-// struct {
-// start *yaml_node_item_t
-// end *yaml_node_item_t
-// top *yaml_node_item_t
-// } items = { NULL, NULL, NULL }
-// node yaml_node_t
-//
-// assert(document) // Non-NULL document object is expected.
-//
-// if (!tag) {
-// tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG
-// }
-//
-// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error
-// tag_copy = yaml_strdup(tag)
-// if (!tag_copy) goto error
-//
-// if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error
-//
-// SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end,
-// style, mark, mark)
-// if (!PUSH(&context, document.nodes, node)) goto error
-//
-// return document.nodes.top - document.nodes.start
-//
-//error:
-// STACK_DEL(&context, items)
-// yaml_free(tag_copy)
-//
-// return 0
-//}
-//
-///*
-// * Add a mapping node to a document.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_document_add_mapping(document *yaml_document_t,
-// tag *yaml_char_t, style yaml_mapping_style_t)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-// mark yaml_mark_t = { 0, 0, 0 }
-// tag_copy *yaml_char_t = NULL
-// struct {
-// start *yaml_node_pair_t
-// end *yaml_node_pair_t
-// top *yaml_node_pair_t
-// } pairs = { NULL, NULL, NULL }
-// node yaml_node_t
-//
-// assert(document) // Non-NULL document object is expected.
-//
-// if (!tag) {
-// tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG
-// }
-//
-// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error
-// tag_copy = yaml_strdup(tag)
-// if (!tag_copy) goto error
-//
-// if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error
-//
-// MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end,
-// style, mark, mark)
-// if (!PUSH(&context, document.nodes, node)) goto error
-//
-// return document.nodes.top - document.nodes.start
-//
-//error:
-// STACK_DEL(&context, pairs)
-// yaml_free(tag_copy)
-//
-// return 0
-//}
-//
-///*
-// * Append an item to a sequence node.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_document_append_sequence_item(document *yaml_document_t,
-// sequence int, item int)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-//
-// assert(document) // Non-NULL document is required.
-// assert(sequence > 0
-// && document.nodes.start + sequence <= document.nodes.top)
-// // Valid sequence id is required.
-// assert(document.nodes.start[sequence-1].type == YAML_SEQUENCE_NODE)
-// // A sequence node is required.
-// assert(item > 0 && document.nodes.start + item <= document.nodes.top)
-// // Valid item id is required.
-//
-// if (!PUSH(&context,
-// document.nodes.start[sequence-1].data.sequence.items, item))
-// return 0
-//
-// return 1
-//}
-//
-///*
-// * Append a pair of a key and a value to a mapping node.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_document_append_mapping_pair(document *yaml_document_t,
-// mapping int, key int, value int)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-//
-// pair yaml_node_pair_t
-//
-// assert(document) // Non-NULL document is required.
-// assert(mapping > 0
-// && document.nodes.start + mapping <= document.nodes.top)
-// // Valid mapping id is required.
-// assert(document.nodes.start[mapping-1].type == YAML_MAPPING_NODE)
-// // A mapping node is required.
-// assert(key > 0 && document.nodes.start + key <= document.nodes.top)
-// // Valid key id is required.
-// assert(value > 0 && document.nodes.start + value <= document.nodes.top)
-// // Valid value id is required.
-//
-// pair.key = key
-// pair.value = value
-//
-// if (!PUSH(&context,
-// document.nodes.start[mapping-1].data.mapping.pairs, pair))
-// return 0
-//
-// return 1
-//}
-//
-//
diff --git a/vendor/gopkg.in/yaml.v3/decode.go b/vendor/gopkg.in/yaml.v3/decode.go
deleted file mode 100644
index 0173b698..00000000
--- a/vendor/gopkg.in/yaml.v3/decode.go
+++ /dev/null
@@ -1,1000 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package yaml
-
-import (
- "encoding"
- "encoding/base64"
- "fmt"
- "io"
- "math"
- "reflect"
- "strconv"
- "time"
-)
-
-// ----------------------------------------------------------------------------
-// Parser, produces a node tree out of a libyaml event stream.
-
-type parser struct {
- parser yaml_parser_t
- event yaml_event_t
- doc *Node
- anchors map[string]*Node
- doneInit bool
- textless bool
-}
-
-func newParser(b []byte) *parser {
- p := parser{}
- if !yaml_parser_initialize(&p.parser) {
- panic("failed to initialize YAML emitter")
- }
- if len(b) == 0 {
- b = []byte{'\n'}
- }
- yaml_parser_set_input_string(&p.parser, b)
- return &p
-}
-
-func newParserFromReader(r io.Reader) *parser {
- p := parser{}
- if !yaml_parser_initialize(&p.parser) {
- panic("failed to initialize YAML emitter")
- }
- yaml_parser_set_input_reader(&p.parser, r)
- return &p
-}
-
-func (p *parser) init() {
- if p.doneInit {
- return
- }
- p.anchors = make(map[string]*Node)
- p.expect(yaml_STREAM_START_EVENT)
- p.doneInit = true
-}
-
-func (p *parser) destroy() {
- if p.event.typ != yaml_NO_EVENT {
- yaml_event_delete(&p.event)
- }
- yaml_parser_delete(&p.parser)
-}
-
-// expect consumes an event from the event stream and
-// checks that it's of the expected type.
-func (p *parser) expect(e yaml_event_type_t) {
- if p.event.typ == yaml_NO_EVENT {
- if !yaml_parser_parse(&p.parser, &p.event) {
- p.fail()
- }
- }
- if p.event.typ == yaml_STREAM_END_EVENT {
- failf("attempted to go past the end of stream; corrupted value?")
- }
- if p.event.typ != e {
- p.parser.problem = fmt.Sprintf("expected %s event but got %s", e, p.event.typ)
- p.fail()
- }
- yaml_event_delete(&p.event)
- p.event.typ = yaml_NO_EVENT
-}
-
-// peek peeks at the next event in the event stream,
-// puts the results into p.event and returns the event type.
-func (p *parser) peek() yaml_event_type_t {
- if p.event.typ != yaml_NO_EVENT {
- return p.event.typ
- }
- // It's curious choice from the underlying API to generally return a
- // positive result on success, but on this case return true in an error
- // scenario. This was the source of bugs in the past (issue #666).
- if !yaml_parser_parse(&p.parser, &p.event) || p.parser.error != yaml_NO_ERROR {
- p.fail()
- }
- return p.event.typ
-}
-
-func (p *parser) fail() {
- var where string
- var line int
- if p.parser.context_mark.line != 0 {
- line = p.parser.context_mark.line
- // Scanner errors don't iterate line before returning error
- if p.parser.error == yaml_SCANNER_ERROR {
- line++
- }
- } else if p.parser.problem_mark.line != 0 {
- line = p.parser.problem_mark.line
- // Scanner errors don't iterate line before returning error
- if p.parser.error == yaml_SCANNER_ERROR {
- line++
- }
- }
- if line != 0 {
- where = "line " + strconv.Itoa(line) + ": "
- }
- var msg string
- if len(p.parser.problem) > 0 {
- msg = p.parser.problem
- } else {
- msg = "unknown problem parsing YAML content"
- }
- failf("%s%s", where, msg)
-}
-
-func (p *parser) anchor(n *Node, anchor []byte) {
- if anchor != nil {
- n.Anchor = string(anchor)
- p.anchors[n.Anchor] = n
- }
-}
-
-func (p *parser) parse() *Node {
- p.init()
- switch p.peek() {
- case yaml_SCALAR_EVENT:
- return p.scalar()
- case yaml_ALIAS_EVENT:
- return p.alias()
- case yaml_MAPPING_START_EVENT:
- return p.mapping()
- case yaml_SEQUENCE_START_EVENT:
- return p.sequence()
- case yaml_DOCUMENT_START_EVENT:
- return p.document()
- case yaml_STREAM_END_EVENT:
- // Happens when attempting to decode an empty buffer.
- return nil
- case yaml_TAIL_COMMENT_EVENT:
- panic("internal error: unexpected tail comment event (please report)")
- default:
- panic("internal error: attempted to parse unknown event (please report): " + p.event.typ.String())
- }
-}
-
-func (p *parser) node(kind Kind, defaultTag, tag, value string) *Node {
- var style Style
- if tag != "" && tag != "!" {
- tag = shortTag(tag)
- style = TaggedStyle
- } else if defaultTag != "" {
- tag = defaultTag
- } else if kind == ScalarNode {
- tag, _ = resolve("", value)
- }
- n := &Node{
- Kind: kind,
- Tag: tag,
- Value: value,
- Style: style,
- }
- if !p.textless {
- n.Line = p.event.start_mark.line + 1
- n.Column = p.event.start_mark.column + 1
- n.HeadComment = string(p.event.head_comment)
- n.LineComment = string(p.event.line_comment)
- n.FootComment = string(p.event.foot_comment)
- }
- return n
-}
-
-func (p *parser) parseChild(parent *Node) *Node {
- child := p.parse()
- parent.Content = append(parent.Content, child)
- return child
-}
-
-func (p *parser) document() *Node {
- n := p.node(DocumentNode, "", "", "")
- p.doc = n
- p.expect(yaml_DOCUMENT_START_EVENT)
- p.parseChild(n)
- if p.peek() == yaml_DOCUMENT_END_EVENT {
- n.FootComment = string(p.event.foot_comment)
- }
- p.expect(yaml_DOCUMENT_END_EVENT)
- return n
-}
-
-func (p *parser) alias() *Node {
- n := p.node(AliasNode, "", "", string(p.event.anchor))
- n.Alias = p.anchors[n.Value]
- if n.Alias == nil {
- failf("unknown anchor '%s' referenced", n.Value)
- }
- p.expect(yaml_ALIAS_EVENT)
- return n
-}
-
-func (p *parser) scalar() *Node {
- var parsedStyle = p.event.scalar_style()
- var nodeStyle Style
- switch {
- case parsedStyle&yaml_DOUBLE_QUOTED_SCALAR_STYLE != 0:
- nodeStyle = DoubleQuotedStyle
- case parsedStyle&yaml_SINGLE_QUOTED_SCALAR_STYLE != 0:
- nodeStyle = SingleQuotedStyle
- case parsedStyle&yaml_LITERAL_SCALAR_STYLE != 0:
- nodeStyle = LiteralStyle
- case parsedStyle&yaml_FOLDED_SCALAR_STYLE != 0:
- nodeStyle = FoldedStyle
- }
- var nodeValue = string(p.event.value)
- var nodeTag = string(p.event.tag)
- var defaultTag string
- if nodeStyle == 0 {
- if nodeValue == "<<" {
- defaultTag = mergeTag
- }
- } else {
- defaultTag = strTag
- }
- n := p.node(ScalarNode, defaultTag, nodeTag, nodeValue)
- n.Style |= nodeStyle
- p.anchor(n, p.event.anchor)
- p.expect(yaml_SCALAR_EVENT)
- return n
-}
-
-func (p *parser) sequence() *Node {
- n := p.node(SequenceNode, seqTag, string(p.event.tag), "")
- if p.event.sequence_style()&yaml_FLOW_SEQUENCE_STYLE != 0 {
- n.Style |= FlowStyle
- }
- p.anchor(n, p.event.anchor)
- p.expect(yaml_SEQUENCE_START_EVENT)
- for p.peek() != yaml_SEQUENCE_END_EVENT {
- p.parseChild(n)
- }
- n.LineComment = string(p.event.line_comment)
- n.FootComment = string(p.event.foot_comment)
- p.expect(yaml_SEQUENCE_END_EVENT)
- return n
-}
-
-func (p *parser) mapping() *Node {
- n := p.node(MappingNode, mapTag, string(p.event.tag), "")
- block := true
- if p.event.mapping_style()&yaml_FLOW_MAPPING_STYLE != 0 {
- block = false
- n.Style |= FlowStyle
- }
- p.anchor(n, p.event.anchor)
- p.expect(yaml_MAPPING_START_EVENT)
- for p.peek() != yaml_MAPPING_END_EVENT {
- k := p.parseChild(n)
- if block && k.FootComment != "" {
- // Must be a foot comment for the prior value when being dedented.
- if len(n.Content) > 2 {
- n.Content[len(n.Content)-3].FootComment = k.FootComment
- k.FootComment = ""
- }
- }
- v := p.parseChild(n)
- if k.FootComment == "" && v.FootComment != "" {
- k.FootComment = v.FootComment
- v.FootComment = ""
- }
- if p.peek() == yaml_TAIL_COMMENT_EVENT {
- if k.FootComment == "" {
- k.FootComment = string(p.event.foot_comment)
- }
- p.expect(yaml_TAIL_COMMENT_EVENT)
- }
- }
- n.LineComment = string(p.event.line_comment)
- n.FootComment = string(p.event.foot_comment)
- if n.Style&FlowStyle == 0 && n.FootComment != "" && len(n.Content) > 1 {
- n.Content[len(n.Content)-2].FootComment = n.FootComment
- n.FootComment = ""
- }
- p.expect(yaml_MAPPING_END_EVENT)
- return n
-}
-
-// ----------------------------------------------------------------------------
-// Decoder, unmarshals a node into a provided value.
-
-type decoder struct {
- doc *Node
- aliases map[*Node]bool
- terrors []string
-
- stringMapType reflect.Type
- generalMapType reflect.Type
-
- knownFields bool
- uniqueKeys bool
- decodeCount int
- aliasCount int
- aliasDepth int
-
- mergedFields map[interface{}]bool
-}
-
-var (
- nodeType = reflect.TypeOf(Node{})
- durationType = reflect.TypeOf(time.Duration(0))
- stringMapType = reflect.TypeOf(map[string]interface{}{})
- generalMapType = reflect.TypeOf(map[interface{}]interface{}{})
- ifaceType = generalMapType.Elem()
- timeType = reflect.TypeOf(time.Time{})
- ptrTimeType = reflect.TypeOf(&time.Time{})
-)
-
-func newDecoder() *decoder {
- d := &decoder{
- stringMapType: stringMapType,
- generalMapType: generalMapType,
- uniqueKeys: true,
- }
- d.aliases = make(map[*Node]bool)
- return d
-}
-
-func (d *decoder) terror(n *Node, tag string, out reflect.Value) {
- if n.Tag != "" {
- tag = n.Tag
- }
- value := n.Value
- if tag != seqTag && tag != mapTag {
- if len(value) > 10 {
- value = " `" + value[:7] + "...`"
- } else {
- value = " `" + value + "`"
- }
- }
- d.terrors = append(d.terrors, fmt.Sprintf("line %d: cannot unmarshal %s%s into %s", n.Line, shortTag(tag), value, out.Type()))
-}
-
-func (d *decoder) callUnmarshaler(n *Node, u Unmarshaler) (good bool) {
- err := u.UnmarshalYAML(n)
- if e, ok := err.(*TypeError); ok {
- d.terrors = append(d.terrors, e.Errors...)
- return false
- }
- if err != nil {
- fail(err)
- }
- return true
-}
-
-func (d *decoder) callObsoleteUnmarshaler(n *Node, u obsoleteUnmarshaler) (good bool) {
- terrlen := len(d.terrors)
- err := u.UnmarshalYAML(func(v interface{}) (err error) {
- defer handleErr(&err)
- d.unmarshal(n, reflect.ValueOf(v))
- if len(d.terrors) > terrlen {
- issues := d.terrors[terrlen:]
- d.terrors = d.terrors[:terrlen]
- return &TypeError{issues}
- }
- return nil
- })
- if e, ok := err.(*TypeError); ok {
- d.terrors = append(d.terrors, e.Errors...)
- return false
- }
- if err != nil {
- fail(err)
- }
- return true
-}
-
-// d.prepare initializes and dereferences pointers and calls UnmarshalYAML
-// if a value is found to implement it.
-// It returns the initialized and dereferenced out value, whether
-// unmarshalling was already done by UnmarshalYAML, and if so whether
-// its types unmarshalled appropriately.
-//
-// If n holds a null value, prepare returns before doing anything.
-func (d *decoder) prepare(n *Node, out reflect.Value) (newout reflect.Value, unmarshaled, good bool) {
- if n.ShortTag() == nullTag {
- return out, false, false
- }
- again := true
- for again {
- again = false
- if out.Kind() == reflect.Ptr {
- if out.IsNil() {
- out.Set(reflect.New(out.Type().Elem()))
- }
- out = out.Elem()
- again = true
- }
- if out.CanAddr() {
- outi := out.Addr().Interface()
- if u, ok := outi.(Unmarshaler); ok {
- good = d.callUnmarshaler(n, u)
- return out, true, good
- }
- if u, ok := outi.(obsoleteUnmarshaler); ok {
- good = d.callObsoleteUnmarshaler(n, u)
- return out, true, good
- }
- }
- }
- return out, false, false
-}
-
-func (d *decoder) fieldByIndex(n *Node, v reflect.Value, index []int) (field reflect.Value) {
- if n.ShortTag() == nullTag {
- return reflect.Value{}
- }
- for _, num := range index {
- for {
- if v.Kind() == reflect.Ptr {
- if v.IsNil() {
- v.Set(reflect.New(v.Type().Elem()))
- }
- v = v.Elem()
- continue
- }
- break
- }
- v = v.Field(num)
- }
- return v
-}
-
-const (
- // 400,000 decode operations is ~500kb of dense object declarations, or
- // ~5kb of dense object declarations with 10000% alias expansion
- alias_ratio_range_low = 400000
-
- // 4,000,000 decode operations is ~5MB of dense object declarations, or
- // ~4.5MB of dense object declarations with 10% alias expansion
- alias_ratio_range_high = 4000000
-
- // alias_ratio_range is the range over which we scale allowed alias ratios
- alias_ratio_range = float64(alias_ratio_range_high - alias_ratio_range_low)
-)
-
-func allowedAliasRatio(decodeCount int) float64 {
- switch {
- case decodeCount <= alias_ratio_range_low:
- // allow 99% to come from alias expansion for small-to-medium documents
- return 0.99
- case decodeCount >= alias_ratio_range_high:
- // allow 10% to come from alias expansion for very large documents
- return 0.10
- default:
- // scale smoothly from 99% down to 10% over the range.
- // this maps to 396,000 - 400,000 allowed alias-driven decodes over the range.
- // 400,000 decode operations is ~100MB of allocations in worst-case scenarios (single-item maps).
- return 0.99 - 0.89*(float64(decodeCount-alias_ratio_range_low)/alias_ratio_range)
- }
-}
-
-func (d *decoder) unmarshal(n *Node, out reflect.Value) (good bool) {
- d.decodeCount++
- if d.aliasDepth > 0 {
- d.aliasCount++
- }
- if d.aliasCount > 100 && d.decodeCount > 1000 && float64(d.aliasCount)/float64(d.decodeCount) > allowedAliasRatio(d.decodeCount) {
- failf("document contains excessive aliasing")
- }
- if out.Type() == nodeType {
- out.Set(reflect.ValueOf(n).Elem())
- return true
- }
- switch n.Kind {
- case DocumentNode:
- return d.document(n, out)
- case AliasNode:
- return d.alias(n, out)
- }
- out, unmarshaled, good := d.prepare(n, out)
- if unmarshaled {
- return good
- }
- switch n.Kind {
- case ScalarNode:
- good = d.scalar(n, out)
- case MappingNode:
- good = d.mapping(n, out)
- case SequenceNode:
- good = d.sequence(n, out)
- case 0:
- if n.IsZero() {
- return d.null(out)
- }
- fallthrough
- default:
- failf("cannot decode node with unknown kind %d", n.Kind)
- }
- return good
-}
-
-func (d *decoder) document(n *Node, out reflect.Value) (good bool) {
- if len(n.Content) == 1 {
- d.doc = n
- d.unmarshal(n.Content[0], out)
- return true
- }
- return false
-}
-
-func (d *decoder) alias(n *Node, out reflect.Value) (good bool) {
- if d.aliases[n] {
- // TODO this could actually be allowed in some circumstances.
- failf("anchor '%s' value contains itself", n.Value)
- }
- d.aliases[n] = true
- d.aliasDepth++
- good = d.unmarshal(n.Alias, out)
- d.aliasDepth--
- delete(d.aliases, n)
- return good
-}
-
-var zeroValue reflect.Value
-
-func resetMap(out reflect.Value) {
- for _, k := range out.MapKeys() {
- out.SetMapIndex(k, zeroValue)
- }
-}
-
-func (d *decoder) null(out reflect.Value) bool {
- if out.CanAddr() {
- switch out.Kind() {
- case reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice:
- out.Set(reflect.Zero(out.Type()))
- return true
- }
- }
- return false
-}
-
-func (d *decoder) scalar(n *Node, out reflect.Value) bool {
- var tag string
- var resolved interface{}
- if n.indicatedString() {
- tag = strTag
- resolved = n.Value
- } else {
- tag, resolved = resolve(n.Tag, n.Value)
- if tag == binaryTag {
- data, err := base64.StdEncoding.DecodeString(resolved.(string))
- if err != nil {
- failf("!!binary value contains invalid base64 data")
- }
- resolved = string(data)
- }
- }
- if resolved == nil {
- return d.null(out)
- }
- if resolvedv := reflect.ValueOf(resolved); out.Type() == resolvedv.Type() {
- // We've resolved to exactly the type we want, so use that.
- out.Set(resolvedv)
- return true
- }
- // Perhaps we can use the value as a TextUnmarshaler to
- // set its value.
- if out.CanAddr() {
- u, ok := out.Addr().Interface().(encoding.TextUnmarshaler)
- if ok {
- var text []byte
- if tag == binaryTag {
- text = []byte(resolved.(string))
- } else {
- // We let any value be unmarshaled into TextUnmarshaler.
- // That might be more lax than we'd like, but the
- // TextUnmarshaler itself should bowl out any dubious values.
- text = []byte(n.Value)
- }
- err := u.UnmarshalText(text)
- if err != nil {
- fail(err)
- }
- return true
- }
- }
- switch out.Kind() {
- case reflect.String:
- if tag == binaryTag {
- out.SetString(resolved.(string))
- return true
- }
- out.SetString(n.Value)
- return true
- case reflect.Interface:
- out.Set(reflect.ValueOf(resolved))
- return true
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- // This used to work in v2, but it's very unfriendly.
- isDuration := out.Type() == durationType
-
- switch resolved := resolved.(type) {
- case int:
- if !isDuration && !out.OverflowInt(int64(resolved)) {
- out.SetInt(int64(resolved))
- return true
- }
- case int64:
- if !isDuration && !out.OverflowInt(resolved) {
- out.SetInt(resolved)
- return true
- }
- case uint64:
- if !isDuration && resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) {
- out.SetInt(int64(resolved))
- return true
- }
- case float64:
- if !isDuration && resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) {
- out.SetInt(int64(resolved))
- return true
- }
- case string:
- if out.Type() == durationType {
- d, err := time.ParseDuration(resolved)
- if err == nil {
- out.SetInt(int64(d))
- return true
- }
- }
- }
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- switch resolved := resolved.(type) {
- case int:
- if resolved >= 0 && !out.OverflowUint(uint64(resolved)) {
- out.SetUint(uint64(resolved))
- return true
- }
- case int64:
- if resolved >= 0 && !out.OverflowUint(uint64(resolved)) {
- out.SetUint(uint64(resolved))
- return true
- }
- case uint64:
- if !out.OverflowUint(uint64(resolved)) {
- out.SetUint(uint64(resolved))
- return true
- }
- case float64:
- if resolved <= math.MaxUint64 && !out.OverflowUint(uint64(resolved)) {
- out.SetUint(uint64(resolved))
- return true
- }
- }
- case reflect.Bool:
- switch resolved := resolved.(type) {
- case bool:
- out.SetBool(resolved)
- return true
- case string:
- // This offers some compatibility with the 1.1 spec (https://yaml.org/type/bool.html).
- // It only works if explicitly attempting to unmarshal into a typed bool value.
- switch resolved {
- case "y", "Y", "yes", "Yes", "YES", "on", "On", "ON":
- out.SetBool(true)
- return true
- case "n", "N", "no", "No", "NO", "off", "Off", "OFF":
- out.SetBool(false)
- return true
- }
- }
- case reflect.Float32, reflect.Float64:
- switch resolved := resolved.(type) {
- case int:
- out.SetFloat(float64(resolved))
- return true
- case int64:
- out.SetFloat(float64(resolved))
- return true
- case uint64:
- out.SetFloat(float64(resolved))
- return true
- case float64:
- out.SetFloat(resolved)
- return true
- }
- case reflect.Struct:
- if resolvedv := reflect.ValueOf(resolved); out.Type() == resolvedv.Type() {
- out.Set(resolvedv)
- return true
- }
- case reflect.Ptr:
- panic("yaml internal error: please report the issue")
- }
- d.terror(n, tag, out)
- return false
-}
-
-func settableValueOf(i interface{}) reflect.Value {
- v := reflect.ValueOf(i)
- sv := reflect.New(v.Type()).Elem()
- sv.Set(v)
- return sv
-}
-
-func (d *decoder) sequence(n *Node, out reflect.Value) (good bool) {
- l := len(n.Content)
-
- var iface reflect.Value
- switch out.Kind() {
- case reflect.Slice:
- out.Set(reflect.MakeSlice(out.Type(), l, l))
- case reflect.Array:
- if l != out.Len() {
- failf("invalid array: want %d elements but got %d", out.Len(), l)
- }
- case reflect.Interface:
- // No type hints. Will have to use a generic sequence.
- iface = out
- out = settableValueOf(make([]interface{}, l))
- default:
- d.terror(n, seqTag, out)
- return false
- }
- et := out.Type().Elem()
-
- j := 0
- for i := 0; i < l; i++ {
- e := reflect.New(et).Elem()
- if ok := d.unmarshal(n.Content[i], e); ok {
- out.Index(j).Set(e)
- j++
- }
- }
- if out.Kind() != reflect.Array {
- out.Set(out.Slice(0, j))
- }
- if iface.IsValid() {
- iface.Set(out)
- }
- return true
-}
-
-func (d *decoder) mapping(n *Node, out reflect.Value) (good bool) {
- l := len(n.Content)
- if d.uniqueKeys {
- nerrs := len(d.terrors)
- for i := 0; i < l; i += 2 {
- ni := n.Content[i]
- for j := i + 2; j < l; j += 2 {
- nj := n.Content[j]
- if ni.Kind == nj.Kind && ni.Value == nj.Value {
- d.terrors = append(d.terrors, fmt.Sprintf("line %d: mapping key %#v already defined at line %d", nj.Line, nj.Value, ni.Line))
- }
- }
- }
- if len(d.terrors) > nerrs {
- return false
- }
- }
- switch out.Kind() {
- case reflect.Struct:
- return d.mappingStruct(n, out)
- case reflect.Map:
- // okay
- case reflect.Interface:
- iface := out
- if isStringMap(n) {
- out = reflect.MakeMap(d.stringMapType)
- } else {
- out = reflect.MakeMap(d.generalMapType)
- }
- iface.Set(out)
- default:
- d.terror(n, mapTag, out)
- return false
- }
-
- outt := out.Type()
- kt := outt.Key()
- et := outt.Elem()
-
- stringMapType := d.stringMapType
- generalMapType := d.generalMapType
- if outt.Elem() == ifaceType {
- if outt.Key().Kind() == reflect.String {
- d.stringMapType = outt
- } else if outt.Key() == ifaceType {
- d.generalMapType = outt
- }
- }
-
- mergedFields := d.mergedFields
- d.mergedFields = nil
-
- var mergeNode *Node
-
- mapIsNew := false
- if out.IsNil() {
- out.Set(reflect.MakeMap(outt))
- mapIsNew = true
- }
- for i := 0; i < l; i += 2 {
- if isMerge(n.Content[i]) {
- mergeNode = n.Content[i+1]
- continue
- }
- k := reflect.New(kt).Elem()
- if d.unmarshal(n.Content[i], k) {
- if mergedFields != nil {
- ki := k.Interface()
- if mergedFields[ki] {
- continue
- }
- mergedFields[ki] = true
- }
- kkind := k.Kind()
- if kkind == reflect.Interface {
- kkind = k.Elem().Kind()
- }
- if kkind == reflect.Map || kkind == reflect.Slice {
- failf("invalid map key: %#v", k.Interface())
- }
- e := reflect.New(et).Elem()
- if d.unmarshal(n.Content[i+1], e) || n.Content[i+1].ShortTag() == nullTag && (mapIsNew || !out.MapIndex(k).IsValid()) {
- out.SetMapIndex(k, e)
- }
- }
- }
-
- d.mergedFields = mergedFields
- if mergeNode != nil {
- d.merge(n, mergeNode, out)
- }
-
- d.stringMapType = stringMapType
- d.generalMapType = generalMapType
- return true
-}
-
-func isStringMap(n *Node) bool {
- if n.Kind != MappingNode {
- return false
- }
- l := len(n.Content)
- for i := 0; i < l; i += 2 {
- shortTag := n.Content[i].ShortTag()
- if shortTag != strTag && shortTag != mergeTag {
- return false
- }
- }
- return true
-}
-
-func (d *decoder) mappingStruct(n *Node, out reflect.Value) (good bool) {
- sinfo, err := getStructInfo(out.Type())
- if err != nil {
- panic(err)
- }
-
- var inlineMap reflect.Value
- var elemType reflect.Type
- if sinfo.InlineMap != -1 {
- inlineMap = out.Field(sinfo.InlineMap)
- elemType = inlineMap.Type().Elem()
- }
-
- for _, index := range sinfo.InlineUnmarshalers {
- field := d.fieldByIndex(n, out, index)
- d.prepare(n, field)
- }
-
- mergedFields := d.mergedFields
- d.mergedFields = nil
- var mergeNode *Node
- var doneFields []bool
- if d.uniqueKeys {
- doneFields = make([]bool, len(sinfo.FieldsList))
- }
- name := settableValueOf("")
- l := len(n.Content)
- for i := 0; i < l; i += 2 {
- ni := n.Content[i]
- if isMerge(ni) {
- mergeNode = n.Content[i+1]
- continue
- }
- if !d.unmarshal(ni, name) {
- continue
- }
- sname := name.String()
- if mergedFields != nil {
- if mergedFields[sname] {
- continue
- }
- mergedFields[sname] = true
- }
- if info, ok := sinfo.FieldsMap[sname]; ok {
- if d.uniqueKeys {
- if doneFields[info.Id] {
- d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s already set in type %s", ni.Line, name.String(), out.Type()))
- continue
- }
- doneFields[info.Id] = true
- }
- var field reflect.Value
- if info.Inline == nil {
- field = out.Field(info.Num)
- } else {
- field = d.fieldByIndex(n, out, info.Inline)
- }
- d.unmarshal(n.Content[i+1], field)
- } else if sinfo.InlineMap != -1 {
- if inlineMap.IsNil() {
- inlineMap.Set(reflect.MakeMap(inlineMap.Type()))
- }
- value := reflect.New(elemType).Elem()
- d.unmarshal(n.Content[i+1], value)
- inlineMap.SetMapIndex(name, value)
- } else if d.knownFields {
- d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s not found in type %s", ni.Line, name.String(), out.Type()))
- }
- }
-
- d.mergedFields = mergedFields
- if mergeNode != nil {
- d.merge(n, mergeNode, out)
- }
- return true
-}
-
-func failWantMap() {
- failf("map merge requires map or sequence of maps as the value")
-}
-
-func (d *decoder) merge(parent *Node, merge *Node, out reflect.Value) {
- mergedFields := d.mergedFields
- if mergedFields == nil {
- d.mergedFields = make(map[interface{}]bool)
- for i := 0; i < len(parent.Content); i += 2 {
- k := reflect.New(ifaceType).Elem()
- if d.unmarshal(parent.Content[i], k) {
- d.mergedFields[k.Interface()] = true
- }
- }
- }
-
- switch merge.Kind {
- case MappingNode:
- d.unmarshal(merge, out)
- case AliasNode:
- if merge.Alias != nil && merge.Alias.Kind != MappingNode {
- failWantMap()
- }
- d.unmarshal(merge, out)
- case SequenceNode:
- for i := 0; i < len(merge.Content); i++ {
- ni := merge.Content[i]
- if ni.Kind == AliasNode {
- if ni.Alias != nil && ni.Alias.Kind != MappingNode {
- failWantMap()
- }
- } else if ni.Kind != MappingNode {
- failWantMap()
- }
- d.unmarshal(ni, out)
- }
- default:
- failWantMap()
- }
-
- d.mergedFields = mergedFields
-}
-
-func isMerge(n *Node) bool {
- return n.Kind == ScalarNode && n.Value == "<<" && (n.Tag == "" || n.Tag == "!" || shortTag(n.Tag) == mergeTag)
-}
diff --git a/vendor/gopkg.in/yaml.v3/emitterc.go b/vendor/gopkg.in/yaml.v3/emitterc.go
deleted file mode 100644
index 0f47c9ca..00000000
--- a/vendor/gopkg.in/yaml.v3/emitterc.go
+++ /dev/null
@@ -1,2020 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-// Copyright (c) 2006-2010 Kirill Simonov
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-package yaml
-
-import (
- "bytes"
- "fmt"
-)
-
-// Flush the buffer if needed.
-func flush(emitter *yaml_emitter_t) bool {
- if emitter.buffer_pos+5 >= len(emitter.buffer) {
- return yaml_emitter_flush(emitter)
- }
- return true
-}
-
-// Put a character to the output buffer.
-func put(emitter *yaml_emitter_t, value byte) bool {
- if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {
- return false
- }
- emitter.buffer[emitter.buffer_pos] = value
- emitter.buffer_pos++
- emitter.column++
- return true
-}
-
-// Put a line break to the output buffer.
-func put_break(emitter *yaml_emitter_t) bool {
- if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {
- return false
- }
- switch emitter.line_break {
- case yaml_CR_BREAK:
- emitter.buffer[emitter.buffer_pos] = '\r'
- emitter.buffer_pos += 1
- case yaml_LN_BREAK:
- emitter.buffer[emitter.buffer_pos] = '\n'
- emitter.buffer_pos += 1
- case yaml_CRLN_BREAK:
- emitter.buffer[emitter.buffer_pos+0] = '\r'
- emitter.buffer[emitter.buffer_pos+1] = '\n'
- emitter.buffer_pos += 2
- default:
- panic("unknown line break setting")
- }
- if emitter.column == 0 {
- emitter.space_above = true
- }
- emitter.column = 0
- emitter.line++
- // [Go] Do this here and below and drop from everywhere else (see commented lines).
- emitter.indention = true
- return true
-}
-
-// Copy a character from a string into buffer.
-func write(emitter *yaml_emitter_t, s []byte, i *int) bool {
- if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {
- return false
- }
- p := emitter.buffer_pos
- w := width(s[*i])
- switch w {
- case 4:
- emitter.buffer[p+3] = s[*i+3]
- fallthrough
- case 3:
- emitter.buffer[p+2] = s[*i+2]
- fallthrough
- case 2:
- emitter.buffer[p+1] = s[*i+1]
- fallthrough
- case 1:
- emitter.buffer[p+0] = s[*i+0]
- default:
- panic("unknown character width")
- }
- emitter.column++
- emitter.buffer_pos += w
- *i += w
- return true
-}
-
-// Write a whole string into buffer.
-func write_all(emitter *yaml_emitter_t, s []byte) bool {
- for i := 0; i < len(s); {
- if !write(emitter, s, &i) {
- return false
- }
- }
- return true
-}
-
-// Copy a line break character from a string into buffer.
-func write_break(emitter *yaml_emitter_t, s []byte, i *int) bool {
- if s[*i] == '\n' {
- if !put_break(emitter) {
- return false
- }
- *i++
- } else {
- if !write(emitter, s, i) {
- return false
- }
- if emitter.column == 0 {
- emitter.space_above = true
- }
- emitter.column = 0
- emitter.line++
- // [Go] Do this here and above and drop from everywhere else (see commented lines).
- emitter.indention = true
- }
- return true
-}
-
-// Set an emitter error and return false.
-func yaml_emitter_set_emitter_error(emitter *yaml_emitter_t, problem string) bool {
- emitter.error = yaml_EMITTER_ERROR
- emitter.problem = problem
- return false
-}
-
-// Emit an event.
-func yaml_emitter_emit(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- emitter.events = append(emitter.events, *event)
- for !yaml_emitter_need_more_events(emitter) {
- event := &emitter.events[emitter.events_head]
- if !yaml_emitter_analyze_event(emitter, event) {
- return false
- }
- if !yaml_emitter_state_machine(emitter, event) {
- return false
- }
- yaml_event_delete(event)
- emitter.events_head++
- }
- return true
-}
-
-// Check if we need to accumulate more events before emitting.
-//
-// We accumulate extra
-// - 1 event for DOCUMENT-START
-// - 2 events for SEQUENCE-START
-// - 3 events for MAPPING-START
-//
-func yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool {
- if emitter.events_head == len(emitter.events) {
- return true
- }
- var accumulate int
- switch emitter.events[emitter.events_head].typ {
- case yaml_DOCUMENT_START_EVENT:
- accumulate = 1
- break
- case yaml_SEQUENCE_START_EVENT:
- accumulate = 2
- break
- case yaml_MAPPING_START_EVENT:
- accumulate = 3
- break
- default:
- return false
- }
- if len(emitter.events)-emitter.events_head > accumulate {
- return false
- }
- var level int
- for i := emitter.events_head; i < len(emitter.events); i++ {
- switch emitter.events[i].typ {
- case yaml_STREAM_START_EVENT, yaml_DOCUMENT_START_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT:
- level++
- case yaml_STREAM_END_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_END_EVENT, yaml_MAPPING_END_EVENT:
- level--
- }
- if level == 0 {
- return false
- }
- }
- return true
-}
-
-// Append a directive to the directives stack.
-func yaml_emitter_append_tag_directive(emitter *yaml_emitter_t, value *yaml_tag_directive_t, allow_duplicates bool) bool {
- for i := 0; i < len(emitter.tag_directives); i++ {
- if bytes.Equal(value.handle, emitter.tag_directives[i].handle) {
- if allow_duplicates {
- return true
- }
- return yaml_emitter_set_emitter_error(emitter, "duplicate %TAG directive")
- }
- }
-
- // [Go] Do we actually need to copy this given garbage collection
- // and the lack of deallocating destructors?
- tag_copy := yaml_tag_directive_t{
- handle: make([]byte, len(value.handle)),
- prefix: make([]byte, len(value.prefix)),
- }
- copy(tag_copy.handle, value.handle)
- copy(tag_copy.prefix, value.prefix)
- emitter.tag_directives = append(emitter.tag_directives, tag_copy)
- return true
-}
-
-// Increase the indentation level.
-func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool) bool {
- emitter.indents = append(emitter.indents, emitter.indent)
- if emitter.indent < 0 {
- if flow {
- emitter.indent = emitter.best_indent
- } else {
- emitter.indent = 0
- }
- } else if !indentless {
- // [Go] This was changed so that indentations are more regular.
- if emitter.states[len(emitter.states)-1] == yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE {
- // The first indent inside a sequence will just skip the "- " indicator.
- emitter.indent += 2
- } else {
- // Everything else aligns to the chosen indentation.
- emitter.indent = emitter.best_indent*((emitter.indent+emitter.best_indent)/emitter.best_indent)
- }
- }
- return true
-}
-
-// State dispatcher.
-func yaml_emitter_state_machine(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- switch emitter.state {
- default:
- case yaml_EMIT_STREAM_START_STATE:
- return yaml_emitter_emit_stream_start(emitter, event)
-
- case yaml_EMIT_FIRST_DOCUMENT_START_STATE:
- return yaml_emitter_emit_document_start(emitter, event, true)
-
- case yaml_EMIT_DOCUMENT_START_STATE:
- return yaml_emitter_emit_document_start(emitter, event, false)
-
- case yaml_EMIT_DOCUMENT_CONTENT_STATE:
- return yaml_emitter_emit_document_content(emitter, event)
-
- case yaml_EMIT_DOCUMENT_END_STATE:
- return yaml_emitter_emit_document_end(emitter, event)
-
- case yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE:
- return yaml_emitter_emit_flow_sequence_item(emitter, event, true, false)
-
- case yaml_EMIT_FLOW_SEQUENCE_TRAIL_ITEM_STATE:
- return yaml_emitter_emit_flow_sequence_item(emitter, event, false, true)
-
- case yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE:
- return yaml_emitter_emit_flow_sequence_item(emitter, event, false, false)
-
- case yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE:
- return yaml_emitter_emit_flow_mapping_key(emitter, event, true, false)
-
- case yaml_EMIT_FLOW_MAPPING_TRAIL_KEY_STATE:
- return yaml_emitter_emit_flow_mapping_key(emitter, event, false, true)
-
- case yaml_EMIT_FLOW_MAPPING_KEY_STATE:
- return yaml_emitter_emit_flow_mapping_key(emitter, event, false, false)
-
- case yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE:
- return yaml_emitter_emit_flow_mapping_value(emitter, event, true)
-
- case yaml_EMIT_FLOW_MAPPING_VALUE_STATE:
- return yaml_emitter_emit_flow_mapping_value(emitter, event, false)
-
- case yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE:
- return yaml_emitter_emit_block_sequence_item(emitter, event, true)
-
- case yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE:
- return yaml_emitter_emit_block_sequence_item(emitter, event, false)
-
- case yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE:
- return yaml_emitter_emit_block_mapping_key(emitter, event, true)
-
- case yaml_EMIT_BLOCK_MAPPING_KEY_STATE:
- return yaml_emitter_emit_block_mapping_key(emitter, event, false)
-
- case yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE:
- return yaml_emitter_emit_block_mapping_value(emitter, event, true)
-
- case yaml_EMIT_BLOCK_MAPPING_VALUE_STATE:
- return yaml_emitter_emit_block_mapping_value(emitter, event, false)
-
- case yaml_EMIT_END_STATE:
- return yaml_emitter_set_emitter_error(emitter, "expected nothing after STREAM-END")
- }
- panic("invalid emitter state")
-}
-
-// Expect STREAM-START.
-func yaml_emitter_emit_stream_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- if event.typ != yaml_STREAM_START_EVENT {
- return yaml_emitter_set_emitter_error(emitter, "expected STREAM-START")
- }
- if emitter.encoding == yaml_ANY_ENCODING {
- emitter.encoding = event.encoding
- if emitter.encoding == yaml_ANY_ENCODING {
- emitter.encoding = yaml_UTF8_ENCODING
- }
- }
- if emitter.best_indent < 2 || emitter.best_indent > 9 {
- emitter.best_indent = 2
- }
- if emitter.best_width >= 0 && emitter.best_width <= emitter.best_indent*2 {
- emitter.best_width = 80
- }
- if emitter.best_width < 0 {
- emitter.best_width = 1<<31 - 1
- }
- if emitter.line_break == yaml_ANY_BREAK {
- emitter.line_break = yaml_LN_BREAK
- }
-
- emitter.indent = -1
- emitter.line = 0
- emitter.column = 0
- emitter.whitespace = true
- emitter.indention = true
- emitter.space_above = true
- emitter.foot_indent = -1
-
- if emitter.encoding != yaml_UTF8_ENCODING {
- if !yaml_emitter_write_bom(emitter) {
- return false
- }
- }
- emitter.state = yaml_EMIT_FIRST_DOCUMENT_START_STATE
- return true
-}
-
-// Expect DOCUMENT-START or STREAM-END.
-func yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
-
- if event.typ == yaml_DOCUMENT_START_EVENT {
-
- if event.version_directive != nil {
- if !yaml_emitter_analyze_version_directive(emitter, event.version_directive) {
- return false
- }
- }
-
- for i := 0; i < len(event.tag_directives); i++ {
- tag_directive := &event.tag_directives[i]
- if !yaml_emitter_analyze_tag_directive(emitter, tag_directive) {
- return false
- }
- if !yaml_emitter_append_tag_directive(emitter, tag_directive, false) {
- return false
- }
- }
-
- for i := 0; i < len(default_tag_directives); i++ {
- tag_directive := &default_tag_directives[i]
- if !yaml_emitter_append_tag_directive(emitter, tag_directive, true) {
- return false
- }
- }
-
- implicit := event.implicit
- if !first || emitter.canonical {
- implicit = false
- }
-
- if emitter.open_ended && (event.version_directive != nil || len(event.tag_directives) > 0) {
- if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
-
- if event.version_directive != nil {
- implicit = false
- if !yaml_emitter_write_indicator(emitter, []byte("%YAML"), true, false, false) {
- return false
- }
- if !yaml_emitter_write_indicator(emitter, []byte("1.1"), true, false, false) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
-
- if len(event.tag_directives) > 0 {
- implicit = false
- for i := 0; i < len(event.tag_directives); i++ {
- tag_directive := &event.tag_directives[i]
- if !yaml_emitter_write_indicator(emitter, []byte("%TAG"), true, false, false) {
- return false
- }
- if !yaml_emitter_write_tag_handle(emitter, tag_directive.handle) {
- return false
- }
- if !yaml_emitter_write_tag_content(emitter, tag_directive.prefix, true) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- }
-
- if yaml_emitter_check_empty_document(emitter) {
- implicit = false
- }
- if !implicit {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if !yaml_emitter_write_indicator(emitter, []byte("---"), true, false, false) {
- return false
- }
- if emitter.canonical || true {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- }
-
- if len(emitter.head_comment) > 0 {
- if !yaml_emitter_process_head_comment(emitter) {
- return false
- }
- if !put_break(emitter) {
- return false
- }
- }
-
- emitter.state = yaml_EMIT_DOCUMENT_CONTENT_STATE
- return true
- }
-
- if event.typ == yaml_STREAM_END_EVENT {
- if emitter.open_ended {
- if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !yaml_emitter_flush(emitter) {
- return false
- }
- emitter.state = yaml_EMIT_END_STATE
- return true
- }
-
- return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-START or STREAM-END")
-}
-
-// Expect the root node.
-func yaml_emitter_emit_document_content(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- emitter.states = append(emitter.states, yaml_EMIT_DOCUMENT_END_STATE)
-
- if !yaml_emitter_process_head_comment(emitter) {
- return false
- }
- if !yaml_emitter_emit_node(emitter, event, true, false, false, false) {
- return false
- }
- if !yaml_emitter_process_line_comment(emitter) {
- return false
- }
- if !yaml_emitter_process_foot_comment(emitter) {
- return false
- }
- return true
-}
-
-// Expect DOCUMENT-END.
-func yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- if event.typ != yaml_DOCUMENT_END_EVENT {
- return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-END")
- }
- // [Go] Force document foot separation.
- emitter.foot_indent = 0
- if !yaml_emitter_process_foot_comment(emitter) {
- return false
- }
- emitter.foot_indent = -1
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if !event.implicit {
- // [Go] Allocate the slice elsewhere.
- if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !yaml_emitter_flush(emitter) {
- return false
- }
- emitter.state = yaml_EMIT_DOCUMENT_START_STATE
- emitter.tag_directives = emitter.tag_directives[:0]
- return true
-}
-
-// Expect a flow item node.
-func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first, trail bool) bool {
- if first {
- if !yaml_emitter_write_indicator(emitter, []byte{'['}, true, true, false) {
- return false
- }
- if !yaml_emitter_increase_indent(emitter, true, false) {
- return false
- }
- emitter.flow_level++
- }
-
- if event.typ == yaml_SEQUENCE_END_EVENT {
- if emitter.canonical && !first && !trail {
- if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
- return false
- }
- }
- emitter.flow_level--
- emitter.indent = emitter.indents[len(emitter.indents)-1]
- emitter.indents = emitter.indents[:len(emitter.indents)-1]
- if emitter.column == 0 || emitter.canonical && !first {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !yaml_emitter_write_indicator(emitter, []byte{']'}, false, false, false) {
- return false
- }
- if !yaml_emitter_process_line_comment(emitter) {
- return false
- }
- if !yaml_emitter_process_foot_comment(emitter) {
- return false
- }
- emitter.state = emitter.states[len(emitter.states)-1]
- emitter.states = emitter.states[:len(emitter.states)-1]
-
- return true
- }
-
- if !first && !trail {
- if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
- return false
- }
- }
-
- if !yaml_emitter_process_head_comment(emitter) {
- return false
- }
- if emitter.column == 0 {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
-
- if emitter.canonical || emitter.column > emitter.best_width {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if len(emitter.line_comment)+len(emitter.foot_comment)+len(emitter.tail_comment) > 0 {
- emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_TRAIL_ITEM_STATE)
- } else {
- emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE)
- }
- if !yaml_emitter_emit_node(emitter, event, false, true, false, false) {
- return false
- }
- if len(emitter.line_comment)+len(emitter.foot_comment)+len(emitter.tail_comment) > 0 {
- if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
- return false
- }
- }
- if !yaml_emitter_process_line_comment(emitter) {
- return false
- }
- if !yaml_emitter_process_foot_comment(emitter) {
- return false
- }
- return true
-}
-
-// Expect a flow key node.
-func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first, trail bool) bool {
- if first {
- if !yaml_emitter_write_indicator(emitter, []byte{'{'}, true, true, false) {
- return false
- }
- if !yaml_emitter_increase_indent(emitter, true, false) {
- return false
- }
- emitter.flow_level++
- }
-
- if event.typ == yaml_MAPPING_END_EVENT {
- if (emitter.canonical || len(emitter.head_comment)+len(emitter.foot_comment)+len(emitter.tail_comment) > 0) && !first && !trail {
- if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
- return false
- }
- }
- if !yaml_emitter_process_head_comment(emitter) {
- return false
- }
- emitter.flow_level--
- emitter.indent = emitter.indents[len(emitter.indents)-1]
- emitter.indents = emitter.indents[:len(emitter.indents)-1]
- if emitter.canonical && !first {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) {
- return false
- }
- if !yaml_emitter_process_line_comment(emitter) {
- return false
- }
- if !yaml_emitter_process_foot_comment(emitter) {
- return false
- }
- emitter.state = emitter.states[len(emitter.states)-1]
- emitter.states = emitter.states[:len(emitter.states)-1]
- return true
- }
-
- if !first && !trail {
- if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
- return false
- }
- }
-
- if !yaml_emitter_process_head_comment(emitter) {
- return false
- }
-
- if emitter.column == 0 {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
-
- if emitter.canonical || emitter.column > emitter.best_width {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
-
- if !emitter.canonical && yaml_emitter_check_simple_key(emitter) {
- emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE)
- return yaml_emitter_emit_node(emitter, event, false, false, true, true)
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, false) {
- return false
- }
- emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_VALUE_STATE)
- return yaml_emitter_emit_node(emitter, event, false, false, true, false)
-}
-
-// Expect a flow value node.
-func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool {
- if simple {
- if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) {
- return false
- }
- } else {
- if emitter.canonical || emitter.column > emitter.best_width {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, false) {
- return false
- }
- }
- if len(emitter.line_comment)+len(emitter.foot_comment)+len(emitter.tail_comment) > 0 {
- emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_TRAIL_KEY_STATE)
- } else {
- emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_KEY_STATE)
- }
- if !yaml_emitter_emit_node(emitter, event, false, false, true, false) {
- return false
- }
- if len(emitter.line_comment)+len(emitter.foot_comment)+len(emitter.tail_comment) > 0 {
- if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
- return false
- }
- }
- if !yaml_emitter_process_line_comment(emitter) {
- return false
- }
- if !yaml_emitter_process_foot_comment(emitter) {
- return false
- }
- return true
-}
-
-// Expect a block item node.
-func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
- if first {
- if !yaml_emitter_increase_indent(emitter, false, false) {
- return false
- }
- }
- if event.typ == yaml_SEQUENCE_END_EVENT {
- emitter.indent = emitter.indents[len(emitter.indents)-1]
- emitter.indents = emitter.indents[:len(emitter.indents)-1]
- emitter.state = emitter.states[len(emitter.states)-1]
- emitter.states = emitter.states[:len(emitter.states)-1]
- return true
- }
- if !yaml_emitter_process_head_comment(emitter) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'-'}, true, false, true) {
- return false
- }
- emitter.states = append(emitter.states, yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE)
- if !yaml_emitter_emit_node(emitter, event, false, true, false, false) {
- return false
- }
- if !yaml_emitter_process_line_comment(emitter) {
- return false
- }
- if !yaml_emitter_process_foot_comment(emitter) {
- return false
- }
- return true
-}
-
-// Expect a block key node.
-func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
- if first {
- if !yaml_emitter_increase_indent(emitter, false, false) {
- return false
- }
- }
- if !yaml_emitter_process_head_comment(emitter) {
- return false
- }
- if event.typ == yaml_MAPPING_END_EVENT {
- emitter.indent = emitter.indents[len(emitter.indents)-1]
- emitter.indents = emitter.indents[:len(emitter.indents)-1]
- emitter.state = emitter.states[len(emitter.states)-1]
- emitter.states = emitter.states[:len(emitter.states)-1]
- return true
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if len(emitter.line_comment) > 0 {
- // [Go] A line comment was provided for the key. That's unusual as the
- // scanner associates line comments with the value. Either way,
- // save the line comment and render it appropriately later.
- emitter.key_line_comment = emitter.line_comment
- emitter.line_comment = nil
- }
- if yaml_emitter_check_simple_key(emitter) {
- emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE)
- return yaml_emitter_emit_node(emitter, event, false, false, true, true)
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, true) {
- return false
- }
- emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_VALUE_STATE)
- return yaml_emitter_emit_node(emitter, event, false, false, true, false)
-}
-
-// Expect a block value node.
-func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool {
- if simple {
- if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) {
- return false
- }
- } else {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, true) {
- return false
- }
- }
- if len(emitter.key_line_comment) > 0 {
- // [Go] Line comments are generally associated with the value, but when there's
- // no value on the same line as a mapping key they end up attached to the
- // key itself.
- if event.typ == yaml_SCALAR_EVENT {
- if len(emitter.line_comment) == 0 {
- // A scalar is coming and it has no line comments by itself yet,
- // so just let it handle the line comment as usual. If it has a
- // line comment, we can't have both so the one from the key is lost.
- emitter.line_comment = emitter.key_line_comment
- emitter.key_line_comment = nil
- }
- } else if event.sequence_style() != yaml_FLOW_SEQUENCE_STYLE && (event.typ == yaml_MAPPING_START_EVENT || event.typ == yaml_SEQUENCE_START_EVENT) {
- // An indented block follows, so write the comment right now.
- emitter.line_comment, emitter.key_line_comment = emitter.key_line_comment, emitter.line_comment
- if !yaml_emitter_process_line_comment(emitter) {
- return false
- }
- emitter.line_comment, emitter.key_line_comment = emitter.key_line_comment, emitter.line_comment
- }
- }
- emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE)
- if !yaml_emitter_emit_node(emitter, event, false, false, true, false) {
- return false
- }
- if !yaml_emitter_process_line_comment(emitter) {
- return false
- }
- if !yaml_emitter_process_foot_comment(emitter) {
- return false
- }
- return true
-}
-
-func yaml_emitter_silent_nil_event(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- return event.typ == yaml_SCALAR_EVENT && event.implicit && !emitter.canonical && len(emitter.scalar_data.value) == 0
-}
-
-// Expect a node.
-func yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t,
- root bool, sequence bool, mapping bool, simple_key bool) bool {
-
- emitter.root_context = root
- emitter.sequence_context = sequence
- emitter.mapping_context = mapping
- emitter.simple_key_context = simple_key
-
- switch event.typ {
- case yaml_ALIAS_EVENT:
- return yaml_emitter_emit_alias(emitter, event)
- case yaml_SCALAR_EVENT:
- return yaml_emitter_emit_scalar(emitter, event)
- case yaml_SEQUENCE_START_EVENT:
- return yaml_emitter_emit_sequence_start(emitter, event)
- case yaml_MAPPING_START_EVENT:
- return yaml_emitter_emit_mapping_start(emitter, event)
- default:
- return yaml_emitter_set_emitter_error(emitter,
- fmt.Sprintf("expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS, but got %v", event.typ))
- }
-}
-
-// Expect ALIAS.
-func yaml_emitter_emit_alias(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- if !yaml_emitter_process_anchor(emitter) {
- return false
- }
- emitter.state = emitter.states[len(emitter.states)-1]
- emitter.states = emitter.states[:len(emitter.states)-1]
- return true
-}
-
-// Expect SCALAR.
-func yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- if !yaml_emitter_select_scalar_style(emitter, event) {
- return false
- }
- if !yaml_emitter_process_anchor(emitter) {
- return false
- }
- if !yaml_emitter_process_tag(emitter) {
- return false
- }
- if !yaml_emitter_increase_indent(emitter, true, false) {
- return false
- }
- if !yaml_emitter_process_scalar(emitter) {
- return false
- }
- emitter.indent = emitter.indents[len(emitter.indents)-1]
- emitter.indents = emitter.indents[:len(emitter.indents)-1]
- emitter.state = emitter.states[len(emitter.states)-1]
- emitter.states = emitter.states[:len(emitter.states)-1]
- return true
-}
-
-// Expect SEQUENCE-START.
-func yaml_emitter_emit_sequence_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- if !yaml_emitter_process_anchor(emitter) {
- return false
- }
- if !yaml_emitter_process_tag(emitter) {
- return false
- }
- if emitter.flow_level > 0 || emitter.canonical || event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE ||
- yaml_emitter_check_empty_sequence(emitter) {
- emitter.state = yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE
- } else {
- emitter.state = yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE
- }
- return true
-}
-
-// Expect MAPPING-START.
-func yaml_emitter_emit_mapping_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- if !yaml_emitter_process_anchor(emitter) {
- return false
- }
- if !yaml_emitter_process_tag(emitter) {
- return false
- }
- if emitter.flow_level > 0 || emitter.canonical || event.mapping_style() == yaml_FLOW_MAPPING_STYLE ||
- yaml_emitter_check_empty_mapping(emitter) {
- emitter.state = yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE
- } else {
- emitter.state = yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE
- }
- return true
-}
-
-// Check if the document content is an empty scalar.
-func yaml_emitter_check_empty_document(emitter *yaml_emitter_t) bool {
- return false // [Go] Huh?
-}
-
-// Check if the next events represent an empty sequence.
-func yaml_emitter_check_empty_sequence(emitter *yaml_emitter_t) bool {
- if len(emitter.events)-emitter.events_head < 2 {
- return false
- }
- return emitter.events[emitter.events_head].typ == yaml_SEQUENCE_START_EVENT &&
- emitter.events[emitter.events_head+1].typ == yaml_SEQUENCE_END_EVENT
-}
-
-// Check if the next events represent an empty mapping.
-func yaml_emitter_check_empty_mapping(emitter *yaml_emitter_t) bool {
- if len(emitter.events)-emitter.events_head < 2 {
- return false
- }
- return emitter.events[emitter.events_head].typ == yaml_MAPPING_START_EVENT &&
- emitter.events[emitter.events_head+1].typ == yaml_MAPPING_END_EVENT
-}
-
-// Check if the next node can be expressed as a simple key.
-func yaml_emitter_check_simple_key(emitter *yaml_emitter_t) bool {
- length := 0
- switch emitter.events[emitter.events_head].typ {
- case yaml_ALIAS_EVENT:
- length += len(emitter.anchor_data.anchor)
- case yaml_SCALAR_EVENT:
- if emitter.scalar_data.multiline {
- return false
- }
- length += len(emitter.anchor_data.anchor) +
- len(emitter.tag_data.handle) +
- len(emitter.tag_data.suffix) +
- len(emitter.scalar_data.value)
- case yaml_SEQUENCE_START_EVENT:
- if !yaml_emitter_check_empty_sequence(emitter) {
- return false
- }
- length += len(emitter.anchor_data.anchor) +
- len(emitter.tag_data.handle) +
- len(emitter.tag_data.suffix)
- case yaml_MAPPING_START_EVENT:
- if !yaml_emitter_check_empty_mapping(emitter) {
- return false
- }
- length += len(emitter.anchor_data.anchor) +
- len(emitter.tag_data.handle) +
- len(emitter.tag_data.suffix)
- default:
- return false
- }
- return length <= 128
-}
-
-// Determine an acceptable scalar style.
-func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event_t) bool {
-
- no_tag := len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0
- if no_tag && !event.implicit && !event.quoted_implicit {
- return yaml_emitter_set_emitter_error(emitter, "neither tag nor implicit flags are specified")
- }
-
- style := event.scalar_style()
- if style == yaml_ANY_SCALAR_STYLE {
- style = yaml_PLAIN_SCALAR_STYLE
- }
- if emitter.canonical {
- style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- }
- if emitter.simple_key_context && emitter.scalar_data.multiline {
- style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- }
-
- if style == yaml_PLAIN_SCALAR_STYLE {
- if emitter.flow_level > 0 && !emitter.scalar_data.flow_plain_allowed ||
- emitter.flow_level == 0 && !emitter.scalar_data.block_plain_allowed {
- style = yaml_SINGLE_QUOTED_SCALAR_STYLE
- }
- if len(emitter.scalar_data.value) == 0 && (emitter.flow_level > 0 || emitter.simple_key_context) {
- style = yaml_SINGLE_QUOTED_SCALAR_STYLE
- }
- if no_tag && !event.implicit {
- style = yaml_SINGLE_QUOTED_SCALAR_STYLE
- }
- }
- if style == yaml_SINGLE_QUOTED_SCALAR_STYLE {
- if !emitter.scalar_data.single_quoted_allowed {
- style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- }
- }
- if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE {
- if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context {
- style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- }
- }
-
- if no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE {
- emitter.tag_data.handle = []byte{'!'}
- }
- emitter.scalar_data.style = style
- return true
-}
-
-// Write an anchor.
-func yaml_emitter_process_anchor(emitter *yaml_emitter_t) bool {
- if emitter.anchor_data.anchor == nil {
- return true
- }
- c := []byte{'&'}
- if emitter.anchor_data.alias {
- c[0] = '*'
- }
- if !yaml_emitter_write_indicator(emitter, c, true, false, false) {
- return false
- }
- return yaml_emitter_write_anchor(emitter, emitter.anchor_data.anchor)
-}
-
-// Write a tag.
-func yaml_emitter_process_tag(emitter *yaml_emitter_t) bool {
- if len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 {
- return true
- }
- if len(emitter.tag_data.handle) > 0 {
- if !yaml_emitter_write_tag_handle(emitter, emitter.tag_data.handle) {
- return false
- }
- if len(emitter.tag_data.suffix) > 0 {
- if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) {
- return false
- }
- }
- } else {
- // [Go] Allocate these slices elsewhere.
- if !yaml_emitter_write_indicator(emitter, []byte("!<"), true, false, false) {
- return false
- }
- if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) {
- return false
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'>'}, false, false, false) {
- return false
- }
- }
- return true
-}
-
-// Write a scalar.
-func yaml_emitter_process_scalar(emitter *yaml_emitter_t) bool {
- switch emitter.scalar_data.style {
- case yaml_PLAIN_SCALAR_STYLE:
- return yaml_emitter_write_plain_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context)
-
- case yaml_SINGLE_QUOTED_SCALAR_STYLE:
- return yaml_emitter_write_single_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context)
-
- case yaml_DOUBLE_QUOTED_SCALAR_STYLE:
- return yaml_emitter_write_double_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context)
-
- case yaml_LITERAL_SCALAR_STYLE:
- return yaml_emitter_write_literal_scalar(emitter, emitter.scalar_data.value)
-
- case yaml_FOLDED_SCALAR_STYLE:
- return yaml_emitter_write_folded_scalar(emitter, emitter.scalar_data.value)
- }
- panic("unknown scalar style")
-}
-
-// Write a head comment.
-func yaml_emitter_process_head_comment(emitter *yaml_emitter_t) bool {
- if len(emitter.tail_comment) > 0 {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if !yaml_emitter_write_comment(emitter, emitter.tail_comment) {
- return false
- }
- emitter.tail_comment = emitter.tail_comment[:0]
- emitter.foot_indent = emitter.indent
- if emitter.foot_indent < 0 {
- emitter.foot_indent = 0
- }
- }
-
- if len(emitter.head_comment) == 0 {
- return true
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if !yaml_emitter_write_comment(emitter, emitter.head_comment) {
- return false
- }
- emitter.head_comment = emitter.head_comment[:0]
- return true
-}
-
-// Write an line comment.
-func yaml_emitter_process_line_comment(emitter *yaml_emitter_t) bool {
- if len(emitter.line_comment) == 0 {
- return true
- }
- if !emitter.whitespace {
- if !put(emitter, ' ') {
- return false
- }
- }
- if !yaml_emitter_write_comment(emitter, emitter.line_comment) {
- return false
- }
- emitter.line_comment = emitter.line_comment[:0]
- return true
-}
-
-// Write a foot comment.
-func yaml_emitter_process_foot_comment(emitter *yaml_emitter_t) bool {
- if len(emitter.foot_comment) == 0 {
- return true
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if !yaml_emitter_write_comment(emitter, emitter.foot_comment) {
- return false
- }
- emitter.foot_comment = emitter.foot_comment[:0]
- emitter.foot_indent = emitter.indent
- if emitter.foot_indent < 0 {
- emitter.foot_indent = 0
- }
- return true
-}
-
-// Check if a %YAML directive is valid.
-func yaml_emitter_analyze_version_directive(emitter *yaml_emitter_t, version_directive *yaml_version_directive_t) bool {
- if version_directive.major != 1 || version_directive.minor != 1 {
- return yaml_emitter_set_emitter_error(emitter, "incompatible %YAML directive")
- }
- return true
-}
-
-// Check if a %TAG directive is valid.
-func yaml_emitter_analyze_tag_directive(emitter *yaml_emitter_t, tag_directive *yaml_tag_directive_t) bool {
- handle := tag_directive.handle
- prefix := tag_directive.prefix
- if len(handle) == 0 {
- return yaml_emitter_set_emitter_error(emitter, "tag handle must not be empty")
- }
- if handle[0] != '!' {
- return yaml_emitter_set_emitter_error(emitter, "tag handle must start with '!'")
- }
- if handle[len(handle)-1] != '!' {
- return yaml_emitter_set_emitter_error(emitter, "tag handle must end with '!'")
- }
- for i := 1; i < len(handle)-1; i += width(handle[i]) {
- if !is_alpha(handle, i) {
- return yaml_emitter_set_emitter_error(emitter, "tag handle must contain alphanumerical characters only")
- }
- }
- if len(prefix) == 0 {
- return yaml_emitter_set_emitter_error(emitter, "tag prefix must not be empty")
- }
- return true
-}
-
-// Check if an anchor is valid.
-func yaml_emitter_analyze_anchor(emitter *yaml_emitter_t, anchor []byte, alias bool) bool {
- if len(anchor) == 0 {
- problem := "anchor value must not be empty"
- if alias {
- problem = "alias value must not be empty"
- }
- return yaml_emitter_set_emitter_error(emitter, problem)
- }
- for i := 0; i < len(anchor); i += width(anchor[i]) {
- if !is_alpha(anchor, i) {
- problem := "anchor value must contain alphanumerical characters only"
- if alias {
- problem = "alias value must contain alphanumerical characters only"
- }
- return yaml_emitter_set_emitter_error(emitter, problem)
- }
- }
- emitter.anchor_data.anchor = anchor
- emitter.anchor_data.alias = alias
- return true
-}
-
-// Check if a tag is valid.
-func yaml_emitter_analyze_tag(emitter *yaml_emitter_t, tag []byte) bool {
- if len(tag) == 0 {
- return yaml_emitter_set_emitter_error(emitter, "tag value must not be empty")
- }
- for i := 0; i < len(emitter.tag_directives); i++ {
- tag_directive := &emitter.tag_directives[i]
- if bytes.HasPrefix(tag, tag_directive.prefix) {
- emitter.tag_data.handle = tag_directive.handle
- emitter.tag_data.suffix = tag[len(tag_directive.prefix):]
- return true
- }
- }
- emitter.tag_data.suffix = tag
- return true
-}
-
-// Check if a scalar is valid.
-func yaml_emitter_analyze_scalar(emitter *yaml_emitter_t, value []byte) bool {
- var (
- block_indicators = false
- flow_indicators = false
- line_breaks = false
- special_characters = false
- tab_characters = false
-
- leading_space = false
- leading_break = false
- trailing_space = false
- trailing_break = false
- break_space = false
- space_break = false
-
- preceded_by_whitespace = false
- followed_by_whitespace = false
- previous_space = false
- previous_break = false
- )
-
- emitter.scalar_data.value = value
-
- if len(value) == 0 {
- emitter.scalar_data.multiline = false
- emitter.scalar_data.flow_plain_allowed = false
- emitter.scalar_data.block_plain_allowed = true
- emitter.scalar_data.single_quoted_allowed = true
- emitter.scalar_data.block_allowed = false
- return true
- }
-
- if len(value) >= 3 && ((value[0] == '-' && value[1] == '-' && value[2] == '-') || (value[0] == '.' && value[1] == '.' && value[2] == '.')) {
- block_indicators = true
- flow_indicators = true
- }
-
- preceded_by_whitespace = true
- for i, w := 0, 0; i < len(value); i += w {
- w = width(value[i])
- followed_by_whitespace = i+w >= len(value) || is_blank(value, i+w)
-
- if i == 0 {
- switch value[i] {
- case '#', ',', '[', ']', '{', '}', '&', '*', '!', '|', '>', '\'', '"', '%', '@', '`':
- flow_indicators = true
- block_indicators = true
- case '?', ':':
- flow_indicators = true
- if followed_by_whitespace {
- block_indicators = true
- }
- case '-':
- if followed_by_whitespace {
- flow_indicators = true
- block_indicators = true
- }
- }
- } else {
- switch value[i] {
- case ',', '?', '[', ']', '{', '}':
- flow_indicators = true
- case ':':
- flow_indicators = true
- if followed_by_whitespace {
- block_indicators = true
- }
- case '#':
- if preceded_by_whitespace {
- flow_indicators = true
- block_indicators = true
- }
- }
- }
-
- if value[i] == '\t' {
- tab_characters = true
- } else if !is_printable(value, i) || !is_ascii(value, i) && !emitter.unicode {
- special_characters = true
- }
- if is_space(value, i) {
- if i == 0 {
- leading_space = true
- }
- if i+width(value[i]) == len(value) {
- trailing_space = true
- }
- if previous_break {
- break_space = true
- }
- previous_space = true
- previous_break = false
- } else if is_break(value, i) {
- line_breaks = true
- if i == 0 {
- leading_break = true
- }
- if i+width(value[i]) == len(value) {
- trailing_break = true
- }
- if previous_space {
- space_break = true
- }
- previous_space = false
- previous_break = true
- } else {
- previous_space = false
- previous_break = false
- }
-
- // [Go]: Why 'z'? Couldn't be the end of the string as that's the loop condition.
- preceded_by_whitespace = is_blankz(value, i)
- }
-
- emitter.scalar_data.multiline = line_breaks
- emitter.scalar_data.flow_plain_allowed = true
- emitter.scalar_data.block_plain_allowed = true
- emitter.scalar_data.single_quoted_allowed = true
- emitter.scalar_data.block_allowed = true
-
- if leading_space || leading_break || trailing_space || trailing_break {
- emitter.scalar_data.flow_plain_allowed = false
- emitter.scalar_data.block_plain_allowed = false
- }
- if trailing_space {
- emitter.scalar_data.block_allowed = false
- }
- if break_space {
- emitter.scalar_data.flow_plain_allowed = false
- emitter.scalar_data.block_plain_allowed = false
- emitter.scalar_data.single_quoted_allowed = false
- }
- if space_break || tab_characters || special_characters {
- emitter.scalar_data.flow_plain_allowed = false
- emitter.scalar_data.block_plain_allowed = false
- emitter.scalar_data.single_quoted_allowed = false
- }
- if space_break || special_characters {
- emitter.scalar_data.block_allowed = false
- }
- if line_breaks {
- emitter.scalar_data.flow_plain_allowed = false
- emitter.scalar_data.block_plain_allowed = false
- }
- if flow_indicators {
- emitter.scalar_data.flow_plain_allowed = false
- }
- if block_indicators {
- emitter.scalar_data.block_plain_allowed = false
- }
- return true
-}
-
-// Check if the event data is valid.
-func yaml_emitter_analyze_event(emitter *yaml_emitter_t, event *yaml_event_t) bool {
-
- emitter.anchor_data.anchor = nil
- emitter.tag_data.handle = nil
- emitter.tag_data.suffix = nil
- emitter.scalar_data.value = nil
-
- if len(event.head_comment) > 0 {
- emitter.head_comment = event.head_comment
- }
- if len(event.line_comment) > 0 {
- emitter.line_comment = event.line_comment
- }
- if len(event.foot_comment) > 0 {
- emitter.foot_comment = event.foot_comment
- }
- if len(event.tail_comment) > 0 {
- emitter.tail_comment = event.tail_comment
- }
-
- switch event.typ {
- case yaml_ALIAS_EVENT:
- if !yaml_emitter_analyze_anchor(emitter, event.anchor, true) {
- return false
- }
-
- case yaml_SCALAR_EVENT:
- if len(event.anchor) > 0 {
- if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) {
- return false
- }
- }
- if len(event.tag) > 0 && (emitter.canonical || (!event.implicit && !event.quoted_implicit)) {
- if !yaml_emitter_analyze_tag(emitter, event.tag) {
- return false
- }
- }
- if !yaml_emitter_analyze_scalar(emitter, event.value) {
- return false
- }
-
- case yaml_SEQUENCE_START_EVENT:
- if len(event.anchor) > 0 {
- if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) {
- return false
- }
- }
- if len(event.tag) > 0 && (emitter.canonical || !event.implicit) {
- if !yaml_emitter_analyze_tag(emitter, event.tag) {
- return false
- }
- }
-
- case yaml_MAPPING_START_EVENT:
- if len(event.anchor) > 0 {
- if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) {
- return false
- }
- }
- if len(event.tag) > 0 && (emitter.canonical || !event.implicit) {
- if !yaml_emitter_analyze_tag(emitter, event.tag) {
- return false
- }
- }
- }
- return true
-}
-
-// Write the BOM character.
-func yaml_emitter_write_bom(emitter *yaml_emitter_t) bool {
- if !flush(emitter) {
- return false
- }
- pos := emitter.buffer_pos
- emitter.buffer[pos+0] = '\xEF'
- emitter.buffer[pos+1] = '\xBB'
- emitter.buffer[pos+2] = '\xBF'
- emitter.buffer_pos += 3
- return true
-}
-
-func yaml_emitter_write_indent(emitter *yaml_emitter_t) bool {
- indent := emitter.indent
- if indent < 0 {
- indent = 0
- }
- if !emitter.indention || emitter.column > indent || (emitter.column == indent && !emitter.whitespace) {
- if !put_break(emitter) {
- return false
- }
- }
- if emitter.foot_indent == indent {
- if !put_break(emitter) {
- return false
- }
- }
- for emitter.column < indent {
- if !put(emitter, ' ') {
- return false
- }
- }
- emitter.whitespace = true
- //emitter.indention = true
- emitter.space_above = false
- emitter.foot_indent = -1
- return true
-}
-
-func yaml_emitter_write_indicator(emitter *yaml_emitter_t, indicator []byte, need_whitespace, is_whitespace, is_indention bool) bool {
- if need_whitespace && !emitter.whitespace {
- if !put(emitter, ' ') {
- return false
- }
- }
- if !write_all(emitter, indicator) {
- return false
- }
- emitter.whitespace = is_whitespace
- emitter.indention = (emitter.indention && is_indention)
- emitter.open_ended = false
- return true
-}
-
-func yaml_emitter_write_anchor(emitter *yaml_emitter_t, value []byte) bool {
- if !write_all(emitter, value) {
- return false
- }
- emitter.whitespace = false
- emitter.indention = false
- return true
-}
-
-func yaml_emitter_write_tag_handle(emitter *yaml_emitter_t, value []byte) bool {
- if !emitter.whitespace {
- if !put(emitter, ' ') {
- return false
- }
- }
- if !write_all(emitter, value) {
- return false
- }
- emitter.whitespace = false
- emitter.indention = false
- return true
-}
-
-func yaml_emitter_write_tag_content(emitter *yaml_emitter_t, value []byte, need_whitespace bool) bool {
- if need_whitespace && !emitter.whitespace {
- if !put(emitter, ' ') {
- return false
- }
- }
- for i := 0; i < len(value); {
- var must_write bool
- switch value[i] {
- case ';', '/', '?', ':', '@', '&', '=', '+', '$', ',', '_', '.', '~', '*', '\'', '(', ')', '[', ']':
- must_write = true
- default:
- must_write = is_alpha(value, i)
- }
- if must_write {
- if !write(emitter, value, &i) {
- return false
- }
- } else {
- w := width(value[i])
- for k := 0; k < w; k++ {
- octet := value[i]
- i++
- if !put(emitter, '%') {
- return false
- }
-
- c := octet >> 4
- if c < 10 {
- c += '0'
- } else {
- c += 'A' - 10
- }
- if !put(emitter, c) {
- return false
- }
-
- c = octet & 0x0f
- if c < 10 {
- c += '0'
- } else {
- c += 'A' - 10
- }
- if !put(emitter, c) {
- return false
- }
- }
- }
- }
- emitter.whitespace = false
- emitter.indention = false
- return true
-}
-
-func yaml_emitter_write_plain_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool {
- if len(value) > 0 && !emitter.whitespace {
- if !put(emitter, ' ') {
- return false
- }
- }
-
- spaces := false
- breaks := false
- for i := 0; i < len(value); {
- if is_space(value, i) {
- if allow_breaks && !spaces && emitter.column > emitter.best_width && !is_space(value, i+1) {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- i += width(value[i])
- } else {
- if !write(emitter, value, &i) {
- return false
- }
- }
- spaces = true
- } else if is_break(value, i) {
- if !breaks && value[i] == '\n' {
- if !put_break(emitter) {
- return false
- }
- }
- if !write_break(emitter, value, &i) {
- return false
- }
- //emitter.indention = true
- breaks = true
- } else {
- if breaks {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !write(emitter, value, &i) {
- return false
- }
- emitter.indention = false
- spaces = false
- breaks = false
- }
- }
-
- if len(value) > 0 {
- emitter.whitespace = false
- }
- emitter.indention = false
- if emitter.root_context {
- emitter.open_ended = true
- }
-
- return true
-}
-
-func yaml_emitter_write_single_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool {
-
- if !yaml_emitter_write_indicator(emitter, []byte{'\''}, true, false, false) {
- return false
- }
-
- spaces := false
- breaks := false
- for i := 0; i < len(value); {
- if is_space(value, i) {
- if allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 && !is_space(value, i+1) {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- i += width(value[i])
- } else {
- if !write(emitter, value, &i) {
- return false
- }
- }
- spaces = true
- } else if is_break(value, i) {
- if !breaks && value[i] == '\n' {
- if !put_break(emitter) {
- return false
- }
- }
- if !write_break(emitter, value, &i) {
- return false
- }
- //emitter.indention = true
- breaks = true
- } else {
- if breaks {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if value[i] == '\'' {
- if !put(emitter, '\'') {
- return false
- }
- }
- if !write(emitter, value, &i) {
- return false
- }
- emitter.indention = false
- spaces = false
- breaks = false
- }
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'\''}, false, false, false) {
- return false
- }
- emitter.whitespace = false
- emitter.indention = false
- return true
-}
-
-func yaml_emitter_write_double_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool {
- spaces := false
- if !yaml_emitter_write_indicator(emitter, []byte{'"'}, true, false, false) {
- return false
- }
-
- for i := 0; i < len(value); {
- if !is_printable(value, i) || (!emitter.unicode && !is_ascii(value, i)) ||
- is_bom(value, i) || is_break(value, i) ||
- value[i] == '"' || value[i] == '\\' {
-
- octet := value[i]
-
- var w int
- var v rune
- switch {
- case octet&0x80 == 0x00:
- w, v = 1, rune(octet&0x7F)
- case octet&0xE0 == 0xC0:
- w, v = 2, rune(octet&0x1F)
- case octet&0xF0 == 0xE0:
- w, v = 3, rune(octet&0x0F)
- case octet&0xF8 == 0xF0:
- w, v = 4, rune(octet&0x07)
- }
- for k := 1; k < w; k++ {
- octet = value[i+k]
- v = (v << 6) + (rune(octet) & 0x3F)
- }
- i += w
-
- if !put(emitter, '\\') {
- return false
- }
-
- var ok bool
- switch v {
- case 0x00:
- ok = put(emitter, '0')
- case 0x07:
- ok = put(emitter, 'a')
- case 0x08:
- ok = put(emitter, 'b')
- case 0x09:
- ok = put(emitter, 't')
- case 0x0A:
- ok = put(emitter, 'n')
- case 0x0b:
- ok = put(emitter, 'v')
- case 0x0c:
- ok = put(emitter, 'f')
- case 0x0d:
- ok = put(emitter, 'r')
- case 0x1b:
- ok = put(emitter, 'e')
- case 0x22:
- ok = put(emitter, '"')
- case 0x5c:
- ok = put(emitter, '\\')
- case 0x85:
- ok = put(emitter, 'N')
- case 0xA0:
- ok = put(emitter, '_')
- case 0x2028:
- ok = put(emitter, 'L')
- case 0x2029:
- ok = put(emitter, 'P')
- default:
- if v <= 0xFF {
- ok = put(emitter, 'x')
- w = 2
- } else if v <= 0xFFFF {
- ok = put(emitter, 'u')
- w = 4
- } else {
- ok = put(emitter, 'U')
- w = 8
- }
- for k := (w - 1) * 4; ok && k >= 0; k -= 4 {
- digit := byte((v >> uint(k)) & 0x0F)
- if digit < 10 {
- ok = put(emitter, digit+'0')
- } else {
- ok = put(emitter, digit+'A'-10)
- }
- }
- }
- if !ok {
- return false
- }
- spaces = false
- } else if is_space(value, i) {
- if allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if is_space(value, i+1) {
- if !put(emitter, '\\') {
- return false
- }
- }
- i += width(value[i])
- } else if !write(emitter, value, &i) {
- return false
- }
- spaces = true
- } else {
- if !write(emitter, value, &i) {
- return false
- }
- spaces = false
- }
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'"'}, false, false, false) {
- return false
- }
- emitter.whitespace = false
- emitter.indention = false
- return true
-}
-
-func yaml_emitter_write_block_scalar_hints(emitter *yaml_emitter_t, value []byte) bool {
- if is_space(value, 0) || is_break(value, 0) {
- indent_hint := []byte{'0' + byte(emitter.best_indent)}
- if !yaml_emitter_write_indicator(emitter, indent_hint, false, false, false) {
- return false
- }
- }
-
- emitter.open_ended = false
-
- var chomp_hint [1]byte
- if len(value) == 0 {
- chomp_hint[0] = '-'
- } else {
- i := len(value) - 1
- for value[i]&0xC0 == 0x80 {
- i--
- }
- if !is_break(value, i) {
- chomp_hint[0] = '-'
- } else if i == 0 {
- chomp_hint[0] = '+'
- emitter.open_ended = true
- } else {
- i--
- for value[i]&0xC0 == 0x80 {
- i--
- }
- if is_break(value, i) {
- chomp_hint[0] = '+'
- emitter.open_ended = true
- }
- }
- }
- if chomp_hint[0] != 0 {
- if !yaml_emitter_write_indicator(emitter, chomp_hint[:], false, false, false) {
- return false
- }
- }
- return true
-}
-
-func yaml_emitter_write_literal_scalar(emitter *yaml_emitter_t, value []byte) bool {
- if !yaml_emitter_write_indicator(emitter, []byte{'|'}, true, false, false) {
- return false
- }
- if !yaml_emitter_write_block_scalar_hints(emitter, value) {
- return false
- }
- if !yaml_emitter_process_line_comment(emitter) {
- return false
- }
- //emitter.indention = true
- emitter.whitespace = true
- breaks := true
- for i := 0; i < len(value); {
- if is_break(value, i) {
- if !write_break(emitter, value, &i) {
- return false
- }
- //emitter.indention = true
- breaks = true
- } else {
- if breaks {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !write(emitter, value, &i) {
- return false
- }
- emitter.indention = false
- breaks = false
- }
- }
-
- return true
-}
-
-func yaml_emitter_write_folded_scalar(emitter *yaml_emitter_t, value []byte) bool {
- if !yaml_emitter_write_indicator(emitter, []byte{'>'}, true, false, false) {
- return false
- }
- if !yaml_emitter_write_block_scalar_hints(emitter, value) {
- return false
- }
- if !yaml_emitter_process_line_comment(emitter) {
- return false
- }
-
- //emitter.indention = true
- emitter.whitespace = true
-
- breaks := true
- leading_spaces := true
- for i := 0; i < len(value); {
- if is_break(value, i) {
- if !breaks && !leading_spaces && value[i] == '\n' {
- k := 0
- for is_break(value, k) {
- k += width(value[k])
- }
- if !is_blankz(value, k) {
- if !put_break(emitter) {
- return false
- }
- }
- }
- if !write_break(emitter, value, &i) {
- return false
- }
- //emitter.indention = true
- breaks = true
- } else {
- if breaks {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- leading_spaces = is_blank(value, i)
- }
- if !breaks && is_space(value, i) && !is_space(value, i+1) && emitter.column > emitter.best_width {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- i += width(value[i])
- } else {
- if !write(emitter, value, &i) {
- return false
- }
- }
- emitter.indention = false
- breaks = false
- }
- }
- return true
-}
-
-func yaml_emitter_write_comment(emitter *yaml_emitter_t, comment []byte) bool {
- breaks := false
- pound := false
- for i := 0; i < len(comment); {
- if is_break(comment, i) {
- if !write_break(emitter, comment, &i) {
- return false
- }
- //emitter.indention = true
- breaks = true
- pound = false
- } else {
- if breaks && !yaml_emitter_write_indent(emitter) {
- return false
- }
- if !pound {
- if comment[i] != '#' && (!put(emitter, '#') || !put(emitter, ' ')) {
- return false
- }
- pound = true
- }
- if !write(emitter, comment, &i) {
- return false
- }
- emitter.indention = false
- breaks = false
- }
- }
- if !breaks && !put_break(emitter) {
- return false
- }
-
- emitter.whitespace = true
- //emitter.indention = true
- return true
-}
diff --git a/vendor/gopkg.in/yaml.v3/encode.go b/vendor/gopkg.in/yaml.v3/encode.go
deleted file mode 100644
index de9e72a3..00000000
--- a/vendor/gopkg.in/yaml.v3/encode.go
+++ /dev/null
@@ -1,577 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package yaml
-
-import (
- "encoding"
- "fmt"
- "io"
- "reflect"
- "regexp"
- "sort"
- "strconv"
- "strings"
- "time"
- "unicode/utf8"
-)
-
-type encoder struct {
- emitter yaml_emitter_t
- event yaml_event_t
- out []byte
- flow bool
- indent int
- doneInit bool
-}
-
-func newEncoder() *encoder {
- e := &encoder{}
- yaml_emitter_initialize(&e.emitter)
- yaml_emitter_set_output_string(&e.emitter, &e.out)
- yaml_emitter_set_unicode(&e.emitter, true)
- return e
-}
-
-func newEncoderWithWriter(w io.Writer) *encoder {
- e := &encoder{}
- yaml_emitter_initialize(&e.emitter)
- yaml_emitter_set_output_writer(&e.emitter, w)
- yaml_emitter_set_unicode(&e.emitter, true)
- return e
-}
-
-func (e *encoder) init() {
- if e.doneInit {
- return
- }
- if e.indent == 0 {
- e.indent = 4
- }
- e.emitter.best_indent = e.indent
- yaml_stream_start_event_initialize(&e.event, yaml_UTF8_ENCODING)
- e.emit()
- e.doneInit = true
-}
-
-func (e *encoder) finish() {
- e.emitter.open_ended = false
- yaml_stream_end_event_initialize(&e.event)
- e.emit()
-}
-
-func (e *encoder) destroy() {
- yaml_emitter_delete(&e.emitter)
-}
-
-func (e *encoder) emit() {
- // This will internally delete the e.event value.
- e.must(yaml_emitter_emit(&e.emitter, &e.event))
-}
-
-func (e *encoder) must(ok bool) {
- if !ok {
- msg := e.emitter.problem
- if msg == "" {
- msg = "unknown problem generating YAML content"
- }
- failf("%s", msg)
- }
-}
-
-func (e *encoder) marshalDoc(tag string, in reflect.Value) {
- e.init()
- var node *Node
- if in.IsValid() {
- node, _ = in.Interface().(*Node)
- }
- if node != nil && node.Kind == DocumentNode {
- e.nodev(in)
- } else {
- yaml_document_start_event_initialize(&e.event, nil, nil, true)
- e.emit()
- e.marshal(tag, in)
- yaml_document_end_event_initialize(&e.event, true)
- e.emit()
- }
-}
-
-func (e *encoder) marshal(tag string, in reflect.Value) {
- tag = shortTag(tag)
- if !in.IsValid() || in.Kind() == reflect.Ptr && in.IsNil() {
- e.nilv()
- return
- }
- iface := in.Interface()
- switch value := iface.(type) {
- case *Node:
- e.nodev(in)
- return
- case Node:
- if !in.CanAddr() {
- var n = reflect.New(in.Type()).Elem()
- n.Set(in)
- in = n
- }
- e.nodev(in.Addr())
- return
- case time.Time:
- e.timev(tag, in)
- return
- case *time.Time:
- e.timev(tag, in.Elem())
- return
- case time.Duration:
- e.stringv(tag, reflect.ValueOf(value.String()))
- return
- case Marshaler:
- v, err := value.MarshalYAML()
- if err != nil {
- fail(err)
- }
- if v == nil {
- e.nilv()
- return
- }
- e.marshal(tag, reflect.ValueOf(v))
- return
- case encoding.TextMarshaler:
- text, err := value.MarshalText()
- if err != nil {
- fail(err)
- }
- in = reflect.ValueOf(string(text))
- case nil:
- e.nilv()
- return
- }
- switch in.Kind() {
- case reflect.Interface:
- e.marshal(tag, in.Elem())
- case reflect.Map:
- e.mapv(tag, in)
- case reflect.Ptr:
- e.marshal(tag, in.Elem())
- case reflect.Struct:
- e.structv(tag, in)
- case reflect.Slice, reflect.Array:
- e.slicev(tag, in)
- case reflect.String:
- e.stringv(tag, in)
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- e.intv(tag, in)
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- e.uintv(tag, in)
- case reflect.Float32, reflect.Float64:
- e.floatv(tag, in)
- case reflect.Bool:
- e.boolv(tag, in)
- default:
- panic("cannot marshal type: " + in.Type().String())
- }
-}
-
-func (e *encoder) mapv(tag string, in reflect.Value) {
- e.mappingv(tag, func() {
- keys := keyList(in.MapKeys())
- sort.Sort(keys)
- for _, k := range keys {
- e.marshal("", k)
- e.marshal("", in.MapIndex(k))
- }
- })
-}
-
-func (e *encoder) fieldByIndex(v reflect.Value, index []int) (field reflect.Value) {
- for _, num := range index {
- for {
- if v.Kind() == reflect.Ptr {
- if v.IsNil() {
- return reflect.Value{}
- }
- v = v.Elem()
- continue
- }
- break
- }
- v = v.Field(num)
- }
- return v
-}
-
-func (e *encoder) structv(tag string, in reflect.Value) {
- sinfo, err := getStructInfo(in.Type())
- if err != nil {
- panic(err)
- }
- e.mappingv(tag, func() {
- for _, info := range sinfo.FieldsList {
- var value reflect.Value
- if info.Inline == nil {
- value = in.Field(info.Num)
- } else {
- value = e.fieldByIndex(in, info.Inline)
- if !value.IsValid() {
- continue
- }
- }
- if info.OmitEmpty && isZero(value) {
- continue
- }
- e.marshal("", reflect.ValueOf(info.Key))
- e.flow = info.Flow
- e.marshal("", value)
- }
- if sinfo.InlineMap >= 0 {
- m := in.Field(sinfo.InlineMap)
- if m.Len() > 0 {
- e.flow = false
- keys := keyList(m.MapKeys())
- sort.Sort(keys)
- for _, k := range keys {
- if _, found := sinfo.FieldsMap[k.String()]; found {
- panic(fmt.Sprintf("cannot have key %q in inlined map: conflicts with struct field", k.String()))
- }
- e.marshal("", k)
- e.flow = false
- e.marshal("", m.MapIndex(k))
- }
- }
- }
- })
-}
-
-func (e *encoder) mappingv(tag string, f func()) {
- implicit := tag == ""
- style := yaml_BLOCK_MAPPING_STYLE
- if e.flow {
- e.flow = false
- style = yaml_FLOW_MAPPING_STYLE
- }
- yaml_mapping_start_event_initialize(&e.event, nil, []byte(tag), implicit, style)
- e.emit()
- f()
- yaml_mapping_end_event_initialize(&e.event)
- e.emit()
-}
-
-func (e *encoder) slicev(tag string, in reflect.Value) {
- implicit := tag == ""
- style := yaml_BLOCK_SEQUENCE_STYLE
- if e.flow {
- e.flow = false
- style = yaml_FLOW_SEQUENCE_STYLE
- }
- e.must(yaml_sequence_start_event_initialize(&e.event, nil, []byte(tag), implicit, style))
- e.emit()
- n := in.Len()
- for i := 0; i < n; i++ {
- e.marshal("", in.Index(i))
- }
- e.must(yaml_sequence_end_event_initialize(&e.event))
- e.emit()
-}
-
-// isBase60 returns whether s is in base 60 notation as defined in YAML 1.1.
-//
-// The base 60 float notation in YAML 1.1 is a terrible idea and is unsupported
-// in YAML 1.2 and by this package, but these should be marshalled quoted for
-// the time being for compatibility with other parsers.
-func isBase60Float(s string) (result bool) {
- // Fast path.
- if s == "" {
- return false
- }
- c := s[0]
- if !(c == '+' || c == '-' || c >= '0' && c <= '9') || strings.IndexByte(s, ':') < 0 {
- return false
- }
- // Do the full match.
- return base60float.MatchString(s)
-}
-
-// From http://yaml.org/type/float.html, except the regular expression there
-// is bogus. In practice parsers do not enforce the "\.[0-9_]*" suffix.
-var base60float = regexp.MustCompile(`^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+(?:\.[0-9_]*)?$`)
-
-// isOldBool returns whether s is bool notation as defined in YAML 1.1.
-//
-// We continue to force strings that YAML 1.1 would interpret as booleans to be
-// rendered as quotes strings so that the marshalled output valid for YAML 1.1
-// parsing.
-func isOldBool(s string) (result bool) {
- switch s {
- case "y", "Y", "yes", "Yes", "YES", "on", "On", "ON",
- "n", "N", "no", "No", "NO", "off", "Off", "OFF":
- return true
- default:
- return false
- }
-}
-
-func (e *encoder) stringv(tag string, in reflect.Value) {
- var style yaml_scalar_style_t
- s := in.String()
- canUsePlain := true
- switch {
- case !utf8.ValidString(s):
- if tag == binaryTag {
- failf("explicitly tagged !!binary data must be base64-encoded")
- }
- if tag != "" {
- failf("cannot marshal invalid UTF-8 data as %s", shortTag(tag))
- }
- // It can't be encoded directly as YAML so use a binary tag
- // and encode it as base64.
- tag = binaryTag
- s = encodeBase64(s)
- case tag == "":
- // Check to see if it would resolve to a specific
- // tag when encoded unquoted. If it doesn't,
- // there's no need to quote it.
- rtag, _ := resolve("", s)
- canUsePlain = rtag == strTag && !(isBase60Float(s) || isOldBool(s))
- }
- // Note: it's possible for user code to emit invalid YAML
- // if they explicitly specify a tag and a string containing
- // text that's incompatible with that tag.
- switch {
- case strings.Contains(s, "\n"):
- if e.flow {
- style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- } else {
- style = yaml_LITERAL_SCALAR_STYLE
- }
- case canUsePlain:
- style = yaml_PLAIN_SCALAR_STYLE
- default:
- style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- }
- e.emitScalar(s, "", tag, style, nil, nil, nil, nil)
-}
-
-func (e *encoder) boolv(tag string, in reflect.Value) {
- var s string
- if in.Bool() {
- s = "true"
- } else {
- s = "false"
- }
- e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE, nil, nil, nil, nil)
-}
-
-func (e *encoder) intv(tag string, in reflect.Value) {
- s := strconv.FormatInt(in.Int(), 10)
- e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE, nil, nil, nil, nil)
-}
-
-func (e *encoder) uintv(tag string, in reflect.Value) {
- s := strconv.FormatUint(in.Uint(), 10)
- e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE, nil, nil, nil, nil)
-}
-
-func (e *encoder) timev(tag string, in reflect.Value) {
- t := in.Interface().(time.Time)
- s := t.Format(time.RFC3339Nano)
- e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE, nil, nil, nil, nil)
-}
-
-func (e *encoder) floatv(tag string, in reflect.Value) {
- // Issue #352: When formatting, use the precision of the underlying value
- precision := 64
- if in.Kind() == reflect.Float32 {
- precision = 32
- }
-
- s := strconv.FormatFloat(in.Float(), 'g', -1, precision)
- switch s {
- case "+Inf":
- s = ".inf"
- case "-Inf":
- s = "-.inf"
- case "NaN":
- s = ".nan"
- }
- e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE, nil, nil, nil, nil)
-}
-
-func (e *encoder) nilv() {
- e.emitScalar("null", "", "", yaml_PLAIN_SCALAR_STYLE, nil, nil, nil, nil)
-}
-
-func (e *encoder) emitScalar(value, anchor, tag string, style yaml_scalar_style_t, head, line, foot, tail []byte) {
- // TODO Kill this function. Replace all initialize calls by their underlining Go literals.
- implicit := tag == ""
- if !implicit {
- tag = longTag(tag)
- }
- e.must(yaml_scalar_event_initialize(&e.event, []byte(anchor), []byte(tag), []byte(value), implicit, implicit, style))
- e.event.head_comment = head
- e.event.line_comment = line
- e.event.foot_comment = foot
- e.event.tail_comment = tail
- e.emit()
-}
-
-func (e *encoder) nodev(in reflect.Value) {
- e.node(in.Interface().(*Node), "")
-}
-
-func (e *encoder) node(node *Node, tail string) {
- // Zero nodes behave as nil.
- if node.Kind == 0 && node.IsZero() {
- e.nilv()
- return
- }
-
- // If the tag was not explicitly requested, and dropping it won't change the
- // implicit tag of the value, don't include it in the presentation.
- var tag = node.Tag
- var stag = shortTag(tag)
- var forceQuoting bool
- if tag != "" && node.Style&TaggedStyle == 0 {
- if node.Kind == ScalarNode {
- if stag == strTag && node.Style&(SingleQuotedStyle|DoubleQuotedStyle|LiteralStyle|FoldedStyle) != 0 {
- tag = ""
- } else {
- rtag, _ := resolve("", node.Value)
- if rtag == stag {
- tag = ""
- } else if stag == strTag {
- tag = ""
- forceQuoting = true
- }
- }
- } else {
- var rtag string
- switch node.Kind {
- case MappingNode:
- rtag = mapTag
- case SequenceNode:
- rtag = seqTag
- }
- if rtag == stag {
- tag = ""
- }
- }
- }
-
- switch node.Kind {
- case DocumentNode:
- yaml_document_start_event_initialize(&e.event, nil, nil, true)
- e.event.head_comment = []byte(node.HeadComment)
- e.emit()
- for _, node := range node.Content {
- e.node(node, "")
- }
- yaml_document_end_event_initialize(&e.event, true)
- e.event.foot_comment = []byte(node.FootComment)
- e.emit()
-
- case SequenceNode:
- style := yaml_BLOCK_SEQUENCE_STYLE
- if node.Style&FlowStyle != 0 {
- style = yaml_FLOW_SEQUENCE_STYLE
- }
- e.must(yaml_sequence_start_event_initialize(&e.event, []byte(node.Anchor), []byte(longTag(tag)), tag == "", style))
- e.event.head_comment = []byte(node.HeadComment)
- e.emit()
- for _, node := range node.Content {
- e.node(node, "")
- }
- e.must(yaml_sequence_end_event_initialize(&e.event))
- e.event.line_comment = []byte(node.LineComment)
- e.event.foot_comment = []byte(node.FootComment)
- e.emit()
-
- case MappingNode:
- style := yaml_BLOCK_MAPPING_STYLE
- if node.Style&FlowStyle != 0 {
- style = yaml_FLOW_MAPPING_STYLE
- }
- yaml_mapping_start_event_initialize(&e.event, []byte(node.Anchor), []byte(longTag(tag)), tag == "", style)
- e.event.tail_comment = []byte(tail)
- e.event.head_comment = []byte(node.HeadComment)
- e.emit()
-
- // The tail logic below moves the foot comment of prior keys to the following key,
- // since the value for each key may be a nested structure and the foot needs to be
- // processed only the entirety of the value is streamed. The last tail is processed
- // with the mapping end event.
- var tail string
- for i := 0; i+1 < len(node.Content); i += 2 {
- k := node.Content[i]
- foot := k.FootComment
- if foot != "" {
- kopy := *k
- kopy.FootComment = ""
- k = &kopy
- }
- e.node(k, tail)
- tail = foot
-
- v := node.Content[i+1]
- e.node(v, "")
- }
-
- yaml_mapping_end_event_initialize(&e.event)
- e.event.tail_comment = []byte(tail)
- e.event.line_comment = []byte(node.LineComment)
- e.event.foot_comment = []byte(node.FootComment)
- e.emit()
-
- case AliasNode:
- yaml_alias_event_initialize(&e.event, []byte(node.Value))
- e.event.head_comment = []byte(node.HeadComment)
- e.event.line_comment = []byte(node.LineComment)
- e.event.foot_comment = []byte(node.FootComment)
- e.emit()
-
- case ScalarNode:
- value := node.Value
- if !utf8.ValidString(value) {
- if stag == binaryTag {
- failf("explicitly tagged !!binary data must be base64-encoded")
- }
- if stag != "" {
- failf("cannot marshal invalid UTF-8 data as %s", stag)
- }
- // It can't be encoded directly as YAML so use a binary tag
- // and encode it as base64.
- tag = binaryTag
- value = encodeBase64(value)
- }
-
- style := yaml_PLAIN_SCALAR_STYLE
- switch {
- case node.Style&DoubleQuotedStyle != 0:
- style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- case node.Style&SingleQuotedStyle != 0:
- style = yaml_SINGLE_QUOTED_SCALAR_STYLE
- case node.Style&LiteralStyle != 0:
- style = yaml_LITERAL_SCALAR_STYLE
- case node.Style&FoldedStyle != 0:
- style = yaml_FOLDED_SCALAR_STYLE
- case strings.Contains(value, "\n"):
- style = yaml_LITERAL_SCALAR_STYLE
- case forceQuoting:
- style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- }
-
- e.emitScalar(value, node.Anchor, tag, style, []byte(node.HeadComment), []byte(node.LineComment), []byte(node.FootComment), []byte(tail))
- default:
- failf("cannot encode node with unknown kind %d", node.Kind)
- }
-}
diff --git a/vendor/gopkg.in/yaml.v3/parserc.go b/vendor/gopkg.in/yaml.v3/parserc.go
deleted file mode 100644
index 268558a0..00000000
--- a/vendor/gopkg.in/yaml.v3/parserc.go
+++ /dev/null
@@ -1,1258 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-// Copyright (c) 2006-2010 Kirill Simonov
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-package yaml
-
-import (
- "bytes"
-)
-
-// The parser implements the following grammar:
-//
-// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END
-// implicit_document ::= block_node DOCUMENT-END*
-// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
-// block_node_or_indentless_sequence ::=
-// ALIAS
-// | properties (block_content | indentless_block_sequence)?
-// | block_content
-// | indentless_block_sequence
-// block_node ::= ALIAS
-// | properties block_content?
-// | block_content
-// flow_node ::= ALIAS
-// | properties flow_content?
-// | flow_content
-// properties ::= TAG ANCHOR? | ANCHOR TAG?
-// block_content ::= block_collection | flow_collection | SCALAR
-// flow_content ::= flow_collection | SCALAR
-// block_collection ::= block_sequence | block_mapping
-// flow_collection ::= flow_sequence | flow_mapping
-// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
-// indentless_sequence ::= (BLOCK-ENTRY block_node?)+
-// block_mapping ::= BLOCK-MAPPING_START
-// ((KEY block_node_or_indentless_sequence?)?
-// (VALUE block_node_or_indentless_sequence?)?)*
-// BLOCK-END
-// flow_sequence ::= FLOW-SEQUENCE-START
-// (flow_sequence_entry FLOW-ENTRY)*
-// flow_sequence_entry?
-// FLOW-SEQUENCE-END
-// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// flow_mapping ::= FLOW-MAPPING-START
-// (flow_mapping_entry FLOW-ENTRY)*
-// flow_mapping_entry?
-// FLOW-MAPPING-END
-// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-
-// Peek the next token in the token queue.
-func peek_token(parser *yaml_parser_t) *yaml_token_t {
- if parser.token_available || yaml_parser_fetch_more_tokens(parser) {
- token := &parser.tokens[parser.tokens_head]
- yaml_parser_unfold_comments(parser, token)
- return token
- }
- return nil
-}
-
-// yaml_parser_unfold_comments walks through the comments queue and joins all
-// comments behind the position of the provided token into the respective
-// top-level comment slices in the parser.
-func yaml_parser_unfold_comments(parser *yaml_parser_t, token *yaml_token_t) {
- for parser.comments_head < len(parser.comments) && token.start_mark.index >= parser.comments[parser.comments_head].token_mark.index {
- comment := &parser.comments[parser.comments_head]
- if len(comment.head) > 0 {
- if token.typ == yaml_BLOCK_END_TOKEN {
- // No heads on ends, so keep comment.head for a follow up token.
- break
- }
- if len(parser.head_comment) > 0 {
- parser.head_comment = append(parser.head_comment, '\n')
- }
- parser.head_comment = append(parser.head_comment, comment.head...)
- }
- if len(comment.foot) > 0 {
- if len(parser.foot_comment) > 0 {
- parser.foot_comment = append(parser.foot_comment, '\n')
- }
- parser.foot_comment = append(parser.foot_comment, comment.foot...)
- }
- if len(comment.line) > 0 {
- if len(parser.line_comment) > 0 {
- parser.line_comment = append(parser.line_comment, '\n')
- }
- parser.line_comment = append(parser.line_comment, comment.line...)
- }
- *comment = yaml_comment_t{}
- parser.comments_head++
- }
-}
-
-// Remove the next token from the queue (must be called after peek_token).
-func skip_token(parser *yaml_parser_t) {
- parser.token_available = false
- parser.tokens_parsed++
- parser.stream_end_produced = parser.tokens[parser.tokens_head].typ == yaml_STREAM_END_TOKEN
- parser.tokens_head++
-}
-
-// Get the next event.
-func yaml_parser_parse(parser *yaml_parser_t, event *yaml_event_t) bool {
- // Erase the event object.
- *event = yaml_event_t{}
-
- // No events after the end of the stream or error.
- if parser.stream_end_produced || parser.error != yaml_NO_ERROR || parser.state == yaml_PARSE_END_STATE {
- return true
- }
-
- // Generate the next event.
- return yaml_parser_state_machine(parser, event)
-}
-
-// Set parser error.
-func yaml_parser_set_parser_error(parser *yaml_parser_t, problem string, problem_mark yaml_mark_t) bool {
- parser.error = yaml_PARSER_ERROR
- parser.problem = problem
- parser.problem_mark = problem_mark
- return false
-}
-
-func yaml_parser_set_parser_error_context(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string, problem_mark yaml_mark_t) bool {
- parser.error = yaml_PARSER_ERROR
- parser.context = context
- parser.context_mark = context_mark
- parser.problem = problem
- parser.problem_mark = problem_mark
- return false
-}
-
-// State dispatcher.
-func yaml_parser_state_machine(parser *yaml_parser_t, event *yaml_event_t) bool {
- //trace("yaml_parser_state_machine", "state:", parser.state.String())
-
- switch parser.state {
- case yaml_PARSE_STREAM_START_STATE:
- return yaml_parser_parse_stream_start(parser, event)
-
- case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE:
- return yaml_parser_parse_document_start(parser, event, true)
-
- case yaml_PARSE_DOCUMENT_START_STATE:
- return yaml_parser_parse_document_start(parser, event, false)
-
- case yaml_PARSE_DOCUMENT_CONTENT_STATE:
- return yaml_parser_parse_document_content(parser, event)
-
- case yaml_PARSE_DOCUMENT_END_STATE:
- return yaml_parser_parse_document_end(parser, event)
-
- case yaml_PARSE_BLOCK_NODE_STATE:
- return yaml_parser_parse_node(parser, event, true, false)
-
- case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE:
- return yaml_parser_parse_node(parser, event, true, true)
-
- case yaml_PARSE_FLOW_NODE_STATE:
- return yaml_parser_parse_node(parser, event, false, false)
-
- case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE:
- return yaml_parser_parse_block_sequence_entry(parser, event, true)
-
- case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE:
- return yaml_parser_parse_block_sequence_entry(parser, event, false)
-
- case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE:
- return yaml_parser_parse_indentless_sequence_entry(parser, event)
-
- case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE:
- return yaml_parser_parse_block_mapping_key(parser, event, true)
-
- case yaml_PARSE_BLOCK_MAPPING_KEY_STATE:
- return yaml_parser_parse_block_mapping_key(parser, event, false)
-
- case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE:
- return yaml_parser_parse_block_mapping_value(parser, event)
-
- case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE:
- return yaml_parser_parse_flow_sequence_entry(parser, event, true)
-
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE:
- return yaml_parser_parse_flow_sequence_entry(parser, event, false)
-
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE:
- return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event)
-
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE:
- return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event)
-
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE:
- return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event)
-
- case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE:
- return yaml_parser_parse_flow_mapping_key(parser, event, true)
-
- case yaml_PARSE_FLOW_MAPPING_KEY_STATE:
- return yaml_parser_parse_flow_mapping_key(parser, event, false)
-
- case yaml_PARSE_FLOW_MAPPING_VALUE_STATE:
- return yaml_parser_parse_flow_mapping_value(parser, event, false)
-
- case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE:
- return yaml_parser_parse_flow_mapping_value(parser, event, true)
-
- default:
- panic("invalid parser state")
- }
-}
-
-// Parse the production:
-// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END
-// ************
-func yaml_parser_parse_stream_start(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_STREAM_START_TOKEN {
- return yaml_parser_set_parser_error(parser, "did not find expected ", token.start_mark)
- }
- parser.state = yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE
- *event = yaml_event_t{
- typ: yaml_STREAM_START_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- encoding: token.encoding,
- }
- skip_token(parser)
- return true
-}
-
-// Parse the productions:
-// implicit_document ::= block_node DOCUMENT-END*
-// *
-// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
-// *************************
-func yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t, implicit bool) bool {
-
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- // Parse extra document end indicators.
- if !implicit {
- for token.typ == yaml_DOCUMENT_END_TOKEN {
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- }
- }
-
- if implicit && token.typ != yaml_VERSION_DIRECTIVE_TOKEN &&
- token.typ != yaml_TAG_DIRECTIVE_TOKEN &&
- token.typ != yaml_DOCUMENT_START_TOKEN &&
- token.typ != yaml_STREAM_END_TOKEN {
- // Parse an implicit document.
- if !yaml_parser_process_directives(parser, nil, nil) {
- return false
- }
- parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE)
- parser.state = yaml_PARSE_BLOCK_NODE_STATE
-
- var head_comment []byte
- if len(parser.head_comment) > 0 {
- // [Go] Scan the header comment backwards, and if an empty line is found, break
- // the header so the part before the last empty line goes into the
- // document header, while the bottom of it goes into a follow up event.
- for i := len(parser.head_comment) - 1; i > 0; i-- {
- if parser.head_comment[i] == '\n' {
- if i == len(parser.head_comment)-1 {
- head_comment = parser.head_comment[:i]
- parser.head_comment = parser.head_comment[i+1:]
- break
- } else if parser.head_comment[i-1] == '\n' {
- head_comment = parser.head_comment[:i-1]
- parser.head_comment = parser.head_comment[i+1:]
- break
- }
- }
- }
- }
-
- *event = yaml_event_t{
- typ: yaml_DOCUMENT_START_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
-
- head_comment: head_comment,
- }
-
- } else if token.typ != yaml_STREAM_END_TOKEN {
- // Parse an explicit document.
- var version_directive *yaml_version_directive_t
- var tag_directives []yaml_tag_directive_t
- start_mark := token.start_mark
- if !yaml_parser_process_directives(parser, &version_directive, &tag_directives) {
- return false
- }
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_DOCUMENT_START_TOKEN {
- yaml_parser_set_parser_error(parser,
- "did not find expected ", token.start_mark)
- return false
- }
- parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE)
- parser.state = yaml_PARSE_DOCUMENT_CONTENT_STATE
- end_mark := token.end_mark
-
- *event = yaml_event_t{
- typ: yaml_DOCUMENT_START_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- version_directive: version_directive,
- tag_directives: tag_directives,
- implicit: false,
- }
- skip_token(parser)
-
- } else {
- // Parse the stream end.
- parser.state = yaml_PARSE_END_STATE
- *event = yaml_event_t{
- typ: yaml_STREAM_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- }
- skip_token(parser)
- }
-
- return true
-}
-
-// Parse the productions:
-// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
-// ***********
-//
-func yaml_parser_parse_document_content(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- if token.typ == yaml_VERSION_DIRECTIVE_TOKEN ||
- token.typ == yaml_TAG_DIRECTIVE_TOKEN ||
- token.typ == yaml_DOCUMENT_START_TOKEN ||
- token.typ == yaml_DOCUMENT_END_TOKEN ||
- token.typ == yaml_STREAM_END_TOKEN {
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
- return yaml_parser_process_empty_scalar(parser, event,
- token.start_mark)
- }
- return yaml_parser_parse_node(parser, event, true, false)
-}
-
-// Parse the productions:
-// implicit_document ::= block_node DOCUMENT-END*
-// *************
-// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
-//
-func yaml_parser_parse_document_end(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- start_mark := token.start_mark
- end_mark := token.start_mark
-
- implicit := true
- if token.typ == yaml_DOCUMENT_END_TOKEN {
- end_mark = token.end_mark
- skip_token(parser)
- implicit = false
- }
-
- parser.tag_directives = parser.tag_directives[:0]
-
- parser.state = yaml_PARSE_DOCUMENT_START_STATE
- *event = yaml_event_t{
- typ: yaml_DOCUMENT_END_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- implicit: implicit,
- }
- yaml_parser_set_event_comments(parser, event)
- if len(event.head_comment) > 0 && len(event.foot_comment) == 0 {
- event.foot_comment = event.head_comment
- event.head_comment = nil
- }
- return true
-}
-
-func yaml_parser_set_event_comments(parser *yaml_parser_t, event *yaml_event_t) {
- event.head_comment = parser.head_comment
- event.line_comment = parser.line_comment
- event.foot_comment = parser.foot_comment
- parser.head_comment = nil
- parser.line_comment = nil
- parser.foot_comment = nil
- parser.tail_comment = nil
- parser.stem_comment = nil
-}
-
-// Parse the productions:
-// block_node_or_indentless_sequence ::=
-// ALIAS
-// *****
-// | properties (block_content | indentless_block_sequence)?
-// ********** *
-// | block_content | indentless_block_sequence
-// *
-// block_node ::= ALIAS
-// *****
-// | properties block_content?
-// ********** *
-// | block_content
-// *
-// flow_node ::= ALIAS
-// *****
-// | properties flow_content?
-// ********** *
-// | flow_content
-// *
-// properties ::= TAG ANCHOR? | ANCHOR TAG?
-// *************************
-// block_content ::= block_collection | flow_collection | SCALAR
-// ******
-// flow_content ::= flow_collection | SCALAR
-// ******
-func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, indentless_sequence bool) bool {
- //defer trace("yaml_parser_parse_node", "block:", block, "indentless_sequence:", indentless_sequence)()
-
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- if token.typ == yaml_ALIAS_TOKEN {
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
- *event = yaml_event_t{
- typ: yaml_ALIAS_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- anchor: token.value,
- }
- yaml_parser_set_event_comments(parser, event)
- skip_token(parser)
- return true
- }
-
- start_mark := token.start_mark
- end_mark := token.start_mark
-
- var tag_token bool
- var tag_handle, tag_suffix, anchor []byte
- var tag_mark yaml_mark_t
- if token.typ == yaml_ANCHOR_TOKEN {
- anchor = token.value
- start_mark = token.start_mark
- end_mark = token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ == yaml_TAG_TOKEN {
- tag_token = true
- tag_handle = token.value
- tag_suffix = token.suffix
- tag_mark = token.start_mark
- end_mark = token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- }
- } else if token.typ == yaml_TAG_TOKEN {
- tag_token = true
- tag_handle = token.value
- tag_suffix = token.suffix
- start_mark = token.start_mark
- tag_mark = token.start_mark
- end_mark = token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ == yaml_ANCHOR_TOKEN {
- anchor = token.value
- end_mark = token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- }
- }
-
- var tag []byte
- if tag_token {
- if len(tag_handle) == 0 {
- tag = tag_suffix
- tag_suffix = nil
- } else {
- for i := range parser.tag_directives {
- if bytes.Equal(parser.tag_directives[i].handle, tag_handle) {
- tag = append([]byte(nil), parser.tag_directives[i].prefix...)
- tag = append(tag, tag_suffix...)
- break
- }
- }
- if len(tag) == 0 {
- yaml_parser_set_parser_error_context(parser,
- "while parsing a node", start_mark,
- "found undefined tag handle", tag_mark)
- return false
- }
- }
- }
-
- implicit := len(tag) == 0
- if indentless_sequence && token.typ == yaml_BLOCK_ENTRY_TOKEN {
- end_mark = token.end_mark
- parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_START_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE),
- }
- return true
- }
- if token.typ == yaml_SCALAR_TOKEN {
- var plain_implicit, quoted_implicit bool
- end_mark = token.end_mark
- if (len(tag) == 0 && token.style == yaml_PLAIN_SCALAR_STYLE) || (len(tag) == 1 && tag[0] == '!') {
- plain_implicit = true
- } else if len(tag) == 0 {
- quoted_implicit = true
- }
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
-
- *event = yaml_event_t{
- typ: yaml_SCALAR_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- value: token.value,
- implicit: plain_implicit,
- quoted_implicit: quoted_implicit,
- style: yaml_style_t(token.style),
- }
- yaml_parser_set_event_comments(parser, event)
- skip_token(parser)
- return true
- }
- if token.typ == yaml_FLOW_SEQUENCE_START_TOKEN {
- // [Go] Some of the events below can be merged as they differ only on style.
- end_mark = token.end_mark
- parser.state = yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_START_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(yaml_FLOW_SEQUENCE_STYLE),
- }
- yaml_parser_set_event_comments(parser, event)
- return true
- }
- if token.typ == yaml_FLOW_MAPPING_START_TOKEN {
- end_mark = token.end_mark
- parser.state = yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE
- *event = yaml_event_t{
- typ: yaml_MAPPING_START_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(yaml_FLOW_MAPPING_STYLE),
- }
- yaml_parser_set_event_comments(parser, event)
- return true
- }
- if block && token.typ == yaml_BLOCK_SEQUENCE_START_TOKEN {
- end_mark = token.end_mark
- parser.state = yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_START_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE),
- }
- if parser.stem_comment != nil {
- event.head_comment = parser.stem_comment
- parser.stem_comment = nil
- }
- return true
- }
- if block && token.typ == yaml_BLOCK_MAPPING_START_TOKEN {
- end_mark = token.end_mark
- parser.state = yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE
- *event = yaml_event_t{
- typ: yaml_MAPPING_START_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(yaml_BLOCK_MAPPING_STYLE),
- }
- if parser.stem_comment != nil {
- event.head_comment = parser.stem_comment
- parser.stem_comment = nil
- }
- return true
- }
- if len(anchor) > 0 || len(tag) > 0 {
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
-
- *event = yaml_event_t{
- typ: yaml_SCALAR_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- quoted_implicit: false,
- style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE),
- }
- return true
- }
-
- context := "while parsing a flow node"
- if block {
- context = "while parsing a block node"
- }
- yaml_parser_set_parser_error_context(parser, context, start_mark,
- "did not find expected node content", token.start_mark)
- return false
-}
-
-// Parse the productions:
-// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
-// ******************** *********** * *********
-//
-func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {
- if first {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- parser.marks = append(parser.marks, token.start_mark)
- skip_token(parser)
- }
-
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- if token.typ == yaml_BLOCK_ENTRY_TOKEN {
- mark := token.end_mark
- prior_head_len := len(parser.head_comment)
- skip_token(parser)
- yaml_parser_split_stem_comment(parser, prior_head_len)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_BLOCK_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE)
- return yaml_parser_parse_node(parser, event, true, false)
- } else {
- parser.state = yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE
- return yaml_parser_process_empty_scalar(parser, event, mark)
- }
- }
- if token.typ == yaml_BLOCK_END_TOKEN {
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
-
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- }
-
- skip_token(parser)
- return true
- }
-
- context_mark := parser.marks[len(parser.marks)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
- return yaml_parser_set_parser_error_context(parser,
- "while parsing a block collection", context_mark,
- "did not find expected '-' indicator", token.start_mark)
-}
-
-// Parse the productions:
-// indentless_sequence ::= (BLOCK-ENTRY block_node?)+
-// *********** *
-func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- if token.typ == yaml_BLOCK_ENTRY_TOKEN {
- mark := token.end_mark
- prior_head_len := len(parser.head_comment)
- skip_token(parser)
- yaml_parser_split_stem_comment(parser, prior_head_len)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_BLOCK_ENTRY_TOKEN &&
- token.typ != yaml_KEY_TOKEN &&
- token.typ != yaml_VALUE_TOKEN &&
- token.typ != yaml_BLOCK_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE)
- return yaml_parser_parse_node(parser, event, true, false)
- }
- parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE
- return yaml_parser_process_empty_scalar(parser, event, mark)
- }
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
-
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.start_mark, // [Go] Shouldn't this be token.end_mark?
- }
- return true
-}
-
-// Split stem comment from head comment.
-//
-// When a sequence or map is found under a sequence entry, the former head comment
-// is assigned to the underlying sequence or map as a whole, not the individual
-// sequence or map entry as would be expected otherwise. To handle this case the
-// previous head comment is moved aside as the stem comment.
-func yaml_parser_split_stem_comment(parser *yaml_parser_t, stem_len int) {
- if stem_len == 0 {
- return
- }
-
- token := peek_token(parser)
- if token == nil || token.typ != yaml_BLOCK_SEQUENCE_START_TOKEN && token.typ != yaml_BLOCK_MAPPING_START_TOKEN {
- return
- }
-
- parser.stem_comment = parser.head_comment[:stem_len]
- if len(parser.head_comment) == stem_len {
- parser.head_comment = nil
- } else {
- // Copy suffix to prevent very strange bugs if someone ever appends
- // further bytes to the prefix in the stem_comment slice above.
- parser.head_comment = append([]byte(nil), parser.head_comment[stem_len+1:]...)
- }
-}
-
-// Parse the productions:
-// block_mapping ::= BLOCK-MAPPING_START
-// *******************
-// ((KEY block_node_or_indentless_sequence?)?
-// *** *
-// (VALUE block_node_or_indentless_sequence?)?)*
-//
-// BLOCK-END
-// *********
-//
-func yaml_parser_parse_block_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {
- if first {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- parser.marks = append(parser.marks, token.start_mark)
- skip_token(parser)
- }
-
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- // [Go] A tail comment was left from the prior mapping value processed. Emit an event
- // as it needs to be processed with that value and not the following key.
- if len(parser.tail_comment) > 0 {
- *event = yaml_event_t{
- typ: yaml_TAIL_COMMENT_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- foot_comment: parser.tail_comment,
- }
- parser.tail_comment = nil
- return true
- }
-
- if token.typ == yaml_KEY_TOKEN {
- mark := token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_KEY_TOKEN &&
- token.typ != yaml_VALUE_TOKEN &&
- token.typ != yaml_BLOCK_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_VALUE_STATE)
- return yaml_parser_parse_node(parser, event, true, true)
- } else {
- parser.state = yaml_PARSE_BLOCK_MAPPING_VALUE_STATE
- return yaml_parser_process_empty_scalar(parser, event, mark)
- }
- } else if token.typ == yaml_BLOCK_END_TOKEN {
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
- *event = yaml_event_t{
- typ: yaml_MAPPING_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- }
- yaml_parser_set_event_comments(parser, event)
- skip_token(parser)
- return true
- }
-
- context_mark := parser.marks[len(parser.marks)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
- return yaml_parser_set_parser_error_context(parser,
- "while parsing a block mapping", context_mark,
- "did not find expected key", token.start_mark)
-}
-
-// Parse the productions:
-// block_mapping ::= BLOCK-MAPPING_START
-//
-// ((KEY block_node_or_indentless_sequence?)?
-//
-// (VALUE block_node_or_indentless_sequence?)?)*
-// ***** *
-// BLOCK-END
-//
-//
-func yaml_parser_parse_block_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ == yaml_VALUE_TOKEN {
- mark := token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_KEY_TOKEN &&
- token.typ != yaml_VALUE_TOKEN &&
- token.typ != yaml_BLOCK_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_KEY_STATE)
- return yaml_parser_parse_node(parser, event, true, true)
- }
- parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE
- return yaml_parser_process_empty_scalar(parser, event, mark)
- }
- parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE
- return yaml_parser_process_empty_scalar(parser, event, token.start_mark)
-}
-
-// Parse the productions:
-// flow_sequence ::= FLOW-SEQUENCE-START
-// *******************
-// (flow_sequence_entry FLOW-ENTRY)*
-// * **********
-// flow_sequence_entry?
-// *
-// FLOW-SEQUENCE-END
-// *****************
-// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// *
-//
-func yaml_parser_parse_flow_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {
- if first {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- parser.marks = append(parser.marks, token.start_mark)
- skip_token(parser)
- }
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN {
- if !first {
- if token.typ == yaml_FLOW_ENTRY_TOKEN {
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- } else {
- context_mark := parser.marks[len(parser.marks)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
- return yaml_parser_set_parser_error_context(parser,
- "while parsing a flow sequence", context_mark,
- "did not find expected ',' or ']'", token.start_mark)
- }
- }
-
- if token.typ == yaml_KEY_TOKEN {
- parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE
- *event = yaml_event_t{
- typ: yaml_MAPPING_START_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- implicit: true,
- style: yaml_style_t(yaml_FLOW_MAPPING_STYLE),
- }
- skip_token(parser)
- return true
- } else if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE)
- return yaml_parser_parse_node(parser, event, false, false)
- }
- }
-
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
-
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- }
- yaml_parser_set_event_comments(parser, event)
-
- skip_token(parser)
- return true
-}
-
-//
-// Parse the productions:
-// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// *** *
-//
-func yaml_parser_parse_flow_sequence_entry_mapping_key(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_VALUE_TOKEN &&
- token.typ != yaml_FLOW_ENTRY_TOKEN &&
- token.typ != yaml_FLOW_SEQUENCE_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE)
- return yaml_parser_parse_node(parser, event, false, false)
- }
- mark := token.end_mark
- skip_token(parser)
- parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE
- return yaml_parser_process_empty_scalar(parser, event, mark)
-}
-
-// Parse the productions:
-// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// ***** *
-//
-func yaml_parser_parse_flow_sequence_entry_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ == yaml_VALUE_TOKEN {
- skip_token(parser)
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_SEQUENCE_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE)
- return yaml_parser_parse_node(parser, event, false, false)
- }
- }
- parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE
- return yaml_parser_process_empty_scalar(parser, event, token.start_mark)
-}
-
-// Parse the productions:
-// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// *
-//
-func yaml_parser_parse_flow_sequence_entry_mapping_end(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE
- *event = yaml_event_t{
- typ: yaml_MAPPING_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.start_mark, // [Go] Shouldn't this be end_mark?
- }
- return true
-}
-
-// Parse the productions:
-// flow_mapping ::= FLOW-MAPPING-START
-// ******************
-// (flow_mapping_entry FLOW-ENTRY)*
-// * **********
-// flow_mapping_entry?
-// ******************
-// FLOW-MAPPING-END
-// ****************
-// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// * *** *
-//
-func yaml_parser_parse_flow_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {
- if first {
- token := peek_token(parser)
- parser.marks = append(parser.marks, token.start_mark)
- skip_token(parser)
- }
-
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- if token.typ != yaml_FLOW_MAPPING_END_TOKEN {
- if !first {
- if token.typ == yaml_FLOW_ENTRY_TOKEN {
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- } else {
- context_mark := parser.marks[len(parser.marks)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
- return yaml_parser_set_parser_error_context(parser,
- "while parsing a flow mapping", context_mark,
- "did not find expected ',' or '}'", token.start_mark)
- }
- }
-
- if token.typ == yaml_KEY_TOKEN {
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_VALUE_TOKEN &&
- token.typ != yaml_FLOW_ENTRY_TOKEN &&
- token.typ != yaml_FLOW_MAPPING_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_VALUE_STATE)
- return yaml_parser_parse_node(parser, event, false, false)
- } else {
- parser.state = yaml_PARSE_FLOW_MAPPING_VALUE_STATE
- return yaml_parser_process_empty_scalar(parser, event, token.start_mark)
- }
- } else if token.typ != yaml_FLOW_MAPPING_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE)
- return yaml_parser_parse_node(parser, event, false, false)
- }
- }
-
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
- *event = yaml_event_t{
- typ: yaml_MAPPING_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- }
- yaml_parser_set_event_comments(parser, event)
- skip_token(parser)
- return true
-}
-
-// Parse the productions:
-// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// * ***** *
-//
-func yaml_parser_parse_flow_mapping_value(parser *yaml_parser_t, event *yaml_event_t, empty bool) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if empty {
- parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE
- return yaml_parser_process_empty_scalar(parser, event, token.start_mark)
- }
- if token.typ == yaml_VALUE_TOKEN {
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_MAPPING_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_KEY_STATE)
- return yaml_parser_parse_node(parser, event, false, false)
- }
- }
- parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE
- return yaml_parser_process_empty_scalar(parser, event, token.start_mark)
-}
-
-// Generate an empty scalar event.
-func yaml_parser_process_empty_scalar(parser *yaml_parser_t, event *yaml_event_t, mark yaml_mark_t) bool {
- *event = yaml_event_t{
- typ: yaml_SCALAR_EVENT,
- start_mark: mark,
- end_mark: mark,
- value: nil, // Empty
- implicit: true,
- style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE),
- }
- return true
-}
-
-var default_tag_directives = []yaml_tag_directive_t{
- {[]byte("!"), []byte("!")},
- {[]byte("!!"), []byte("tag:yaml.org,2002:")},
-}
-
-// Parse directives.
-func yaml_parser_process_directives(parser *yaml_parser_t,
- version_directive_ref **yaml_version_directive_t,
- tag_directives_ref *[]yaml_tag_directive_t) bool {
-
- var version_directive *yaml_version_directive_t
- var tag_directives []yaml_tag_directive_t
-
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- for token.typ == yaml_VERSION_DIRECTIVE_TOKEN || token.typ == yaml_TAG_DIRECTIVE_TOKEN {
- if token.typ == yaml_VERSION_DIRECTIVE_TOKEN {
- if version_directive != nil {
- yaml_parser_set_parser_error(parser,
- "found duplicate %YAML directive", token.start_mark)
- return false
- }
- if token.major != 1 || token.minor != 1 {
- yaml_parser_set_parser_error(parser,
- "found incompatible YAML document", token.start_mark)
- return false
- }
- version_directive = &yaml_version_directive_t{
- major: token.major,
- minor: token.minor,
- }
- } else if token.typ == yaml_TAG_DIRECTIVE_TOKEN {
- value := yaml_tag_directive_t{
- handle: token.value,
- prefix: token.prefix,
- }
- if !yaml_parser_append_tag_directive(parser, value, false, token.start_mark) {
- return false
- }
- tag_directives = append(tag_directives, value)
- }
-
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- }
-
- for i := range default_tag_directives {
- if !yaml_parser_append_tag_directive(parser, default_tag_directives[i], true, token.start_mark) {
- return false
- }
- }
-
- if version_directive_ref != nil {
- *version_directive_ref = version_directive
- }
- if tag_directives_ref != nil {
- *tag_directives_ref = tag_directives
- }
- return true
-}
-
-// Append a tag directive to the directives stack.
-func yaml_parser_append_tag_directive(parser *yaml_parser_t, value yaml_tag_directive_t, allow_duplicates bool, mark yaml_mark_t) bool {
- for i := range parser.tag_directives {
- if bytes.Equal(value.handle, parser.tag_directives[i].handle) {
- if allow_duplicates {
- return true
- }
- return yaml_parser_set_parser_error(parser, "found duplicate %TAG directive", mark)
- }
- }
-
- // [Go] I suspect the copy is unnecessary. This was likely done
- // because there was no way to track ownership of the data.
- value_copy := yaml_tag_directive_t{
- handle: make([]byte, len(value.handle)),
- prefix: make([]byte, len(value.prefix)),
- }
- copy(value_copy.handle, value.handle)
- copy(value_copy.prefix, value.prefix)
- parser.tag_directives = append(parser.tag_directives, value_copy)
- return true
-}
diff --git a/vendor/gopkg.in/yaml.v3/readerc.go b/vendor/gopkg.in/yaml.v3/readerc.go
deleted file mode 100644
index b7de0a89..00000000
--- a/vendor/gopkg.in/yaml.v3/readerc.go
+++ /dev/null
@@ -1,434 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-// Copyright (c) 2006-2010 Kirill Simonov
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-package yaml
-
-import (
- "io"
-)
-
-// Set the reader error and return 0.
-func yaml_parser_set_reader_error(parser *yaml_parser_t, problem string, offset int, value int) bool {
- parser.error = yaml_READER_ERROR
- parser.problem = problem
- parser.problem_offset = offset
- parser.problem_value = value
- return false
-}
-
-// Byte order marks.
-const (
- bom_UTF8 = "\xef\xbb\xbf"
- bom_UTF16LE = "\xff\xfe"
- bom_UTF16BE = "\xfe\xff"
-)
-
-// Determine the input stream encoding by checking the BOM symbol. If no BOM is
-// found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure.
-func yaml_parser_determine_encoding(parser *yaml_parser_t) bool {
- // Ensure that we had enough bytes in the raw buffer.
- for !parser.eof && len(parser.raw_buffer)-parser.raw_buffer_pos < 3 {
- if !yaml_parser_update_raw_buffer(parser) {
- return false
- }
- }
-
- // Determine the encoding.
- buf := parser.raw_buffer
- pos := parser.raw_buffer_pos
- avail := len(buf) - pos
- if avail >= 2 && buf[pos] == bom_UTF16LE[0] && buf[pos+1] == bom_UTF16LE[1] {
- parser.encoding = yaml_UTF16LE_ENCODING
- parser.raw_buffer_pos += 2
- parser.offset += 2
- } else if avail >= 2 && buf[pos] == bom_UTF16BE[0] && buf[pos+1] == bom_UTF16BE[1] {
- parser.encoding = yaml_UTF16BE_ENCODING
- parser.raw_buffer_pos += 2
- parser.offset += 2
- } else if avail >= 3 && buf[pos] == bom_UTF8[0] && buf[pos+1] == bom_UTF8[1] && buf[pos+2] == bom_UTF8[2] {
- parser.encoding = yaml_UTF8_ENCODING
- parser.raw_buffer_pos += 3
- parser.offset += 3
- } else {
- parser.encoding = yaml_UTF8_ENCODING
- }
- return true
-}
-
-// Update the raw buffer.
-func yaml_parser_update_raw_buffer(parser *yaml_parser_t) bool {
- size_read := 0
-
- // Return if the raw buffer is full.
- if parser.raw_buffer_pos == 0 && len(parser.raw_buffer) == cap(parser.raw_buffer) {
- return true
- }
-
- // Return on EOF.
- if parser.eof {
- return true
- }
-
- // Move the remaining bytes in the raw buffer to the beginning.
- if parser.raw_buffer_pos > 0 && parser.raw_buffer_pos < len(parser.raw_buffer) {
- copy(parser.raw_buffer, parser.raw_buffer[parser.raw_buffer_pos:])
- }
- parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)-parser.raw_buffer_pos]
- parser.raw_buffer_pos = 0
-
- // Call the read handler to fill the buffer.
- size_read, err := parser.read_handler(parser, parser.raw_buffer[len(parser.raw_buffer):cap(parser.raw_buffer)])
- parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)+size_read]
- if err == io.EOF {
- parser.eof = true
- } else if err != nil {
- return yaml_parser_set_reader_error(parser, "input error: "+err.Error(), parser.offset, -1)
- }
- return true
-}
-
-// Ensure that the buffer contains at least `length` characters.
-// Return true on success, false on failure.
-//
-// The length is supposed to be significantly less that the buffer size.
-func yaml_parser_update_buffer(parser *yaml_parser_t, length int) bool {
- if parser.read_handler == nil {
- panic("read handler must be set")
- }
-
- // [Go] This function was changed to guarantee the requested length size at EOF.
- // The fact we need to do this is pretty awful, but the description above implies
- // for that to be the case, and there are tests
-
- // If the EOF flag is set and the raw buffer is empty, do nothing.
- if parser.eof && parser.raw_buffer_pos == len(parser.raw_buffer) {
- // [Go] ACTUALLY! Read the documentation of this function above.
- // This is just broken. To return true, we need to have the
- // given length in the buffer. Not doing that means every single
- // check that calls this function to make sure the buffer has a
- // given length is Go) panicking; or C) accessing invalid memory.
- //return true
- }
-
- // Return if the buffer contains enough characters.
- if parser.unread >= length {
- return true
- }
-
- // Determine the input encoding if it is not known yet.
- if parser.encoding == yaml_ANY_ENCODING {
- if !yaml_parser_determine_encoding(parser) {
- return false
- }
- }
-
- // Move the unread characters to the beginning of the buffer.
- buffer_len := len(parser.buffer)
- if parser.buffer_pos > 0 && parser.buffer_pos < buffer_len {
- copy(parser.buffer, parser.buffer[parser.buffer_pos:])
- buffer_len -= parser.buffer_pos
- parser.buffer_pos = 0
- } else if parser.buffer_pos == buffer_len {
- buffer_len = 0
- parser.buffer_pos = 0
- }
-
- // Open the whole buffer for writing, and cut it before returning.
- parser.buffer = parser.buffer[:cap(parser.buffer)]
-
- // Fill the buffer until it has enough characters.
- first := true
- for parser.unread < length {
-
- // Fill the raw buffer if necessary.
- if !first || parser.raw_buffer_pos == len(parser.raw_buffer) {
- if !yaml_parser_update_raw_buffer(parser) {
- parser.buffer = parser.buffer[:buffer_len]
- return false
- }
- }
- first = false
-
- // Decode the raw buffer.
- inner:
- for parser.raw_buffer_pos != len(parser.raw_buffer) {
- var value rune
- var width int
-
- raw_unread := len(parser.raw_buffer) - parser.raw_buffer_pos
-
- // Decode the next character.
- switch parser.encoding {
- case yaml_UTF8_ENCODING:
- // Decode a UTF-8 character. Check RFC 3629
- // (http://www.ietf.org/rfc/rfc3629.txt) for more details.
- //
- // The following table (taken from the RFC) is used for
- // decoding.
- //
- // Char. number range | UTF-8 octet sequence
- // (hexadecimal) | (binary)
- // --------------------+------------------------------------
- // 0000 0000-0000 007F | 0xxxxxxx
- // 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
- // 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
- // 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- //
- // Additionally, the characters in the range 0xD800-0xDFFF
- // are prohibited as they are reserved for use with UTF-16
- // surrogate pairs.
-
- // Determine the length of the UTF-8 sequence.
- octet := parser.raw_buffer[parser.raw_buffer_pos]
- switch {
- case octet&0x80 == 0x00:
- width = 1
- case octet&0xE0 == 0xC0:
- width = 2
- case octet&0xF0 == 0xE0:
- width = 3
- case octet&0xF8 == 0xF0:
- width = 4
- default:
- // The leading octet is invalid.
- return yaml_parser_set_reader_error(parser,
- "invalid leading UTF-8 octet",
- parser.offset, int(octet))
- }
-
- // Check if the raw buffer contains an incomplete character.
- if width > raw_unread {
- if parser.eof {
- return yaml_parser_set_reader_error(parser,
- "incomplete UTF-8 octet sequence",
- parser.offset, -1)
- }
- break inner
- }
-
- // Decode the leading octet.
- switch {
- case octet&0x80 == 0x00:
- value = rune(octet & 0x7F)
- case octet&0xE0 == 0xC0:
- value = rune(octet & 0x1F)
- case octet&0xF0 == 0xE0:
- value = rune(octet & 0x0F)
- case octet&0xF8 == 0xF0:
- value = rune(octet & 0x07)
- default:
- value = 0
- }
-
- // Check and decode the trailing octets.
- for k := 1; k < width; k++ {
- octet = parser.raw_buffer[parser.raw_buffer_pos+k]
-
- // Check if the octet is valid.
- if (octet & 0xC0) != 0x80 {
- return yaml_parser_set_reader_error(parser,
- "invalid trailing UTF-8 octet",
- parser.offset+k, int(octet))
- }
-
- // Decode the octet.
- value = (value << 6) + rune(octet&0x3F)
- }
-
- // Check the length of the sequence against the value.
- switch {
- case width == 1:
- case width == 2 && value >= 0x80:
- case width == 3 && value >= 0x800:
- case width == 4 && value >= 0x10000:
- default:
- return yaml_parser_set_reader_error(parser,
- "invalid length of a UTF-8 sequence",
- parser.offset, -1)
- }
-
- // Check the range of the value.
- if value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF {
- return yaml_parser_set_reader_error(parser,
- "invalid Unicode character",
- parser.offset, int(value))
- }
-
- case yaml_UTF16LE_ENCODING, yaml_UTF16BE_ENCODING:
- var low, high int
- if parser.encoding == yaml_UTF16LE_ENCODING {
- low, high = 0, 1
- } else {
- low, high = 1, 0
- }
-
- // The UTF-16 encoding is not as simple as one might
- // naively think. Check RFC 2781
- // (http://www.ietf.org/rfc/rfc2781.txt).
- //
- // Normally, two subsequent bytes describe a Unicode
- // character. However a special technique (called a
- // surrogate pair) is used for specifying character
- // values larger than 0xFFFF.
- //
- // A surrogate pair consists of two pseudo-characters:
- // high surrogate area (0xD800-0xDBFF)
- // low surrogate area (0xDC00-0xDFFF)
- //
- // The following formulas are used for decoding
- // and encoding characters using surrogate pairs:
- //
- // U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF)
- // U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF)
- // W1 = 110110yyyyyyyyyy
- // W2 = 110111xxxxxxxxxx
- //
- // where U is the character value, W1 is the high surrogate
- // area, W2 is the low surrogate area.
-
- // Check for incomplete UTF-16 character.
- if raw_unread < 2 {
- if parser.eof {
- return yaml_parser_set_reader_error(parser,
- "incomplete UTF-16 character",
- parser.offset, -1)
- }
- break inner
- }
-
- // Get the character.
- value = rune(parser.raw_buffer[parser.raw_buffer_pos+low]) +
- (rune(parser.raw_buffer[parser.raw_buffer_pos+high]) << 8)
-
- // Check for unexpected low surrogate area.
- if value&0xFC00 == 0xDC00 {
- return yaml_parser_set_reader_error(parser,
- "unexpected low surrogate area",
- parser.offset, int(value))
- }
-
- // Check for a high surrogate area.
- if value&0xFC00 == 0xD800 {
- width = 4
-
- // Check for incomplete surrogate pair.
- if raw_unread < 4 {
- if parser.eof {
- return yaml_parser_set_reader_error(parser,
- "incomplete UTF-16 surrogate pair",
- parser.offset, -1)
- }
- break inner
- }
-
- // Get the next character.
- value2 := rune(parser.raw_buffer[parser.raw_buffer_pos+low+2]) +
- (rune(parser.raw_buffer[parser.raw_buffer_pos+high+2]) << 8)
-
- // Check for a low surrogate area.
- if value2&0xFC00 != 0xDC00 {
- return yaml_parser_set_reader_error(parser,
- "expected low surrogate area",
- parser.offset+2, int(value2))
- }
-
- // Generate the value of the surrogate pair.
- value = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF)
- } else {
- width = 2
- }
-
- default:
- panic("impossible")
- }
-
- // Check if the character is in the allowed range:
- // #x9 | #xA | #xD | [#x20-#x7E] (8 bit)
- // | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] (16 bit)
- // | [#x10000-#x10FFFF] (32 bit)
- switch {
- case value == 0x09:
- case value == 0x0A:
- case value == 0x0D:
- case value >= 0x20 && value <= 0x7E:
- case value == 0x85:
- case value >= 0xA0 && value <= 0xD7FF:
- case value >= 0xE000 && value <= 0xFFFD:
- case value >= 0x10000 && value <= 0x10FFFF:
- default:
- return yaml_parser_set_reader_error(parser,
- "control characters are not allowed",
- parser.offset, int(value))
- }
-
- // Move the raw pointers.
- parser.raw_buffer_pos += width
- parser.offset += width
-
- // Finally put the character into the buffer.
- if value <= 0x7F {
- // 0000 0000-0000 007F . 0xxxxxxx
- parser.buffer[buffer_len+0] = byte(value)
- buffer_len += 1
- } else if value <= 0x7FF {
- // 0000 0080-0000 07FF . 110xxxxx 10xxxxxx
- parser.buffer[buffer_len+0] = byte(0xC0 + (value >> 6))
- parser.buffer[buffer_len+1] = byte(0x80 + (value & 0x3F))
- buffer_len += 2
- } else if value <= 0xFFFF {
- // 0000 0800-0000 FFFF . 1110xxxx 10xxxxxx 10xxxxxx
- parser.buffer[buffer_len+0] = byte(0xE0 + (value >> 12))
- parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 6) & 0x3F))
- parser.buffer[buffer_len+2] = byte(0x80 + (value & 0x3F))
- buffer_len += 3
- } else {
- // 0001 0000-0010 FFFF . 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- parser.buffer[buffer_len+0] = byte(0xF0 + (value >> 18))
- parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 12) & 0x3F))
- parser.buffer[buffer_len+2] = byte(0x80 + ((value >> 6) & 0x3F))
- parser.buffer[buffer_len+3] = byte(0x80 + (value & 0x3F))
- buffer_len += 4
- }
-
- parser.unread++
- }
-
- // On EOF, put NUL into the buffer and return.
- if parser.eof {
- parser.buffer[buffer_len] = 0
- buffer_len++
- parser.unread++
- break
- }
- }
- // [Go] Read the documentation of this function above. To return true,
- // we need to have the given length in the buffer. Not doing that means
- // every single check that calls this function to make sure the buffer
- // has a given length is Go) panicking; or C) accessing invalid memory.
- // This happens here due to the EOF above breaking early.
- for buffer_len < length {
- parser.buffer[buffer_len] = 0
- buffer_len++
- }
- parser.buffer = parser.buffer[:buffer_len]
- return true
-}
diff --git a/vendor/gopkg.in/yaml.v3/resolve.go b/vendor/gopkg.in/yaml.v3/resolve.go
deleted file mode 100644
index 64ae8880..00000000
--- a/vendor/gopkg.in/yaml.v3/resolve.go
+++ /dev/null
@@ -1,326 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package yaml
-
-import (
- "encoding/base64"
- "math"
- "regexp"
- "strconv"
- "strings"
- "time"
-)
-
-type resolveMapItem struct {
- value interface{}
- tag string
-}
-
-var resolveTable = make([]byte, 256)
-var resolveMap = make(map[string]resolveMapItem)
-
-func init() {
- t := resolveTable
- t[int('+')] = 'S' // Sign
- t[int('-')] = 'S'
- for _, c := range "0123456789" {
- t[int(c)] = 'D' // Digit
- }
- for _, c := range "yYnNtTfFoO~" {
- t[int(c)] = 'M' // In map
- }
- t[int('.')] = '.' // Float (potentially in map)
-
- var resolveMapList = []struct {
- v interface{}
- tag string
- l []string
- }{
- {true, boolTag, []string{"true", "True", "TRUE"}},
- {false, boolTag, []string{"false", "False", "FALSE"}},
- {nil, nullTag, []string{"", "~", "null", "Null", "NULL"}},
- {math.NaN(), floatTag, []string{".nan", ".NaN", ".NAN"}},
- {math.Inf(+1), floatTag, []string{".inf", ".Inf", ".INF"}},
- {math.Inf(+1), floatTag, []string{"+.inf", "+.Inf", "+.INF"}},
- {math.Inf(-1), floatTag, []string{"-.inf", "-.Inf", "-.INF"}},
- {"<<", mergeTag, []string{"<<"}},
- }
-
- m := resolveMap
- for _, item := range resolveMapList {
- for _, s := range item.l {
- m[s] = resolveMapItem{item.v, item.tag}
- }
- }
-}
-
-const (
- nullTag = "!!null"
- boolTag = "!!bool"
- strTag = "!!str"
- intTag = "!!int"
- floatTag = "!!float"
- timestampTag = "!!timestamp"
- seqTag = "!!seq"
- mapTag = "!!map"
- binaryTag = "!!binary"
- mergeTag = "!!merge"
-)
-
-var longTags = make(map[string]string)
-var shortTags = make(map[string]string)
-
-func init() {
- for _, stag := range []string{nullTag, boolTag, strTag, intTag, floatTag, timestampTag, seqTag, mapTag, binaryTag, mergeTag} {
- ltag := longTag(stag)
- longTags[stag] = ltag
- shortTags[ltag] = stag
- }
-}
-
-const longTagPrefix = "tag:yaml.org,2002:"
-
-func shortTag(tag string) string {
- if strings.HasPrefix(tag, longTagPrefix) {
- if stag, ok := shortTags[tag]; ok {
- return stag
- }
- return "!!" + tag[len(longTagPrefix):]
- }
- return tag
-}
-
-func longTag(tag string) string {
- if strings.HasPrefix(tag, "!!") {
- if ltag, ok := longTags[tag]; ok {
- return ltag
- }
- return longTagPrefix + tag[2:]
- }
- return tag
-}
-
-func resolvableTag(tag string) bool {
- switch tag {
- case "", strTag, boolTag, intTag, floatTag, nullTag, timestampTag:
- return true
- }
- return false
-}
-
-var yamlStyleFloat = regexp.MustCompile(`^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?$`)
-
-func resolve(tag string, in string) (rtag string, out interface{}) {
- tag = shortTag(tag)
- if !resolvableTag(tag) {
- return tag, in
- }
-
- defer func() {
- switch tag {
- case "", rtag, strTag, binaryTag:
- return
- case floatTag:
- if rtag == intTag {
- switch v := out.(type) {
- case int64:
- rtag = floatTag
- out = float64(v)
- return
- case int:
- rtag = floatTag
- out = float64(v)
- return
- }
- }
- }
- failf("cannot decode %s `%s` as a %s", shortTag(rtag), in, shortTag(tag))
- }()
-
- // Any data is accepted as a !!str or !!binary.
- // Otherwise, the prefix is enough of a hint about what it might be.
- hint := byte('N')
- if in != "" {
- hint = resolveTable[in[0]]
- }
- if hint != 0 && tag != strTag && tag != binaryTag {
- // Handle things we can lookup in a map.
- if item, ok := resolveMap[in]; ok {
- return item.tag, item.value
- }
-
- // Base 60 floats are a bad idea, were dropped in YAML 1.2, and
- // are purposefully unsupported here. They're still quoted on
- // the way out for compatibility with other parser, though.
-
- switch hint {
- case 'M':
- // We've already checked the map above.
-
- case '.':
- // Not in the map, so maybe a normal float.
- floatv, err := strconv.ParseFloat(in, 64)
- if err == nil {
- return floatTag, floatv
- }
-
- case 'D', 'S':
- // Int, float, or timestamp.
- // Only try values as a timestamp if the value is unquoted or there's an explicit
- // !!timestamp tag.
- if tag == "" || tag == timestampTag {
- t, ok := parseTimestamp(in)
- if ok {
- return timestampTag, t
- }
- }
-
- plain := strings.Replace(in, "_", "", -1)
- intv, err := strconv.ParseInt(plain, 0, 64)
- if err == nil {
- if intv == int64(int(intv)) {
- return intTag, int(intv)
- } else {
- return intTag, intv
- }
- }
- uintv, err := strconv.ParseUint(plain, 0, 64)
- if err == nil {
- return intTag, uintv
- }
- if yamlStyleFloat.MatchString(plain) {
- floatv, err := strconv.ParseFloat(plain, 64)
- if err == nil {
- return floatTag, floatv
- }
- }
- if strings.HasPrefix(plain, "0b") {
- intv, err := strconv.ParseInt(plain[2:], 2, 64)
- if err == nil {
- if intv == int64(int(intv)) {
- return intTag, int(intv)
- } else {
- return intTag, intv
- }
- }
- uintv, err := strconv.ParseUint(plain[2:], 2, 64)
- if err == nil {
- return intTag, uintv
- }
- } else if strings.HasPrefix(plain, "-0b") {
- intv, err := strconv.ParseInt("-"+plain[3:], 2, 64)
- if err == nil {
- if true || intv == int64(int(intv)) {
- return intTag, int(intv)
- } else {
- return intTag, intv
- }
- }
- }
- // Octals as introduced in version 1.2 of the spec.
- // Octals from the 1.1 spec, spelled as 0777, are still
- // decoded by default in v3 as well for compatibility.
- // May be dropped in v4 depending on how usage evolves.
- if strings.HasPrefix(plain, "0o") {
- intv, err := strconv.ParseInt(plain[2:], 8, 64)
- if err == nil {
- if intv == int64(int(intv)) {
- return intTag, int(intv)
- } else {
- return intTag, intv
- }
- }
- uintv, err := strconv.ParseUint(plain[2:], 8, 64)
- if err == nil {
- return intTag, uintv
- }
- } else if strings.HasPrefix(plain, "-0o") {
- intv, err := strconv.ParseInt("-"+plain[3:], 8, 64)
- if err == nil {
- if true || intv == int64(int(intv)) {
- return intTag, int(intv)
- } else {
- return intTag, intv
- }
- }
- }
- default:
- panic("internal error: missing handler for resolver table: " + string(rune(hint)) + " (with " + in + ")")
- }
- }
- return strTag, in
-}
-
-// encodeBase64 encodes s as base64 that is broken up into multiple lines
-// as appropriate for the resulting length.
-func encodeBase64(s string) string {
- const lineLen = 70
- encLen := base64.StdEncoding.EncodedLen(len(s))
- lines := encLen/lineLen + 1
- buf := make([]byte, encLen*2+lines)
- in := buf[0:encLen]
- out := buf[encLen:]
- base64.StdEncoding.Encode(in, []byte(s))
- k := 0
- for i := 0; i < len(in); i += lineLen {
- j := i + lineLen
- if j > len(in) {
- j = len(in)
- }
- k += copy(out[k:], in[i:j])
- if lines > 1 {
- out[k] = '\n'
- k++
- }
- }
- return string(out[:k])
-}
-
-// This is a subset of the formats allowed by the regular expression
-// defined at http://yaml.org/type/timestamp.html.
-var allowedTimestampFormats = []string{
- "2006-1-2T15:4:5.999999999Z07:00", // RCF3339Nano with short date fields.
- "2006-1-2t15:4:5.999999999Z07:00", // RFC3339Nano with short date fields and lower-case "t".
- "2006-1-2 15:4:5.999999999", // space separated with no time zone
- "2006-1-2", // date only
- // Notable exception: time.Parse cannot handle: "2001-12-14 21:59:43.10 -5"
- // from the set of examples.
-}
-
-// parseTimestamp parses s as a timestamp string and
-// returns the timestamp and reports whether it succeeded.
-// Timestamp formats are defined at http://yaml.org/type/timestamp.html
-func parseTimestamp(s string) (time.Time, bool) {
- // TODO write code to check all the formats supported by
- // http://yaml.org/type/timestamp.html instead of using time.Parse.
-
- // Quick check: all date formats start with YYYY-.
- i := 0
- for ; i < len(s); i++ {
- if c := s[i]; c < '0' || c > '9' {
- break
- }
- }
- if i != 4 || i == len(s) || s[i] != '-' {
- return time.Time{}, false
- }
- for _, format := range allowedTimestampFormats {
- if t, err := time.Parse(format, s); err == nil {
- return t, true
- }
- }
- return time.Time{}, false
-}
diff --git a/vendor/gopkg.in/yaml.v3/scannerc.go b/vendor/gopkg.in/yaml.v3/scannerc.go
deleted file mode 100644
index ca007010..00000000
--- a/vendor/gopkg.in/yaml.v3/scannerc.go
+++ /dev/null
@@ -1,3038 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-// Copyright (c) 2006-2010 Kirill Simonov
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-package yaml
-
-import (
- "bytes"
- "fmt"
-)
-
-// Introduction
-// ************
-//
-// The following notes assume that you are familiar with the YAML specification
-// (http://yaml.org/spec/1.2/spec.html). We mostly follow it, although in
-// some cases we are less restrictive that it requires.
-//
-// The process of transforming a YAML stream into a sequence of events is
-// divided on two steps: Scanning and Parsing.
-//
-// The Scanner transforms the input stream into a sequence of tokens, while the
-// parser transform the sequence of tokens produced by the Scanner into a
-// sequence of parsing events.
-//
-// The Scanner is rather clever and complicated. The Parser, on the contrary,
-// is a straightforward implementation of a recursive-descendant parser (or,
-// LL(1) parser, as it is usually called).
-//
-// Actually there are two issues of Scanning that might be called "clever", the
-// rest is quite straightforward. The issues are "block collection start" and
-// "simple keys". Both issues are explained below in details.
-//
-// Here the Scanning step is explained and implemented. We start with the list
-// of all the tokens produced by the Scanner together with short descriptions.
-//
-// Now, tokens:
-//
-// STREAM-START(encoding) # The stream start.
-// STREAM-END # The stream end.
-// VERSION-DIRECTIVE(major,minor) # The '%YAML' directive.
-// TAG-DIRECTIVE(handle,prefix) # The '%TAG' directive.
-// DOCUMENT-START # '---'
-// DOCUMENT-END # '...'
-// BLOCK-SEQUENCE-START # Indentation increase denoting a block
-// BLOCK-MAPPING-START # sequence or a block mapping.
-// BLOCK-END # Indentation decrease.
-// FLOW-SEQUENCE-START # '['
-// FLOW-SEQUENCE-END # ']'
-// BLOCK-SEQUENCE-START # '{'
-// BLOCK-SEQUENCE-END # '}'
-// BLOCK-ENTRY # '-'
-// FLOW-ENTRY # ','
-// KEY # '?' or nothing (simple keys).
-// VALUE # ':'
-// ALIAS(anchor) # '*anchor'
-// ANCHOR(anchor) # '&anchor'
-// TAG(handle,suffix) # '!handle!suffix'
-// SCALAR(value,style) # A scalar.
-//
-// The following two tokens are "virtual" tokens denoting the beginning and the
-// end of the stream:
-//
-// STREAM-START(encoding)
-// STREAM-END
-//
-// We pass the information about the input stream encoding with the
-// STREAM-START token.
-//
-// The next two tokens are responsible for tags:
-//
-// VERSION-DIRECTIVE(major,minor)
-// TAG-DIRECTIVE(handle,prefix)
-//
-// Example:
-//
-// %YAML 1.1
-// %TAG ! !foo
-// %TAG !yaml! tag:yaml.org,2002:
-// ---
-//
-// The correspoding sequence of tokens:
-//
-// STREAM-START(utf-8)
-// VERSION-DIRECTIVE(1,1)
-// TAG-DIRECTIVE("!","!foo")
-// TAG-DIRECTIVE("!yaml","tag:yaml.org,2002:")
-// DOCUMENT-START
-// STREAM-END
-//
-// Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole
-// line.
-//
-// The document start and end indicators are represented by:
-//
-// DOCUMENT-START
-// DOCUMENT-END
-//
-// Note that if a YAML stream contains an implicit document (without '---'
-// and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be
-// produced.
-//
-// In the following examples, we present whole documents together with the
-// produced tokens.
-//
-// 1. An implicit document:
-//
-// 'a scalar'
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// SCALAR("a scalar",single-quoted)
-// STREAM-END
-//
-// 2. An explicit document:
-//
-// ---
-// 'a scalar'
-// ...
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// DOCUMENT-START
-// SCALAR("a scalar",single-quoted)
-// DOCUMENT-END
-// STREAM-END
-//
-// 3. Several documents in a stream:
-//
-// 'a scalar'
-// ---
-// 'another scalar'
-// ---
-// 'yet another scalar'
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// SCALAR("a scalar",single-quoted)
-// DOCUMENT-START
-// SCALAR("another scalar",single-quoted)
-// DOCUMENT-START
-// SCALAR("yet another scalar",single-quoted)
-// STREAM-END
-//
-// We have already introduced the SCALAR token above. The following tokens are
-// used to describe aliases, anchors, tag, and scalars:
-//
-// ALIAS(anchor)
-// ANCHOR(anchor)
-// TAG(handle,suffix)
-// SCALAR(value,style)
-//
-// The following series of examples illustrate the usage of these tokens:
-//
-// 1. A recursive sequence:
-//
-// &A [ *A ]
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// ANCHOR("A")
-// FLOW-SEQUENCE-START
-// ALIAS("A")
-// FLOW-SEQUENCE-END
-// STREAM-END
-//
-// 2. A tagged scalar:
-//
-// !!float "3.14" # A good approximation.
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// TAG("!!","float")
-// SCALAR("3.14",double-quoted)
-// STREAM-END
-//
-// 3. Various scalar styles:
-//
-// --- # Implicit empty plain scalars do not produce tokens.
-// --- a plain scalar
-// --- 'a single-quoted scalar'
-// --- "a double-quoted scalar"
-// --- |-
-// a literal scalar
-// --- >-
-// a folded
-// scalar
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// DOCUMENT-START
-// DOCUMENT-START
-// SCALAR("a plain scalar",plain)
-// DOCUMENT-START
-// SCALAR("a single-quoted scalar",single-quoted)
-// DOCUMENT-START
-// SCALAR("a double-quoted scalar",double-quoted)
-// DOCUMENT-START
-// SCALAR("a literal scalar",literal)
-// DOCUMENT-START
-// SCALAR("a folded scalar",folded)
-// STREAM-END
-//
-// Now it's time to review collection-related tokens. We will start with
-// flow collections:
-//
-// FLOW-SEQUENCE-START
-// FLOW-SEQUENCE-END
-// FLOW-MAPPING-START
-// FLOW-MAPPING-END
-// FLOW-ENTRY
-// KEY
-// VALUE
-//
-// The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and
-// FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}'
-// correspondingly. FLOW-ENTRY represent the ',' indicator. Finally the
-// indicators '?' and ':', which are used for denoting mapping keys and values,
-// are represented by the KEY and VALUE tokens.
-//
-// The following examples show flow collections:
-//
-// 1. A flow sequence:
-//
-// [item 1, item 2, item 3]
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// FLOW-SEQUENCE-START
-// SCALAR("item 1",plain)
-// FLOW-ENTRY
-// SCALAR("item 2",plain)
-// FLOW-ENTRY
-// SCALAR("item 3",plain)
-// FLOW-SEQUENCE-END
-// STREAM-END
-//
-// 2. A flow mapping:
-//
-// {
-// a simple key: a value, # Note that the KEY token is produced.
-// ? a complex key: another value,
-// }
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// FLOW-MAPPING-START
-// KEY
-// SCALAR("a simple key",plain)
-// VALUE
-// SCALAR("a value",plain)
-// FLOW-ENTRY
-// KEY
-// SCALAR("a complex key",plain)
-// VALUE
-// SCALAR("another value",plain)
-// FLOW-ENTRY
-// FLOW-MAPPING-END
-// STREAM-END
-//
-// A simple key is a key which is not denoted by the '?' indicator. Note that
-// the Scanner still produce the KEY token whenever it encounters a simple key.
-//
-// For scanning block collections, the following tokens are used (note that we
-// repeat KEY and VALUE here):
-//
-// BLOCK-SEQUENCE-START
-// BLOCK-MAPPING-START
-// BLOCK-END
-// BLOCK-ENTRY
-// KEY
-// VALUE
-//
-// The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation
-// increase that precedes a block collection (cf. the INDENT token in Python).
-// The token BLOCK-END denote indentation decrease that ends a block collection
-// (cf. the DEDENT token in Python). However YAML has some syntax pecularities
-// that makes detections of these tokens more complex.
-//
-// The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators
-// '-', '?', and ':' correspondingly.
-//
-// The following examples show how the tokens BLOCK-SEQUENCE-START,
-// BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner:
-//
-// 1. Block sequences:
-//
-// - item 1
-// - item 2
-// -
-// - item 3.1
-// - item 3.2
-// -
-// key 1: value 1
-// key 2: value 2
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// BLOCK-SEQUENCE-START
-// BLOCK-ENTRY
-// SCALAR("item 1",plain)
-// BLOCK-ENTRY
-// SCALAR("item 2",plain)
-// BLOCK-ENTRY
-// BLOCK-SEQUENCE-START
-// BLOCK-ENTRY
-// SCALAR("item 3.1",plain)
-// BLOCK-ENTRY
-// SCALAR("item 3.2",plain)
-// BLOCK-END
-// BLOCK-ENTRY
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("key 1",plain)
-// VALUE
-// SCALAR("value 1",plain)
-// KEY
-// SCALAR("key 2",plain)
-// VALUE
-// SCALAR("value 2",plain)
-// BLOCK-END
-// BLOCK-END
-// STREAM-END
-//
-// 2. Block mappings:
-//
-// a simple key: a value # The KEY token is produced here.
-// ? a complex key
-// : another value
-// a mapping:
-// key 1: value 1
-// key 2: value 2
-// a sequence:
-// - item 1
-// - item 2
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("a simple key",plain)
-// VALUE
-// SCALAR("a value",plain)
-// KEY
-// SCALAR("a complex key",plain)
-// VALUE
-// SCALAR("another value",plain)
-// KEY
-// SCALAR("a mapping",plain)
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("key 1",plain)
-// VALUE
-// SCALAR("value 1",plain)
-// KEY
-// SCALAR("key 2",plain)
-// VALUE
-// SCALAR("value 2",plain)
-// BLOCK-END
-// KEY
-// SCALAR("a sequence",plain)
-// VALUE
-// BLOCK-SEQUENCE-START
-// BLOCK-ENTRY
-// SCALAR("item 1",plain)
-// BLOCK-ENTRY
-// SCALAR("item 2",plain)
-// BLOCK-END
-// BLOCK-END
-// STREAM-END
-//
-// YAML does not always require to start a new block collection from a new
-// line. If the current line contains only '-', '?', and ':' indicators, a new
-// block collection may start at the current line. The following examples
-// illustrate this case:
-//
-// 1. Collections in a sequence:
-//
-// - - item 1
-// - item 2
-// - key 1: value 1
-// key 2: value 2
-// - ? complex key
-// : complex value
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// BLOCK-SEQUENCE-START
-// BLOCK-ENTRY
-// BLOCK-SEQUENCE-START
-// BLOCK-ENTRY
-// SCALAR("item 1",plain)
-// BLOCK-ENTRY
-// SCALAR("item 2",plain)
-// BLOCK-END
-// BLOCK-ENTRY
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("key 1",plain)
-// VALUE
-// SCALAR("value 1",plain)
-// KEY
-// SCALAR("key 2",plain)
-// VALUE
-// SCALAR("value 2",plain)
-// BLOCK-END
-// BLOCK-ENTRY
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("complex key")
-// VALUE
-// SCALAR("complex value")
-// BLOCK-END
-// BLOCK-END
-// STREAM-END
-//
-// 2. Collections in a mapping:
-//
-// ? a sequence
-// : - item 1
-// - item 2
-// ? a mapping
-// : key 1: value 1
-// key 2: value 2
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("a sequence",plain)
-// VALUE
-// BLOCK-SEQUENCE-START
-// BLOCK-ENTRY
-// SCALAR("item 1",plain)
-// BLOCK-ENTRY
-// SCALAR("item 2",plain)
-// BLOCK-END
-// KEY
-// SCALAR("a mapping",plain)
-// VALUE
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("key 1",plain)
-// VALUE
-// SCALAR("value 1",plain)
-// KEY
-// SCALAR("key 2",plain)
-// VALUE
-// SCALAR("value 2",plain)
-// BLOCK-END
-// BLOCK-END
-// STREAM-END
-//
-// YAML also permits non-indented sequences if they are included into a block
-// mapping. In this case, the token BLOCK-SEQUENCE-START is not produced:
-//
-// key:
-// - item 1 # BLOCK-SEQUENCE-START is NOT produced here.
-// - item 2
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("key",plain)
-// VALUE
-// BLOCK-ENTRY
-// SCALAR("item 1",plain)
-// BLOCK-ENTRY
-// SCALAR("item 2",plain)
-// BLOCK-END
-//
-
-// Ensure that the buffer contains the required number of characters.
-// Return true on success, false on failure (reader error or memory error).
-func cache(parser *yaml_parser_t, length int) bool {
- // [Go] This was inlined: !cache(A, B) -> unread < B && !update(A, B)
- return parser.unread >= length || yaml_parser_update_buffer(parser, length)
-}
-
-// Advance the buffer pointer.
-func skip(parser *yaml_parser_t) {
- if !is_blank(parser.buffer, parser.buffer_pos) {
- parser.newlines = 0
- }
- parser.mark.index++
- parser.mark.column++
- parser.unread--
- parser.buffer_pos += width(parser.buffer[parser.buffer_pos])
-}
-
-func skip_line(parser *yaml_parser_t) {
- if is_crlf(parser.buffer, parser.buffer_pos) {
- parser.mark.index += 2
- parser.mark.column = 0
- parser.mark.line++
- parser.unread -= 2
- parser.buffer_pos += 2
- parser.newlines++
- } else if is_break(parser.buffer, parser.buffer_pos) {
- parser.mark.index++
- parser.mark.column = 0
- parser.mark.line++
- parser.unread--
- parser.buffer_pos += width(parser.buffer[parser.buffer_pos])
- parser.newlines++
- }
-}
-
-// Copy a character to a string buffer and advance pointers.
-func read(parser *yaml_parser_t, s []byte) []byte {
- if !is_blank(parser.buffer, parser.buffer_pos) {
- parser.newlines = 0
- }
- w := width(parser.buffer[parser.buffer_pos])
- if w == 0 {
- panic("invalid character sequence")
- }
- if len(s) == 0 {
- s = make([]byte, 0, 32)
- }
- if w == 1 && len(s)+w <= cap(s) {
- s = s[:len(s)+1]
- s[len(s)-1] = parser.buffer[parser.buffer_pos]
- parser.buffer_pos++
- } else {
- s = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...)
- parser.buffer_pos += w
- }
- parser.mark.index++
- parser.mark.column++
- parser.unread--
- return s
-}
-
-// Copy a line break character to a string buffer and advance pointers.
-func read_line(parser *yaml_parser_t, s []byte) []byte {
- buf := parser.buffer
- pos := parser.buffer_pos
- switch {
- case buf[pos] == '\r' && buf[pos+1] == '\n':
- // CR LF . LF
- s = append(s, '\n')
- parser.buffer_pos += 2
- parser.mark.index++
- parser.unread--
- case buf[pos] == '\r' || buf[pos] == '\n':
- // CR|LF . LF
- s = append(s, '\n')
- parser.buffer_pos += 1
- case buf[pos] == '\xC2' && buf[pos+1] == '\x85':
- // NEL . LF
- s = append(s, '\n')
- parser.buffer_pos += 2
- case buf[pos] == '\xE2' && buf[pos+1] == '\x80' && (buf[pos+2] == '\xA8' || buf[pos+2] == '\xA9'):
- // LS|PS . LS|PS
- s = append(s, buf[parser.buffer_pos:pos+3]...)
- parser.buffer_pos += 3
- default:
- return s
- }
- parser.mark.index++
- parser.mark.column = 0
- parser.mark.line++
- parser.unread--
- parser.newlines++
- return s
-}
-
-// Get the next token.
-func yaml_parser_scan(parser *yaml_parser_t, token *yaml_token_t) bool {
- // Erase the token object.
- *token = yaml_token_t{} // [Go] Is this necessary?
-
- // No tokens after STREAM-END or error.
- if parser.stream_end_produced || parser.error != yaml_NO_ERROR {
- return true
- }
-
- // Ensure that the tokens queue contains enough tokens.
- if !parser.token_available {
- if !yaml_parser_fetch_more_tokens(parser) {
- return false
- }
- }
-
- // Fetch the next token from the queue.
- *token = parser.tokens[parser.tokens_head]
- parser.tokens_head++
- parser.tokens_parsed++
- parser.token_available = false
-
- if token.typ == yaml_STREAM_END_TOKEN {
- parser.stream_end_produced = true
- }
- return true
-}
-
-// Set the scanner error and return false.
-func yaml_parser_set_scanner_error(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string) bool {
- parser.error = yaml_SCANNER_ERROR
- parser.context = context
- parser.context_mark = context_mark
- parser.problem = problem
- parser.problem_mark = parser.mark
- return false
-}
-
-func yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, context_mark yaml_mark_t, problem string) bool {
- context := "while parsing a tag"
- if directive {
- context = "while parsing a %TAG directive"
- }
- return yaml_parser_set_scanner_error(parser, context, context_mark, problem)
-}
-
-func trace(args ...interface{}) func() {
- pargs := append([]interface{}{"+++"}, args...)
- fmt.Println(pargs...)
- pargs = append([]interface{}{"---"}, args...)
- return func() { fmt.Println(pargs...) }
-}
-
-// Ensure that the tokens queue contains at least one token which can be
-// returned to the Parser.
-func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool {
- // While we need more tokens to fetch, do it.
- for {
- // [Go] The comment parsing logic requires a lookahead of two tokens
- // so that foot comments may be parsed in time of associating them
- // with the tokens that are parsed before them, and also for line
- // comments to be transformed into head comments in some edge cases.
- if parser.tokens_head < len(parser.tokens)-2 {
- // If a potential simple key is at the head position, we need to fetch
- // the next token to disambiguate it.
- head_tok_idx, ok := parser.simple_keys_by_tok[parser.tokens_parsed]
- if !ok {
- break
- } else if valid, ok := yaml_simple_key_is_valid(parser, &parser.simple_keys[head_tok_idx]); !ok {
- return false
- } else if !valid {
- break
- }
- }
- // Fetch the next token.
- if !yaml_parser_fetch_next_token(parser) {
- return false
- }
- }
-
- parser.token_available = true
- return true
-}
-
-// The dispatcher for token fetchers.
-func yaml_parser_fetch_next_token(parser *yaml_parser_t) (ok bool) {
- // Ensure that the buffer is initialized.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- // Check if we just started scanning. Fetch STREAM-START then.
- if !parser.stream_start_produced {
- return yaml_parser_fetch_stream_start(parser)
- }
-
- scan_mark := parser.mark
-
- // Eat whitespaces and comments until we reach the next token.
- if !yaml_parser_scan_to_next_token(parser) {
- return false
- }
-
- // [Go] While unrolling indents, transform the head comments of prior
- // indentation levels observed after scan_start into foot comments at
- // the respective indexes.
-
- // Check the indentation level against the current column.
- if !yaml_parser_unroll_indent(parser, parser.mark.column, scan_mark) {
- return false
- }
-
- // Ensure that the buffer contains at least 4 characters. 4 is the length
- // of the longest indicators ('--- ' and '... ').
- if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) {
- return false
- }
-
- // Is it the end of the stream?
- if is_z(parser.buffer, parser.buffer_pos) {
- return yaml_parser_fetch_stream_end(parser)
- }
-
- // Is it a directive?
- if parser.mark.column == 0 && parser.buffer[parser.buffer_pos] == '%' {
- return yaml_parser_fetch_directive(parser)
- }
-
- buf := parser.buffer
- pos := parser.buffer_pos
-
- // Is it the document start indicator?
- if parser.mark.column == 0 && buf[pos] == '-' && buf[pos+1] == '-' && buf[pos+2] == '-' && is_blankz(buf, pos+3) {
- return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_START_TOKEN)
- }
-
- // Is it the document end indicator?
- if parser.mark.column == 0 && buf[pos] == '.' && buf[pos+1] == '.' && buf[pos+2] == '.' && is_blankz(buf, pos+3) {
- return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_END_TOKEN)
- }
-
- comment_mark := parser.mark
- if len(parser.tokens) > 0 && (parser.flow_level == 0 && buf[pos] == ':' || parser.flow_level > 0 && buf[pos] == ',') {
- // Associate any following comments with the prior token.
- comment_mark = parser.tokens[len(parser.tokens)-1].start_mark
- }
- defer func() {
- if !ok {
- return
- }
- if len(parser.tokens) > 0 && parser.tokens[len(parser.tokens)-1].typ == yaml_BLOCK_ENTRY_TOKEN {
- // Sequence indicators alone have no line comments. It becomes
- // a head comment for whatever follows.
- return
- }
- if !yaml_parser_scan_line_comment(parser, comment_mark) {
- ok = false
- return
- }
- }()
-
- // Is it the flow sequence start indicator?
- if buf[pos] == '[' {
- return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_SEQUENCE_START_TOKEN)
- }
-
- // Is it the flow mapping start indicator?
- if parser.buffer[parser.buffer_pos] == '{' {
- return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_MAPPING_START_TOKEN)
- }
-
- // Is it the flow sequence end indicator?
- if parser.buffer[parser.buffer_pos] == ']' {
- return yaml_parser_fetch_flow_collection_end(parser,
- yaml_FLOW_SEQUENCE_END_TOKEN)
- }
-
- // Is it the flow mapping end indicator?
- if parser.buffer[parser.buffer_pos] == '}' {
- return yaml_parser_fetch_flow_collection_end(parser,
- yaml_FLOW_MAPPING_END_TOKEN)
- }
-
- // Is it the flow entry indicator?
- if parser.buffer[parser.buffer_pos] == ',' {
- return yaml_parser_fetch_flow_entry(parser)
- }
-
- // Is it the block entry indicator?
- if parser.buffer[parser.buffer_pos] == '-' && is_blankz(parser.buffer, parser.buffer_pos+1) {
- return yaml_parser_fetch_block_entry(parser)
- }
-
- // Is it the key indicator?
- if parser.buffer[parser.buffer_pos] == '?' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) {
- return yaml_parser_fetch_key(parser)
- }
-
- // Is it the value indicator?
- if parser.buffer[parser.buffer_pos] == ':' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) {
- return yaml_parser_fetch_value(parser)
- }
-
- // Is it an alias?
- if parser.buffer[parser.buffer_pos] == '*' {
- return yaml_parser_fetch_anchor(parser, yaml_ALIAS_TOKEN)
- }
-
- // Is it an anchor?
- if parser.buffer[parser.buffer_pos] == '&' {
- return yaml_parser_fetch_anchor(parser, yaml_ANCHOR_TOKEN)
- }
-
- // Is it a tag?
- if parser.buffer[parser.buffer_pos] == '!' {
- return yaml_parser_fetch_tag(parser)
- }
-
- // Is it a literal scalar?
- if parser.buffer[parser.buffer_pos] == '|' && parser.flow_level == 0 {
- return yaml_parser_fetch_block_scalar(parser, true)
- }
-
- // Is it a folded scalar?
- if parser.buffer[parser.buffer_pos] == '>' && parser.flow_level == 0 {
- return yaml_parser_fetch_block_scalar(parser, false)
- }
-
- // Is it a single-quoted scalar?
- if parser.buffer[parser.buffer_pos] == '\'' {
- return yaml_parser_fetch_flow_scalar(parser, true)
- }
-
- // Is it a double-quoted scalar?
- if parser.buffer[parser.buffer_pos] == '"' {
- return yaml_parser_fetch_flow_scalar(parser, false)
- }
-
- // Is it a plain scalar?
- //
- // A plain scalar may start with any non-blank characters except
- //
- // '-', '?', ':', ',', '[', ']', '{', '}',
- // '#', '&', '*', '!', '|', '>', '\'', '\"',
- // '%', '@', '`'.
- //
- // In the block context (and, for the '-' indicator, in the flow context
- // too), it may also start with the characters
- //
- // '-', '?', ':'
- //
- // if it is followed by a non-space character.
- //
- // The last rule is more restrictive than the specification requires.
- // [Go] TODO Make this logic more reasonable.
- //switch parser.buffer[parser.buffer_pos] {
- //case '-', '?', ':', ',', '?', '-', ',', ':', ']', '[', '}', '{', '&', '#', '!', '*', '>', '|', '"', '\'', '@', '%', '-', '`':
- //}
- if !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '-' ||
- parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':' ||
- parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '[' ||
- parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' ||
- parser.buffer[parser.buffer_pos] == '}' || parser.buffer[parser.buffer_pos] == '#' ||
- parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '*' ||
- parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '|' ||
- parser.buffer[parser.buffer_pos] == '>' || parser.buffer[parser.buffer_pos] == '\'' ||
- parser.buffer[parser.buffer_pos] == '"' || parser.buffer[parser.buffer_pos] == '%' ||
- parser.buffer[parser.buffer_pos] == '@' || parser.buffer[parser.buffer_pos] == '`') ||
- (parser.buffer[parser.buffer_pos] == '-' && !is_blank(parser.buffer, parser.buffer_pos+1)) ||
- (parser.flow_level == 0 &&
- (parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':') &&
- !is_blankz(parser.buffer, parser.buffer_pos+1)) {
- return yaml_parser_fetch_plain_scalar(parser)
- }
-
- // If we don't determine the token type so far, it is an error.
- return yaml_parser_set_scanner_error(parser,
- "while scanning for the next token", parser.mark,
- "found character that cannot start any token")
-}
-
-func yaml_simple_key_is_valid(parser *yaml_parser_t, simple_key *yaml_simple_key_t) (valid, ok bool) {
- if !simple_key.possible {
- return false, true
- }
-
- // The 1.2 specification says:
- //
- // "If the ? indicator is omitted, parsing needs to see past the
- // implicit key to recognize it as such. To limit the amount of
- // lookahead required, the “:” indicator must appear at most 1024
- // Unicode characters beyond the start of the key. In addition, the key
- // is restricted to a single line."
- //
- if simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index {
- // Check if the potential simple key to be removed is required.
- if simple_key.required {
- return false, yaml_parser_set_scanner_error(parser,
- "while scanning a simple key", simple_key.mark,
- "could not find expected ':'")
- }
- simple_key.possible = false
- return false, true
- }
- return true, true
-}
-
-// Check if a simple key may start at the current position and add it if
-// needed.
-func yaml_parser_save_simple_key(parser *yaml_parser_t) bool {
- // A simple key is required at the current position if the scanner is in
- // the block context and the current column coincides with the indentation
- // level.
-
- required := parser.flow_level == 0 && parser.indent == parser.mark.column
-
- //
- // If the current position may start a simple key, save it.
- //
- if parser.simple_key_allowed {
- simple_key := yaml_simple_key_t{
- possible: true,
- required: required,
- token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head),
- mark: parser.mark,
- }
-
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
- parser.simple_keys[len(parser.simple_keys)-1] = simple_key
- parser.simple_keys_by_tok[simple_key.token_number] = len(parser.simple_keys) - 1
- }
- return true
-}
-
-// Remove a potential simple key at the current flow level.
-func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool {
- i := len(parser.simple_keys) - 1
- if parser.simple_keys[i].possible {
- // If the key is required, it is an error.
- if parser.simple_keys[i].required {
- return yaml_parser_set_scanner_error(parser,
- "while scanning a simple key", parser.simple_keys[i].mark,
- "could not find expected ':'")
- }
- // Remove the key from the stack.
- parser.simple_keys[i].possible = false
- delete(parser.simple_keys_by_tok, parser.simple_keys[i].token_number)
- }
- return true
-}
-
-// max_flow_level limits the flow_level
-const max_flow_level = 10000
-
-// Increase the flow level and resize the simple key list if needed.
-func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool {
- // Reset the simple key on the next level.
- parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{
- possible: false,
- required: false,
- token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head),
- mark: parser.mark,
- })
-
- // Increase the flow level.
- parser.flow_level++
- if parser.flow_level > max_flow_level {
- return yaml_parser_set_scanner_error(parser,
- "while increasing flow level", parser.simple_keys[len(parser.simple_keys)-1].mark,
- fmt.Sprintf("exceeded max depth of %d", max_flow_level))
- }
- return true
-}
-
-// Decrease the flow level.
-func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool {
- if parser.flow_level > 0 {
- parser.flow_level--
- last := len(parser.simple_keys) - 1
- delete(parser.simple_keys_by_tok, parser.simple_keys[last].token_number)
- parser.simple_keys = parser.simple_keys[:last]
- }
- return true
-}
-
-// max_indents limits the indents stack size
-const max_indents = 10000
-
-// Push the current indentation level to the stack and set the new level
-// the current column is greater than the indentation level. In this case,
-// append or insert the specified token into the token queue.
-func yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml_token_type_t, mark yaml_mark_t) bool {
- // In the flow context, do nothing.
- if parser.flow_level > 0 {
- return true
- }
-
- if parser.indent < column {
- // Push the current indentation level to the stack and set the new
- // indentation level.
- parser.indents = append(parser.indents, parser.indent)
- parser.indent = column
- if len(parser.indents) > max_indents {
- return yaml_parser_set_scanner_error(parser,
- "while increasing indent level", parser.simple_keys[len(parser.simple_keys)-1].mark,
- fmt.Sprintf("exceeded max depth of %d", max_indents))
- }
-
- // Create a token and insert it into the queue.
- token := yaml_token_t{
- typ: typ,
- start_mark: mark,
- end_mark: mark,
- }
- if number > -1 {
- number -= parser.tokens_parsed
- }
- yaml_insert_token(parser, number, &token)
- }
- return true
-}
-
-// Pop indentation levels from the indents stack until the current level
-// becomes less or equal to the column. For each indentation level, append
-// the BLOCK-END token.
-func yaml_parser_unroll_indent(parser *yaml_parser_t, column int, scan_mark yaml_mark_t) bool {
- // In the flow context, do nothing.
- if parser.flow_level > 0 {
- return true
- }
-
- block_mark := scan_mark
- block_mark.index--
-
- // Loop through the indentation levels in the stack.
- for parser.indent > column {
-
- // [Go] Reposition the end token before potential following
- // foot comments of parent blocks. For that, search
- // backwards for recent comments that were at the same
- // indent as the block that is ending now.
- stop_index := block_mark.index
- for i := len(parser.comments) - 1; i >= 0; i-- {
- comment := &parser.comments[i]
-
- if comment.end_mark.index < stop_index {
- // Don't go back beyond the start of the comment/whitespace scan, unless column < 0.
- // If requested indent column is < 0, then the document is over and everything else
- // is a foot anyway.
- break
- }
- if comment.start_mark.column == parser.indent+1 {
- // This is a good match. But maybe there's a former comment
- // at that same indent level, so keep searching.
- block_mark = comment.start_mark
- }
-
- // While the end of the former comment matches with
- // the start of the following one, we know there's
- // nothing in between and scanning is still safe.
- stop_index = comment.scan_mark.index
- }
-
- // Create a token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_BLOCK_END_TOKEN,
- start_mark: block_mark,
- end_mark: block_mark,
- }
- yaml_insert_token(parser, -1, &token)
-
- // Pop the indentation level.
- parser.indent = parser.indents[len(parser.indents)-1]
- parser.indents = parser.indents[:len(parser.indents)-1]
- }
- return true
-}
-
-// Initialize the scanner and produce the STREAM-START token.
-func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool {
-
- // Set the initial indentation.
- parser.indent = -1
-
- // Initialize the simple key stack.
- parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{})
-
- parser.simple_keys_by_tok = make(map[int]int)
-
- // A simple key is allowed at the beginning of the stream.
- parser.simple_key_allowed = true
-
- // We have started.
- parser.stream_start_produced = true
-
- // Create the STREAM-START token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_STREAM_START_TOKEN,
- start_mark: parser.mark,
- end_mark: parser.mark,
- encoding: parser.encoding,
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the STREAM-END token and shut down the scanner.
-func yaml_parser_fetch_stream_end(parser *yaml_parser_t) bool {
-
- // Force new line.
- if parser.mark.column != 0 {
- parser.mark.column = 0
- parser.mark.line++
- }
-
- // Reset the indentation level.
- if !yaml_parser_unroll_indent(parser, -1, parser.mark) {
- return false
- }
-
- // Reset simple keys.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- parser.simple_key_allowed = false
-
- // Create the STREAM-END token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_STREAM_END_TOKEN,
- start_mark: parser.mark,
- end_mark: parser.mark,
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token.
-func yaml_parser_fetch_directive(parser *yaml_parser_t) bool {
- // Reset the indentation level.
- if !yaml_parser_unroll_indent(parser, -1, parser.mark) {
- return false
- }
-
- // Reset simple keys.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- parser.simple_key_allowed = false
-
- // Create the YAML-DIRECTIVE or TAG-DIRECTIVE token.
- token := yaml_token_t{}
- if !yaml_parser_scan_directive(parser, &token) {
- return false
- }
- // Append the token to the queue.
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the DOCUMENT-START or DOCUMENT-END token.
-func yaml_parser_fetch_document_indicator(parser *yaml_parser_t, typ yaml_token_type_t) bool {
- // Reset the indentation level.
- if !yaml_parser_unroll_indent(parser, -1, parser.mark) {
- return false
- }
-
- // Reset simple keys.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- parser.simple_key_allowed = false
-
- // Consume the token.
- start_mark := parser.mark
-
- skip(parser)
- skip(parser)
- skip(parser)
-
- end_mark := parser.mark
-
- // Create the DOCUMENT-START or DOCUMENT-END token.
- token := yaml_token_t{
- typ: typ,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- // Append the token to the queue.
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token.
-func yaml_parser_fetch_flow_collection_start(parser *yaml_parser_t, typ yaml_token_type_t) bool {
-
- // The indicators '[' and '{' may start a simple key.
- if !yaml_parser_save_simple_key(parser) {
- return false
- }
-
- // Increase the flow level.
- if !yaml_parser_increase_flow_level(parser) {
- return false
- }
-
- // A simple key may follow the indicators '[' and '{'.
- parser.simple_key_allowed = true
-
- // Consume the token.
- start_mark := parser.mark
- skip(parser)
- end_mark := parser.mark
-
- // Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token.
- token := yaml_token_t{
- typ: typ,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- // Append the token to the queue.
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the FLOW-SEQUENCE-END or FLOW-MAPPING-END token.
-func yaml_parser_fetch_flow_collection_end(parser *yaml_parser_t, typ yaml_token_type_t) bool {
- // Reset any potential simple key on the current flow level.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- // Decrease the flow level.
- if !yaml_parser_decrease_flow_level(parser) {
- return false
- }
-
- // No simple keys after the indicators ']' and '}'.
- parser.simple_key_allowed = false
-
- // Consume the token.
-
- start_mark := parser.mark
- skip(parser)
- end_mark := parser.mark
-
- // Create the FLOW-SEQUENCE-END of FLOW-MAPPING-END token.
- token := yaml_token_t{
- typ: typ,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- // Append the token to the queue.
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the FLOW-ENTRY token.
-func yaml_parser_fetch_flow_entry(parser *yaml_parser_t) bool {
- // Reset any potential simple keys on the current flow level.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- // Simple keys are allowed after ','.
- parser.simple_key_allowed = true
-
- // Consume the token.
- start_mark := parser.mark
- skip(parser)
- end_mark := parser.mark
-
- // Create the FLOW-ENTRY token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_FLOW_ENTRY_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the BLOCK-ENTRY token.
-func yaml_parser_fetch_block_entry(parser *yaml_parser_t) bool {
- // Check if the scanner is in the block context.
- if parser.flow_level == 0 {
- // Check if we are allowed to start a new entry.
- if !parser.simple_key_allowed {
- return yaml_parser_set_scanner_error(parser, "", parser.mark,
- "block sequence entries are not allowed in this context")
- }
- // Add the BLOCK-SEQUENCE-START token if needed.
- if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_SEQUENCE_START_TOKEN, parser.mark) {
- return false
- }
- } else {
- // It is an error for the '-' indicator to occur in the flow context,
- // but we let the Parser detect and report about it because the Parser
- // is able to point to the context.
- }
-
- // Reset any potential simple keys on the current flow level.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- // Simple keys are allowed after '-'.
- parser.simple_key_allowed = true
-
- // Consume the token.
- start_mark := parser.mark
- skip(parser)
- end_mark := parser.mark
-
- // Create the BLOCK-ENTRY token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_BLOCK_ENTRY_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the KEY token.
-func yaml_parser_fetch_key(parser *yaml_parser_t) bool {
-
- // In the block context, additional checks are required.
- if parser.flow_level == 0 {
- // Check if we are allowed to start a new key (not nessesary simple).
- if !parser.simple_key_allowed {
- return yaml_parser_set_scanner_error(parser, "", parser.mark,
- "mapping keys are not allowed in this context")
- }
- // Add the BLOCK-MAPPING-START token if needed.
- if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) {
- return false
- }
- }
-
- // Reset any potential simple keys on the current flow level.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- // Simple keys are allowed after '?' in the block context.
- parser.simple_key_allowed = parser.flow_level == 0
-
- // Consume the token.
- start_mark := parser.mark
- skip(parser)
- end_mark := parser.mark
-
- // Create the KEY token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_KEY_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the VALUE token.
-func yaml_parser_fetch_value(parser *yaml_parser_t) bool {
-
- simple_key := &parser.simple_keys[len(parser.simple_keys)-1]
-
- // Have we found a simple key?
- if valid, ok := yaml_simple_key_is_valid(parser, simple_key); !ok {
- return false
-
- } else if valid {
-
- // Create the KEY token and insert it into the queue.
- token := yaml_token_t{
- typ: yaml_KEY_TOKEN,
- start_mark: simple_key.mark,
- end_mark: simple_key.mark,
- }
- yaml_insert_token(parser, simple_key.token_number-parser.tokens_parsed, &token)
-
- // In the block context, we may need to add the BLOCK-MAPPING-START token.
- if !yaml_parser_roll_indent(parser, simple_key.mark.column,
- simple_key.token_number,
- yaml_BLOCK_MAPPING_START_TOKEN, simple_key.mark) {
- return false
- }
-
- // Remove the simple key.
- simple_key.possible = false
- delete(parser.simple_keys_by_tok, simple_key.token_number)
-
- // A simple key cannot follow another simple key.
- parser.simple_key_allowed = false
-
- } else {
- // The ':' indicator follows a complex key.
-
- // In the block context, extra checks are required.
- if parser.flow_level == 0 {
-
- // Check if we are allowed to start a complex value.
- if !parser.simple_key_allowed {
- return yaml_parser_set_scanner_error(parser, "", parser.mark,
- "mapping values are not allowed in this context")
- }
-
- // Add the BLOCK-MAPPING-START token if needed.
- if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) {
- return false
- }
- }
-
- // Simple keys after ':' are allowed in the block context.
- parser.simple_key_allowed = parser.flow_level == 0
- }
-
- // Consume the token.
- start_mark := parser.mark
- skip(parser)
- end_mark := parser.mark
-
- // Create the VALUE token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_VALUE_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the ALIAS or ANCHOR token.
-func yaml_parser_fetch_anchor(parser *yaml_parser_t, typ yaml_token_type_t) bool {
- // An anchor or an alias could be a simple key.
- if !yaml_parser_save_simple_key(parser) {
- return false
- }
-
- // A simple key cannot follow an anchor or an alias.
- parser.simple_key_allowed = false
-
- // Create the ALIAS or ANCHOR token and append it to the queue.
- var token yaml_token_t
- if !yaml_parser_scan_anchor(parser, &token, typ) {
- return false
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the TAG token.
-func yaml_parser_fetch_tag(parser *yaml_parser_t) bool {
- // A tag could be a simple key.
- if !yaml_parser_save_simple_key(parser) {
- return false
- }
-
- // A simple key cannot follow a tag.
- parser.simple_key_allowed = false
-
- // Create the TAG token and append it to the queue.
- var token yaml_token_t
- if !yaml_parser_scan_tag(parser, &token) {
- return false
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the SCALAR(...,literal) or SCALAR(...,folded) tokens.
-func yaml_parser_fetch_block_scalar(parser *yaml_parser_t, literal bool) bool {
- // Remove any potential simple keys.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- // A simple key may follow a block scalar.
- parser.simple_key_allowed = true
-
- // Create the SCALAR token and append it to the queue.
- var token yaml_token_t
- if !yaml_parser_scan_block_scalar(parser, &token, literal) {
- return false
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the SCALAR(...,single-quoted) or SCALAR(...,double-quoted) tokens.
-func yaml_parser_fetch_flow_scalar(parser *yaml_parser_t, single bool) bool {
- // A plain scalar could be a simple key.
- if !yaml_parser_save_simple_key(parser) {
- return false
- }
-
- // A simple key cannot follow a flow scalar.
- parser.simple_key_allowed = false
-
- // Create the SCALAR token and append it to the queue.
- var token yaml_token_t
- if !yaml_parser_scan_flow_scalar(parser, &token, single) {
- return false
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the SCALAR(...,plain) token.
-func yaml_parser_fetch_plain_scalar(parser *yaml_parser_t) bool {
- // A plain scalar could be a simple key.
- if !yaml_parser_save_simple_key(parser) {
- return false
- }
-
- // A simple key cannot follow a flow scalar.
- parser.simple_key_allowed = false
-
- // Create the SCALAR token and append it to the queue.
- var token yaml_token_t
- if !yaml_parser_scan_plain_scalar(parser, &token) {
- return false
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Eat whitespaces and comments until the next token is found.
-func yaml_parser_scan_to_next_token(parser *yaml_parser_t) bool {
-
- scan_mark := parser.mark
-
- // Until the next token is not found.
- for {
- // Allow the BOM mark to start a line.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if parser.mark.column == 0 && is_bom(parser.buffer, parser.buffer_pos) {
- skip(parser)
- }
-
- // Eat whitespaces.
- // Tabs are allowed:
- // - in the flow context
- // - in the block context, but not at the beginning of the line or
- // after '-', '?', or ':' (complex value).
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- for parser.buffer[parser.buffer_pos] == ' ' || ((parser.flow_level > 0 || !parser.simple_key_allowed) && parser.buffer[parser.buffer_pos] == '\t') {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Check if we just had a line comment under a sequence entry that
- // looks more like a header to the following content. Similar to this:
- //
- // - # The comment
- // - Some data
- //
- // If so, transform the line comment to a head comment and reposition.
- if len(parser.comments) > 0 && len(parser.tokens) > 1 {
- tokenA := parser.tokens[len(parser.tokens)-2]
- tokenB := parser.tokens[len(parser.tokens)-1]
- comment := &parser.comments[len(parser.comments)-1]
- if tokenA.typ == yaml_BLOCK_SEQUENCE_START_TOKEN && tokenB.typ == yaml_BLOCK_ENTRY_TOKEN && len(comment.line) > 0 && !is_break(parser.buffer, parser.buffer_pos) {
- // If it was in the prior line, reposition so it becomes a
- // header of the follow up token. Otherwise, keep it in place
- // so it becomes a header of the former.
- comment.head = comment.line
- comment.line = nil
- if comment.start_mark.line == parser.mark.line-1 {
- comment.token_mark = parser.mark
- }
- }
- }
-
- // Eat a comment until a line break.
- if parser.buffer[parser.buffer_pos] == '#' {
- if !yaml_parser_scan_comments(parser, scan_mark) {
- return false
- }
- }
-
- // If it is a line break, eat it.
- if is_break(parser.buffer, parser.buffer_pos) {
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- skip_line(parser)
-
- // In the block context, a new line may start a simple key.
- if parser.flow_level == 0 {
- parser.simple_key_allowed = true
- }
- } else {
- break // We have found a token.
- }
- }
-
- return true
-}
-
-// Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token.
-//
-// Scope:
-// %YAML 1.1 # a comment \n
-// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-// %TAG !yaml! tag:yaml.org,2002: \n
-// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-//
-func yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool {
- // Eat '%'.
- start_mark := parser.mark
- skip(parser)
-
- // Scan the directive name.
- var name []byte
- if !yaml_parser_scan_directive_name(parser, start_mark, &name) {
- return false
- }
-
- // Is it a YAML directive?
- if bytes.Equal(name, []byte("YAML")) {
- // Scan the VERSION directive value.
- var major, minor int8
- if !yaml_parser_scan_version_directive_value(parser, start_mark, &major, &minor) {
- return false
- }
- end_mark := parser.mark
-
- // Create a VERSION-DIRECTIVE token.
- *token = yaml_token_t{
- typ: yaml_VERSION_DIRECTIVE_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- major: major,
- minor: minor,
- }
-
- // Is it a TAG directive?
- } else if bytes.Equal(name, []byte("TAG")) {
- // Scan the TAG directive value.
- var handle, prefix []byte
- if !yaml_parser_scan_tag_directive_value(parser, start_mark, &handle, &prefix) {
- return false
- }
- end_mark := parser.mark
-
- // Create a TAG-DIRECTIVE token.
- *token = yaml_token_t{
- typ: yaml_TAG_DIRECTIVE_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- value: handle,
- prefix: prefix,
- }
-
- // Unknown directive.
- } else {
- yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "found unknown directive name")
- return false
- }
-
- // Eat the rest of the line including any comments.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- for is_blank(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- if parser.buffer[parser.buffer_pos] == '#' {
- // [Go] Discard this inline comment for the time being.
- //if !yaml_parser_scan_line_comment(parser, start_mark) {
- // return false
- //}
- for !is_breakz(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
- }
-
- // Check if we are at the end of the line.
- if !is_breakz(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "did not find expected comment or line break")
- return false
- }
-
- // Eat a line break.
- if is_break(parser.buffer, parser.buffer_pos) {
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- skip_line(parser)
- }
-
- return true
-}
-
-// Scan the directive name.
-//
-// Scope:
-// %YAML 1.1 # a comment \n
-// ^^^^
-// %TAG !yaml! tag:yaml.org,2002: \n
-// ^^^
-//
-func yaml_parser_scan_directive_name(parser *yaml_parser_t, start_mark yaml_mark_t, name *[]byte) bool {
- // Consume the directive name.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- var s []byte
- for is_alpha(parser.buffer, parser.buffer_pos) {
- s = read(parser, s)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Check if the name is empty.
- if len(s) == 0 {
- yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "could not find expected directive name")
- return false
- }
-
- // Check for an blank character after the name.
- if !is_blankz(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "found unexpected non-alphabetical character")
- return false
- }
- *name = s
- return true
-}
-
-// Scan the value of VERSION-DIRECTIVE.
-//
-// Scope:
-// %YAML 1.1 # a comment \n
-// ^^^^^^
-func yaml_parser_scan_version_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, major, minor *int8) bool {
- // Eat whitespaces.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- for is_blank(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Consume the major version number.
- if !yaml_parser_scan_version_directive_number(parser, start_mark, major) {
- return false
- }
-
- // Eat '.'.
- if parser.buffer[parser.buffer_pos] != '.' {
- return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
- start_mark, "did not find expected digit or '.' character")
- }
-
- skip(parser)
-
- // Consume the minor version number.
- if !yaml_parser_scan_version_directive_number(parser, start_mark, minor) {
- return false
- }
- return true
-}
-
-const max_number_length = 2
-
-// Scan the version number of VERSION-DIRECTIVE.
-//
-// Scope:
-// %YAML 1.1 # a comment \n
-// ^
-// %YAML 1.1 # a comment \n
-// ^
-func yaml_parser_scan_version_directive_number(parser *yaml_parser_t, start_mark yaml_mark_t, number *int8) bool {
-
- // Repeat while the next character is digit.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- var value, length int8
- for is_digit(parser.buffer, parser.buffer_pos) {
- // Check if the number is too long.
- length++
- if length > max_number_length {
- return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
- start_mark, "found extremely long version number")
- }
- value = value*10 + int8(as_digit(parser.buffer, parser.buffer_pos))
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Check if the number was present.
- if length == 0 {
- return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
- start_mark, "did not find expected version number")
- }
- *number = value
- return true
-}
-
-// Scan the value of a TAG-DIRECTIVE token.
-//
-// Scope:
-// %TAG !yaml! tag:yaml.org,2002: \n
-// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-//
-func yaml_parser_scan_tag_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, handle, prefix *[]byte) bool {
- var handle_value, prefix_value []byte
-
- // Eat whitespaces.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- for is_blank(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Scan a handle.
- if !yaml_parser_scan_tag_handle(parser, true, start_mark, &handle_value) {
- return false
- }
-
- // Expect a whitespace.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if !is_blank(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
- start_mark, "did not find expected whitespace")
- return false
- }
-
- // Eat whitespaces.
- for is_blank(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Scan a prefix.
- if !yaml_parser_scan_tag_uri(parser, true, nil, start_mark, &prefix_value) {
- return false
- }
-
- // Expect a whitespace or line break.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if !is_blankz(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
- start_mark, "did not find expected whitespace or line break")
- return false
- }
-
- *handle = handle_value
- *prefix = prefix_value
- return true
-}
-
-func yaml_parser_scan_anchor(parser *yaml_parser_t, token *yaml_token_t, typ yaml_token_type_t) bool {
- var s []byte
-
- // Eat the indicator character.
- start_mark := parser.mark
- skip(parser)
-
- // Consume the value.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- for is_alpha(parser.buffer, parser.buffer_pos) {
- s = read(parser, s)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- end_mark := parser.mark
-
- /*
- * Check if length of the anchor is greater than 0 and it is followed by
- * a whitespace character or one of the indicators:
- *
- * '?', ':', ',', ']', '}', '%', '@', '`'.
- */
-
- if len(s) == 0 ||
- !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '?' ||
- parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == ',' ||
- parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '}' ||
- parser.buffer[parser.buffer_pos] == '%' || parser.buffer[parser.buffer_pos] == '@' ||
- parser.buffer[parser.buffer_pos] == '`') {
- context := "while scanning an alias"
- if typ == yaml_ANCHOR_TOKEN {
- context = "while scanning an anchor"
- }
- yaml_parser_set_scanner_error(parser, context, start_mark,
- "did not find expected alphabetic or numeric character")
- return false
- }
-
- // Create a token.
- *token = yaml_token_t{
- typ: typ,
- start_mark: start_mark,
- end_mark: end_mark,
- value: s,
- }
-
- return true
-}
-
-/*
- * Scan a TAG token.
- */
-
-func yaml_parser_scan_tag(parser *yaml_parser_t, token *yaml_token_t) bool {
- var handle, suffix []byte
-
- start_mark := parser.mark
-
- // Check if the tag is in the canonical form.
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
-
- if parser.buffer[parser.buffer_pos+1] == '<' {
- // Keep the handle as ''
-
- // Eat '!<'
- skip(parser)
- skip(parser)
-
- // Consume the tag value.
- if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) {
- return false
- }
-
- // Check for '>' and eat it.
- if parser.buffer[parser.buffer_pos] != '>' {
- yaml_parser_set_scanner_error(parser, "while scanning a tag",
- start_mark, "did not find the expected '>'")
- return false
- }
-
- skip(parser)
- } else {
- // The tag has either the '!suffix' or the '!handle!suffix' form.
-
- // First, try to scan a handle.
- if !yaml_parser_scan_tag_handle(parser, false, start_mark, &handle) {
- return false
- }
-
- // Check if it is, indeed, handle.
- if handle[0] == '!' && len(handle) > 1 && handle[len(handle)-1] == '!' {
- // Scan the suffix now.
- if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) {
- return false
- }
- } else {
- // It wasn't a handle after all. Scan the rest of the tag.
- if !yaml_parser_scan_tag_uri(parser, false, handle, start_mark, &suffix) {
- return false
- }
-
- // Set the handle to '!'.
- handle = []byte{'!'}
-
- // A special case: the '!' tag. Set the handle to '' and the
- // suffix to '!'.
- if len(suffix) == 0 {
- handle, suffix = suffix, handle
- }
- }
- }
-
- // Check the character which ends the tag.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if !is_blankz(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a tag",
- start_mark, "did not find expected whitespace or line break")
- return false
- }
-
- end_mark := parser.mark
-
- // Create a token.
- *token = yaml_token_t{
- typ: yaml_TAG_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- value: handle,
- suffix: suffix,
- }
- return true
-}
-
-// Scan a tag handle.
-func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, handle *[]byte) bool {
- // Check the initial '!' character.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if parser.buffer[parser.buffer_pos] != '!' {
- yaml_parser_set_scanner_tag_error(parser, directive,
- start_mark, "did not find expected '!'")
- return false
- }
-
- var s []byte
-
- // Copy the '!' character.
- s = read(parser, s)
-
- // Copy all subsequent alphabetical and numerical characters.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- for is_alpha(parser.buffer, parser.buffer_pos) {
- s = read(parser, s)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Check if the trailing character is '!' and copy it.
- if parser.buffer[parser.buffer_pos] == '!' {
- s = read(parser, s)
- } else {
- // It's either the '!' tag or not really a tag handle. If it's a %TAG
- // directive, it's an error. If it's a tag token, it must be a part of URI.
- if directive && string(s) != "!" {
- yaml_parser_set_scanner_tag_error(parser, directive,
- start_mark, "did not find expected '!'")
- return false
- }
- }
-
- *handle = s
- return true
-}
-
-// Scan a tag.
-func yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte, start_mark yaml_mark_t, uri *[]byte) bool {
- //size_t length = head ? strlen((char *)head) : 0
- var s []byte
- hasTag := len(head) > 0
-
- // Copy the head if needed.
- //
- // Note that we don't copy the leading '!' character.
- if len(head) > 1 {
- s = append(s, head[1:]...)
- }
-
- // Scan the tag.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- // The set of characters that may appear in URI is as follows:
- //
- // '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&',
- // '=', '+', '$', ',', '.', '!', '~', '*', '\'', '(', ')', '[', ']',
- // '%'.
- // [Go] TODO Convert this into more reasonable logic.
- for is_alpha(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == ';' ||
- parser.buffer[parser.buffer_pos] == '/' || parser.buffer[parser.buffer_pos] == '?' ||
- parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == '@' ||
- parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '=' ||
- parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '$' ||
- parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '.' ||
- parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '~' ||
- parser.buffer[parser.buffer_pos] == '*' || parser.buffer[parser.buffer_pos] == '\'' ||
- parser.buffer[parser.buffer_pos] == '(' || parser.buffer[parser.buffer_pos] == ')' ||
- parser.buffer[parser.buffer_pos] == '[' || parser.buffer[parser.buffer_pos] == ']' ||
- parser.buffer[parser.buffer_pos] == '%' {
- // Check if it is a URI-escape sequence.
- if parser.buffer[parser.buffer_pos] == '%' {
- if !yaml_parser_scan_uri_escapes(parser, directive, start_mark, &s) {
- return false
- }
- } else {
- s = read(parser, s)
- }
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- hasTag = true
- }
-
- if !hasTag {
- yaml_parser_set_scanner_tag_error(parser, directive,
- start_mark, "did not find expected tag URI")
- return false
- }
- *uri = s
- return true
-}
-
-// Decode an URI-escape sequence corresponding to a single UTF-8 character.
-func yaml_parser_scan_uri_escapes(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, s *[]byte) bool {
-
- // Decode the required number of characters.
- w := 1024
- for w > 0 {
- // Check for a URI-escaped octet.
- if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) {
- return false
- }
-
- if !(parser.buffer[parser.buffer_pos] == '%' &&
- is_hex(parser.buffer, parser.buffer_pos+1) &&
- is_hex(parser.buffer, parser.buffer_pos+2)) {
- return yaml_parser_set_scanner_tag_error(parser, directive,
- start_mark, "did not find URI escaped octet")
- }
-
- // Get the octet.
- octet := byte((as_hex(parser.buffer, parser.buffer_pos+1) << 4) + as_hex(parser.buffer, parser.buffer_pos+2))
-
- // If it is the leading octet, determine the length of the UTF-8 sequence.
- if w == 1024 {
- w = width(octet)
- if w == 0 {
- return yaml_parser_set_scanner_tag_error(parser, directive,
- start_mark, "found an incorrect leading UTF-8 octet")
- }
- } else {
- // Check if the trailing octet is correct.
- if octet&0xC0 != 0x80 {
- return yaml_parser_set_scanner_tag_error(parser, directive,
- start_mark, "found an incorrect trailing UTF-8 octet")
- }
- }
-
- // Copy the octet and move the pointers.
- *s = append(*s, octet)
- skip(parser)
- skip(parser)
- skip(parser)
- w--
- }
- return true
-}
-
-// Scan a block scalar.
-func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, literal bool) bool {
- // Eat the indicator '|' or '>'.
- start_mark := parser.mark
- skip(parser)
-
- // Scan the additional block scalar indicators.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- // Check for a chomping indicator.
- var chomping, increment int
- if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' {
- // Set the chomping method and eat the indicator.
- if parser.buffer[parser.buffer_pos] == '+' {
- chomping = +1
- } else {
- chomping = -1
- }
- skip(parser)
-
- // Check for an indentation indicator.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if is_digit(parser.buffer, parser.buffer_pos) {
- // Check that the indentation is greater than 0.
- if parser.buffer[parser.buffer_pos] == '0' {
- yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "found an indentation indicator equal to 0")
- return false
- }
-
- // Get the indentation level and eat the indicator.
- increment = as_digit(parser.buffer, parser.buffer_pos)
- skip(parser)
- }
-
- } else if is_digit(parser.buffer, parser.buffer_pos) {
- // Do the same as above, but in the opposite order.
-
- if parser.buffer[parser.buffer_pos] == '0' {
- yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "found an indentation indicator equal to 0")
- return false
- }
- increment = as_digit(parser.buffer, parser.buffer_pos)
- skip(parser)
-
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' {
- if parser.buffer[parser.buffer_pos] == '+' {
- chomping = +1
- } else {
- chomping = -1
- }
- skip(parser)
- }
- }
-
- // Eat whitespaces and comments to the end of the line.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- for is_blank(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
- if parser.buffer[parser.buffer_pos] == '#' {
- if !yaml_parser_scan_line_comment(parser, start_mark) {
- return false
- }
- for !is_breakz(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
- }
-
- // Check if we are at the end of the line.
- if !is_breakz(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "did not find expected comment or line break")
- return false
- }
-
- // Eat a line break.
- if is_break(parser.buffer, parser.buffer_pos) {
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- skip_line(parser)
- }
-
- end_mark := parser.mark
-
- // Set the indentation level if it was specified.
- var indent int
- if increment > 0 {
- if parser.indent >= 0 {
- indent = parser.indent + increment
- } else {
- indent = increment
- }
- }
-
- // Scan the leading line breaks and determine the indentation level if needed.
- var s, leading_break, trailing_breaks []byte
- if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) {
- return false
- }
-
- // Scan the block scalar content.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- var leading_blank, trailing_blank bool
- for parser.mark.column == indent && !is_z(parser.buffer, parser.buffer_pos) {
- // We are at the beginning of a non-empty line.
-
- // Is it a trailing whitespace?
- trailing_blank = is_blank(parser.buffer, parser.buffer_pos)
-
- // Check if we need to fold the leading line break.
- if !literal && !leading_blank && !trailing_blank && len(leading_break) > 0 && leading_break[0] == '\n' {
- // Do we need to join the lines by space?
- if len(trailing_breaks) == 0 {
- s = append(s, ' ')
- }
- } else {
- s = append(s, leading_break...)
- }
- leading_break = leading_break[:0]
-
- // Append the remaining line breaks.
- s = append(s, trailing_breaks...)
- trailing_breaks = trailing_breaks[:0]
-
- // Is it a leading whitespace?
- leading_blank = is_blank(parser.buffer, parser.buffer_pos)
-
- // Consume the current line.
- for !is_breakz(parser.buffer, parser.buffer_pos) {
- s = read(parser, s)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Consume the line break.
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
-
- leading_break = read_line(parser, leading_break)
-
- // Eat the following indentation spaces and line breaks.
- if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) {
- return false
- }
- }
-
- // Chomp the tail.
- if chomping != -1 {
- s = append(s, leading_break...)
- }
- if chomping == 1 {
- s = append(s, trailing_breaks...)
- }
-
- // Create a token.
- *token = yaml_token_t{
- typ: yaml_SCALAR_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- value: s,
- style: yaml_LITERAL_SCALAR_STYLE,
- }
- if !literal {
- token.style = yaml_FOLDED_SCALAR_STYLE
- }
- return true
-}
-
-// Scan indentation spaces and line breaks for a block scalar. Determine the
-// indentation level if needed.
-func yaml_parser_scan_block_scalar_breaks(parser *yaml_parser_t, indent *int, breaks *[]byte, start_mark yaml_mark_t, end_mark *yaml_mark_t) bool {
- *end_mark = parser.mark
-
- // Eat the indentation spaces and line breaks.
- max_indent := 0
- for {
- // Eat the indentation spaces.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- for (*indent == 0 || parser.mark.column < *indent) && is_space(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
- if parser.mark.column > max_indent {
- max_indent = parser.mark.column
- }
-
- // Check for a tab character messing the indentation.
- if (*indent == 0 || parser.mark.column < *indent) && is_tab(parser.buffer, parser.buffer_pos) {
- return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "found a tab character where an indentation space is expected")
- }
-
- // Have we found a non-empty line?
- if !is_break(parser.buffer, parser.buffer_pos) {
- break
- }
-
- // Consume the line break.
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- // [Go] Should really be returning breaks instead.
- *breaks = read_line(parser, *breaks)
- *end_mark = parser.mark
- }
-
- // Determine the indentation level if needed.
- if *indent == 0 {
- *indent = max_indent
- if *indent < parser.indent+1 {
- *indent = parser.indent + 1
- }
- if *indent < 1 {
- *indent = 1
- }
- }
- return true
-}
-
-// Scan a quoted scalar.
-func yaml_parser_scan_flow_scalar(parser *yaml_parser_t, token *yaml_token_t, single bool) bool {
- // Eat the left quote.
- start_mark := parser.mark
- skip(parser)
-
- // Consume the content of the quoted scalar.
- var s, leading_break, trailing_breaks, whitespaces []byte
- for {
- // Check that there are no document indicators at the beginning of the line.
- if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) {
- return false
- }
-
- if parser.mark.column == 0 &&
- ((parser.buffer[parser.buffer_pos+0] == '-' &&
- parser.buffer[parser.buffer_pos+1] == '-' &&
- parser.buffer[parser.buffer_pos+2] == '-') ||
- (parser.buffer[parser.buffer_pos+0] == '.' &&
- parser.buffer[parser.buffer_pos+1] == '.' &&
- parser.buffer[parser.buffer_pos+2] == '.')) &&
- is_blankz(parser.buffer, parser.buffer_pos+3) {
- yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
- start_mark, "found unexpected document indicator")
- return false
- }
-
- // Check for EOF.
- if is_z(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
- start_mark, "found unexpected end of stream")
- return false
- }
-
- // Consume non-blank characters.
- leading_blanks := false
- for !is_blankz(parser.buffer, parser.buffer_pos) {
- if single && parser.buffer[parser.buffer_pos] == '\'' && parser.buffer[parser.buffer_pos+1] == '\'' {
- // Is is an escaped single quote.
- s = append(s, '\'')
- skip(parser)
- skip(parser)
-
- } else if single && parser.buffer[parser.buffer_pos] == '\'' {
- // It is a right single quote.
- break
- } else if !single && parser.buffer[parser.buffer_pos] == '"' {
- // It is a right double quote.
- break
-
- } else if !single && parser.buffer[parser.buffer_pos] == '\\' && is_break(parser.buffer, parser.buffer_pos+1) {
- // It is an escaped line break.
- if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) {
- return false
- }
- skip(parser)
- skip_line(parser)
- leading_blanks = true
- break
-
- } else if !single && parser.buffer[parser.buffer_pos] == '\\' {
- // It is an escape sequence.
- code_length := 0
-
- // Check the escape character.
- switch parser.buffer[parser.buffer_pos+1] {
- case '0':
- s = append(s, 0)
- case 'a':
- s = append(s, '\x07')
- case 'b':
- s = append(s, '\x08')
- case 't', '\t':
- s = append(s, '\x09')
- case 'n':
- s = append(s, '\x0A')
- case 'v':
- s = append(s, '\x0B')
- case 'f':
- s = append(s, '\x0C')
- case 'r':
- s = append(s, '\x0D')
- case 'e':
- s = append(s, '\x1B')
- case ' ':
- s = append(s, '\x20')
- case '"':
- s = append(s, '"')
- case '\'':
- s = append(s, '\'')
- case '\\':
- s = append(s, '\\')
- case 'N': // NEL (#x85)
- s = append(s, '\xC2')
- s = append(s, '\x85')
- case '_': // #xA0
- s = append(s, '\xC2')
- s = append(s, '\xA0')
- case 'L': // LS (#x2028)
- s = append(s, '\xE2')
- s = append(s, '\x80')
- s = append(s, '\xA8')
- case 'P': // PS (#x2029)
- s = append(s, '\xE2')
- s = append(s, '\x80')
- s = append(s, '\xA9')
- case 'x':
- code_length = 2
- case 'u':
- code_length = 4
- case 'U':
- code_length = 8
- default:
- yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
- start_mark, "found unknown escape character")
- return false
- }
-
- skip(parser)
- skip(parser)
-
- // Consume an arbitrary escape code.
- if code_length > 0 {
- var value int
-
- // Scan the character value.
- if parser.unread < code_length && !yaml_parser_update_buffer(parser, code_length) {
- return false
- }
- for k := 0; k < code_length; k++ {
- if !is_hex(parser.buffer, parser.buffer_pos+k) {
- yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
- start_mark, "did not find expected hexdecimal number")
- return false
- }
- value = (value << 4) + as_hex(parser.buffer, parser.buffer_pos+k)
- }
-
- // Check the value and write the character.
- if (value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF {
- yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
- start_mark, "found invalid Unicode character escape code")
- return false
- }
- if value <= 0x7F {
- s = append(s, byte(value))
- } else if value <= 0x7FF {
- s = append(s, byte(0xC0+(value>>6)))
- s = append(s, byte(0x80+(value&0x3F)))
- } else if value <= 0xFFFF {
- s = append(s, byte(0xE0+(value>>12)))
- s = append(s, byte(0x80+((value>>6)&0x3F)))
- s = append(s, byte(0x80+(value&0x3F)))
- } else {
- s = append(s, byte(0xF0+(value>>18)))
- s = append(s, byte(0x80+((value>>12)&0x3F)))
- s = append(s, byte(0x80+((value>>6)&0x3F)))
- s = append(s, byte(0x80+(value&0x3F)))
- }
-
- // Advance the pointer.
- for k := 0; k < code_length; k++ {
- skip(parser)
- }
- }
- } else {
- // It is a non-escaped non-blank character.
- s = read(parser, s)
- }
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- }
-
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- // Check if we are at the end of the scalar.
- if single {
- if parser.buffer[parser.buffer_pos] == '\'' {
- break
- }
- } else {
- if parser.buffer[parser.buffer_pos] == '"' {
- break
- }
- }
-
- // Consume blank characters.
- for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) {
- if is_blank(parser.buffer, parser.buffer_pos) {
- // Consume a space or a tab character.
- if !leading_blanks {
- whitespaces = read(parser, whitespaces)
- } else {
- skip(parser)
- }
- } else {
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
-
- // Check if it is a first line break.
- if !leading_blanks {
- whitespaces = whitespaces[:0]
- leading_break = read_line(parser, leading_break)
- leading_blanks = true
- } else {
- trailing_breaks = read_line(parser, trailing_breaks)
- }
- }
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Join the whitespaces or fold line breaks.
- if leading_blanks {
- // Do we need to fold line breaks?
- if len(leading_break) > 0 && leading_break[0] == '\n' {
- if len(trailing_breaks) == 0 {
- s = append(s, ' ')
- } else {
- s = append(s, trailing_breaks...)
- }
- } else {
- s = append(s, leading_break...)
- s = append(s, trailing_breaks...)
- }
- trailing_breaks = trailing_breaks[:0]
- leading_break = leading_break[:0]
- } else {
- s = append(s, whitespaces...)
- whitespaces = whitespaces[:0]
- }
- }
-
- // Eat the right quote.
- skip(parser)
- end_mark := parser.mark
-
- // Create a token.
- *token = yaml_token_t{
- typ: yaml_SCALAR_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- value: s,
- style: yaml_SINGLE_QUOTED_SCALAR_STYLE,
- }
- if !single {
- token.style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- }
- return true
-}
-
-// Scan a plain scalar.
-func yaml_parser_scan_plain_scalar(parser *yaml_parser_t, token *yaml_token_t) bool {
-
- var s, leading_break, trailing_breaks, whitespaces []byte
- var leading_blanks bool
- var indent = parser.indent + 1
-
- start_mark := parser.mark
- end_mark := parser.mark
-
- // Consume the content of the plain scalar.
- for {
- // Check for a document indicator.
- if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) {
- return false
- }
- if parser.mark.column == 0 &&
- ((parser.buffer[parser.buffer_pos+0] == '-' &&
- parser.buffer[parser.buffer_pos+1] == '-' &&
- parser.buffer[parser.buffer_pos+2] == '-') ||
- (parser.buffer[parser.buffer_pos+0] == '.' &&
- parser.buffer[parser.buffer_pos+1] == '.' &&
- parser.buffer[parser.buffer_pos+2] == '.')) &&
- is_blankz(parser.buffer, parser.buffer_pos+3) {
- break
- }
-
- // Check for a comment.
- if parser.buffer[parser.buffer_pos] == '#' {
- break
- }
-
- // Consume non-blank characters.
- for !is_blankz(parser.buffer, parser.buffer_pos) {
-
- // Check for indicators that may end a plain scalar.
- if (parser.buffer[parser.buffer_pos] == ':' && is_blankz(parser.buffer, parser.buffer_pos+1)) ||
- (parser.flow_level > 0 &&
- (parser.buffer[parser.buffer_pos] == ',' ||
- parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == '[' ||
- parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' ||
- parser.buffer[parser.buffer_pos] == '}')) {
- break
- }
-
- // Check if we need to join whitespaces and breaks.
- if leading_blanks || len(whitespaces) > 0 {
- if leading_blanks {
- // Do we need to fold line breaks?
- if leading_break[0] == '\n' {
- if len(trailing_breaks) == 0 {
- s = append(s, ' ')
- } else {
- s = append(s, trailing_breaks...)
- }
- } else {
- s = append(s, leading_break...)
- s = append(s, trailing_breaks...)
- }
- trailing_breaks = trailing_breaks[:0]
- leading_break = leading_break[:0]
- leading_blanks = false
- } else {
- s = append(s, whitespaces...)
- whitespaces = whitespaces[:0]
- }
- }
-
- // Copy the character.
- s = read(parser, s)
-
- end_mark = parser.mark
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- }
-
- // Is it the end?
- if !(is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos)) {
- break
- }
-
- // Consume blank characters.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) {
- if is_blank(parser.buffer, parser.buffer_pos) {
-
- // Check for tab characters that abuse indentation.
- if leading_blanks && parser.mark.column < indent && is_tab(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
- start_mark, "found a tab character that violates indentation")
- return false
- }
-
- // Consume a space or a tab character.
- if !leading_blanks {
- whitespaces = read(parser, whitespaces)
- } else {
- skip(parser)
- }
- } else {
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
-
- // Check if it is a first line break.
- if !leading_blanks {
- whitespaces = whitespaces[:0]
- leading_break = read_line(parser, leading_break)
- leading_blanks = true
- } else {
- trailing_breaks = read_line(parser, trailing_breaks)
- }
- }
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Check indentation level.
- if parser.flow_level == 0 && parser.mark.column < indent {
- break
- }
- }
-
- // Create a token.
- *token = yaml_token_t{
- typ: yaml_SCALAR_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- value: s,
- style: yaml_PLAIN_SCALAR_STYLE,
- }
-
- // Note that we change the 'simple_key_allowed' flag.
- if leading_blanks {
- parser.simple_key_allowed = true
- }
- return true
-}
-
-func yaml_parser_scan_line_comment(parser *yaml_parser_t, token_mark yaml_mark_t) bool {
- if parser.newlines > 0 {
- return true
- }
-
- var start_mark yaml_mark_t
- var text []byte
-
- for peek := 0; peek < 512; peek++ {
- if parser.unread < peek+1 && !yaml_parser_update_buffer(parser, peek+1) {
- break
- }
- if is_blank(parser.buffer, parser.buffer_pos+peek) {
- continue
- }
- if parser.buffer[parser.buffer_pos+peek] == '#' {
- seen := parser.mark.index+peek
- for {
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if is_breakz(parser.buffer, parser.buffer_pos) {
- if parser.mark.index >= seen {
- break
- }
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- skip_line(parser)
- } else if parser.mark.index >= seen {
- if len(text) == 0 {
- start_mark = parser.mark
- }
- text = read(parser, text)
- } else {
- skip(parser)
- }
- }
- }
- break
- }
- if len(text) > 0 {
- parser.comments = append(parser.comments, yaml_comment_t{
- token_mark: token_mark,
- start_mark: start_mark,
- line: text,
- })
- }
- return true
-}
-
-func yaml_parser_scan_comments(parser *yaml_parser_t, scan_mark yaml_mark_t) bool {
- token := parser.tokens[len(parser.tokens)-1]
-
- if token.typ == yaml_FLOW_ENTRY_TOKEN && len(parser.tokens) > 1 {
- token = parser.tokens[len(parser.tokens)-2]
- }
-
- var token_mark = token.start_mark
- var start_mark yaml_mark_t
- var next_indent = parser.indent
- if next_indent < 0 {
- next_indent = 0
- }
-
- var recent_empty = false
- var first_empty = parser.newlines <= 1
-
- var line = parser.mark.line
- var column = parser.mark.column
-
- var text []byte
-
- // The foot line is the place where a comment must start to
- // still be considered as a foot of the prior content.
- // If there's some content in the currently parsed line, then
- // the foot is the line below it.
- var foot_line = -1
- if scan_mark.line > 0 {
- foot_line = parser.mark.line-parser.newlines+1
- if parser.newlines == 0 && parser.mark.column > 1 {
- foot_line++
- }
- }
-
- var peek = 0
- for ; peek < 512; peek++ {
- if parser.unread < peek+1 && !yaml_parser_update_buffer(parser, peek+1) {
- break
- }
- column++
- if is_blank(parser.buffer, parser.buffer_pos+peek) {
- continue
- }
- c := parser.buffer[parser.buffer_pos+peek]
- var close_flow = parser.flow_level > 0 && (c == ']' || c == '}')
- if close_flow || is_breakz(parser.buffer, parser.buffer_pos+peek) {
- // Got line break or terminator.
- if close_flow || !recent_empty {
- if close_flow || first_empty && (start_mark.line == foot_line && token.typ != yaml_VALUE_TOKEN || start_mark.column-1 < next_indent) {
- // This is the first empty line and there were no empty lines before,
- // so this initial part of the comment is a foot of the prior token
- // instead of being a head for the following one. Split it up.
- // Alternatively, this might also be the last comment inside a flow
- // scope, so it must be a footer.
- if len(text) > 0 {
- if start_mark.column-1 < next_indent {
- // If dedented it's unrelated to the prior token.
- token_mark = start_mark
- }
- parser.comments = append(parser.comments, yaml_comment_t{
- scan_mark: scan_mark,
- token_mark: token_mark,
- start_mark: start_mark,
- end_mark: yaml_mark_t{parser.mark.index + peek, line, column},
- foot: text,
- })
- scan_mark = yaml_mark_t{parser.mark.index + peek, line, column}
- token_mark = scan_mark
- text = nil
- }
- } else {
- if len(text) > 0 && parser.buffer[parser.buffer_pos+peek] != 0 {
- text = append(text, '\n')
- }
- }
- }
- if !is_break(parser.buffer, parser.buffer_pos+peek) {
- break
- }
- first_empty = false
- recent_empty = true
- column = 0
- line++
- continue
- }
-
- if len(text) > 0 && (close_flow || column-1 < next_indent && column != start_mark.column) {
- // The comment at the different indentation is a foot of the
- // preceding data rather than a head of the upcoming one.
- parser.comments = append(parser.comments, yaml_comment_t{
- scan_mark: scan_mark,
- token_mark: token_mark,
- start_mark: start_mark,
- end_mark: yaml_mark_t{parser.mark.index + peek, line, column},
- foot: text,
- })
- scan_mark = yaml_mark_t{parser.mark.index + peek, line, column}
- token_mark = scan_mark
- text = nil
- }
-
- if parser.buffer[parser.buffer_pos+peek] != '#' {
- break
- }
-
- if len(text) == 0 {
- start_mark = yaml_mark_t{parser.mark.index + peek, line, column}
- } else {
- text = append(text, '\n')
- }
-
- recent_empty = false
-
- // Consume until after the consumed comment line.
- seen := parser.mark.index+peek
- for {
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if is_breakz(parser.buffer, parser.buffer_pos) {
- if parser.mark.index >= seen {
- break
- }
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- skip_line(parser)
- } else if parser.mark.index >= seen {
- text = read(parser, text)
- } else {
- skip(parser)
- }
- }
-
- peek = 0
- column = 0
- line = parser.mark.line
- next_indent = parser.indent
- if next_indent < 0 {
- next_indent = 0
- }
- }
-
- if len(text) > 0 {
- parser.comments = append(parser.comments, yaml_comment_t{
- scan_mark: scan_mark,
- token_mark: start_mark,
- start_mark: start_mark,
- end_mark: yaml_mark_t{parser.mark.index + peek - 1, line, column},
- head: text,
- })
- }
- return true
-}
diff --git a/vendor/gopkg.in/yaml.v3/sorter.go b/vendor/gopkg.in/yaml.v3/sorter.go
deleted file mode 100644
index 9210ece7..00000000
--- a/vendor/gopkg.in/yaml.v3/sorter.go
+++ /dev/null
@@ -1,134 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package yaml
-
-import (
- "reflect"
- "unicode"
-)
-
-type keyList []reflect.Value
-
-func (l keyList) Len() int { return len(l) }
-func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] }
-func (l keyList) Less(i, j int) bool {
- a := l[i]
- b := l[j]
- ak := a.Kind()
- bk := b.Kind()
- for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() {
- a = a.Elem()
- ak = a.Kind()
- }
- for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() {
- b = b.Elem()
- bk = b.Kind()
- }
- af, aok := keyFloat(a)
- bf, bok := keyFloat(b)
- if aok && bok {
- if af != bf {
- return af < bf
- }
- if ak != bk {
- return ak < bk
- }
- return numLess(a, b)
- }
- if ak != reflect.String || bk != reflect.String {
- return ak < bk
- }
- ar, br := []rune(a.String()), []rune(b.String())
- digits := false
- for i := 0; i < len(ar) && i < len(br); i++ {
- if ar[i] == br[i] {
- digits = unicode.IsDigit(ar[i])
- continue
- }
- al := unicode.IsLetter(ar[i])
- bl := unicode.IsLetter(br[i])
- if al && bl {
- return ar[i] < br[i]
- }
- if al || bl {
- if digits {
- return al
- } else {
- return bl
- }
- }
- var ai, bi int
- var an, bn int64
- if ar[i] == '0' || br[i] == '0' {
- for j := i - 1; j >= 0 && unicode.IsDigit(ar[j]); j-- {
- if ar[j] != '0' {
- an = 1
- bn = 1
- break
- }
- }
- }
- for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ {
- an = an*10 + int64(ar[ai]-'0')
- }
- for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ {
- bn = bn*10 + int64(br[bi]-'0')
- }
- if an != bn {
- return an < bn
- }
- if ai != bi {
- return ai < bi
- }
- return ar[i] < br[i]
- }
- return len(ar) < len(br)
-}
-
-// keyFloat returns a float value for v if it is a number/bool
-// and whether it is a number/bool or not.
-func keyFloat(v reflect.Value) (f float64, ok bool) {
- switch v.Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return float64(v.Int()), true
- case reflect.Float32, reflect.Float64:
- return v.Float(), true
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- return float64(v.Uint()), true
- case reflect.Bool:
- if v.Bool() {
- return 1, true
- }
- return 0, true
- }
- return 0, false
-}
-
-// numLess returns whether a < b.
-// a and b must necessarily have the same kind.
-func numLess(a, b reflect.Value) bool {
- switch a.Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return a.Int() < b.Int()
- case reflect.Float32, reflect.Float64:
- return a.Float() < b.Float()
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- return a.Uint() < b.Uint()
- case reflect.Bool:
- return !a.Bool() && b.Bool()
- }
- panic("not a number")
-}
diff --git a/vendor/gopkg.in/yaml.v3/writerc.go b/vendor/gopkg.in/yaml.v3/writerc.go
deleted file mode 100644
index b8a116bf..00000000
--- a/vendor/gopkg.in/yaml.v3/writerc.go
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-// Copyright (c) 2006-2010 Kirill Simonov
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-package yaml
-
-// Set the writer error and return false.
-func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool {
- emitter.error = yaml_WRITER_ERROR
- emitter.problem = problem
- return false
-}
-
-// Flush the output buffer.
-func yaml_emitter_flush(emitter *yaml_emitter_t) bool {
- if emitter.write_handler == nil {
- panic("write handler not set")
- }
-
- // Check if the buffer is empty.
- if emitter.buffer_pos == 0 {
- return true
- }
-
- if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil {
- return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error())
- }
- emitter.buffer_pos = 0
- return true
-}
diff --git a/vendor/gopkg.in/yaml.v3/yaml.go b/vendor/gopkg.in/yaml.v3/yaml.go
deleted file mode 100644
index 8cec6da4..00000000
--- a/vendor/gopkg.in/yaml.v3/yaml.go
+++ /dev/null
@@ -1,698 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package yaml implements YAML support for the Go language.
-//
-// Source code and other details for the project are available at GitHub:
-//
-// https://github.com/go-yaml/yaml
-//
-package yaml
-
-import (
- "errors"
- "fmt"
- "io"
- "reflect"
- "strings"
- "sync"
- "unicode/utf8"
-)
-
-// The Unmarshaler interface may be implemented by types to customize their
-// behavior when being unmarshaled from a YAML document.
-type Unmarshaler interface {
- UnmarshalYAML(value *Node) error
-}
-
-type obsoleteUnmarshaler interface {
- UnmarshalYAML(unmarshal func(interface{}) error) error
-}
-
-// The Marshaler interface may be implemented by types to customize their
-// behavior when being marshaled into a YAML document. The returned value
-// is marshaled in place of the original value implementing Marshaler.
-//
-// If an error is returned by MarshalYAML, the marshaling procedure stops
-// and returns with the provided error.
-type Marshaler interface {
- MarshalYAML() (interface{}, error)
-}
-
-// Unmarshal decodes the first document found within the in byte slice
-// and assigns decoded values into the out value.
-//
-// Maps and pointers (to a struct, string, int, etc) are accepted as out
-// values. If an internal pointer within a struct is not initialized,
-// the yaml package will initialize it if necessary for unmarshalling
-// the provided data. The out parameter must not be nil.
-//
-// The type of the decoded values should be compatible with the respective
-// values in out. If one or more values cannot be decoded due to a type
-// mismatches, decoding continues partially until the end of the YAML
-// content, and a *yaml.TypeError is returned with details for all
-// missed values.
-//
-// Struct fields are only unmarshalled if they are exported (have an
-// upper case first letter), and are unmarshalled using the field name
-// lowercased as the default key. Custom keys may be defined via the
-// "yaml" name in the field tag: the content preceding the first comma
-// is used as the key, and the following comma-separated options are
-// used to tweak the marshalling process (see Marshal).
-// Conflicting names result in a runtime error.
-//
-// For example:
-//
-// type T struct {
-// F int `yaml:"a,omitempty"`
-// B int
-// }
-// var t T
-// yaml.Unmarshal([]byte("a: 1\nb: 2"), &t)
-//
-// See the documentation of Marshal for the format of tags and a list of
-// supported tag options.
-//
-func Unmarshal(in []byte, out interface{}) (err error) {
- return unmarshal(in, out, false)
-}
-
-// A Decoder reads and decodes YAML values from an input stream.
-type Decoder struct {
- parser *parser
- knownFields bool
-}
-
-// NewDecoder returns a new decoder that reads from r.
-//
-// The decoder introduces its own buffering and may read
-// data from r beyond the YAML values requested.
-func NewDecoder(r io.Reader) *Decoder {
- return &Decoder{
- parser: newParserFromReader(r),
- }
-}
-
-// KnownFields ensures that the keys in decoded mappings to
-// exist as fields in the struct being decoded into.
-func (dec *Decoder) KnownFields(enable bool) {
- dec.knownFields = enable
-}
-
-// Decode reads the next YAML-encoded value from its input
-// and stores it in the value pointed to by v.
-//
-// See the documentation for Unmarshal for details about the
-// conversion of YAML into a Go value.
-func (dec *Decoder) Decode(v interface{}) (err error) {
- d := newDecoder()
- d.knownFields = dec.knownFields
- defer handleErr(&err)
- node := dec.parser.parse()
- if node == nil {
- return io.EOF
- }
- out := reflect.ValueOf(v)
- if out.Kind() == reflect.Ptr && !out.IsNil() {
- out = out.Elem()
- }
- d.unmarshal(node, out)
- if len(d.terrors) > 0 {
- return &TypeError{d.terrors}
- }
- return nil
-}
-
-// Decode decodes the node and stores its data into the value pointed to by v.
-//
-// See the documentation for Unmarshal for details about the
-// conversion of YAML into a Go value.
-func (n *Node) Decode(v interface{}) (err error) {
- d := newDecoder()
- defer handleErr(&err)
- out := reflect.ValueOf(v)
- if out.Kind() == reflect.Ptr && !out.IsNil() {
- out = out.Elem()
- }
- d.unmarshal(n, out)
- if len(d.terrors) > 0 {
- return &TypeError{d.terrors}
- }
- return nil
-}
-
-func unmarshal(in []byte, out interface{}, strict bool) (err error) {
- defer handleErr(&err)
- d := newDecoder()
- p := newParser(in)
- defer p.destroy()
- node := p.parse()
- if node != nil {
- v := reflect.ValueOf(out)
- if v.Kind() == reflect.Ptr && !v.IsNil() {
- v = v.Elem()
- }
- d.unmarshal(node, v)
- }
- if len(d.terrors) > 0 {
- return &TypeError{d.terrors}
- }
- return nil
-}
-
-// Marshal serializes the value provided into a YAML document. The structure
-// of the generated document will reflect the structure of the value itself.
-// Maps and pointers (to struct, string, int, etc) are accepted as the in value.
-//
-// Struct fields are only marshalled if they are exported (have an upper case
-// first letter), and are marshalled using the field name lowercased as the
-// default key. Custom keys may be defined via the "yaml" name in the field
-// tag: the content preceding the first comma is used as the key, and the
-// following comma-separated options are used to tweak the marshalling process.
-// Conflicting names result in a runtime error.
-//
-// The field tag format accepted is:
-//
-// `(...) yaml:"[][,[,]]" (...)`
-//
-// The following flags are currently supported:
-//
-// omitempty Only include the field if it's not set to the zero
-// value for the type or to empty slices or maps.
-// Zero valued structs will be omitted if all their public
-// fields are zero, unless they implement an IsZero
-// method (see the IsZeroer interface type), in which
-// case the field will be excluded if IsZero returns true.
-//
-// flow Marshal using a flow style (useful for structs,
-// sequences and maps).
-//
-// inline Inline the field, which must be a struct or a map,
-// causing all of its fields or keys to be processed as if
-// they were part of the outer struct. For maps, keys must
-// not conflict with the yaml keys of other struct fields.
-//
-// In addition, if the key is "-", the field is ignored.
-//
-// For example:
-//
-// type T struct {
-// F int `yaml:"a,omitempty"`
-// B int
-// }
-// yaml.Marshal(&T{B: 2}) // Returns "b: 2\n"
-// yaml.Marshal(&T{F: 1}} // Returns "a: 1\nb: 0\n"
-//
-func Marshal(in interface{}) (out []byte, err error) {
- defer handleErr(&err)
- e := newEncoder()
- defer e.destroy()
- e.marshalDoc("", reflect.ValueOf(in))
- e.finish()
- out = e.out
- return
-}
-
-// An Encoder writes YAML values to an output stream.
-type Encoder struct {
- encoder *encoder
-}
-
-// NewEncoder returns a new encoder that writes to w.
-// The Encoder should be closed after use to flush all data
-// to w.
-func NewEncoder(w io.Writer) *Encoder {
- return &Encoder{
- encoder: newEncoderWithWriter(w),
- }
-}
-
-// Encode writes the YAML encoding of v to the stream.
-// If multiple items are encoded to the stream, the
-// second and subsequent document will be preceded
-// with a "---" document separator, but the first will not.
-//
-// See the documentation for Marshal for details about the conversion of Go
-// values to YAML.
-func (e *Encoder) Encode(v interface{}) (err error) {
- defer handleErr(&err)
- e.encoder.marshalDoc("", reflect.ValueOf(v))
- return nil
-}
-
-// Encode encodes value v and stores its representation in n.
-//
-// See the documentation for Marshal for details about the
-// conversion of Go values into YAML.
-func (n *Node) Encode(v interface{}) (err error) {
- defer handleErr(&err)
- e := newEncoder()
- defer e.destroy()
- e.marshalDoc("", reflect.ValueOf(v))
- e.finish()
- p := newParser(e.out)
- p.textless = true
- defer p.destroy()
- doc := p.parse()
- *n = *doc.Content[0]
- return nil
-}
-
-// SetIndent changes the used indentation used when encoding.
-func (e *Encoder) SetIndent(spaces int) {
- if spaces < 0 {
- panic("yaml: cannot indent to a negative number of spaces")
- }
- e.encoder.indent = spaces
-}
-
-// Close closes the encoder by writing any remaining data.
-// It does not write a stream terminating string "...".
-func (e *Encoder) Close() (err error) {
- defer handleErr(&err)
- e.encoder.finish()
- return nil
-}
-
-func handleErr(err *error) {
- if v := recover(); v != nil {
- if e, ok := v.(yamlError); ok {
- *err = e.err
- } else {
- panic(v)
- }
- }
-}
-
-type yamlError struct {
- err error
-}
-
-func fail(err error) {
- panic(yamlError{err})
-}
-
-func failf(format string, args ...interface{}) {
- panic(yamlError{fmt.Errorf("yaml: "+format, args...)})
-}
-
-// A TypeError is returned by Unmarshal when one or more fields in
-// the YAML document cannot be properly decoded into the requested
-// types. When this error is returned, the value is still
-// unmarshaled partially.
-type TypeError struct {
- Errors []string
-}
-
-func (e *TypeError) Error() string {
- return fmt.Sprintf("yaml: unmarshal errors:\n %s", strings.Join(e.Errors, "\n "))
-}
-
-type Kind uint32
-
-const (
- DocumentNode Kind = 1 << iota
- SequenceNode
- MappingNode
- ScalarNode
- AliasNode
-)
-
-type Style uint32
-
-const (
- TaggedStyle Style = 1 << iota
- DoubleQuotedStyle
- SingleQuotedStyle
- LiteralStyle
- FoldedStyle
- FlowStyle
-)
-
-// Node represents an element in the YAML document hierarchy. While documents
-// are typically encoded and decoded into higher level types, such as structs
-// and maps, Node is an intermediate representation that allows detailed
-// control over the content being decoded or encoded.
-//
-// It's worth noting that although Node offers access into details such as
-// line numbers, colums, and comments, the content when re-encoded will not
-// have its original textual representation preserved. An effort is made to
-// render the data plesantly, and to preserve comments near the data they
-// describe, though.
-//
-// Values that make use of the Node type interact with the yaml package in the
-// same way any other type would do, by encoding and decoding yaml data
-// directly or indirectly into them.
-//
-// For example:
-//
-// var person struct {
-// Name string
-// Address yaml.Node
-// }
-// err := yaml.Unmarshal(data, &person)
-//
-// Or by itself:
-//
-// var person Node
-// err := yaml.Unmarshal(data, &person)
-//
-type Node struct {
- // Kind defines whether the node is a document, a mapping, a sequence,
- // a scalar value, or an alias to another node. The specific data type of
- // scalar nodes may be obtained via the ShortTag and LongTag methods.
- Kind Kind
-
- // Style allows customizing the apperance of the node in the tree.
- Style Style
-
- // Tag holds the YAML tag defining the data type for the value.
- // When decoding, this field will always be set to the resolved tag,
- // even when it wasn't explicitly provided in the YAML content.
- // When encoding, if this field is unset the value type will be
- // implied from the node properties, and if it is set, it will only
- // be serialized into the representation if TaggedStyle is used or
- // the implicit tag diverges from the provided one.
- Tag string
-
- // Value holds the unescaped and unquoted represenation of the value.
- Value string
-
- // Anchor holds the anchor name for this node, which allows aliases to point to it.
- Anchor string
-
- // Alias holds the node that this alias points to. Only valid when Kind is AliasNode.
- Alias *Node
-
- // Content holds contained nodes for documents, mappings, and sequences.
- Content []*Node
-
- // HeadComment holds any comments in the lines preceding the node and
- // not separated by an empty line.
- HeadComment string
-
- // LineComment holds any comments at the end of the line where the node is in.
- LineComment string
-
- // FootComment holds any comments following the node and before empty lines.
- FootComment string
-
- // Line and Column hold the node position in the decoded YAML text.
- // These fields are not respected when encoding the node.
- Line int
- Column int
-}
-
-// IsZero returns whether the node has all of its fields unset.
-func (n *Node) IsZero() bool {
- return n.Kind == 0 && n.Style == 0 && n.Tag == "" && n.Value == "" && n.Anchor == "" && n.Alias == nil && n.Content == nil &&
- n.HeadComment == "" && n.LineComment == "" && n.FootComment == "" && n.Line == 0 && n.Column == 0
-}
-
-
-// LongTag returns the long form of the tag that indicates the data type for
-// the node. If the Tag field isn't explicitly defined, one will be computed
-// based on the node properties.
-func (n *Node) LongTag() string {
- return longTag(n.ShortTag())
-}
-
-// ShortTag returns the short form of the YAML tag that indicates data type for
-// the node. If the Tag field isn't explicitly defined, one will be computed
-// based on the node properties.
-func (n *Node) ShortTag() string {
- if n.indicatedString() {
- return strTag
- }
- if n.Tag == "" || n.Tag == "!" {
- switch n.Kind {
- case MappingNode:
- return mapTag
- case SequenceNode:
- return seqTag
- case AliasNode:
- if n.Alias != nil {
- return n.Alias.ShortTag()
- }
- case ScalarNode:
- tag, _ := resolve("", n.Value)
- return tag
- case 0:
- // Special case to make the zero value convenient.
- if n.IsZero() {
- return nullTag
- }
- }
- return ""
- }
- return shortTag(n.Tag)
-}
-
-func (n *Node) indicatedString() bool {
- return n.Kind == ScalarNode &&
- (shortTag(n.Tag) == strTag ||
- (n.Tag == "" || n.Tag == "!") && n.Style&(SingleQuotedStyle|DoubleQuotedStyle|LiteralStyle|FoldedStyle) != 0)
-}
-
-// SetString is a convenience function that sets the node to a string value
-// and defines its style in a pleasant way depending on its content.
-func (n *Node) SetString(s string) {
- n.Kind = ScalarNode
- if utf8.ValidString(s) {
- n.Value = s
- n.Tag = strTag
- } else {
- n.Value = encodeBase64(s)
- n.Tag = binaryTag
- }
- if strings.Contains(n.Value, "\n") {
- n.Style = LiteralStyle
- }
-}
-
-// --------------------------------------------------------------------------
-// Maintain a mapping of keys to structure field indexes
-
-// The code in this section was copied from mgo/bson.
-
-// structInfo holds details for the serialization of fields of
-// a given struct.
-type structInfo struct {
- FieldsMap map[string]fieldInfo
- FieldsList []fieldInfo
-
- // InlineMap is the number of the field in the struct that
- // contains an ,inline map, or -1 if there's none.
- InlineMap int
-
- // InlineUnmarshalers holds indexes to inlined fields that
- // contain unmarshaler values.
- InlineUnmarshalers [][]int
-}
-
-type fieldInfo struct {
- Key string
- Num int
- OmitEmpty bool
- Flow bool
- // Id holds the unique field identifier, so we can cheaply
- // check for field duplicates without maintaining an extra map.
- Id int
-
- // Inline holds the field index if the field is part of an inlined struct.
- Inline []int
-}
-
-var structMap = make(map[reflect.Type]*structInfo)
-var fieldMapMutex sync.RWMutex
-var unmarshalerType reflect.Type
-
-func init() {
- var v Unmarshaler
- unmarshalerType = reflect.ValueOf(&v).Elem().Type()
-}
-
-func getStructInfo(st reflect.Type) (*structInfo, error) {
- fieldMapMutex.RLock()
- sinfo, found := structMap[st]
- fieldMapMutex.RUnlock()
- if found {
- return sinfo, nil
- }
-
- n := st.NumField()
- fieldsMap := make(map[string]fieldInfo)
- fieldsList := make([]fieldInfo, 0, n)
- inlineMap := -1
- inlineUnmarshalers := [][]int(nil)
- for i := 0; i != n; i++ {
- field := st.Field(i)
- if field.PkgPath != "" && !field.Anonymous {
- continue // Private field
- }
-
- info := fieldInfo{Num: i}
-
- tag := field.Tag.Get("yaml")
- if tag == "" && strings.Index(string(field.Tag), ":") < 0 {
- tag = string(field.Tag)
- }
- if tag == "-" {
- continue
- }
-
- inline := false
- fields := strings.Split(tag, ",")
- if len(fields) > 1 {
- for _, flag := range fields[1:] {
- switch flag {
- case "omitempty":
- info.OmitEmpty = true
- case "flow":
- info.Flow = true
- case "inline":
- inline = true
- default:
- return nil, errors.New(fmt.Sprintf("unsupported flag %q in tag %q of type %s", flag, tag, st))
- }
- }
- tag = fields[0]
- }
-
- if inline {
- switch field.Type.Kind() {
- case reflect.Map:
- if inlineMap >= 0 {
- return nil, errors.New("multiple ,inline maps in struct " + st.String())
- }
- if field.Type.Key() != reflect.TypeOf("") {
- return nil, errors.New("option ,inline needs a map with string keys in struct " + st.String())
- }
- inlineMap = info.Num
- case reflect.Struct, reflect.Ptr:
- ftype := field.Type
- for ftype.Kind() == reflect.Ptr {
- ftype = ftype.Elem()
- }
- if ftype.Kind() != reflect.Struct {
- return nil, errors.New("option ,inline may only be used on a struct or map field")
- }
- if reflect.PtrTo(ftype).Implements(unmarshalerType) {
- inlineUnmarshalers = append(inlineUnmarshalers, []int{i})
- } else {
- sinfo, err := getStructInfo(ftype)
- if err != nil {
- return nil, err
- }
- for _, index := range sinfo.InlineUnmarshalers {
- inlineUnmarshalers = append(inlineUnmarshalers, append([]int{i}, index...))
- }
- for _, finfo := range sinfo.FieldsList {
- if _, found := fieldsMap[finfo.Key]; found {
- msg := "duplicated key '" + finfo.Key + "' in struct " + st.String()
- return nil, errors.New(msg)
- }
- if finfo.Inline == nil {
- finfo.Inline = []int{i, finfo.Num}
- } else {
- finfo.Inline = append([]int{i}, finfo.Inline...)
- }
- finfo.Id = len(fieldsList)
- fieldsMap[finfo.Key] = finfo
- fieldsList = append(fieldsList, finfo)
- }
- }
- default:
- return nil, errors.New("option ,inline may only be used on a struct or map field")
- }
- continue
- }
-
- if tag != "" {
- info.Key = tag
- } else {
- info.Key = strings.ToLower(field.Name)
- }
-
- if _, found = fieldsMap[info.Key]; found {
- msg := "duplicated key '" + info.Key + "' in struct " + st.String()
- return nil, errors.New(msg)
- }
-
- info.Id = len(fieldsList)
- fieldsList = append(fieldsList, info)
- fieldsMap[info.Key] = info
- }
-
- sinfo = &structInfo{
- FieldsMap: fieldsMap,
- FieldsList: fieldsList,
- InlineMap: inlineMap,
- InlineUnmarshalers: inlineUnmarshalers,
- }
-
- fieldMapMutex.Lock()
- structMap[st] = sinfo
- fieldMapMutex.Unlock()
- return sinfo, nil
-}
-
-// IsZeroer is used to check whether an object is zero to
-// determine whether it should be omitted when marshaling
-// with the omitempty flag. One notable implementation
-// is time.Time.
-type IsZeroer interface {
- IsZero() bool
-}
-
-func isZero(v reflect.Value) bool {
- kind := v.Kind()
- if z, ok := v.Interface().(IsZeroer); ok {
- if (kind == reflect.Ptr || kind == reflect.Interface) && v.IsNil() {
- return true
- }
- return z.IsZero()
- }
- switch kind {
- case reflect.String:
- return len(v.String()) == 0
- case reflect.Interface, reflect.Ptr:
- return v.IsNil()
- case reflect.Slice:
- return v.Len() == 0
- case reflect.Map:
- return v.Len() == 0
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return v.Int() == 0
- case reflect.Float32, reflect.Float64:
- return v.Float() == 0
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- return v.Uint() == 0
- case reflect.Bool:
- return !v.Bool()
- case reflect.Struct:
- vt := v.Type()
- for i := v.NumField() - 1; i >= 0; i-- {
- if vt.Field(i).PkgPath != "" {
- continue // Private field
- }
- if !isZero(v.Field(i)) {
- return false
- }
- }
- return true
- }
- return false
-}
diff --git a/vendor/gopkg.in/yaml.v3/yamlh.go b/vendor/gopkg.in/yaml.v3/yamlh.go
deleted file mode 100644
index 7c6d0077..00000000
--- a/vendor/gopkg.in/yaml.v3/yamlh.go
+++ /dev/null
@@ -1,807 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-// Copyright (c) 2006-2010 Kirill Simonov
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-package yaml
-
-import (
- "fmt"
- "io"
-)
-
-// The version directive data.
-type yaml_version_directive_t struct {
- major int8 // The major version number.
- minor int8 // The minor version number.
-}
-
-// The tag directive data.
-type yaml_tag_directive_t struct {
- handle []byte // The tag handle.
- prefix []byte // The tag prefix.
-}
-
-type yaml_encoding_t int
-
-// The stream encoding.
-const (
- // Let the parser choose the encoding.
- yaml_ANY_ENCODING yaml_encoding_t = iota
-
- yaml_UTF8_ENCODING // The default UTF-8 encoding.
- yaml_UTF16LE_ENCODING // The UTF-16-LE encoding with BOM.
- yaml_UTF16BE_ENCODING // The UTF-16-BE encoding with BOM.
-)
-
-type yaml_break_t int
-
-// Line break types.
-const (
- // Let the parser choose the break type.
- yaml_ANY_BREAK yaml_break_t = iota
-
- yaml_CR_BREAK // Use CR for line breaks (Mac style).
- yaml_LN_BREAK // Use LN for line breaks (Unix style).
- yaml_CRLN_BREAK // Use CR LN for line breaks (DOS style).
-)
-
-type yaml_error_type_t int
-
-// Many bad things could happen with the parser and emitter.
-const (
- // No error is produced.
- yaml_NO_ERROR yaml_error_type_t = iota
-
- yaml_MEMORY_ERROR // Cannot allocate or reallocate a block of memory.
- yaml_READER_ERROR // Cannot read or decode the input stream.
- yaml_SCANNER_ERROR // Cannot scan the input stream.
- yaml_PARSER_ERROR // Cannot parse the input stream.
- yaml_COMPOSER_ERROR // Cannot compose a YAML document.
- yaml_WRITER_ERROR // Cannot write to the output stream.
- yaml_EMITTER_ERROR // Cannot emit a YAML stream.
-)
-
-// The pointer position.
-type yaml_mark_t struct {
- index int // The position index.
- line int // The position line.
- column int // The position column.
-}
-
-// Node Styles
-
-type yaml_style_t int8
-
-type yaml_scalar_style_t yaml_style_t
-
-// Scalar styles.
-const (
- // Let the emitter choose the style.
- yaml_ANY_SCALAR_STYLE yaml_scalar_style_t = 0
-
- yaml_PLAIN_SCALAR_STYLE yaml_scalar_style_t = 1 << iota // The plain scalar style.
- yaml_SINGLE_QUOTED_SCALAR_STYLE // The single-quoted scalar style.
- yaml_DOUBLE_QUOTED_SCALAR_STYLE // The double-quoted scalar style.
- yaml_LITERAL_SCALAR_STYLE // The literal scalar style.
- yaml_FOLDED_SCALAR_STYLE // The folded scalar style.
-)
-
-type yaml_sequence_style_t yaml_style_t
-
-// Sequence styles.
-const (
- // Let the emitter choose the style.
- yaml_ANY_SEQUENCE_STYLE yaml_sequence_style_t = iota
-
- yaml_BLOCK_SEQUENCE_STYLE // The block sequence style.
- yaml_FLOW_SEQUENCE_STYLE // The flow sequence style.
-)
-
-type yaml_mapping_style_t yaml_style_t
-
-// Mapping styles.
-const (
- // Let the emitter choose the style.
- yaml_ANY_MAPPING_STYLE yaml_mapping_style_t = iota
-
- yaml_BLOCK_MAPPING_STYLE // The block mapping style.
- yaml_FLOW_MAPPING_STYLE // The flow mapping style.
-)
-
-// Tokens
-
-type yaml_token_type_t int
-
-// Token types.
-const (
- // An empty token.
- yaml_NO_TOKEN yaml_token_type_t = iota
-
- yaml_STREAM_START_TOKEN // A STREAM-START token.
- yaml_STREAM_END_TOKEN // A STREAM-END token.
-
- yaml_VERSION_DIRECTIVE_TOKEN // A VERSION-DIRECTIVE token.
- yaml_TAG_DIRECTIVE_TOKEN // A TAG-DIRECTIVE token.
- yaml_DOCUMENT_START_TOKEN // A DOCUMENT-START token.
- yaml_DOCUMENT_END_TOKEN // A DOCUMENT-END token.
-
- yaml_BLOCK_SEQUENCE_START_TOKEN // A BLOCK-SEQUENCE-START token.
- yaml_BLOCK_MAPPING_START_TOKEN // A BLOCK-SEQUENCE-END token.
- yaml_BLOCK_END_TOKEN // A BLOCK-END token.
-
- yaml_FLOW_SEQUENCE_START_TOKEN // A FLOW-SEQUENCE-START token.
- yaml_FLOW_SEQUENCE_END_TOKEN // A FLOW-SEQUENCE-END token.
- yaml_FLOW_MAPPING_START_TOKEN // A FLOW-MAPPING-START token.
- yaml_FLOW_MAPPING_END_TOKEN // A FLOW-MAPPING-END token.
-
- yaml_BLOCK_ENTRY_TOKEN // A BLOCK-ENTRY token.
- yaml_FLOW_ENTRY_TOKEN // A FLOW-ENTRY token.
- yaml_KEY_TOKEN // A KEY token.
- yaml_VALUE_TOKEN // A VALUE token.
-
- yaml_ALIAS_TOKEN // An ALIAS token.
- yaml_ANCHOR_TOKEN // An ANCHOR token.
- yaml_TAG_TOKEN // A TAG token.
- yaml_SCALAR_TOKEN // A SCALAR token.
-)
-
-func (tt yaml_token_type_t) String() string {
- switch tt {
- case yaml_NO_TOKEN:
- return "yaml_NO_TOKEN"
- case yaml_STREAM_START_TOKEN:
- return "yaml_STREAM_START_TOKEN"
- case yaml_STREAM_END_TOKEN:
- return "yaml_STREAM_END_TOKEN"
- case yaml_VERSION_DIRECTIVE_TOKEN:
- return "yaml_VERSION_DIRECTIVE_TOKEN"
- case yaml_TAG_DIRECTIVE_TOKEN:
- return "yaml_TAG_DIRECTIVE_TOKEN"
- case yaml_DOCUMENT_START_TOKEN:
- return "yaml_DOCUMENT_START_TOKEN"
- case yaml_DOCUMENT_END_TOKEN:
- return "yaml_DOCUMENT_END_TOKEN"
- case yaml_BLOCK_SEQUENCE_START_TOKEN:
- return "yaml_BLOCK_SEQUENCE_START_TOKEN"
- case yaml_BLOCK_MAPPING_START_TOKEN:
- return "yaml_BLOCK_MAPPING_START_TOKEN"
- case yaml_BLOCK_END_TOKEN:
- return "yaml_BLOCK_END_TOKEN"
- case yaml_FLOW_SEQUENCE_START_TOKEN:
- return "yaml_FLOW_SEQUENCE_START_TOKEN"
- case yaml_FLOW_SEQUENCE_END_TOKEN:
- return "yaml_FLOW_SEQUENCE_END_TOKEN"
- case yaml_FLOW_MAPPING_START_TOKEN:
- return "yaml_FLOW_MAPPING_START_TOKEN"
- case yaml_FLOW_MAPPING_END_TOKEN:
- return "yaml_FLOW_MAPPING_END_TOKEN"
- case yaml_BLOCK_ENTRY_TOKEN:
- return "yaml_BLOCK_ENTRY_TOKEN"
- case yaml_FLOW_ENTRY_TOKEN:
- return "yaml_FLOW_ENTRY_TOKEN"
- case yaml_KEY_TOKEN:
- return "yaml_KEY_TOKEN"
- case yaml_VALUE_TOKEN:
- return "yaml_VALUE_TOKEN"
- case yaml_ALIAS_TOKEN:
- return "yaml_ALIAS_TOKEN"
- case yaml_ANCHOR_TOKEN:
- return "yaml_ANCHOR_TOKEN"
- case yaml_TAG_TOKEN:
- return "yaml_TAG_TOKEN"
- case yaml_SCALAR_TOKEN:
- return "yaml_SCALAR_TOKEN"
- }
- return ""
-}
-
-// The token structure.
-type yaml_token_t struct {
- // The token type.
- typ yaml_token_type_t
-
- // The start/end of the token.
- start_mark, end_mark yaml_mark_t
-
- // The stream encoding (for yaml_STREAM_START_TOKEN).
- encoding yaml_encoding_t
-
- // The alias/anchor/scalar value or tag/tag directive handle
- // (for yaml_ALIAS_TOKEN, yaml_ANCHOR_TOKEN, yaml_SCALAR_TOKEN, yaml_TAG_TOKEN, yaml_TAG_DIRECTIVE_TOKEN).
- value []byte
-
- // The tag suffix (for yaml_TAG_TOKEN).
- suffix []byte
-
- // The tag directive prefix (for yaml_TAG_DIRECTIVE_TOKEN).
- prefix []byte
-
- // The scalar style (for yaml_SCALAR_TOKEN).
- style yaml_scalar_style_t
-
- // The version directive major/minor (for yaml_VERSION_DIRECTIVE_TOKEN).
- major, minor int8
-}
-
-// Events
-
-type yaml_event_type_t int8
-
-// Event types.
-const (
- // An empty event.
- yaml_NO_EVENT yaml_event_type_t = iota
-
- yaml_STREAM_START_EVENT // A STREAM-START event.
- yaml_STREAM_END_EVENT // A STREAM-END event.
- yaml_DOCUMENT_START_EVENT // A DOCUMENT-START event.
- yaml_DOCUMENT_END_EVENT // A DOCUMENT-END event.
- yaml_ALIAS_EVENT // An ALIAS event.
- yaml_SCALAR_EVENT // A SCALAR event.
- yaml_SEQUENCE_START_EVENT // A SEQUENCE-START event.
- yaml_SEQUENCE_END_EVENT // A SEQUENCE-END event.
- yaml_MAPPING_START_EVENT // A MAPPING-START event.
- yaml_MAPPING_END_EVENT // A MAPPING-END event.
- yaml_TAIL_COMMENT_EVENT
-)
-
-var eventStrings = []string{
- yaml_NO_EVENT: "none",
- yaml_STREAM_START_EVENT: "stream start",
- yaml_STREAM_END_EVENT: "stream end",
- yaml_DOCUMENT_START_EVENT: "document start",
- yaml_DOCUMENT_END_EVENT: "document end",
- yaml_ALIAS_EVENT: "alias",
- yaml_SCALAR_EVENT: "scalar",
- yaml_SEQUENCE_START_EVENT: "sequence start",
- yaml_SEQUENCE_END_EVENT: "sequence end",
- yaml_MAPPING_START_EVENT: "mapping start",
- yaml_MAPPING_END_EVENT: "mapping end",
- yaml_TAIL_COMMENT_EVENT: "tail comment",
-}
-
-func (e yaml_event_type_t) String() string {
- if e < 0 || int(e) >= len(eventStrings) {
- return fmt.Sprintf("unknown event %d", e)
- }
- return eventStrings[e]
-}
-
-// The event structure.
-type yaml_event_t struct {
-
- // The event type.
- typ yaml_event_type_t
-
- // The start and end of the event.
- start_mark, end_mark yaml_mark_t
-
- // The document encoding (for yaml_STREAM_START_EVENT).
- encoding yaml_encoding_t
-
- // The version directive (for yaml_DOCUMENT_START_EVENT).
- version_directive *yaml_version_directive_t
-
- // The list of tag directives (for yaml_DOCUMENT_START_EVENT).
- tag_directives []yaml_tag_directive_t
-
- // The comments
- head_comment []byte
- line_comment []byte
- foot_comment []byte
- tail_comment []byte
-
- // The anchor (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_ALIAS_EVENT).
- anchor []byte
-
- // The tag (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT).
- tag []byte
-
- // The scalar value (for yaml_SCALAR_EVENT).
- value []byte
-
- // Is the document start/end indicator implicit, or the tag optional?
- // (for yaml_DOCUMENT_START_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_SCALAR_EVENT).
- implicit bool
-
- // Is the tag optional for any non-plain style? (for yaml_SCALAR_EVENT).
- quoted_implicit bool
-
- // The style (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT).
- style yaml_style_t
-}
-
-func (e *yaml_event_t) scalar_style() yaml_scalar_style_t { return yaml_scalar_style_t(e.style) }
-func (e *yaml_event_t) sequence_style() yaml_sequence_style_t { return yaml_sequence_style_t(e.style) }
-func (e *yaml_event_t) mapping_style() yaml_mapping_style_t { return yaml_mapping_style_t(e.style) }
-
-// Nodes
-
-const (
- yaml_NULL_TAG = "tag:yaml.org,2002:null" // The tag !!null with the only possible value: null.
- yaml_BOOL_TAG = "tag:yaml.org,2002:bool" // The tag !!bool with the values: true and false.
- yaml_STR_TAG = "tag:yaml.org,2002:str" // The tag !!str for string values.
- yaml_INT_TAG = "tag:yaml.org,2002:int" // The tag !!int for integer values.
- yaml_FLOAT_TAG = "tag:yaml.org,2002:float" // The tag !!float for float values.
- yaml_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp" // The tag !!timestamp for date and time values.
-
- yaml_SEQ_TAG = "tag:yaml.org,2002:seq" // The tag !!seq is used to denote sequences.
- yaml_MAP_TAG = "tag:yaml.org,2002:map" // The tag !!map is used to denote mapping.
-
- // Not in original libyaml.
- yaml_BINARY_TAG = "tag:yaml.org,2002:binary"
- yaml_MERGE_TAG = "tag:yaml.org,2002:merge"
-
- yaml_DEFAULT_SCALAR_TAG = yaml_STR_TAG // The default scalar tag is !!str.
- yaml_DEFAULT_SEQUENCE_TAG = yaml_SEQ_TAG // The default sequence tag is !!seq.
- yaml_DEFAULT_MAPPING_TAG = yaml_MAP_TAG // The default mapping tag is !!map.
-)
-
-type yaml_node_type_t int
-
-// Node types.
-const (
- // An empty node.
- yaml_NO_NODE yaml_node_type_t = iota
-
- yaml_SCALAR_NODE // A scalar node.
- yaml_SEQUENCE_NODE // A sequence node.
- yaml_MAPPING_NODE // A mapping node.
-)
-
-// An element of a sequence node.
-type yaml_node_item_t int
-
-// An element of a mapping node.
-type yaml_node_pair_t struct {
- key int // The key of the element.
- value int // The value of the element.
-}
-
-// The node structure.
-type yaml_node_t struct {
- typ yaml_node_type_t // The node type.
- tag []byte // The node tag.
-
- // The node data.
-
- // The scalar parameters (for yaml_SCALAR_NODE).
- scalar struct {
- value []byte // The scalar value.
- length int // The length of the scalar value.
- style yaml_scalar_style_t // The scalar style.
- }
-
- // The sequence parameters (for YAML_SEQUENCE_NODE).
- sequence struct {
- items_data []yaml_node_item_t // The stack of sequence items.
- style yaml_sequence_style_t // The sequence style.
- }
-
- // The mapping parameters (for yaml_MAPPING_NODE).
- mapping struct {
- pairs_data []yaml_node_pair_t // The stack of mapping pairs (key, value).
- pairs_start *yaml_node_pair_t // The beginning of the stack.
- pairs_end *yaml_node_pair_t // The end of the stack.
- pairs_top *yaml_node_pair_t // The top of the stack.
- style yaml_mapping_style_t // The mapping style.
- }
-
- start_mark yaml_mark_t // The beginning of the node.
- end_mark yaml_mark_t // The end of the node.
-
-}
-
-// The document structure.
-type yaml_document_t struct {
-
- // The document nodes.
- nodes []yaml_node_t
-
- // The version directive.
- version_directive *yaml_version_directive_t
-
- // The list of tag directives.
- tag_directives_data []yaml_tag_directive_t
- tag_directives_start int // The beginning of the tag directives list.
- tag_directives_end int // The end of the tag directives list.
-
- start_implicit int // Is the document start indicator implicit?
- end_implicit int // Is the document end indicator implicit?
-
- // The start/end of the document.
- start_mark, end_mark yaml_mark_t
-}
-
-// The prototype of a read handler.
-//
-// The read handler is called when the parser needs to read more bytes from the
-// source. The handler should write not more than size bytes to the buffer.
-// The number of written bytes should be set to the size_read variable.
-//
-// [in,out] data A pointer to an application data specified by
-// yaml_parser_set_input().
-// [out] buffer The buffer to write the data from the source.
-// [in] size The size of the buffer.
-// [out] size_read The actual number of bytes read from the source.
-//
-// On success, the handler should return 1. If the handler failed,
-// the returned value should be 0. On EOF, the handler should set the
-// size_read to 0 and return 1.
-type yaml_read_handler_t func(parser *yaml_parser_t, buffer []byte) (n int, err error)
-
-// This structure holds information about a potential simple key.
-type yaml_simple_key_t struct {
- possible bool // Is a simple key possible?
- required bool // Is a simple key required?
- token_number int // The number of the token.
- mark yaml_mark_t // The position mark.
-}
-
-// The states of the parser.
-type yaml_parser_state_t int
-
-const (
- yaml_PARSE_STREAM_START_STATE yaml_parser_state_t = iota
-
- yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE // Expect the beginning of an implicit document.
- yaml_PARSE_DOCUMENT_START_STATE // Expect DOCUMENT-START.
- yaml_PARSE_DOCUMENT_CONTENT_STATE // Expect the content of a document.
- yaml_PARSE_DOCUMENT_END_STATE // Expect DOCUMENT-END.
- yaml_PARSE_BLOCK_NODE_STATE // Expect a block node.
- yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE // Expect a block node or indentless sequence.
- yaml_PARSE_FLOW_NODE_STATE // Expect a flow node.
- yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a block sequence.
- yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE // Expect an entry of a block sequence.
- yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE // Expect an entry of an indentless sequence.
- yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping.
- yaml_PARSE_BLOCK_MAPPING_KEY_STATE // Expect a block mapping key.
- yaml_PARSE_BLOCK_MAPPING_VALUE_STATE // Expect a block mapping value.
- yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a flow sequence.
- yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE // Expect an entry of a flow sequence.
- yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE // Expect a key of an ordered mapping.
- yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE // Expect a value of an ordered mapping.
- yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE // Expect the and of an ordered mapping entry.
- yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping.
- yaml_PARSE_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping.
- yaml_PARSE_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping.
- yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE // Expect an empty value of a flow mapping.
- yaml_PARSE_END_STATE // Expect nothing.
-)
-
-func (ps yaml_parser_state_t) String() string {
- switch ps {
- case yaml_PARSE_STREAM_START_STATE:
- return "yaml_PARSE_STREAM_START_STATE"
- case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE:
- return "yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE"
- case yaml_PARSE_DOCUMENT_START_STATE:
- return "yaml_PARSE_DOCUMENT_START_STATE"
- case yaml_PARSE_DOCUMENT_CONTENT_STATE:
- return "yaml_PARSE_DOCUMENT_CONTENT_STATE"
- case yaml_PARSE_DOCUMENT_END_STATE:
- return "yaml_PARSE_DOCUMENT_END_STATE"
- case yaml_PARSE_BLOCK_NODE_STATE:
- return "yaml_PARSE_BLOCK_NODE_STATE"
- case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE:
- return "yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE"
- case yaml_PARSE_FLOW_NODE_STATE:
- return "yaml_PARSE_FLOW_NODE_STATE"
- case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE:
- return "yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE"
- case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE:
- return "yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE"
- case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE:
- return "yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE"
- case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE:
- return "yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE"
- case yaml_PARSE_BLOCK_MAPPING_KEY_STATE:
- return "yaml_PARSE_BLOCK_MAPPING_KEY_STATE"
- case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE:
- return "yaml_PARSE_BLOCK_MAPPING_VALUE_STATE"
- case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE:
- return "yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE"
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE:
- return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE"
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE:
- return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE"
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE:
- return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE"
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE:
- return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE"
- case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE:
- return "yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE"
- case yaml_PARSE_FLOW_MAPPING_KEY_STATE:
- return "yaml_PARSE_FLOW_MAPPING_KEY_STATE"
- case yaml_PARSE_FLOW_MAPPING_VALUE_STATE:
- return "yaml_PARSE_FLOW_MAPPING_VALUE_STATE"
- case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE:
- return "yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE"
- case yaml_PARSE_END_STATE:
- return "yaml_PARSE_END_STATE"
- }
- return ""
-}
-
-// This structure holds aliases data.
-type yaml_alias_data_t struct {
- anchor []byte // The anchor.
- index int // The node id.
- mark yaml_mark_t // The anchor mark.
-}
-
-// The parser structure.
-//
-// All members are internal. Manage the structure using the
-// yaml_parser_ family of functions.
-type yaml_parser_t struct {
-
- // Error handling
-
- error yaml_error_type_t // Error type.
-
- problem string // Error description.
-
- // The byte about which the problem occurred.
- problem_offset int
- problem_value int
- problem_mark yaml_mark_t
-
- // The error context.
- context string
- context_mark yaml_mark_t
-
- // Reader stuff
-
- read_handler yaml_read_handler_t // Read handler.
-
- input_reader io.Reader // File input data.
- input []byte // String input data.
- input_pos int
-
- eof bool // EOF flag
-
- buffer []byte // The working buffer.
- buffer_pos int // The current position of the buffer.
-
- unread int // The number of unread characters in the buffer.
-
- newlines int // The number of line breaks since last non-break/non-blank character
-
- raw_buffer []byte // The raw buffer.
- raw_buffer_pos int // The current position of the buffer.
-
- encoding yaml_encoding_t // The input encoding.
-
- offset int // The offset of the current position (in bytes).
- mark yaml_mark_t // The mark of the current position.
-
- // Comments
-
- head_comment []byte // The current head comments
- line_comment []byte // The current line comments
- foot_comment []byte // The current foot comments
- tail_comment []byte // Foot comment that happens at the end of a block.
- stem_comment []byte // Comment in item preceding a nested structure (list inside list item, etc)
-
- comments []yaml_comment_t // The folded comments for all parsed tokens
- comments_head int
-
- // Scanner stuff
-
- stream_start_produced bool // Have we started to scan the input stream?
- stream_end_produced bool // Have we reached the end of the input stream?
-
- flow_level int // The number of unclosed '[' and '{' indicators.
-
- tokens []yaml_token_t // The tokens queue.
- tokens_head int // The head of the tokens queue.
- tokens_parsed int // The number of tokens fetched from the queue.
- token_available bool // Does the tokens queue contain a token ready for dequeueing.
-
- indent int // The current indentation level.
- indents []int // The indentation levels stack.
-
- simple_key_allowed bool // May a simple key occur at the current position?
- simple_keys []yaml_simple_key_t // The stack of simple keys.
- simple_keys_by_tok map[int]int // possible simple_key indexes indexed by token_number
-
- // Parser stuff
-
- state yaml_parser_state_t // The current parser state.
- states []yaml_parser_state_t // The parser states stack.
- marks []yaml_mark_t // The stack of marks.
- tag_directives []yaml_tag_directive_t // The list of TAG directives.
-
- // Dumper stuff
-
- aliases []yaml_alias_data_t // The alias data.
-
- document *yaml_document_t // The currently parsed document.
-}
-
-type yaml_comment_t struct {
-
- scan_mark yaml_mark_t // Position where scanning for comments started
- token_mark yaml_mark_t // Position after which tokens will be associated with this comment
- start_mark yaml_mark_t // Position of '#' comment mark
- end_mark yaml_mark_t // Position where comment terminated
-
- head []byte
- line []byte
- foot []byte
-}
-
-// Emitter Definitions
-
-// The prototype of a write handler.
-//
-// The write handler is called when the emitter needs to flush the accumulated
-// characters to the output. The handler should write @a size bytes of the
-// @a buffer to the output.
-//
-// @param[in,out] data A pointer to an application data specified by
-// yaml_emitter_set_output().
-// @param[in] buffer The buffer with bytes to be written.
-// @param[in] size The size of the buffer.
-//
-// @returns On success, the handler should return @c 1. If the handler failed,
-// the returned value should be @c 0.
-//
-type yaml_write_handler_t func(emitter *yaml_emitter_t, buffer []byte) error
-
-type yaml_emitter_state_t int
-
-// The emitter states.
-const (
- // Expect STREAM-START.
- yaml_EMIT_STREAM_START_STATE yaml_emitter_state_t = iota
-
- yaml_EMIT_FIRST_DOCUMENT_START_STATE // Expect the first DOCUMENT-START or STREAM-END.
- yaml_EMIT_DOCUMENT_START_STATE // Expect DOCUMENT-START or STREAM-END.
- yaml_EMIT_DOCUMENT_CONTENT_STATE // Expect the content of a document.
- yaml_EMIT_DOCUMENT_END_STATE // Expect DOCUMENT-END.
- yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a flow sequence.
- yaml_EMIT_FLOW_SEQUENCE_TRAIL_ITEM_STATE // Expect the next item of a flow sequence, with the comma already written out
- yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE // Expect an item of a flow sequence.
- yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping.
- yaml_EMIT_FLOW_MAPPING_TRAIL_KEY_STATE // Expect the next key of a flow mapping, with the comma already written out
- yaml_EMIT_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping.
- yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a flow mapping.
- yaml_EMIT_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping.
- yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a block sequence.
- yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE // Expect an item of a block sequence.
- yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping.
- yaml_EMIT_BLOCK_MAPPING_KEY_STATE // Expect the key of a block mapping.
- yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a block mapping.
- yaml_EMIT_BLOCK_MAPPING_VALUE_STATE // Expect a value of a block mapping.
- yaml_EMIT_END_STATE // Expect nothing.
-)
-
-// The emitter structure.
-//
-// All members are internal. Manage the structure using the @c yaml_emitter_
-// family of functions.
-type yaml_emitter_t struct {
-
- // Error handling
-
- error yaml_error_type_t // Error type.
- problem string // Error description.
-
- // Writer stuff
-
- write_handler yaml_write_handler_t // Write handler.
-
- output_buffer *[]byte // String output data.
- output_writer io.Writer // File output data.
-
- buffer []byte // The working buffer.
- buffer_pos int // The current position of the buffer.
-
- raw_buffer []byte // The raw buffer.
- raw_buffer_pos int // The current position of the buffer.
-
- encoding yaml_encoding_t // The stream encoding.
-
- // Emitter stuff
-
- canonical bool // If the output is in the canonical style?
- best_indent int // The number of indentation spaces.
- best_width int // The preferred width of the output lines.
- unicode bool // Allow unescaped non-ASCII characters?
- line_break yaml_break_t // The preferred line break.
-
- state yaml_emitter_state_t // The current emitter state.
- states []yaml_emitter_state_t // The stack of states.
-
- events []yaml_event_t // The event queue.
- events_head int // The head of the event queue.
-
- indents []int // The stack of indentation levels.
-
- tag_directives []yaml_tag_directive_t // The list of tag directives.
-
- indent int // The current indentation level.
-
- flow_level int // The current flow level.
-
- root_context bool // Is it the document root context?
- sequence_context bool // Is it a sequence context?
- mapping_context bool // Is it a mapping context?
- simple_key_context bool // Is it a simple mapping key context?
-
- line int // The current line.
- column int // The current column.
- whitespace bool // If the last character was a whitespace?
- indention bool // If the last character was an indentation character (' ', '-', '?', ':')?
- open_ended bool // If an explicit document end is required?
-
- space_above bool // Is there's an empty line above?
- foot_indent int // The indent used to write the foot comment above, or -1 if none.
-
- // Anchor analysis.
- anchor_data struct {
- anchor []byte // The anchor value.
- alias bool // Is it an alias?
- }
-
- // Tag analysis.
- tag_data struct {
- handle []byte // The tag handle.
- suffix []byte // The tag suffix.
- }
-
- // Scalar analysis.
- scalar_data struct {
- value []byte // The scalar value.
- multiline bool // Does the scalar contain line breaks?
- flow_plain_allowed bool // Can the scalar be expessed in the flow plain style?
- block_plain_allowed bool // Can the scalar be expressed in the block plain style?
- single_quoted_allowed bool // Can the scalar be expressed in the single quoted style?
- block_allowed bool // Can the scalar be expressed in the literal or folded styles?
- style yaml_scalar_style_t // The output style.
- }
-
- // Comments
- head_comment []byte
- line_comment []byte
- foot_comment []byte
- tail_comment []byte
-
- key_line_comment []byte
-
- // Dumper stuff
-
- opened bool // If the stream was already opened?
- closed bool // If the stream was already closed?
-
- // The information associated with the document nodes.
- anchors *struct {
- references int // The number of references.
- anchor int // The anchor id.
- serialized bool // If the node has been emitted?
- }
-
- last_anchor_id int // The last assigned anchor id.
-
- document *yaml_document_t // The currently emitted document.
-}
diff --git a/vendor/gopkg.in/yaml.v3/yamlprivateh.go b/vendor/gopkg.in/yaml.v3/yamlprivateh.go
deleted file mode 100644
index e88f9c54..00000000
--- a/vendor/gopkg.in/yaml.v3/yamlprivateh.go
+++ /dev/null
@@ -1,198 +0,0 @@
-//
-// Copyright (c) 2011-2019 Canonical Ltd
-// Copyright (c) 2006-2010 Kirill Simonov
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-package yaml
-
-const (
- // The size of the input raw buffer.
- input_raw_buffer_size = 512
-
- // The size of the input buffer.
- // It should be possible to decode the whole raw buffer.
- input_buffer_size = input_raw_buffer_size * 3
-
- // The size of the output buffer.
- output_buffer_size = 128
-
- // The size of the output raw buffer.
- // It should be possible to encode the whole output buffer.
- output_raw_buffer_size = (output_buffer_size*2 + 2)
-
- // The size of other stacks and queues.
- initial_stack_size = 16
- initial_queue_size = 16
- initial_string_size = 16
-)
-
-// Check if the character at the specified position is an alphabetical
-// character, a digit, '_', or '-'.
-func is_alpha(b []byte, i int) bool {
- return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-'
-}
-
-// Check if the character at the specified position is a digit.
-func is_digit(b []byte, i int) bool {
- return b[i] >= '0' && b[i] <= '9'
-}
-
-// Get the value of a digit.
-func as_digit(b []byte, i int) int {
- return int(b[i]) - '0'
-}
-
-// Check if the character at the specified position is a hex-digit.
-func is_hex(b []byte, i int) bool {
- return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f'
-}
-
-// Get the value of a hex-digit.
-func as_hex(b []byte, i int) int {
- bi := b[i]
- if bi >= 'A' && bi <= 'F' {
- return int(bi) - 'A' + 10
- }
- if bi >= 'a' && bi <= 'f' {
- return int(bi) - 'a' + 10
- }
- return int(bi) - '0'
-}
-
-// Check if the character is ASCII.
-func is_ascii(b []byte, i int) bool {
- return b[i] <= 0x7F
-}
-
-// Check if the character at the start of the buffer can be printed unescaped.
-func is_printable(b []byte, i int) bool {
- return ((b[i] == 0x0A) || // . == #x0A
- (b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E
- (b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF
- (b[i] > 0xC2 && b[i] < 0xED) ||
- (b[i] == 0xED && b[i+1] < 0xA0) ||
- (b[i] == 0xEE) ||
- (b[i] == 0xEF && // #xE000 <= . <= #xFFFD
- !(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF
- !(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF))))
-}
-
-// Check if the character at the specified position is NUL.
-func is_z(b []byte, i int) bool {
- return b[i] == 0x00
-}
-
-// Check if the beginning of the buffer is a BOM.
-func is_bom(b []byte, i int) bool {
- return b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF
-}
-
-// Check if the character at the specified position is space.
-func is_space(b []byte, i int) bool {
- return b[i] == ' '
-}
-
-// Check if the character at the specified position is tab.
-func is_tab(b []byte, i int) bool {
- return b[i] == '\t'
-}
-
-// Check if the character at the specified position is blank (space or tab).
-func is_blank(b []byte, i int) bool {
- //return is_space(b, i) || is_tab(b, i)
- return b[i] == ' ' || b[i] == '\t'
-}
-
-// Check if the character at the specified position is a line break.
-func is_break(b []byte, i int) bool {
- return (b[i] == '\r' || // CR (#xD)
- b[i] == '\n' || // LF (#xA)
- b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029)
-}
-
-func is_crlf(b []byte, i int) bool {
- return b[i] == '\r' && b[i+1] == '\n'
-}
-
-// Check if the character is a line break or NUL.
-func is_breakz(b []byte, i int) bool {
- //return is_break(b, i) || is_z(b, i)
- return (
- // is_break:
- b[i] == '\r' || // CR (#xD)
- b[i] == '\n' || // LF (#xA)
- b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)
- // is_z:
- b[i] == 0)
-}
-
-// Check if the character is a line break, space, or NUL.
-func is_spacez(b []byte, i int) bool {
- //return is_space(b, i) || is_breakz(b, i)
- return (
- // is_space:
- b[i] == ' ' ||
- // is_breakz:
- b[i] == '\r' || // CR (#xD)
- b[i] == '\n' || // LF (#xA)
- b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)
- b[i] == 0)
-}
-
-// Check if the character is a line break, space, tab, or NUL.
-func is_blankz(b []byte, i int) bool {
- //return is_blank(b, i) || is_breakz(b, i)
- return (
- // is_blank:
- b[i] == ' ' || b[i] == '\t' ||
- // is_breakz:
- b[i] == '\r' || // CR (#xD)
- b[i] == '\n' || // LF (#xA)
- b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)
- b[i] == 0)
-}
-
-// Determine the width of the character.
-func width(b byte) int {
- // Don't replace these by a switch without first
- // confirming that it is being inlined.
- if b&0x80 == 0x00 {
- return 1
- }
- if b&0xE0 == 0xC0 {
- return 2
- }
- if b&0xF0 == 0xE0 {
- return 3
- }
- if b&0xF8 == 0xF0 {
- return 4
- }
- return 0
-
-}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index c91c5a68..14e001b4 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -5,170 +5,6 @@ github.com/aliyun/aliyun-oss-go-sdk/oss
## explicit; go 1.16
github.com/allegro/bigcache/v3
github.com/allegro/bigcache/v3/queue
-# github.com/aws/aws-sdk-go v1.44.173
-## explicit; go 1.11
-github.com/aws/aws-sdk-go/aws
-github.com/aws/aws-sdk-go/aws/arn
-github.com/aws/aws-sdk-go/aws/awserr
-github.com/aws/aws-sdk-go/aws/awsutil
-github.com/aws/aws-sdk-go/aws/client
-github.com/aws/aws-sdk-go/aws/client/metadata
-github.com/aws/aws-sdk-go/aws/corehandlers
-github.com/aws/aws-sdk-go/aws/credentials
-github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds
-github.com/aws/aws-sdk-go/aws/credentials/endpointcreds
-github.com/aws/aws-sdk-go/aws/credentials/processcreds
-github.com/aws/aws-sdk-go/aws/credentials/ssocreds
-github.com/aws/aws-sdk-go/aws/credentials/stscreds
-github.com/aws/aws-sdk-go/aws/csm
-github.com/aws/aws-sdk-go/aws/defaults
-github.com/aws/aws-sdk-go/aws/ec2metadata
-github.com/aws/aws-sdk-go/aws/endpoints
-github.com/aws/aws-sdk-go/aws/request
-github.com/aws/aws-sdk-go/aws/session
-github.com/aws/aws-sdk-go/aws/signer/v4
-github.com/aws/aws-sdk-go/internal/context
-github.com/aws/aws-sdk-go/internal/ini
-github.com/aws/aws-sdk-go/internal/s3shared
-github.com/aws/aws-sdk-go/internal/s3shared/arn
-github.com/aws/aws-sdk-go/internal/s3shared/s3err
-github.com/aws/aws-sdk-go/internal/sdkio
-github.com/aws/aws-sdk-go/internal/sdkmath
-github.com/aws/aws-sdk-go/internal/sdkrand
-github.com/aws/aws-sdk-go/internal/sdkuri
-github.com/aws/aws-sdk-go/internal/shareddefaults
-github.com/aws/aws-sdk-go/internal/strings
-github.com/aws/aws-sdk-go/internal/sync/singleflight
-github.com/aws/aws-sdk-go/private/checksum
-github.com/aws/aws-sdk-go/private/protocol
-github.com/aws/aws-sdk-go/private/protocol/eventstream
-github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi
-github.com/aws/aws-sdk-go/private/protocol/json/jsonutil
-github.com/aws/aws-sdk-go/private/protocol/jsonrpc
-github.com/aws/aws-sdk-go/private/protocol/query
-github.com/aws/aws-sdk-go/private/protocol/query/queryutil
-github.com/aws/aws-sdk-go/private/protocol/rest
-github.com/aws/aws-sdk-go/private/protocol/restjson
-github.com/aws/aws-sdk-go/private/protocol/restxml
-github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil
-github.com/aws/aws-sdk-go/service/s3
-github.com/aws/aws-sdk-go/service/sso
-github.com/aws/aws-sdk-go/service/sso/ssoiface
-github.com/aws/aws-sdk-go/service/sts
-github.com/aws/aws-sdk-go/service/sts/stsiface
-# github.com/aws/aws-sdk-go-v2 v1.17.3
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2
-github.com/aws/aws-sdk-go-v2/aws
-github.com/aws/aws-sdk-go-v2/aws/arn
-github.com/aws/aws-sdk-go-v2/aws/defaults
-github.com/aws/aws-sdk-go-v2/aws/middleware
-github.com/aws/aws-sdk-go-v2/aws/protocol/query
-github.com/aws/aws-sdk-go-v2/aws/protocol/restjson
-github.com/aws/aws-sdk-go-v2/aws/protocol/xml
-github.com/aws/aws-sdk-go-v2/aws/ratelimit
-github.com/aws/aws-sdk-go-v2/aws/retry
-github.com/aws/aws-sdk-go-v2/aws/signer/internal/v4
-github.com/aws/aws-sdk-go-v2/aws/signer/v4
-github.com/aws/aws-sdk-go-v2/aws/transport/http
-github.com/aws/aws-sdk-go-v2/internal/rand
-github.com/aws/aws-sdk-go-v2/internal/sdk
-github.com/aws/aws-sdk-go-v2/internal/sdkio
-github.com/aws/aws-sdk-go-v2/internal/shareddefaults
-github.com/aws/aws-sdk-go-v2/internal/strings
-github.com/aws/aws-sdk-go-v2/internal/sync/singleflight
-github.com/aws/aws-sdk-go-v2/internal/timeconv
-# github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream
-github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/eventstreamapi
-# github.com/aws/aws-sdk-go-v2/config v1.18.7
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/config
-# github.com/aws/aws-sdk-go-v2/credentials v1.13.7
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/credentials
-github.com/aws/aws-sdk-go-v2/credentials/ec2rolecreds
-github.com/aws/aws-sdk-go-v2/credentials/endpointcreds
-github.com/aws/aws-sdk-go-v2/credentials/endpointcreds/internal/client
-github.com/aws/aws-sdk-go-v2/credentials/processcreds
-github.com/aws/aws-sdk-go-v2/credentials/ssocreds
-github.com/aws/aws-sdk-go-v2/credentials/stscreds
-# github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.21
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/feature/ec2/imds
-github.com/aws/aws-sdk-go-v2/feature/ec2/imds/internal/config
-# github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.27
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/internal/configsources
-# github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.21
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/internal/endpoints/v2
-# github.com/aws/aws-sdk-go-v2/internal/ini v1.3.28
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/internal/ini
-# github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.18
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/internal/v4a
-github.com/aws/aws-sdk-go-v2/internal/v4a/internal/crypto
-github.com/aws/aws-sdk-go-v2/internal/v4a/internal/v4
-# github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding
-# github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.22
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/service/internal/checksum
-# github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.21
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/service/internal/presigned-url
-# github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.21
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/service/internal/s3shared
-github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn
-github.com/aws/aws-sdk-go-v2/service/internal/s3shared/config
-# github.com/aws/aws-sdk-go-v2/service/s3 v1.29.6
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/service/s3
-github.com/aws/aws-sdk-go-v2/service/s3/internal/arn
-github.com/aws/aws-sdk-go-v2/service/s3/internal/customizations
-github.com/aws/aws-sdk-go-v2/service/s3/internal/endpoints
-github.com/aws/aws-sdk-go-v2/service/s3/types
-# github.com/aws/aws-sdk-go-v2/service/sso v1.11.28
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/service/sso
-github.com/aws/aws-sdk-go-v2/service/sso/internal/endpoints
-github.com/aws/aws-sdk-go-v2/service/sso/types
-# github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.11
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/service/ssooidc
-github.com/aws/aws-sdk-go-v2/service/ssooidc/internal/endpoints
-github.com/aws/aws-sdk-go-v2/service/ssooidc/types
-# github.com/aws/aws-sdk-go-v2/service/sts v1.17.7
-## explicit; go 1.15
-github.com/aws/aws-sdk-go-v2/service/sts
-github.com/aws/aws-sdk-go-v2/service/sts/internal/endpoints
-github.com/aws/aws-sdk-go-v2/service/sts/types
-# github.com/aws/smithy-go v1.13.5
-## explicit; go 1.15
-github.com/aws/smithy-go
-github.com/aws/smithy-go/auth/bearer
-github.com/aws/smithy-go/context
-github.com/aws/smithy-go/document
-github.com/aws/smithy-go/encoding
-github.com/aws/smithy-go/encoding/httpbinding
-github.com/aws/smithy-go/encoding/json
-github.com/aws/smithy-go/encoding/xml
-github.com/aws/smithy-go/internal/sync/singleflight
-github.com/aws/smithy-go/io
-github.com/aws/smithy-go/logging
-github.com/aws/smithy-go/middleware
-github.com/aws/smithy-go/ptr
-github.com/aws/smithy-go/rand
-github.com/aws/smithy-go/sync
-github.com/aws/smithy-go/time
-github.com/aws/smithy-go/transport/http
-github.com/aws/smithy-go/transport/http/internal/io
-github.com/aws/smithy-go/waiter
# github.com/baidubce/bce-sdk-go v0.9.141
## explicit; go 1.11
github.com/baidubce/bce-sdk-go/auth
@@ -191,9 +27,6 @@ github.com/cespare/xxhash/v2
# github.com/clbanning/mxj v1.8.4
## explicit
github.com/clbanning/mxj
-# github.com/davecgh/go-spew v1.1.1
-## explicit
-github.com/davecgh/go-spew/spew
# github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f
## explicit
github.com/dgryski/go-rendezvous
@@ -213,8 +46,8 @@ github.com/gin-gonic/gin/render
## explicit; go 1.12
github.com/go-ole/go-ole
github.com/go-ole/go-ole/oleutil
-# github.com/go-playground/locales v0.14.0
-## explicit; go 1.13
+# github.com/go-playground/locales v0.14.1
+## explicit; go 1.17
github.com/go-playground/locales
github.com/go-playground/locales/currency
github.com/go-playground/locales/en
@@ -289,19 +122,9 @@ github.com/jinzhu/inflection
# github.com/jinzhu/now v1.1.5
## explicit; go 1.12
github.com/jinzhu/now
-# github.com/jmespath/go-jmespath v0.4.0
-## explicit; go 1.14
-github.com/jmespath/go-jmespath
# github.com/json-iterator/go v1.1.12
## explicit; go 1.12
github.com/json-iterator/go
-# github.com/kamva/mgm/v3 v3.5.0
-## explicit; go 1.14
-github.com/kamva/mgm/v3
-github.com/kamva/mgm/v3/builder
-github.com/kamva/mgm/v3/field
-github.com/kamva/mgm/v3/internal/util
-github.com/kamva/mgm/v3/operator
# github.com/klauspost/compress v1.15.14
## explicit; go 1.17
github.com/klauspost/compress
@@ -311,22 +134,6 @@ github.com/klauspost/compress/internal/cpuinfo
github.com/klauspost/compress/internal/snapref
github.com/klauspost/compress/zstd
github.com/klauspost/compress/zstd/internal/xxhash
-# github.com/ks3sdklib/aws-sdk-go v1.2.0
-## explicit; go 1.16
-github.com/ks3sdklib/aws-sdk-go/aws
-github.com/ks3sdklib/aws-sdk-go/aws/awserr
-github.com/ks3sdklib/aws-sdk-go/aws/awsutil
-github.com/ks3sdklib/aws-sdk-go/aws/credentials
-github.com/ks3sdklib/aws-sdk-go/internal/apierr
-github.com/ks3sdklib/aws-sdk-go/internal/endpoints
-github.com/ks3sdklib/aws-sdk-go/internal/protocol/query
-github.com/ks3sdklib/aws-sdk-go/internal/protocol/query/queryutil
-github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest
-github.com/ks3sdklib/aws-sdk-go/internal/protocol/restxml
-github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil
-github.com/ks3sdklib/aws-sdk-go/internal/signer/v2
-github.com/ks3sdklib/aws-sdk-go/internal/signer/v4
-github.com/ks3sdklib/aws-sdk-go/service/s3
# github.com/leodido/go-urn v1.2.1
## explicit; go 1.13
github.com/leodido/go-urn
@@ -383,9 +190,6 @@ github.com/pelletier/go-toml/v2/unstable
# github.com/pkg/errors v0.9.1
## explicit
github.com/pkg/errors
-# github.com/pmezard/go-difflib v1.0.0
-## explicit
-github.com/pmezard/go-difflib/difflib
# github.com/qiniu/go-sdk/v7 v7.14.0
## explicit; go 1.14
github.com/qiniu/go-sdk/v7
@@ -422,10 +226,6 @@ github.com/shirou/gopsutil/process
# github.com/sirupsen/logrus v1.9.0
## explicit; go 1.13
github.com/sirupsen/logrus
-# github.com/stretchr/testify v1.8.1
-## explicit; go 1.13
-github.com/stretchr/testify/assert
-github.com/stretchr/testify/require
# github.com/syndtr/goleveldb v1.0.0
## explicit
github.com/syndtr/goleveldb/leveldb
@@ -645,9 +445,6 @@ gopkg.in/gomail.v2
# gopkg.in/yaml.v2 v2.4.0
## explicit; go 1.15
gopkg.in/yaml.v2
-# gopkg.in/yaml.v3 v3.0.1
-## explicit
-gopkg.in/yaml.v3
# gorm.io/datatypes v1.1.0
## explicit; go 1.18
gorm.io/datatypes