Skip to content

Commit e7370d9

Browse files
committed
chore: remove cyclic imports after merges
1 parent 2811465 commit e7370d9

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

pkg/client/ionscale/auth.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import (
77
"errors"
88
"fmt"
99
"github.com/99designs/keyring"
10-
"github.com/jsiebens/ionscale/internal/config"
1110
"github.com/jsiebens/ionscale/internal/key"
1211
"github.com/jsiebens/ionscale/internal/token"
12+
"os"
13+
"strconv"
1314
)
1415

1516
const (
@@ -22,7 +23,7 @@ func LoadClientAuth(addr string, systemAdminKey string) (ClientAuth, error) {
2223
if err != nil {
2324
return nil, fmt.Errorf("invalid system admin key")
2425
}
25-
tid := config.GetUint64("IONSCALE_SYSTEM_ADMIN_DEFAULT_TAILNET_ID", 0)
26+
tid := getEnvUint64("IONSCALE_SYSTEM_ADMIN_DEFAULT_TAILNET_ID", 0)
2627
return systemAdminTokenSession{key: *k, tid: tid}, nil
2728
}
2829

@@ -129,3 +130,15 @@ func createKeyName(addr string) string {
129130
x := hex.EncodeToString(sum[:])
130131
return fmt.Sprintf("ionscale:%s", x)
131132
}
133+
134+
func getEnvUint64(key string, defaultValue uint64) uint64 {
135+
v := os.Getenv(key)
136+
if v != "" {
137+
vi, err := strconv.ParseUint(v, 10, 64)
138+
if err != nil {
139+
return defaultValue
140+
}
141+
return vi
142+
}
143+
return defaultValue
144+
}

0 commit comments

Comments
 (0)