forked from kubemq-io/kubemq-sources
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
35 lines (31 loc) · 897 Bytes
/
options.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
package activemq
import (
"fmt"
"github.com/kubemq-io/kubemq-sources/config"
)
type options struct {
host string
destination string
username string
password string
dynamicMapping bool
}
func parseOptions(cfg config.Spec) (options, error) {
o := options{}
var err error
o.host, err = cfg.Properties.MustParseString("host")
if err != nil {
return options{}, fmt.Errorf("error parsing host, %w", err)
}
o.destination, err = cfg.Properties.MustParseString("destination")
if err != nil {
return options{}, fmt.Errorf("error parsing destination, %w", err)
}
o.username = cfg.Properties.ParseString("username", "")
o.password = cfg.Properties.ParseString("password", "")
o.dynamicMapping, err = cfg.Properties.MustParseBool("dynamic_mapping")
if err != nil {
return options{}, fmt.Errorf("error parsing dynamic_mapping, %w", err)
}
return o, nil
}