Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3a79286
feat: add commands
ogzhanolguncu Jul 14, 2025
30531e7
feat: allow configuring name,desc and version
ogzhanolguncu Jul 14, 2025
53e33f9
feat: pass env to cli
ogzhanolguncu Jul 14, 2025
cc55b1d
feat: match the initial impl
ogzhanolguncu Jul 14, 2025
82d3393
feat: add new progress aniamtion
ogzhanolguncu Jul 14, 2025
d05bce4
feat: add tracker step for each phase
ogzhanolguncu Jul 14, 2025
9e1b02a
refactor: improve animations and errors
ogzhanolguncu Jul 15, 2025
aa7cde2
feat: use proper orchestrafor managing steps and trackers
ogzhanolguncu Jul 15, 2025
454828e
refactor: rename build to run
ogzhanolguncu Jul 15, 2025
f058067
refactor: remove UI logic from api
ogzhanolguncu Jul 15, 2025
7e1a3b4
chore: remove redundant commands
ogzhanolguncu Jul 15, 2025
238c658
refactor: remove ui bloat
ogzhanolguncu Jul 15, 2025
e8ab3dc
feat: add colors for make it distinguishable
ogzhanolguncu Jul 15, 2025
2cd7fa4
Merge branch 'main' into ENG-1903
ogzhanolguncu Jul 15, 2025
9152767
fix: steps
ogzhanolguncu Jul 15, 2025
52fe00d
fix: code rabbit issues
ogzhanolguncu Jul 15, 2025
f80dd82
feat: add proper flag parsing logic
ogzhanolguncu Jul 16, 2025
496a994
refactor: show help if required args are missing
ogzhanolguncu Jul 16, 2025
b8f964f
feat: add missing commands
ogzhanolguncu Jul 16, 2025
1f5b476
fix: code rabbit comments
ogzhanolguncu Jul 16, 2025
74f407a
refactor: fix redundancy
ogzhanolguncu Jul 16, 2025
2a8f0ed
Merge branch 'main' into ENG-1903
ogzhanolguncu Jul 16, 2025
c93dfdd
feat: add config generation
ogzhanolguncu Jul 16, 2025
ecbe3f2
chore: fmt
ogzhanolguncu Jul 16, 2025
5a83cce
Merge branch 'main' of github.com:unkeyed/unkey into add-config-gener…
ogzhanolguncu Jul 17, 2025
d6e0edd
fix: change final output of success
ogzhanolguncu Jul 17, 2025
550d22f
feat: replace old cli with new cli
ogzhanolguncu Jul 17, 2025
9f90f23
Merge branch 'main' of github.com:unkeyed/unkey into add-config-gener…
ogzhanolguncu Jul 21, 2025
2040a9a
fix: ui order
ogzhanolguncu Jul 21, 2025
11510ce
fix: docker errors
ogzhanolguncu Jul 21, 2025
4b2ed82
refactor: improve error handling
ogzhanolguncu Jul 21, 2025
2e450ef
refactor: move constants to top
ogzhanolguncu Jul 21, 2025
1e9f186
refactor: add some delay to version poll
ogzhanolguncu Jul 21, 2025
7f73b9c
refactor: replace old cli with new one
ogzhanolguncu Jul 21, 2025
395fb5f
fix: code rabit issues
ogzhanolguncu Jul 21, 2025
6ef87a2
fix: coderabbit issue
ogzhanolguncu Jul 21, 2025
2796519
docs: explain artificial delay
chronark Jul 22, 2025
86f0c40
fix: PR comments
ogzhanolguncu Jul 22, 2025
117d081
Merge branch 'add-config-generation-to-cli' of github.com:unkeyed/unk…
ogzhanolguncu Jul 22, 2025
b17db16
fix: coderabbit comment
ogzhanolguncu Jul 22, 2025
dedb385
fix: use hardcoded strings for temp docker build
ogzhanolguncu Jul 22, 2025
d953360
Merge branch 'main' into add-config-generation-to-cli
chronark Jul 23, 2025
0d55fb6
Merge branch 'main' of github.com:unkeyed/unkey into add-config-gener…
ogzhanolguncu Jul 23, 2025
206ea81
fix: broken test
ogzhanolguncu Jul 23, 2025
bb80723
fix: exit tests and make sure API is consistent
ogzhanolguncu Jul 23, 2025
617b38c
Merge branch 'main' into add-config-generation-to-cli
ogzhanolguncu Jul 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 53 additions & 155 deletions go/cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"

