Skip to content

Commit f15af8c

Browse files
committed
Migrate to new configuration structure.
1 parent d2ee5ac commit f15af8c

31 files changed

+615
-234
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# hidden files
22
.*
33

4+
# configuration files
5+
*.toml
6+
47
# binaries
58
dist/
69
build/
710
docs/public/
811

912
# dependencies
1013
vendor/
11-

Dockerfile-devel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ ENV PATH=$PATH:$PROJECT_PATH/build
55
ENV CGO_ENABLED=0
66
ENV GO_EXTRA_BUILD_ARGS="-a -installsuffix cgo"
77

8-
RUN apk add --no-cache ca-certificates make git bash
8+
RUN apk add --no-cache ca-certificates make git bash alpine-sdk ruby ruby-dev libffi-dev
9+
RUN gem install fpm --no-rdoc --no-ri
910

1011
RUN mkdir -p $PROJECT_PATH
1112
COPY . $PROJECT_PATH

Dockerfile.arm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ FROM arm32v6/golang:1.9-alpine3.6 AS development
22

33
ENV PROJECT_PATH=/go/src/github.com/brocaar/lora-gateway-bridge
44
ENV PATH=$PATH:$PROJECT_PATH/build
5+
ENV CGO_ENABLED=0
6+
ENV GO_EXTRA_BUILD_ARGS="-a -installsuffix cgo"
57

68
RUN apk add --no-cache ca-certificates make git bash
79

Gopkg.lock

Lines changed: 99 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
branch = "master"
1010
name = "github.com/brocaar/lorawan"
1111

12-
[[constraint]]
13-
name = "github.com/codegangsta/cli"
14-
version = "1.20.0"
15-
1612
[[constraint]]
1713
name = "github.com/eclipse/paho.mqtt.golang"
1814
branch = "master"
@@ -24,3 +20,15 @@
2420
[[constraint]]
2521
name = "github.com/smartystreets/goconvey"
2622
version = "1.6.3"
23+
24+
[[constraint]]
25+
branch = "master"
26+
name = "github.com/spf13/cobra"
27+
28+
[[constraint]]
29+
branch = "master"
30+
name = "github.com/spf13/viper"
31+
32+
[[constraint]]
33+
name = "github.com/pkg/errors"
34+
version = "0.8.0"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Orne Brocaar
3+
Copyright (c) 2018 Orne Brocaar
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package cmd
2+
3+
import (
4+
"html/template"
5+
"os"
6+
7+
"github.com/brocaar/lora-gateway-bridge/internal/config"
8+
"github.com/pkg/errors"
9+
"github.com/spf13/cobra"
10+
)
11+
12+
// when updating this template, don't forget to update config.md!
13+
const configTemplate = `[general]
14+
# debug=5, info=4, warning=3, error=2, fatal=1, panic=0
15+
log_level = {{ .General.LogLevel }}
16+
17+
18+
# Configuration which relates to the packet-forwarder.
19+
[packet_forwarder]
20+
# ip:port to bind the UDP listener to
21+
#
22+
# Example: 0.0.0.0:1700 to listen on port 1700 for all network interfaces.
23+
# This is the listeren to which the packet-forwarder forwards its data
24+
# so make sure the 'serv_port_up' and 'serv_port_down' from your
25+
# packet-forwarder matches this port.
26+
udp_bind = "{{ .PacketForwarder.UDPBind }}"
27+
28+
# Skip the CRC status-check of received packets
29+
#
30+
# This is only has effect when the packet-forwarder is configured to forward
31+
# LoRa frames with CRC errors.
32+
skip_crc_check = {{ .PacketForwarder.SkipCRCCheck }}
33+
34+
35+
# Configuration for the MQTT backend.
36+
[backend.mqtt]
37+
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
38+
server="{{ .Backend.MQTT.Server }}"
39+
40+
# Connect with the given username (optional)
41+
username="{{ .Backend.MQTT.Username }}"
42+
43+
# Connect with the given password (optional)
44+
password="{{ .Backend.MQTT.Password }}"
45+
46+
# CA certificate file (optional)
47+
#
48+
# Use this when setting up a secure connection (when server uses ssl://...)
49+
# but the certificate used by the server is not trusted by any CA certificate
50+
# on the server (e.g. when self generated).
51+
ca_cert="{{ .Backend.MQTT.CACert }}"
52+
53+
# mqtt TLS certificate file (optional)
54+
tls_cert="{{ .Backend.MQTT.TLSCert }}"
55+
56+
# mqtt TLS key file (optional)
57+
tls_key="{{ .Backend.MQTT.TLSKey }}"
58+
`
59+
60+
var configCmd = &cobra.Command{
61+
Use: "configfile",
62+
Short: "Print the LoRa Gateway Bridge configuration file",
63+
RunE: func(cmd *cobra.Command, args []string) error {
64+
t := template.Must(template.New("config").Parse(configTemplate))
65+
err := t.Execute(os.Stdout, config.C)
66+
if err != nil {
67+
return errors.Wrap(err, "execute config template error")
68+
}
69+
return nil
70+
},
71+
}

0 commit comments

Comments
 (0)