aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2026-06-02 13:13:08 -0400
committerSam Anthony <sam@samanthony.xyz>2026-06-02 13:13:08 -0400
commit80ca94381b48d5766c5bcf7897a804d6e2443a69 (patch)
tree1210780353af2f3c10427f5ce36f3dc3abf3edb2 /cmd
parent06ba9b3e492ca47f6f966bd7bd6044809b989c30 (diff)
downloadlulu-669c9bea2c09847df87c6a12abb29a3597cd8f4c.zip
credentials structHEADv0.2.0master
Diffstat (limited to 'cmd')
-rw-r--r--cmd/lulu/creds.go22
-rw-r--r--cmd/lulu/main.go2
2 files changed, 11 insertions, 13 deletions
diff --git a/cmd/lulu/creds.go b/cmd/lulu/creds.go
index e26f0ce..abb904e 100644
--- a/cmd/lulu/creds.go
+++ b/cmd/lulu/creds.go
@@ -7,6 +7,8 @@ import (
"strings"
"github.com/adrg/xdg"
+
+ "git.samanthony.xyz/lulu"
)
var (
@@ -17,26 +19,22 @@ var (
sandboxSecretFile = filepath.Join(configDir, "sandbox", "secret")
)
-// Credentials contains the client-key and client-secret used to
-// authenticate to the API.
-type Credentials struct {
- key, secret string
-}
-
-func readCreds(sandbox bool) (Credentials, error) {
+func readCreds(sandbox bool) (lulu.Credentials, error) {
keyf, secf := keyFile, secretFile
if sandbox {
keyf, secf = sandboxKeyFile, sandboxSecretFile
}
- key, err := readFile(keyf)
+ var creds lulu.Credentials
+ var err error
+ creds.Key, err = readFile(keyf)
if err != nil {
- return Credentials{}, fmt.Errorf("error reading client-key file: %w", err)
+ return creds, fmt.Errorf("error reading client-key file: %w", err)
}
- sec, err := readFile(secf)
+ creds.Secret, err = readFile(secf)
if err != nil {
- return Credentials{}, fmt.Errorf("error reading client-secret file: %w", err)
+ return creds, fmt.Errorf("error reading client-secret file: %w", err)
}
- return Credentials{key, sec}, nil
+ return creds, nil
}
func readFile(path string) (string, error) {
diff --git a/cmd/lulu/main.go b/cmd/lulu/main.go
index 6a9bcba..0609279 100644
--- a/cmd/lulu/main.go
+++ b/cmd/lulu/main.go
@@ -24,7 +24,7 @@ func main() {
creds, err := readCreds(cli.Sandbox)
ctx.FatalIfErrorf(err)
- clnt, err := lulu.NewClient(context.Background(), creds.key, creds.secret)
+ clnt, err := lulu.NewClient(context.Background(), creds)
ctx.FatalIfErrorf(err)
err = ctx.Run(cli.Globals, clnt)