summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-06-15 10:49:39 +0300
committerPaul Buetow <paul@buetow.org>2024-06-15 10:49:39 +0300
commit5722509b4c05a26b029a1c053d25571beabcc29c (patch)
tree6870133fdb24dfae8328bea281d9d78243c2059b
parent0a4fd9b0b8bcd91e008e905e21de9d87953e3022 (diff)
initial client
-rw-r--r--Taskfile.yml4
-rw-r--r--internal/config/client/client.go24
2 files changed, 28 insertions, 0 deletions
diff --git a/Taskfile.yml b/Taskfile.yml
index a8347d2..36d0832 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -1,13 +1,17 @@
version: '3'
tasks:
+ default:
+ deps: ["build"]
build:
cmds:
- go build -o gosd cmd/gosd/main.go
+ - go build -o gos cmd/gos/main.go
dev:
deps: ["test", "vet", "lint"]
cmds:
- go build -race -o gosd cmd/gosd/main.go
+ - go build -race -o gos cmd/gos/main.go
test:
cmds:
- go clean -testcache
diff --git a/internal/config/client/client.go b/internal/config/client/client.go
new file mode 100644
index 0000000..9329759
--- /dev/null
+++ b/internal/config/client/client.go
@@ -0,0 +1,24 @@
+package client
+
+import (
+ "strings"
+
+ "codeberg.org/snonux/gos/internal/config"
+)
+
+type ClientConfig struct {
+ Server string `json:"Partner,omitempty"`
+ ApiKey string `json:"ApiKey,omitempty"`
+}
+
+func New(configFile string) (ClientConfig, error) {
+ conf, _ := config.FromFile[ClientConfig](configFile)
+ conf.Server = config.FromENV("Servers", conf.Server)
+ conf.ApiKey = config.FromENV("ApiKey", conf.ApiKey)
+
+ return conf, nil
+}
+
+func (conf ClientConfig) Servers() []string {
+ return strings.Split(conf.Server, ",")
+}