"github.com/unkeyed/unkey/go/apps/api"
"github.com/unkeyed/unkey/go/pkg/cli"
"github.com/unkeyed/unkey/go/pkg/clock"
"github.com/unkeyed/unkey/go/pkg/tls"
"github.com/unkeyed/unkey/go/pkg/uid"
"github.com/urfave/cli/v3"
)

var Cmd = &cli.Command{
Expand All @@ -16,176 +16,74 @@ var Cmd = &cli.Command{

Flags: []cli.Flag{
// Server Configuration
&cli.IntFlag{
Name: "http-port",
Usage: "HTTP port for the API server to listen on. Default: 7070",
Sources: cli.EnvVars("UNKEY_HTTP_PORT"),
Value: 7070,
Required: false,
},
&cli.BoolFlag{
Name: "color",
Usage: "Enable colored log output. Default: true",
Sources: cli.EnvVars("UNKEY_LOGS_COLOR"),
Value: true,
Required: false,
},
&cli.BoolFlag{
Name: "test-mode",
Usage: "Enable test mode. WARNING: Potentially unsafe, may trust client inputs blindly. Default: false",
Sources: cli.EnvVars("UNKEY_TEST_MODE"),
Value: false,
Required: false,
},
cli.Int("http-port", "HTTP port for the API server to listen on. Default: 7070",
cli.Default(7070), cli.EnvVar("UNKEY_HTTP_PORT")),
cli.Bool("color", "Enable colored log output. Default: true",
cli.Default(true), cli.EnvVar("UNKEY_LOGS_COLOR")),
cli.Bool("test-mode", "Enable test mode. WARNING: Potentially unsafe, may trust client inputs blindly. Default: false",
cli.Default(false), cli.EnvVar("UNKEY_TEST_MODE")),

// Instance Identification
&cli.StringFlag{
Name: "platform",
Usage: "Cloud platform identifier for this node. Used for logging and metrics.",
Sources: cli.EnvVars("UNKEY_PLATFORM"),
Required: false,
},
&cli.StringFlag{
Name: "image",
Usage: "Container image identifier. Used for logging and metrics.",
Sources: cli.EnvVars("UNKEY_IMAGE"),
Required: false,
},
&cli.StringFlag{
Name: "region",
Usage: "Geographic region identifier. Used for logging and routing. Default: unknown",
Sources: cli.EnvVars("UNKEY_REGION", "AWS_REGION"),
Value: "unknown",
Required: false,
},
&cli.StringFlag{
Name: "instance-id",
Usage: "Unique identifier for this instance. Auto-generated if not provided.",
Sources: cli.EnvVars("UNKEY_INSTANCE_ID"),
Value: uid.New(uid.InstancePrefix, 4),
Required: false,
},
cli.String("platform", "Cloud platform identifier for this node. Used for logging and metrics.",
cli.EnvVar("UNKEY_PLATFORM")),
cli.String("image", "Container image identifier. Used for logging and metrics.",
cli.EnvVar("UNKEY_IMAGE")),
cli.String("region", "Geographic region identifier. Used for logging and routing. Default: unknown",
cli.Default("unknown"), cli.EnvVar("UNKEY_REGION"), cli.EnvVar("AWS_REGION")),
cli.String("instance-id", "Unique identifier for this instance. Auto-generated if not provided.",
cli.Default(uid.New(uid.InstancePrefix, 4)), cli.EnvVar("UNKEY_INSTANCE_ID")),

// Database Configuration
&cli.StringFlag{
Name: "database-primary",
Usage: "MySQL connection string for primary database. Required for all deployments. Example: user:pass@host:3306/unkey?parseTime=true",
Sources: cli.EnvVars("UNKEY_DATABASE_PRIMARY"),
Required: true,
},
&cli.StringFlag{
Name: "database-replica",
Usage: "MySQL connection string for read-replica. Reduces load on primary database. Format same as database-primary.",
Sources: cli.EnvVars("UNKEY_DATABASE_REPLICA"),
Required: false,
},
cli.String("database-primary", "MySQL connection string for primary database. Required for all deployments. Example: user:pass@host:3306/unkey?parseTime=true",
cli.Required(), cli.EnvVar("UNKEY_DATABASE_PRIMARY")),
cli.String("database-replica", "MySQL connection string for read-replica. Reduces load on primary database. Format same as database-primary.",
cli.EnvVar("UNKEY_DATABASE_REPLICA")),

// Caching and Storage
&cli.StringFlag{
Name: "redis-url",
Usage: "Redis connection string for rate-limiting and distributed counters. Example: redis://localhost:6379",
Sources: cli.EnvVars("UNKEY_REDIS_URL"),
Required: false,
},
&cli.StringFlag{
Name: "clickhouse-url",
Usage: "ClickHouse connection string for analytics. Recommended for production. Example: clickhouse://user:pass@host:9000/unkey",
Sources: cli.EnvVars("UNKEY_CLICKHOUSE_URL"),
Required: false,
},
cli.String("redis-url", "Redis connection string for rate-limiting and distributed counters. Example: redis://localhost:6379",
cli.EnvVar("UNKEY_REDIS_URL")),
cli.String("clickhouse-url", "ClickHouse connection string for analytics. Recommended for production. Example: clickhouse://user:pass@host:9000/unkey",
cli.EnvVar("UNKEY_CLICKHOUSE_URL")),

// Observability
&cli.BoolFlag{
Name: "otel",
Usage: "Enable OpenTelemetry tracing and metrics",
Sources: cli.EnvVars("UNKEY_OTEL"),
Required: false,
},
cli.Bool("otel", "Enable OpenTelemetry tracing and metrics",
cli.EnvVar("UNKEY_OTEL")),
cli.Float("otel-trace-sampling-rate", "Sampling rate for OpenTelemetry traces (0.0-1.0). Only used when --otel is provided. Default: 0.25",
cli.Default(0.25), cli.EnvVar("UNKEY_OTEL_TRACE_SAMPLING_RATE")),
cli.Int("prometheus-port", "Enable Prometheus /metrics endpoint on specified port. Set to 0 to disable.",
cli.Default(0), cli.EnvVar("UNKEY_PROMETHEUS_PORT")),

// TLS Configuration
&cli.StringFlag{
Name: "tls-cert-file",
Usage: "Path to TLS certificate file for HTTPS. Both cert and key must be provided to enable HTTPS.",
Sources: cli.EnvVars("UNKEY_TLS_CERT_FILE"),
Required: false,
TakesFile: true,
},
&cli.StringFlag{
Name: "tls-key-file",
Usage: "Path to TLS key file for HTTPS. Both cert and key must be provided to enable HTTPS.",
Sources: cli.EnvVars("UNKEY_TLS_KEY_FILE"),
Required: false,
TakesFile: true,
},

&cli.FloatFlag{
Name: "otel-trace-sampling-rate",
Usage: "Sampling rate for OpenTelemetry traces (0.0-1.0). Only used when --otel is provided. Default: 0.25",
Sources: cli.EnvVars("UNKEY_OTEL_TRACE_SAMPLING_RATE"),
Value: 0.25,
Required: false,
},
&cli.IntFlag{
Name: "prometheus-port",
Usage: "Enable Prometheus /metrics endpoint on specified port. Set to 0 to disable.",
Sources: cli.EnvVars("UNKEY_PROMETHEUS_PORT"),
Value: 0,
Required: false,
},
cli.String("tls-cert-file", "Path to TLS certificate file for HTTPS. Both cert and key must be provided to enable HTTPS.",
cli.EnvVar("UNKEY_TLS_CERT_FILE")),
cli.String("tls-key-file", "Path to TLS key file for HTTPS. Both cert and key must be provided to enable HTTPS.",
cli.EnvVar("UNKEY_TLS_KEY_FILE")),

// Vault Configuration
&cli.StringSliceFlag{
Name: "vault-master-keys",
Usage: "Vault master keys for encryption",
Sources: cli.EnvVars("UNKEY_VAULT_MASTER_KEYS"),
Value: []string{},
Required: false,
},
cli.StringSlice("vault-master-keys", "Vault master keys for encryption",
cli.EnvVar("UNKEY_VAULT_MASTER_KEYS")),

// S3 Configuration
&cli.StringFlag{
Name: "vault-s3-url",
Usage: "S3 Compatible Endpoint URL ",
Sources: cli.EnvVars("UNKEY_VAULT_S3_URL"),
Value: "",
Required: false,
},
&cli.StringFlag{
Name: "vault-s3-bucket",
Usage: "S3 bucket name",
Sources: cli.EnvVars("UNKEY_VAULT_S3_BUCKET"),
Value: "",
Required: false,
},
&cli.StringFlag{
Name: "vault-s3-access-key-id",
Usage: "S3 access key ID",
Sources: cli.EnvVars("UNKEY_VAULT_S3_ACCESS_KEY_ID"),
Value: "",
Required: false,
},
&cli.StringFlag{
Name: "vault-s3-secret-access-key",
Usage: "S3 secret access key",
Sources: cli.EnvVars("UNKEY_VAULT_S3_SECRET_ACCESS_KEY"),
Value: "",
Required: false,
},
cli.String("vault-s3-url", "S3 Compatible Endpoint URL",
cli.EnvVar("UNKEY_VAULT_S3_URL")),
cli.String("vault-s3-bucket", "S3 bucket name",
cli.EnvVar("UNKEY_VAULT_S3_BUCKET")),
cli.String("vault-s3-access-key-id", "S3 access key ID",
cli.EnvVar("UNKEY_VAULT_S3_ACCESS_KEY_ID")),
cli.String("vault-s3-secret-access-key", "S3 secret access key",
cli.EnvVar("UNKEY_VAULT_S3_SECRET_ACCESS_KEY")),

// ClickHouse Proxy Service Configuration
&cli.BoolFlag{
Name: "chproxy-enabled",
Usage: "Enable ClickHouse proxy endpoints for high-throughput event collection",
Sources: cli.EnvVars("UNKEY_CHPROXY_ENABLED"),
Value: false,
Required: false,
},
&cli.StringFlag{
Name: "chproxy-auth-token",
Usage: "Authentication token for ClickHouse proxy endpoints. Required when proxy is enabled.",
Sources: cli.EnvVars("UNKEY_CHPROXY_AUTH_TOKEN"),
Required: false,
},
cli.Bool(
"chproxy-enabled",
"Enable ClickHouse proxy endpoints for high-throughput event collection",
cli.EnvVar("UNKEY_CHPROXY_ENABLED"),
),
cli.String(
"chproxy-auth-token",
"Authentication token for ClickHouse proxy endpoints. Required when proxy is enabled.",
cli.EnvVar("UNKEY_CHPROXY_AUTH_TOKEN"),
),
},

Action: action,
Expand Down
107 changes: 0 additions & 107 deletions go/cmd/cli/cli/command.go

This file was deleted.

Loading
Loading