reloader
This commit is contained in:
@ -18,6 +18,8 @@ metadata:
|
|||||||
namespace: udi
|
namespace: udi
|
||||||
labels:
|
labels:
|
||||||
app: udi
|
app: udi
|
||||||
|
annotations:
|
||||||
|
secret.reloader.stakater.com/reload: "udi-conf,udi-db-cred"
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
selector:
|
selector:
|
||||||
|
@ -24,6 +24,7 @@ type SingleValueExtractorHandler struct {
|
|||||||
|
|
||||||
const TOPIC_SEL = "topic"
|
const TOPIC_SEL = "topic"
|
||||||
const PAYLOAD_SEL = "payload"
|
const PAYLOAD_SEL = "payload"
|
||||||
|
const PAYLOAD_FULL_SEL = "payload-full"
|
||||||
const CONSTANT_SEL = "constant"
|
const CONSTANT_SEL = "constant"
|
||||||
|
|
||||||
type localConfig struct {
|
type localConfig struct {
|
||||||
@ -76,18 +77,20 @@ func NewSveHandler(config config.HandlerConfigT) handler.Handler {
|
|||||||
// empty device is valid
|
// empty device is valid
|
||||||
localConfig.device = config.Attributes["device"]
|
localConfig.device = config.Attributes["device"]
|
||||||
|
|
||||||
if config.Attributes["valueFrom"] != TOPIC_SEL && config.Attributes["valueFrom"] != PAYLOAD_SEL {
|
if config.Attributes["valueFrom"] != TOPIC_SEL && config.Attributes["valueFrom"] != PAYLOAD_SEL && config.Attributes["valueFrom"] != PAYLOAD_FULL_SEL {
|
||||||
log.Printf("Error: invalid value %s for valueFrom", config.Attributes["valueFrom"])
|
log.Printf("Error: invalid value %s for valueFrom", config.Attributes["valueFrom"])
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
localConfig.valueFrom = config.Attributes["valueFrom"]
|
localConfig.valueFrom = config.Attributes["valueFrom"]
|
||||||
|
|
||||||
valuePart, err2 := strconv.Atoi(config.Attributes["valuePart"])
|
if config.Attributes["valueFrom"] != PAYLOAD_FULL_SEL {
|
||||||
if err2 != nil {
|
valuePart, err2 := strconv.Atoi(config.Attributes["valuePart"])
|
||||||
log.Printf("Error: unable to convert valuePart to number: %s", err2)
|
if err2 != nil {
|
||||||
return t
|
log.Printf("Error: unable to convert valuePart to number: %s", err2)
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
localConfig.valuePart = valuePart
|
||||||
}
|
}
|
||||||
localConfig.valuePart = valuePart
|
|
||||||
|
|
||||||
if config.Attributes["unitFrom"] != TOPIC_SEL && config.Attributes["unitFrom"] != PAYLOAD_SEL && config.Attributes["unitFrom"] != CONSTANT_SEL {
|
if config.Attributes["unitFrom"] != TOPIC_SEL && config.Attributes["unitFrom"] != PAYLOAD_SEL && config.Attributes["unitFrom"] != CONSTANT_SEL {
|
||||||
log.Printf("Error: invalid value %s for unitFrom", config.Attributes["unitFrom"])
|
log.Printf("Error: invalid value %s for unitFrom", config.Attributes["unitFrom"])
|
||||||
@ -95,12 +98,14 @@ func NewSveHandler(config config.HandlerConfigT) handler.Handler {
|
|||||||
}
|
}
|
||||||
localConfig.unitFrom = config.Attributes["unitFrom"]
|
localConfig.unitFrom = config.Attributes["unitFrom"]
|
||||||
|
|
||||||
unitPart, err3 := strconv.Atoi(config.Attributes["unitPart"])
|
if config.Attributes["unitFrom"] != CONSTANT_SEL {
|
||||||
if err3 != nil {
|
unitPart, err3 := strconv.Atoi(config.Attributes["unitPart"])
|
||||||
log.Printf("Error: unable to convert unitPart to number: %s", err3)
|
if err3 != nil {
|
||||||
return t
|
log.Printf("Error: unable to convert unitPart to number: %s", err3)
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
localConfig.unitPart = unitPart
|
||||||
}
|
}
|
||||||
localConfig.unitPart = unitPart
|
|
||||||
|
|
||||||
// empty unit is valid
|
// empty unit is valid
|
||||||
localConfig.unit = config.Attributes["unit"]
|
localConfig.unit = config.Attributes["unit"]
|
||||||
@ -183,6 +188,8 @@ func (self *SingleValueExtractorHandler) Handle(message handler.MessageT) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
variable.Value = payloadMatches[self.config.valuePart]
|
variable.Value = payloadMatches[self.config.valuePart]
|
||||||
|
case PAYLOAD_FULL_SEL:
|
||||||
|
variable.Value = message.Payload
|
||||||
}
|
}
|
||||||
|
|
||||||
switch self.config.unitFrom {
|
switch self.config.unitFrom {
|
||||||
|
Reference in New Issue
Block a user