Prototype a MQTT Source #6187
knative-style.yaml
on: pull_request
style
/
changes
5s
style
/
...
/
Auto-format and Check
18s
style
/
...
/
Lint
3m 45s
style
/
...
/
Do Not Submit
10s
style
/
...
/
shell
0s
style
/
...
/
yaml
20s
style
/
...
/
github_actions
0s
Matrix: style / Golang / Boilerplate Check
Annotations
7 errors and 5 warnings
style / Golang / Auto-format and Check:
cmd/mqttsource/main.go#L1
Please run goimports.
diff --git a/cmd/mqttsource/main.go b/cmd/mqttsource/main.go
index aa30f6b..e9cbd93 100644
--- a/cmd/mqttsource/main.go
+++ b/cmd/mqttsource/main.go
@@ -20,8 +20,8 @@ var (
eventType string
eventSource string
- topic string
- clientid string
+ topic string
+ clientid string
)
func init() {
@@ -39,24 +39,24 @@ func main() {
k_sink := os.Getenv("K_SINK")
if k_sink != "" {
- sink = k_sink
+ sink = k_sink
}
// "source" flag must not be empty for operation.
if source == "" {
- log.Fatal("A valid MQTT broker URL must be defined.")
+ log.Fatal("A valid MQTT broker URL must be defined.")
}
// The event's source defaults to the MQTT broker URL.
if eventSource == "" {
- eventSource = source
+ eventSource = source
}
ctx := cloudevents.ContextWithTarget(context.Background(), sink)
conn, err := net.Dial("tcp", source)
if err != nil {
- log.Fatalf("failed to connect to MQTT broker: %s", err.Error())
+ log.Fatalf("failed to connect to MQTT broker: %s", err.Error())
}
config := &paho.ClientConfig{
@@ -65,10 +65,10 @@ func main() {
}
subscribeOpt := &paho.Subscribe{
- Subscriptions: []paho.SubscribeOptions{
- {Topic: topic,
- QoS: 0},
- },
+ Subscriptions: []paho.SubscribeOptions{
+ {Topic: topic,
+ QoS: 0},
+ },
}
p, err := mqtt_paho.New(ctx, config, mqtt_paho.WithSubscribe(subscribeOpt))
@@ -84,8 +84,8 @@ func main() {
log.Printf("MQTT source start consuming messages from %s\n", source)
err = c.StartReceiver(ctx, func(ctx context.Context, event cloudevents.Event) {
- receive(ctx, event, c)
-})
+ receive(ctx, event, c)
+ })
if err != nil {
log.Fatalf("failed to start receiver: %s", err)
} else {
@@ -96,13 +96,12 @@ func main() {
func receive(ctx context.Context, event cloudevents.Event, c cloudevents.Client) {
log.Printf("%s", event)
- data := event.Data()
+ data := event.Data()
newEvent := cloudevents.NewEvent(cloudevents.VersionV1)
newEvent.SetType(eventType)
- newEvent.SetSource(eventSource)
- _ = newEvent.SetData(cloudevents.ApplicationJSON, data)
+ newEvent.SetSource(eventSource)
+ _ = newEvent.SetData(cloudevents.ApplicationJSON, data)
if result := c.Send(ctx, newEvent); !cloudevents.IsACK(result) {
log.Printf("sending event to channel failed: %v", result)
+ }
}
-}
-
|
style / Golang / Auto-format and Check
Process completed with exit code 1.
|
style / Golang / Boilerplate Check (go):
cmd/mqttsource/main.go#L1
[Go headers] reported by reviewdog 🐶
missing boilerplate:
Raw Output:
cmd/mqttsource/main.go:1: missing boilerplate:
/*
Copyright 2024 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
|
style / Golang / Boilerplate Check (go)
Process completed with exit code 1.
|
style / Golang / Lint:
cmd/mqttsource/main.go#L69
[trailing whitespace] reported by reviewdog 🐶
{Topic: topic,
Raw Output:
cmd/mqttsource/main.go:69: {Topic: topic,
|
style / Golang / Lint:
cmd/mqttsource/main.go#L99
[trailing whitespace] reported by reviewdog 🐶
data := event.Data()
Raw Output:
cmd/mqttsource/main.go:99: data := event.Data()
|
style / Golang / Lint
Process completed with exit code 1.
|
style / Golang / Boilerplate Check (sh)
Restore cache failed: Dependencies file is not found in /home/runner/work/eventing/eventing. Supported file pattern: go.sum
|
style / Golang / Auto-format and Check
Restore cache failed: Dependencies file is not found in /home/runner/work/eventing/eventing. Supported file pattern: go.sum
|
style / suggester / yaml
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/checkout@v3. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
|
style / Golang / Boilerplate Check (go)
Restore cache failed: Dependencies file is not found in /home/runner/work/eventing/eventing. Supported file pattern: go.sum
|
style / Golang / Lint
Restore cache failed: Dependencies file is not found in /home/runner/work/eventing/eventing. Supported file pattern: go.sum
|