diff --git a/README.md b/README.md index 76dc643..7ca4083 100644 --- a/README.md +++ b/README.md @@ -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 ` - Set log level (trace, debug, info, warn, error, fatal, print) +- `--project ` - Scope requests to a project ID (or set `KERNEL_PROJECT` to a project ID) ## JSON Output @@ -622,7 +623,7 @@ Automated authentication for web services. The `run` command orchestrates the fu - `kernel api-keys create` - Create a new API key - `--name ` - API key name (required) - `--days-to-expire ` - Number of days until expiry (1-3650); omit for never - - `--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 ` - 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 diff --git a/cmd/root.go b/cmd/root.go index aae3506..d1ef4e8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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) @@ -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...) diff --git a/cmd/root_test.go b/cmd/root_test.go index 57cd192..4a28433 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -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) {