docs: README#44
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds provider-prefixed environment-variable resolution, removes the context parameter from gcloud.SetupEnvJson and updates callers, changes gcloud credential handling to accept KEY/KEY_FILE envs (writing KEY to a file when provided), and rewrites README to document GCP auth, provider usage, and CLI workflows. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
37ba5c8 to
3d3ea5d
Compare
|
@skevetter please take a look (unlike https://github.com/skevetter/devpod, this repository does not let me request review...) |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
pkg/options/options.go (1)
103-119: Add a focused regression test forGetEnvPrefixed.This helper now sits on the option and auth lookup paths, and the default
GCLOUDpath plusmy-gcloud -> MY_GCLOUDnormalization are easy to regress. A small table-driven test aroundgetEnv/GetEnvPrefixedwould lock the new behavior down.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/options/options.go` around lines 103 - 119, Add a focused table-driven unit test for getEnv and GetEnvPrefixed that verifies the default provider lookup and provider-name normalization; write cases that (1) set no DEVPOD_PROVIDER and ensure GetEnvPrefixed looks up DEVPOD_PROVIDER_GCLOUD_<KEY>, (2) set DEVPOD_PROVIDER="my-gcloud" and ensure it normalizes to DEVPOD_PROVIDER_MY_GCLOUD_<KEY>, and (3) verify getEnv returns the direct env var when present and falls back to GetEnvPrefixed otherwise; in the test mutate os.Setenv / os.Unsetenv for DEVPOD_PROVIDER and the expected env keys and restore environment after each case, and assert expected returned strings from getEnv/GetEnvPrefixed (name the test TestGetEnvPrefixed_TableDriven or similar).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Around line 63-66: Update the README text to mention that auth environment
variables are also resolved with the provider-specific prefix: explain that
options.GetEnvPrefixed in pkg/gcloud/gcloud.go looks up KEY_FILE and KEY using
the provider name (e.g., DEVPOD_PROVIDER_MY_GCLOUD_KEY_FILE and
DEVPOD_PROVIDER_MY_GCLOUD_KEY for a provider named "my-gcloud"), and remind CLI
users to set DEVPOD_PROVIDER to the chosen provider name so lookup does not fall
back to GCLOUD; mirror this addition where similar option-prefix examples appear
(around lines 172-178).
- Around line 23-24: Fix multiple copy typos across the README: change "Before
you can you this provider" to "Before you can use this provider", replace
"loose" with "lose" wherever it appears, correct "This provides…" to the
intended phrasing/capitalization (e.g., "This provides…" → "These provide…" or
rephrase to match surrounding context), capitalize "google" to "Google" in the
options table, and correct ".enrc" to ".envrc"; apply these edits at the other
referenced occurrences (lines 72-73, 134-135, 151, and 231-233) to ensure
consistent wording.
- Around line 161-166: The README shows setting DEVPOD_PROVIDER_GCLOUD_PROJECT
and DEVPOD_PROVIDER_GCLOUD_ZONE as plain assignments which are not exported to
child processes; change the example so the variables are exported (or assigned
inline with the command) before running devpod provider add gcloud — update the
two symbols DEVPOD_PROVIDER_GCLOUD_PROJECT and DEVPOD_PROVIDER_GCLOUD_ZONE to
use export (or demonstrate inline assignment) and keep the final command devpod
provider add gcloud as shown.
---
Nitpick comments:
In `@pkg/options/options.go`:
- Around line 103-119: Add a focused table-driven unit test for getEnv and
GetEnvPrefixed that verifies the default provider lookup and provider-name
normalization; write cases that (1) set no DEVPOD_PROVIDER and ensure
GetEnvPrefixed looks up DEVPOD_PROVIDER_GCLOUD_<KEY>, (2) set
DEVPOD_PROVIDER="my-gcloud" and ensure it normalizes to
DEVPOD_PROVIDER_MY_GCLOUD_<KEY>, and (3) verify getEnv returns the direct env
var when present and falls back to GetEnvPrefixed otherwise; in the test mutate
os.Setenv / os.Unsetenv for DEVPOD_PROVIDER and the expected env keys and
restore environment after each case, and assert expected returned strings from
getEnv/GetEnvPrefixed (name the test TestGetEnvPrefixed_TableDriven or similar).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e0e975e9-9d3c-48e4-bb7d-7dccf31d1461
📒 Files selected for processing (4)
README.mdhack/provider/main.gopkg/gcloud/gcloud.gopkg/options/options.go
5b1d56d to
4219348
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
README.md (1)
67-73:⚠️ Potential issue | 🟠 MajorInclude
KEY_FILEin the non-default provider rename example too.This section currently shows only
..._KEYremapping. The code resolves bothKEY_FILEandKEY, so readers should see both renamed forms for custom provider names.Suggested doc update
names of the environment variables that supply values for the options change accordingly: `DEVPOD_PROVIDER_GCLOUD_KEY` becomes `DEVPOD_PROVIDER_MY_GCLOUD_KEY`. +Likewise, `DEVPOD_PROVIDER_GCLOUD_KEY_FILE` becomes +`DEVPOD_PROVIDER_MY_GCLOUD_KEY_FILE`.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@README.md` around lines 67 - 73, Update the example text around the custom provider rename (the paragraph using the example command `devpod provider add gcloud --name my-gcloud`) to show that both KEY and KEY_FILE environment variables are renamed; explicitly show `DEVPOD_PROVIDER_GCLOUD_KEY` -> `DEVPOD_PROVIDER_MY_GCLOUD_KEY` and `DEVPOD_PROVIDER_GCLOUD_KEY_FILE` -> `DEVPOD_PROVIDER_MY_GCLOUD_KEY_FILE`, and adjust the surrounding sentence to state that both KEY and KEY_FILE are remapped when using a non-default provider name.
🧹 Nitpick comments (1)
pkg/options/options.go (1)
103-110: Prefer provider-scoped env vars before unprefixed fallbacks.Current lookup order lets generic env vars override provider-specific ones. That can cause surprising values in multi-provider/context workflows.
Suggested adjustment
func getEnv(key string) string { - val := os.Getenv(key) - if val != "" { - return val - } - - return GetEnvPrefixed(key) + if val := GetEnvPrefixed(key); val != "" { + return val + } + return os.Getenv(key) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/options/options.go` around lines 103 - 110, The getEnv function currently returns the unprefixed os.Getenv(key) value before falling back to GetEnvPrefixed(key), which lets generic env vars override provider-scoped ones; change getEnv to first try the provider-scoped lookup via GetEnvPrefixed(key) and return it if non-empty, otherwise fall back to os.Getenv(key) so provider-scoped env vars take precedence; adjust the function body around getEnv and references to GetEnvPrefixed to preserve the same empty-string semantics.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Around line 108-110: The fenced code block in README.md is missing a language
tag which triggers MD040; update the block around the service account example to
include a plain-text language tag (e.g., change the opening fence from ``` to
```text) so the block becomes a text-labeled fenced code block and satisfies the
markdown linter.
---
Duplicate comments:
In `@README.md`:
- Around line 67-73: Update the example text around the custom provider rename
(the paragraph using the example command `devpod provider add gcloud --name
my-gcloud`) to show that both KEY and KEY_FILE environment variables are
renamed; explicitly show `DEVPOD_PROVIDER_GCLOUD_KEY` ->
`DEVPOD_PROVIDER_MY_GCLOUD_KEY` and `DEVPOD_PROVIDER_GCLOUD_KEY_FILE` ->
`DEVPOD_PROVIDER_MY_GCLOUD_KEY_FILE`, and adjust the surrounding sentence to
state that both KEY and KEY_FILE are remapped when using a non-default provider
name.
---
Nitpick comments:
In `@pkg/options/options.go`:
- Around line 103-110: The getEnv function currently returns the unprefixed
os.Getenv(key) value before falling back to GetEnvPrefixed(key), which lets
generic env vars override provider-scoped ones; change getEnv to first try the
provider-scoped lookup via GetEnvPrefixed(key) and return it if non-empty,
otherwise fall back to os.Getenv(key) so provider-scoped env vars take
precedence; adjust the function body around getEnv and references to
GetEnvPrefixed to preserve the same empty-string semantics.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 18d0982c-c865-4db6-a1d5-aeec2933a933
📒 Files selected for processing (4)
README.mdhack/provider/main.gopkg/gcloud/gcloud.gopkg/options/options.go
🚧 Files skipped from review as they are similar to previous changes (1)
- pkg/gcloud/gcloud.go
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/options/options.go (1)
90-97:⚠️ Potential issue | 🟡 MinorImprove missing-env error text to include provider-prefixed key.
fromEnvOrErrornow resolves via provider-prefixed env first, but the error still only tells users to define rawKEY. On Line 93 this can mislead users who setDEVPOD_PROVIDER_*variables.Suggested patch
func fromEnvOrError(name string) (string, error) { val := getEnv(name) if val == "" { + providerName := os.Getenv("DEVPOD_PROVIDER") + if providerName == "" { + providerName = "GCLOUD" + } + providerName = strings.ToUpper(strings.ReplaceAll(providerName, "-", "_")) return "", fmt.Errorf( - "couldn't find option %s in environment, please make sure %s is defined", + "couldn't find option %s in environment, please define DEVPOD_PROVIDER_%s_%s (or %s)", name, - name, + providerName, + name, + name, ) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/options/options.go` around lines 90 - 97, The error message in fromEnvOrError currently tells users to define the raw key even though getEnv resolves provider-prefixed keys first; update fromEnvOrError to compute the provider-prefixed key (the same lookup used by getEnv) and include that provider-prefixed environment variable name in the fmt.Errorf message so the error suggests the correct DEVPOD_PROVIDER_* key (reference functions fromEnvOrError and getEnv).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Around line 75-77: Fix the typos in the service-account section of README.md:
change the phrase "service accounts`s" to "service accounts" in the sentence
that starts "Since this approach uses JSON `key`s for authentication..." and
rename the heading/text "Serviced Accounts for Instances" to "Service Accounts
for Instances" (update both occurrences if duplicated).
---
Outside diff comments:
In `@pkg/options/options.go`:
- Around line 90-97: The error message in fromEnvOrError currently tells users
to define the raw key even though getEnv resolves provider-prefixed keys first;
update fromEnvOrError to compute the provider-prefixed key (the same lookup used
by getEnv) and include that provider-prefixed environment variable name in the
fmt.Errorf message so the error suggests the correct DEVPOD_PROVIDER_* key
(reference functions fromEnvOrError and getEnv).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 23888d60-ed21-4209-9ac8-2b84b5e8b172
📒 Files selected for processing (4)
README.mdhack/provider/main.gopkg/gcloud/gcloud.gopkg/options/options.go
🚧 Files skipped from review as they are similar to previous changes (1)
- hack/provider/main.go
There was a problem hiding this comment.
♻️ Duplicate comments (1)
README.md (1)
75-78:⚠️ Potential issue | 🟡 MinorFix typo in service account reference.
Line 76 has a malformed backtick/possessive:
service accountssshould beservice accounts`.📝 Suggested fix
Since this approach uses JSON `key`s for authentication, -and only `service accounts`s have such keys, +and only `service accounts` have such keys, you need to use a `service account`.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@README.md` around lines 75 - 78, Fix the malformed backtick/possessive in the README by replacing the incorrect inline code string `service accounts`s` with the correct `service accounts` in the sentence that reads "Since this approach uses JSON `key`s for authentication, and only `service accounts`s have such keys, you need to use a `service account`."; update the quoted token `service accounts`s` to `service accounts` so the backticks and plural form are correct.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@README.md`:
- Around line 75-78: Fix the malformed backtick/possessive in the README by
replacing the incorrect inline code string `service accounts`s` with the correct
`service accounts` in the sentence that reads "Since this approach uses JSON
`key`s for authentication, and only `service accounts`s have such keys, you need
to use a `service account`."; update the quoted token `service accounts`s` to
`service accounts` so the backticks and plural form are correct.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4e8f2c63-a69b-420c-90fb-dde5882ae41f
📒 Files selected for processing (4)
README.mdhack/provider/main.gopkg/gcloud/gcloud.gopkg/options/options.go
🚧 Files skipped from review as they are similar to previous changes (2)
- hack/provider/main.go
- pkg/gcloud/gcloud.go
1b493a8 to
59c0475
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
README.md (1)
136-152: Consider addingKEY_FILEandKEYoptions to the table.The options table documents most provider options but omits
KEY_FILEandKEY, which are documented separately in the Environment Variable section. For completeness and discoverability, consider adding them to this table since they are defined as provider options inhack/provider/main.go(lines 227-232).📝 Suggested addition to options table
| NAME | REQUIRED | DESCRIPTION | DEFAULT | |---------------------------|----------|-------------------------------------------------------------------------|------------------------------------------------------| | AGENT_PATH | false | The path where to inject the DevPod agent to. | /var/lib/toolbox/devpod | | DISK_IMAGE | false | The disk image to use. | projects/cos-cloud/global/images/cos-101-17162-127-5 | | DISK_SIZE | false | The disk size to use (GB). | 40 | | INACTIVITY_TIMEOUT | false | If defined, will automatically stop the VM after the inactivity period. | 5m | | INJECT_DOCKER_CREDENTIALS | false | If DevPod should inject docker credentials into the remote host. | true | | INJECT_GIT_CREDENTIALS | false | If DevPod should inject git credentials into the remote host. | true | +| KEY | false | Google Cloud JSON key (content). | | +| KEY_FILE | false | Path to the Google Cloud JSON key file. | | | MACHINE_TYPE | false | The machine type to use. | c2-standard-4 |🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@README.md` around lines 136 - 152, Add the missing provider options KEY_FILE and KEY to the options table in README.md so they are discoverable alongside the other variables; include entries with their REQUIRED status, a short DESCRIPTION matching how they are used in the provider (e.g., "Path to the private key file used for SSH" for KEY_FILE and "Private key contents or path used for SSH authentication" for KEY), and sensible DEFAULT values or leave blank if none, referencing the existing table format and the same terminology used for other entries to match the definitions in hack/provider/main.go where KEY_FILE and KEY are parsed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@README.md`:
- Around line 136-152: Add the missing provider options KEY_FILE and KEY to the
options table in README.md so they are discoverable alongside the other
variables; include entries with their REQUIRED status, a short DESCRIPTION
matching how they are used in the provider (e.g., "Path to the private key file
used for SSH" for KEY_FILE and "Private key contents or path used for SSH
authentication" for KEY), and sensible DEFAULT values or leave blank if none,
referencing the existing table format and the same terminology used for other
entries to match the definitions in hack/provider/main.go where KEY_FILE and KEY
are parsed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e49425c3-9a74-40ee-9a19-1bdc3df08093
📒 Files selected for processing (4)
README.mdhack/provider/main.gopkg/gcloud/gcloud.gopkg/options/options.go
8469012 to
7812e45
Compare
Enable a developer that never used Google Cloud to start running workspaces on it - fix: typos - chore: remove unused parameters - docs: documentation enhancements - feat: take provider name into account for environment lookup - feat: elevate undocumented Google Cloud key environment variables to provider options
I believe that documentation should be complete enough for a developer that never used Google Cloud to be able to start running workspaces on it without further research :)
Summary by CodeRabbit
New Features
Documentation