Skip to content

Commit

Permalink
chore: remove cyclic imports after merges
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiebens committed Mar 15, 2024
1 parent 2811465 commit e7370d9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions pkg/client/ionscale/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"errors"
"fmt"
"github.com/99designs/keyring"
"github.com/jsiebens/ionscale/internal/config"
"github.com/jsiebens/ionscale/internal/key"
"github.com/jsiebens/ionscale/internal/token"
"os"
"strconv"
)

const (
Expand All @@ -22,7 +23,7 @@ func LoadClientAuth(addr string, systemAdminKey string) (ClientAuth, error) {
if err != nil {
return nil, fmt.Errorf("invalid system admin key")
}
tid := config.GetUint64("IONSCALE_SYSTEM_ADMIN_DEFAULT_TAILNET_ID", 0)
tid := getEnvUint64("IONSCALE_SYSTEM_ADMIN_DEFAULT_TAILNET_ID", 0)
return systemAdminTokenSession{key: *k, tid: tid}, nil
}

Expand Down Expand Up @@ -129,3 +130,15 @@ func createKeyName(addr string) string {
x := hex.EncodeToString(sum[:])
return fmt.Sprintf("ionscale:%s", x)
}

func getEnvUint64(key string, defaultValue uint64) uint64 {
v := os.Getenv(key)
if v != "" {
vi, err := strconv.ParseUint(v, 10, 64)
if err != nil {
return defaultValue
}
return vi
}
return defaultValue
}

0 comments on commit e7370d9

Please sign in to comment.