mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
rebase: make use of v0.0.8 of kmip go client
The new release has some important fixes available with it Ref: https://github.com/ThalesGroup/kmip-go/releases/tag/v0.0.8 Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
d63185b061
commit
0f2daca5c2
124
vendor/github.com/gemalto/kmip-go/ttlv/decoder.go
generated
vendored
124
vendor/github.com/gemalto/kmip-go/ttlv/decoder.go
generated
vendored
@ -26,31 +26,31 @@ var ErrUnexpectedValue = errors.New("no field was found to unmarshal value into"
|
||||
// Unmarshal maps TTLV values to golang values according to the following
|
||||
// rules:
|
||||
//
|
||||
// 1. If the destination value is interface{}, it will be set to the result
|
||||
// of TTLV.Value()
|
||||
// 2. If the destination implements Unmarshaler, that will be called.
|
||||
// 3. If the destination is a slice (except for []byte), append the
|
||||
// unmarshalled value to the slice
|
||||
// 4. Structure unmarshals into a struct. See rules
|
||||
// below for matching struct fields to the values in the Structure.
|
||||
// 5. Interval unmarshals into an int64
|
||||
// 6. DateTime and DateTimeExtended ummarshal into time.Time
|
||||
// 7. ByteString unmarshals to a []byte
|
||||
// 8. TextString unmarshals into a string
|
||||
// 9. Boolean unmarshals into a bool
|
||||
// 10. Enumeration can unmarshal into an int, int8, int16, int32, or their
|
||||
// 1. If the destination value is interface{}, it will be set to the result
|
||||
// of TTLV.Value()
|
||||
// 2. If the destination implements Unmarshaler, that will be called.
|
||||
// 3. If the destination is a slice (except for []byte), append the
|
||||
// unmarshalled value to the slice
|
||||
// 4. Structure unmarshals into a struct. See rules
|
||||
// below for matching struct fields to the values in the Structure.
|
||||
// 5. Interval unmarshals into an int64
|
||||
// 6. DateTime and DateTimeExtended ummarshal into time.Time
|
||||
// 7. ByteString unmarshals to a []byte
|
||||
// 8. TextString unmarshals into a string
|
||||
// 9. Boolean unmarshals into a bool
|
||||
// 10. Enumeration can unmarshal into an int, int8, int16, int32, or their
|
||||
// uint counterparts. If the KMIP value overflows the destination, a
|
||||
// *UnmarshalerError with cause ErrIntOverflow is returned.
|
||||
// 11. Integer can unmarshal to the same types as Enumeration, with the
|
||||
// 11. Integer can unmarshal to the same types as Enumeration, with the
|
||||
// same overflow check.
|
||||
// 12. LongInteger unmarshals to int64 or uint64
|
||||
// 13. BitInteger unmarshals to big.Int.
|
||||
// 12. LongInteger unmarshals to int64 or uint64
|
||||
// 13. BitInteger unmarshals to big.Int.
|
||||
//
|
||||
// If the destination value is not a supported type, an *UnmarshalerError with
|
||||
// cause ErrUnsupportedTypeError is returned. If the source value's type is not recognized,
|
||||
// *UnmarshalerError with cause ErrInvalidType is returned.
|
||||
//
|
||||
// Unmarshaling Structure
|
||||
// # Unmarshaling Structure
|
||||
//
|
||||
// Unmarshal will try to match the values in the Structure with the fields in the
|
||||
// destination struct. Structure is an array of values, while a struct is more like
|
||||
@ -62,55 +62,59 @@ var ErrUnexpectedValue = errors.New("no field was found to unmarshal value into"
|
||||
// and type of the field. It uses the following rules, in order:
|
||||
//
|
||||
// 1. If the type of a field is a struct, and the struct contains a field named "TTLVTag", and the field
|
||||
// has a "ttlv" struct tag, the value of the struct tag will be parsed using ParseTag(). If
|
||||
// parsing fails, an error is returned. The type and value of the TTLVTag field is ignored.
|
||||
// In this example, the F field will map to TagDeactivationDate:
|
||||
// has a "ttlv" struct tag, the value of the struct tag will be parsed using ParseTag(). If
|
||||
// parsing fails, an error is returned. The type and value of the TTLVTag field is ignored.
|
||||
//
|
||||
// type Bar struct {
|
||||
// F Foo
|
||||
// }
|
||||
// type Foo struct {
|
||||
// TTLVTag struct{} `ttlv:"DeactivationDate"`
|
||||
// }
|
||||
// In this example, the F field will map to TagDeactivationDate.
|
||||
//
|
||||
// If Bar uses a struct tag on F indicating a different tag, it is an error:
|
||||
// type Bar struct {
|
||||
// F Foo
|
||||
// }
|
||||
//
|
||||
// type Foo struct {
|
||||
// TTLVTag struct{} `ttlv:"DeactivationDate"`
|
||||
// }
|
||||
//
|
||||
// If Bar uses a struct tag on F indicating a different tag, it is an error:
|
||||
//
|
||||
// type Bar struct {
|
||||
// F Foo `ttlv:"DerivationData"` // this will cause an ErrTagConflict
|
||||
// // because conflict Bar's field tag
|
||||
// // conflicts with Foo's intrinsic tag
|
||||
// F2 Foo `ttlv:"0x420034"` // the value can also be hex
|
||||
// }
|
||||
//
|
||||
// type Bar struct {
|
||||
// F Foo `ttlv:"DerivationData"` // this will cause an ErrTagConflict
|
||||
// // because conflict Bar's field tag
|
||||
// // conflicts with Foo's intrinsic tag
|
||||
// F2 Foo `ttlv:"0x420034"` // the value can also be hex
|
||||
// }
|
||||
// 2. If the type of the field is a struct, and the struct contains a field named "TTLVTag",
|
||||
// and that field is of type ttlv.Tag and is not empty, the value of the field will be the
|
||||
// inferred Tag. For example:
|
||||
// and that field is of type ttlv.Tag and is not empty, the value of the field will be the
|
||||
// inferred Tag. For example:
|
||||
//
|
||||
// type Foo struct {
|
||||
// TTLVTag ttlv.Tag
|
||||
// }
|
||||
// f := Foo{TTLVTag: ttlv.TagState}
|
||||
// type Foo struct {
|
||||
// TTLVTag ttlv.Tag
|
||||
// }
|
||||
// f := Foo{TTLVTag: ttlv.TagState}
|
||||
//
|
||||
// This allows you to dynamically set the KMIP tag that a value will marshal to.
|
||||
//
|
||||
// This allows you to dynamically set the KMIP tag that a value will marshal to.
|
||||
// 3. The "ttlv" struct tag can be used to indicate the tag for a field. The value will
|
||||
// be parsed with ParseTag()
|
||||
// be parsed with ParseTag():
|
||||
//
|
||||
// type Bar struct {
|
||||
// F Foo `ttlv:"DerivationData"`
|
||||
// }
|
||||
// type Bar struct {
|
||||
// F Foo `ttlv:"DerivationData"`
|
||||
// }
|
||||
//
|
||||
// 4. The name of the field is parsed with ParseTag():
|
||||
//
|
||||
// type Bar struct {
|
||||
// DerivationData int
|
||||
// }
|
||||
// type Bar struct {
|
||||
// DerivationData int
|
||||
// }
|
||||
//
|
||||
// 5. The name of the field's type is parsed with ParseTab():
|
||||
//
|
||||
// type DerivationData int
|
||||
// type DerivationData int
|
||||
//
|
||||
// type Bar struct {
|
||||
// dd DerivationData
|
||||
// }
|
||||
// type Bar struct {
|
||||
// dd DerivationData
|
||||
// }
|
||||
//
|
||||
// If no tag value can be inferred, the field is ignored. Multiple fields
|
||||
// *cannot* map to the same KMIP tag. If they do, an ErrTagConflict will
|
||||
@ -122,13 +126,13 @@ var ErrUnexpectedValue = errors.New("no field was found to unmarshal value into"
|
||||
// If the value cannot be matched with a field, Unmarshal will look for
|
||||
// the first field with the "any" struct flag set and unmarshal into that:
|
||||
//
|
||||
// type Foo struct {
|
||||
// Comment string // the Comment will unmarshal into this
|
||||
// EverythingElse []interface{} `,any` // all other values will unmarshal into this
|
||||
// AnotherAny []interface{} `,any` // allowed, but ignored. first any field will always match
|
||||
// NotLegal []interface{} `TagComment,any` // you cannot specify a tag and the any flag.
|
||||
// // will return error
|
||||
// }
|
||||
// type Foo struct {
|
||||
// Comment string // the Comment will unmarshal into this
|
||||
// EverythingElse []interface{} `,any` // all other values will unmarshal into this
|
||||
// AnotherAny []interface{} `,any` // allowed, but ignored. first any field will always match
|
||||
// NotLegal []interface{} `TagComment,any` // you cannot specify a tag and the any flag.
|
||||
// // will return error
|
||||
// }
|
||||
//
|
||||
// If after applying these rules no destination field is found, the KMIP value is ignored.
|
||||
func Unmarshal(ttlv TTLV, v interface{}) error {
|
||||
@ -318,7 +322,7 @@ func (dec *Decoder) unmarshal(val reflect.Value, ttlv TTLV) error {
|
||||
}
|
||||
|
||||
val.SetBool(ttlv.ValueBoolean())
|
||||
// nolint:dupl
|
||||
//nolint:dupl
|
||||
case TypeEnumeration:
|
||||
switch val.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32:
|
||||
@ -338,7 +342,7 @@ func (dec *Decoder) unmarshal(val reflect.Value, ttlv TTLV) error {
|
||||
default:
|
||||
return typeMismatchErr()
|
||||
}
|
||||
// nolint:dupl
|
||||
//nolint:dupl
|
||||
case TypeInteger:
|
||||
switch val.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32:
|
||||
|
77
vendor/github.com/gemalto/kmip-go/ttlv/encoder.go
generated
vendored
77
vendor/github.com/gemalto/kmip-go/ttlv/encoder.go
generated
vendored
@ -40,56 +40,69 @@ var (
|
||||
// and from the inferred KMIP tag, according to these rules:
|
||||
//
|
||||
// 1. If the value is a TTLV, it is copied byte for byte
|
||||
// 2. If the value implements Marshaler, call that
|
||||
// 3. If the struct field has an "omitempty" flag, and the value is
|
||||
// zero, skip the field:
|
||||
//
|
||||
// type Foo struct {
|
||||
// Comment string `ttlv:,omitempty`
|
||||
// }
|
||||
// 2. If the value implements Marshaler, call that
|
||||
//
|
||||
// 3. If the struct field has an "omitempty" flag, and the value is
|
||||
// zero, skip the field:
|
||||
//
|
||||
// type Foo struct {
|
||||
// Comment string `ttlv:,omitempty`
|
||||
// }
|
||||
//
|
||||
// 4. If the value is a slice (except []byte) or array, marshal all
|
||||
// values concatenated
|
||||
// values concatenated
|
||||
//
|
||||
// 5. If a tag has not been inferred at this point, return *MarshalerError with
|
||||
// cause ErrNoTag
|
||||
// cause ErrNoTag
|
||||
//
|
||||
// 6. If the Tag is registered as an enum, or has the "enum" struct tag flag, attempt
|
||||
// to marshal as an Enumeration. int, int8, int16, int32, and their uint counterparts
|
||||
// can be marshaled as an Enumeration. A string can be marshaled to an Enumeration
|
||||
// if the string contains a number, a 4 byte (8 char) hex string with the prefix "0x",
|
||||
// or the normalized name of an enum value registered to this tag. Examples:
|
||||
// to marshal as an Enumeration. int, int8, int16, int32, and their uint counterparts
|
||||
// can be marshaled as an Enumeration. A string can be marshaled to an Enumeration
|
||||
// if the string contains a number, a 4 byte (8 char) hex string with the prefix "0x",
|
||||
// or the normalized name of an enum value registered to this tag. Examples:
|
||||
//
|
||||
// type Foo struct {
|
||||
// CancellationResult string // will encode as an Enumeration because
|
||||
// // the tag CancellationResult is registered
|
||||
// // as an enum.
|
||||
// C int `ttlv:"Comment,enum" // The tag Comment is not registered as an enum
|
||||
// // but the enum flag will force this to encode
|
||||
// // as an enumeration.
|
||||
// }
|
||||
// type Foo struct {
|
||||
// CancellationResult string // will encode as an Enumeration because
|
||||
// // the tag CancellationResult is registered
|
||||
// // as an enum.
|
||||
// C int `ttlv:"Comment,enum" // The tag Comment is not registered as an enum
|
||||
// // but the enum flag will force this to encode
|
||||
// // as an enumeration.
|
||||
// }
|
||||
//
|
||||
// If the string can't be interpreted as an enum value, it will be encoded as a TextString. If
|
||||
// the "enum" struct flag is set, the value *must* successfully encode to an Enumeration using
|
||||
// above rules, or an error is returned.
|
||||
//
|
||||
// If the string can't be interpreted as an enum value, it will be encoded as a TextString. If
|
||||
// the "enum" struct flag is set, the value *must* successfully encode to an Enumeration using
|
||||
// above rules, or an error is returned.
|
||||
// 7. If the Tag is registered as a bitmask, or has the "bitmask" struct tag flag, attempt
|
||||
// to marshal to an Integer, following the same rules as for Enumerations. The ParseInt()
|
||||
// function is used to parse string values.
|
||||
// 9. time.Time marshals to DateTime. If the field has the "datetimeextended" struct flag,
|
||||
// marshal as DateTimeExtended. Example:
|
||||
// to marshal to an Integer, following the same rules as for Enumerations. The ParseInt()
|
||||
// function is used to parse string values.
|
||||
//
|
||||
// type Foo struct {
|
||||
// ActivationDate time.Time `ttlv:",datetimeextended"`
|
||||
// }
|
||||
// 9. time.Time marshals to DateTime. If the field has the "datetimeextended" struct flag,
|
||||
// marshal as DateTimeExtended. Example:
|
||||
//
|
||||
// type Foo struct {
|
||||
// ActivationDate time.Time `ttlv:",datetimeextended"`
|
||||
// }
|
||||
//
|
||||
// 10. big.Int marshals to BigInteger
|
||||
//
|
||||
// 11. time.Duration marshals to Interval
|
||||
//
|
||||
// 12. string marshals to TextString
|
||||
//
|
||||
// 13. []byte marshals to ByteString
|
||||
//
|
||||
// 14. all int and uint variants except int64 and uint64 marshal to Integer. If the golang
|
||||
// value overflows the KMIP value, *MarshalerError with cause ErrIntOverflow is returned
|
||||
// value overflows the KMIP value, *MarshalerError with cause ErrIntOverflow is returned
|
||||
//
|
||||
// 15. int64 and uint64 marshal to LongInteger
|
||||
//
|
||||
// 16. bool marshals to Boolean
|
||||
//
|
||||
// 17. structs marshal to Structure. Each field of the struct will be marshaled into the
|
||||
// values of the Structure according to the above rules.
|
||||
// values of the Structure according to the above rules.
|
||||
//
|
||||
// Any other golang type will return *MarshalerError with cause ErrUnsupportedTypeError.
|
||||
func Marshal(v interface{}) (TTLV, error) {
|
||||
|
7
vendor/github.com/gemalto/kmip-go/ttlv/formatting.go
generated
vendored
7
vendor/github.com/gemalto/kmip-go/ttlv/formatting.go
generated
vendored
@ -143,9 +143,9 @@ func FormatInt(i int32, enumMap EnumMap) string {
|
||||
// See FormatEnum for examples of the formats which can be parsed.
|
||||
// It will also parse numeric strings. Examples:
|
||||
//
|
||||
// ParseEnum("UnableToCancel", registry.EnumForTag(TagCancellationResult))
|
||||
// ParseEnum("0x00000002")
|
||||
// ParseEnum("2")
|
||||
// ParseEnum("UnableToCancel", registry.EnumForTag(TagCancellationResult))
|
||||
// ParseEnum("0x00000002")
|
||||
// ParseEnum("2")
|
||||
//
|
||||
// Returns ErrInvalidHexString if the string is invalid hex, or
|
||||
// if the hex value is less than 1 byte or more than 4 bytes (ignoring
|
||||
@ -289,7 +289,6 @@ func ParseType(s string, enumMap EnumMap) (Type, error) {
|
||||
// be the name from the spec. Names should be in the normalized format
|
||||
// described in the KMIP spec (see NormalizeName()).
|
||||
//
|
||||
//
|
||||
// Value enumerations are used for encoding and decoding KMIP Enumeration values,
|
||||
// KMIP Integer bitmask values, Types, and Tags.
|
||||
type EnumMap interface {
|
||||
|
2
vendor/github.com/gemalto/kmip-go/ttlv/registry.go
generated
vendored
2
vendor/github.com/gemalto/kmip-go/ttlv/registry.go
generated
vendored
@ -15,7 +15,7 @@ import (
|
||||
// program.
|
||||
var DefaultRegistry Registry
|
||||
|
||||
// nolint:gochecknoinits
|
||||
//nolint:gochecknoinits
|
||||
func init() {
|
||||
RegisterTypes(&DefaultRegistry)
|
||||
}
|
||||
|
13
vendor/github.com/gemalto/kmip-go/ttlv/types.go
generated
vendored
13
vendor/github.com/gemalto/kmip-go/ttlv/types.go
generated
vendored
@ -94,12 +94,13 @@ func (t DateTimeExtended) MarshalTTLV(e *Encoder, tag Tag) error {
|
||||
// bytes and native go types. It's useful in tests, or where you want to construct
|
||||
// an arbitrary TTLV structure in code without declaring a bespoke type, e.g.:
|
||||
//
|
||||
// v := ttlv.Value{Tag: TagBatchCount, Value: Values{
|
||||
// Value{Tag: TagComment, Value: "red"},
|
||||
// Value{Tag: TagComment, Value: "blue"},
|
||||
// Value{Tag: TagComment, Value: "green"},
|
||||
// }
|
||||
// t, err := ttlv.Marshal(v)
|
||||
// v := ttlv.Value{
|
||||
// Tag: TagBatchCount, Value: Values{
|
||||
// Value{Tag: TagComment, Value: "red"},
|
||||
// Value{Tag: TagComment, Value: "blue"},
|
||||
// Value{Tag: TagComment, Value: "green"},
|
||||
// }
|
||||
// t, err := ttlv.Marshal(v)
|
||||
//
|
||||
// KMIP Structure types are mapped to the Values go type. When marshaling, if the Value
|
||||
// field is set to a Values{}, the resulting TTLV will be TypeStructure. When unmarshaling
|
||||
|
Reference in New Issue
Block a user