Skip to content

Commit

Permalink
feat: account id added
Browse files Browse the repository at this point in the history
  • Loading branch information
tolgaOzen committed Jan 12, 2024
1 parent a4c4884 commit b8de123
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions example.config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
account_id: ""

# The server section specifies the HTTP and gRPC server settings,
# including whether or not TLS is enabled and the certificate and
# key file locations.
Expand Down
2 changes: 2 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
type (
// Config is the main configuration structure containing various sections for different aspects of the application.
Config struct {
AccountID string `mapstructure:"account_id"`
Server `mapstructure:"server"` // Server configuration for both HTTP and gRPC
Log `mapstructure:"logger"` // Logging configuration
Profiler `mapstructure:"profiler"` // Profiler configuration
Expand Down Expand Up @@ -242,6 +243,7 @@ func NewConfigWithFile(dir string) (*Config, error) {
// DefaultConfig - Creates default config.
func DefaultConfig() *Config {
return &Config{
AccountID: "",
Server: Server{
HTTP: HTTP{
Enabled: true,
Expand Down
8 changes: 2 additions & 6 deletions internal/info.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package internal

import (
"github.com/rs/xid"
)

// Identifier is the unique identifier for the Permify.
var Identifier = xid.New().String()
var Identifier = ""

/*
✨ OneLiner: Open-source authorization service inspired by Google Zanzibar
Expand All @@ -20,7 +16,7 @@ var Identifier = xid.New().String()
*/
const (
// Version is the last release of the Permify (e.g. v0.1.0)
Version = "v0.6.8"
Version = "v0.6.9"

// Banner is the view for terminal.
Banner = `
Expand Down
8 changes: 8 additions & 0 deletions pkg/cmd/flags/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ func RegisterServeFlags(cmd *cobra.Command) {
panic(err)
}

flags.String("account-id", conf.AccountID, "account id")
if err = viper.BindPFlag("account_id", flags.Lookup("account-id")); err != nil {
panic(err)
}
if err = viper.BindEnv("account_id", "PERMIFY_ACCOUNT_ID"); err != nil {
panic(err)
}

// Server
flags.Int64("server-rate-limit", conf.Server.RateLimit, "the maximum number of requests the server should handle per second")
if err = viper.BindPFlag("server.rate_limit", flags.Lookup("server-rate-limit")); err != nil {
Expand Down
5 changes: 5 additions & 0 deletions pkg/cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ func serve() func(cmd *cobra.Command, args []string) error {
red := color.New(color.FgGreen)
_, _ = red.Printf(internal.Banner, internal.Version)

internal.Identifier = cfg.AccountID
if internal.Identifier == "" {
slog.Warn("Account ID is not set. Please fill in the Account ID for better support. Get your Account ID from https://permify.co/account")
}

var handler slog.Handler
switch cfg.Log.Output {
case "json":
Expand Down

0 comments on commit b8de123

Please sign in to comment.