-
Notifications
You must be signed in to change notification settings - Fork 141
feat(claude-code): add managed_settings input for policy delivery via /etc/claude-code #863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4b83931
6745a0b
7bd449d
3b399bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ ARG_CLAUDE_BINARY_PATH="$${ARG_CLAUDE_BINARY_PATH//\$HOME/$HOME}" | |
| ARG_MCP=$(echo -n '${ARG_MCP}' | base64 -d) | ||
| ARG_MCP_CONFIG_REMOTE_PATH=$(echo -n '${ARG_MCP_CONFIG_REMOTE_PATH}' | base64 -d) | ||
| ARG_ENABLE_AI_GATEWAY='${ARG_ENABLE_AI_GATEWAY}' | ||
| ARG_MANAGED_SETTINGS_JSON=$(echo -n '${ARG_MANAGED_SETTINGS_JSON}' | base64 -d) | ||
|
|
||
| export PATH="$${ARG_CLAUDE_BINARY_PATH}:$PATH" | ||
|
|
||
|
|
@@ -29,6 +30,7 @@ printf "ARG_CLAUDE_BINARY_PATH: %s\n" "$${ARG_CLAUDE_BINARY_PATH}" | |
| printf "ARG_MCP: %s\n" "$${ARG_MCP}" | ||
| printf "ARG_MCP_CONFIG_REMOTE_PATH: %s\n" "$${ARG_MCP_CONFIG_REMOTE_PATH}" | ||
| printf "ARG_ENABLE_AI_GATEWAY: %s\n" "$${ARG_ENABLE_AI_GATEWAY}" | ||
| printf "ARG_MANAGED_SETTINGS_JSON: %s\n" "$${ARG_MANAGED_SETTINGS_JSON}" | ||
|
|
||
| echo "--------------------------------" | ||
|
|
||
|
|
@@ -144,6 +146,32 @@ function setup_claude_configurations() { | |
|
|
||
| } | ||
|
|
||
| function write_managed_settings() { | ||
| if [ -z "$${ARG_MANAGED_SETTINGS_JSON}" ]; then | ||
| return | ||
| fi | ||
|
|
||
| local dropin_dir="/etc/claude-code/managed-settings.d" | ||
| local target="$${dropin_dir}/10-coder.json" | ||
|
|
||
| if ! echo "$${ARG_MANAGED_SETTINGS_JSON}" | jq empty 2> /dev/null; then | ||
| echo "Warning: managed_settings is not valid JSON, skipping policy write" | ||
| return | ||
| fi | ||
|
|
||
| if command_exists sudo; then | ||
| sudo mkdir -p "$${dropin_dir}" | ||
| echo "$${ARG_MANAGED_SETTINGS_JSON}" | sudo tee "$${target}" > /dev/null | ||
| sudo chmod 0644 "$${target}" | ||
| else | ||
| mkdir -p "$${dropin_dir}" | ||
| echo "$${ARG_MANAGED_SETTINGS_JSON}" > "$${target}" | ||
| chmod 0644 "$${target}" | ||
| fi | ||
|
|
||
| echo "Wrote Claude Code managed settings to $${target}" | ||
| } | ||
|
|
||
| function configure_standalone_mode() { | ||
| echo "Configuring Claude Code for standalone mode..." | ||
|
|
||
|
|
@@ -158,8 +186,6 @@ function configure_standalone_mode() { | |
| echo "Updating existing Claude configuration at $${claude_config}" | ||
|
|
||
| jq '.autoUpdaterStatus = "disabled" | | ||
| .autoModeAccepted = true | | ||
| .bypassPermissionsModeAccepted = true | | ||
|
Comment on lines
-161
to
-162
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did we remove this? AFAIK, these were needed for skipping the welcome wizard.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the reason they are removing them is because you are able to set these same behaviors through managed settings. Which is probably better than us pre-seeding it for all users in this hacky unobservable way. Although I think we should probably test this a bit more before committing since we want to make sure this won't introduce too big of a behavioral shift in the module for users who have this running in a task workflow.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This serves the standalone mode, which we need to set anyway when a user provides a
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You know I think you are right here. These are mostly just for the dialogue boxes unless they get suppressed now somehow. |
||
| .hasAcknowledgedCostThreshold = true | | ||
| .hasCompletedOnboarding = true' \ | ||
| "$${claude_config}" > "$${claude_config}.tmp" && mv "$${claude_config}.tmp" "$${claude_config}" | ||
|
|
@@ -168,8 +194,6 @@ function configure_standalone_mode() { | |
| cat > "$${claude_config}" << EOF | ||
| { | ||
| "autoUpdaterStatus": "disabled", | ||
| "autoModeAccepted": true, | ||
| "bypassPermissionsModeAccepted": true, | ||
| "hasAcknowledgedCostThreshold": true, | ||
| "hasCompletedOnboarding": true | ||
| } | ||
|
|
@@ -189,4 +213,5 @@ EOF | |
|
|
||
| install_claude_code_cli | ||
| setup_claude_configurations | ||
| write_managed_settings | ||
| configure_standalone_mode | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matifali for reference this is how you would pass similar behavior through managed settings rather than pre-seeding it.
So essentially someone could set
defaultMode=autoand same with the rest for claude-code running for tasks and this would work over even thesettings.json