WEB_SERVICES_DOMAIN := $(ROOT_DOMAIN)
MACHINES_HOST := machines.$(WEB_SERVICES_DOMAIN)
MACHINES_MQTT_TOPIC := machines/events
-ROOT_CA_NAME := FooCorp Root
-INT_CA_NAME := FooCorp Intermediate mTLS
-DEVICE_TRUST_TOKEN_NAME := FooCorp Device Trust
+DBUS_PREFIX := dev.fuhry.runtime
+DBUS_PATH := /$(subst .,/,$(DBUS_PREFIX))
+ORG_NAME := FooCorp
+ORG_SLUG := runtime
+SYSTEM_CONF_DIR := /etc/$(ORG_SLUG)
+ROOT_CA_NAME := $(ORG_NAME) Root
+INT_CA_NAME := $(ORG_NAME) Intermediate mTLS
+DEVICE_TRUST_TOKEN_NAME := $(ORG_NAME) Device Trust
LDFLAGS :=
-LDFLAGS += -X=go.fuhry.dev/runtime/constants.RootDomain=$(ROOT_DOMAIN)
-LDFLAGS += -X=go.fuhry.dev/runtime/constants.DefaultRegion=$(DEFAULT_REGION)
-LDFLAGS += -X=go.fuhry.dev/runtime/constants.DefaultHostDomain=$(DEFAULT_HOST_DOMAIN)
-LDFLAGS += -X=go.fuhry.dev/runtime/constants.SDDomain=$(SD_DOMAIN)
-LDFLAGS += -X=go.fuhry.dev/runtime/constants.WebServicesDomain=$(WEB_SERVICES_DOMAIN)
-LDFLAGS += -X=go.fuhry.dev/runtime/constants.MachinesHost=$(MACHINES_HOST)
-LDFLAGS += -X=go.fuhry.dev/runtime/constants.MachinesMqttTopic=$(MACHINES_MQTT_TOPIC)
-#LDFLAGS += -X="go.fuhry.dev/runtime/constants.RootCAName=$(ROOT_CA_NAME)"
-#LDFLAGS += -X="go.fuhry.dev/runtime/constants.IntCAName=$(INT_CA_NAME)"
-#LDFLAGS += -X="go.fuhry.dev/runtime/constants.DeviceTrustTokenName=$(DEVICE_TRUST_TOKEN_NAME)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.RootDomain=$(ROOT_DOMAIN)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.DefaultRegion=$(DEFAULT_REGION)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.DefaultHostDomain=$(DEFAULT_HOST_DOMAIN)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.SDDomain=$(SD_DOMAIN)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.WebServicesDomain=$(WEB_SERVICES_DOMAIN)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.MachinesHost=$(MACHINES_HOST)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.MachinesMqttTopic=$(MACHINES_MQTT_TOPIC)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.DbusPrefix=$(DBUS_PREFIX)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.DbusPath=$(DBUS_PATH)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.OrgName=$(ORG_NAME)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.OrgSlug=$(ORG_SLUG)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.SystemConfDir=$(SYSTEM_CONF_DIR)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.RootCAName=$(ROOT_CA_NAME)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.IntCAName=$(INT_CA_NAME)"
+LDFLAGS += -X "go.fuhry.dev/runtime/constants.DeviceTrustTokenName=$(DEVICE_TRUST_TOKEN_NAME)"
define GOPROG_template =
GOMAINS += $(1)/$(2)
package constants
+import "strings"
+
var (
RootDomain = "fuhry.dev"
DefaultRegion = "hq"
WebServicesDomain = RootDomain
MachinesHost = "machines." + WebServicesDomain
MachinesMqttTopic = "machines/events"
+ DbusPrefix = "dev.fuhry.runtime"
+ DbusPath = "/" + strings.ReplaceAll(DbusPrefix, ".", "/")
+
+ OrgName = "FooCorp"
+ OrgSlug = "runtime"
+ SystemConfDir = "/etc/" + OrgSlug
- RootCAName = "FooCorp Root"
- IntCAName = "FooCorp Intermediate mTLS"
- DeviceTrustTokenName = "FooCorp Device Trust"
+ RootCAName = OrgName + " Root"
+ IntCAName = OrgName + " Intermediate mTLS"
+ DeviceTrustTokenName = OrgName + " Device Trust"
)
"path"
"strings"
+ "go.fuhry.dev/runtime/constants"
"go.fuhry.dev/runtime/mtls"
"go.fuhry.dev/runtime/utils/log"
"gopkg.in/yaml.v3"
var aclSearchPaths = []string{
".",
- "/etc/runtime/grpc",
+ path.Join(constants.SystemConfDir, "grpc"),
}
func TryLoadAcl(serverId mtls.Identity) ACLChecker {
"fmt"
"github.com/godbus/dbus/v5"
+ "go.fuhry.dev/runtime/constants"
)
type MetricType uint
ErrMetricNotFound
)
-const DbusServiceName = "dev.fuhry.runtime.metrics.MetricCollector.v1"
-const DbusServicePath = "/dev/fuhry/runtime/metrics/MetricCollector"
+var DbusServiceName = constants.DbusPrefix + ".metrics.MetricCollector.v1"
+var DbusServicePath = constants.DbusPath + "/metrics/MetricCollector"
+
const SingletonInstanceDiscriminator = "GLOBAL"
type KV map[string]string
return dbus.ConnectSystemBus()
}
-const dbusInterface = `
+var dbusInterface = `
<node>
<interface name="` + metricbus.DbusServiceName + `">
<method name="Ping">
s.log.V(2).Notice("Connected to D-Bus")
- dbusConn.Export(s.servicer, metricbus.DbusServicePath, metricbus.DbusServiceName)
- dbusConn.Export(introspect.Introspectable(dbusInterface), metricbus.DbusServicePath, "org.fredesktop.DBus.Introspectable")
+ dbusConn.Export(s.servicer, dbus.ObjectPath(metricbus.DbusServicePath), metricbus.DbusServiceName)
+ dbusConn.Export(introspect.Introspectable(dbusInterface), dbus.ObjectPath(metricbus.DbusServicePath), "org.fredesktop.DBus.Introspectable")
reply, err := dbusConn.RequestName(metricbus.DbusServiceName, dbus.NameFlagDoNotQueue)
if err != nil {
var globalDbusMetricBusObj dbus.BusObject
var globalDbusMetricBusObjMu sync.Mutex
-const metricBusApiPrefix = metricbus.DbusServiceName
+var metricBusApiPrefix = metricbus.DbusServiceName
type metricBusLowLevelClient struct {
ctx context.Context
if globalDbusMetricBusObj == nil {
conn := mustGlobalDbusConn(ctx)
- globalDbusMetricBusObj = conn.Object(metricBusApiPrefix, metricbus.DbusServicePath)
+ globalDbusMetricBusObj = conn.Object(metricBusApiPrefix, dbus.ObjectPath(metricbus.DbusServicePath))
if globalDbusMetricBusObj == nil {
log.Default().Errorf("failed to get BusObject")