Set message content-type based on the trigger.Spec.ContentType (#279)
This commit is contained in:
committed by
Soam Vasani
parent
b5e3e4e625
commit
961ee069ed
+15
-4
@@ -65,6 +65,11 @@ func mqtCreate(c *cli.Context) error {
|
||||
fatal("Listen topic should not equal to response topic")
|
||||
}
|
||||
|
||||
contentType := c.String("contenttype")
|
||||
if len(contentType) == 0 {
|
||||
contentType = "application/json"
|
||||
}
|
||||
|
||||
checkMQTopicAvailability(mqType, topic, respTopic)
|
||||
|
||||
mqt := tpr.Messagequeuetrigger{
|
||||
@@ -80,6 +85,7 @@ func mqtCreate(c *cli.Context) error {
|
||||
MessageQueueType: mqType,
|
||||
Topic: topic,
|
||||
ResponseTopic: respTopic,
|
||||
ContentType: contentType,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -103,6 +109,7 @@ func mqtUpdate(c *cli.Context) error {
|
||||
topic := c.String("topic")
|
||||
respTopic := c.String("resptopic")
|
||||
fnName := c.String("function")
|
||||
contentType := c.String("contenttype")
|
||||
|
||||
mqt, err := client.MessageQueueTriggerGet(&api.ObjectMeta{
|
||||
Name: mqtName,
|
||||
@@ -125,6 +132,10 @@ func mqtUpdate(c *cli.Context) error {
|
||||
mqt.Spec.FunctionReference.Name = fnName
|
||||
updated = true
|
||||
}
|
||||
if len(contentType) > 0 {
|
||||
mqt.Spec.ContentType = contentType
|
||||
updated = true
|
||||
}
|
||||
|
||||
if !updated {
|
||||
fatal("Nothing to update. Use --topic, --resptopic, or --function.")
|
||||
@@ -162,11 +173,11 @@ func mqtList(c *cli.Context) error {
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\n",
|
||||
"NAME", "FUNCTION_NAME", "MESSAGE_QUEUE_TYPE", "TOPIC", "RESPONSE_TOPIC")
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
"NAME", "FUNCTION_NAME", "MESSAGE_QUEUE_TYPE", "TOPIC", "RESPONSE_TOPIC", "PUB_MSG_CONTENT_TYPE")
|
||||
for _, mqt := range mqts {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\n",
|
||||
mqt.Metadata.Name, mqt.Spec.FunctionReference.Name, mqt.Spec.MessageQueueType, mqt.Spec.Topic, mqt.Spec.ResponseTopic)
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
mqt.Metadata.Name, mqt.Spec.FunctionReference.Name, mqt.Spec.MessageQueueType, mqt.Spec.Topic, mqt.Spec.ResponseTopic, mqt.Spec.ContentType)
|
||||
}
|
||||
w.Flush()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user