forked from hashicorp/vault
-
Notifications
You must be signed in to change notification settings - Fork 0
/
field_type.go
78 lines (66 loc) · 2.01 KB
/
field_type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package framework
// FieldType is the enum of types that a field can be.
type FieldType uint
const (
TypeInvalid FieldType = 0
TypeString FieldType = iota
TypeInt
TypeBool
TypeMap
// TypeDurationSecond represent as seconds, this can be either an
// integer or go duration format string (e.g. 24h)
TypeDurationSecond
// TypeSlice represents a slice of any type
TypeSlice
// TypeStringSlice is a helper for TypeSlice that returns a sanitized
// slice of strings
TypeStringSlice
// TypeCommaStringSlice is a helper for TypeSlice that returns a sanitized
// slice of strings and also supports parsing a comma-separated list in
// a string field
TypeCommaStringSlice
// TypeLowerCaseString is a helper for TypeString that returns a lowercase
// version of the provided string
TypeLowerCaseString
// TypeNameString represents a name that is URI safe and follows specific
// rules. These rules include start and end with an alphanumeric
// character and characters in the middle can be alphanumeric or . or -.
TypeNameString
// TypeKVPairs allows you to represent the data as a map or a list of
// equal sign delimited key pairs
TypeKVPairs
// TypeCommaIntSlice is a helper for TypeSlice that returns a sanitized
// slice of Ints
TypeCommaIntSlice
// TypeHeader is a helper for sending request headers through to Vault.
// For instance, the AWS and AliCloud credential plugins both act as a
// benevolent MITM for a request, and the headers are sent through and
// parsed.
TypeHeader
)
func (t FieldType) String() string {
switch t {
case TypeString:
return "string"
case TypeLowerCaseString:
return "lowercase string"
case TypeNameString:
return "name string"
case TypeInt:
return "int"
case TypeBool:
return "bool"
case TypeMap:
return "map"
case TypeKVPairs:
return "keypair"
case TypeDurationSecond:
return "duration (sec)"
case TypeSlice, TypeStringSlice, TypeCommaStringSlice, TypeCommaIntSlice:
return "slice"
case TypeHeader:
return "header"
default:
return "unknown type"
}
}