Documentation ¶
Overview ¶
Package paramsenc implements decoding of parameters that stored in AWS Systems Manager Parameter Store.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder decodes values from fetched SSM parameters.
func NewDecoder ¶
NewDecoder returns a new decoder that reads from params.
func (*Decoder) Decode ¶
Decode decodes SSM parameters that previously given into Go values.
Supported Go value types are: - string - int family - slices
- the element type must be also Decode()'s supported type
- only string list parameter can be decoded
- the type implements encoding.TextUnmarshaler
Example ¶
params := []types.Parameter{ {Name: strRef("/str"), Type: types.ParameterTypeString, Value: strRef("strValue")}, {Name: strRef("/int"), Type: types.ParameterTypeString, Value: strRef("64")}, {Name: strRef("/strSlice"), Type: types.ParameterTypeStringList, Value: strRef("a,b,c")}, } type x struct { Str string `ssmp:"/str"` Int int `ssmp:"/int"` StrSlice []string `ssmp:"/strSlice"` } var v x if err := NewDecoder(params).Decode(&v); err != nil { panic(err) } fmt.Printf("%#v\n", v)
Output: paramsenc.x{Str:"strValue", Int:64, StrSlice:[]string{"a", "b", "c"}}
Example (WithPathPrefix) ¶
params := []types.Parameter{ {Name: strRef("/my/str"), Type: types.ParameterTypeString, Value: strRef("strValue")}, {Name: strRef("/my/int"), Type: types.ParameterTypeString, Value: strRef("64")}, {Name: strRef("/my/strSlice"), Type: types.ParameterTypeStringList, Value: strRef("a,b,c")}, } type x struct { Str string `ssmp:"/str"` Int int `ssmp:"/int"` StrSlice []string `ssmp:"/strSlice"` } var v x if err := NewDecoder(params, WithPathPrefix("/my")).Decode(&v); err != nil { panic(err) } fmt.Printf("%#v\n", v)
Output: paramsenc.x{Str:"strValue", Int:64, StrSlice:[]string{"a", "b", "c"}}
type Option ¶
type Option func(d *Decoder)
Option is a function changes the decoder's behavior
func WithPathPrefix ¶
WithPathPrefix returns an Option that indicates the decoder to treat pathPrefix as common prefix.
The decoder searches corresponding parameter using its name without pathPrefix.
Click to show internal directories.
Click to hide internal directories.