Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Create an API key from the [Kernel dashboard](https://dashboard.onkernel.com).
- `--version`, `-v` - Print the CLI version
- `--no-color` - Disable color output
- `--log-level <level>` - Set log level (trace, debug, info, warn, error, fatal, print)
- `--project <project-id>` - Scope requests to a project ID (or set `KERNEL_PROJECT` to a project ID)

## JSON Output

Expand Down Expand Up @@ -621,7 +622,7 @@ Automated authentication for web services. The `run` command orchestrates the fu
- `kernel api-keys create` - Create a new API key
- `--name <name>` - API key name (required)
- `--days-to-expire <days>` - Number of days until expiry (1-3650); omit for never
- `--project-id <project_id>` - Create a project-scoped API key for this project ID; omit for org-wide. This is different from global `--project`, which only scopes the CLI request.
- `--project-id <project_id>` - Create a project-scoped API key for this project ID; omit for org-wide. This is different from global `--project`, which scopes the CLI request to a project ID.
- `--output json`, `-o json` - Output raw JSON object, including the one-time plaintext key

- `kernel api-keys list` - List API keys
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func init() {
rootCmd.PersistentFlags().BoolP("version", "v", false, "Print the CLI version")
rootCmd.PersistentFlags().BoolP("no-color", "", false, "Disable color output")
rootCmd.PersistentFlags().String("log-level", "warn", "Set the log level (trace, debug, info, warn, error, fatal, print)")
rootCmd.PersistentFlags().String("project", "", "Project ID or name to scope all requests to (or set KERNEL_PROJECT env var)")
rootCmd.PersistentFlags().String("project", "", "Project ID to scope all requests to (or set KERNEL_PROJECT to a project ID)")
rootCmd.SilenceUsage = true
rootCmd.SilenceErrors = true
cobra.OnInitialize(initConfig)
Expand All @@ -143,7 +143,7 @@ func init() {
projectVal = resolveProjectSelection(projectVal)

if projectVal != "" {
clientOpts = append(clientOpts, option.WithHeader("X-Kernel-Project-Id", projectVal))
clientOpts = append(clientOpts, option.WithProjectID(projectVal))
}

client, err := auth.GetAuthenticatedClient(clientOpts...)
Expand Down
8 changes: 4 additions & 4 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ func TestIsAuthExempt(t *testing.T) {

func TestResolveProjectSelection(t *testing.T) {
t.Run("flag value wins over env var", func(t *testing.T) {
t.Setenv("KERNEL_PROJECT", "env-project")
assert.Equal(t, "flag-project", resolveProjectSelection("flag-project"))
t.Setenv("KERNEL_PROJECT", "env-project-id")
assert.Equal(t, "flag-project-id", resolveProjectSelection("flag-project-id"))
})

t.Run("env var used when no flag", func(t *testing.T) {
t.Setenv("KERNEL_PROJECT", "env-project")
assert.Equal(t, "env-project", resolveProjectSelection(""))
t.Setenv("KERNEL_PROJECT", "env-project-id")
assert.Equal(t, "env-project-id", resolveProjectSelection(""))
})

t.Run("empty when no flag or env var", func(t *testing.T) {
Expand Down