-
Notifications
You must be signed in to change notification settings - Fork 54
Add a feature to the tailscale devcontainer to auto-set the operator #58
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?
Conversation
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.
Pull Request Overview
This PR adds functionality to automatically set a Tailscale operator in devcontainers. The feature allows users to specify an operator value that can be a literal username or the special value "$USER" which resolves to the current devcontainer user.
Key changes:
- Added operator parameter handling with special "$USER" expansion logic
- Enhanced the tailscale up command to include operator argument when specified
- Added test scenario for the new operator functionality
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/tailscale/tailscaled-devcontainer-start.sh | Added operator parameter processing and integrated operator argument into tailscale up command |
test/tailscale/scenarios.json | Added test scenario for operator functionality using "$USER" value |
test/tailscale/tailscale_operator.sh | Added test script file (appears to be a placeholder) |
test/tailscale/tailscale_operator.sh
Outdated
@@ -0,0 +1 @@ | |||
test.sh |
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.
The test file contains only 'test.sh' which appears to be a placeholder. This should contain actual test logic for the operator functionality.
test.sh | |
#!/bin/bash | |
# Basic test for Tailscale operator functionality | |
set -e | |
# Path to the operator binary (update as needed) | |
OPERATOR_BIN="./tailscale-operator" | |
# Check if the operator binary exists | |
if [ ! -f "$OPERATOR_BIN" ]; then | |
echo "FAIL: Operator binary not found at $OPERATOR_BIN" | |
exit 1 | |
fi | |
# Check if the operator binary is executable | |
if [ ! -x "$OPERATOR_BIN" ]; then | |
echo "FAIL: Operator binary is not executable" | |
exit 1 | |
fi | |
# Run the operator with --version and check output | |
VERSION_OUTPUT=$("$OPERATOR_BIN" --version 2>&1) | |
if [[ "$VERSION_OUTPUT" == "" ]]; then | |
echo "FAIL: Operator did not return a version" | |
exit 1 | |
fi | |
echo "PASS: Operator binary exists, is executable, and returns version:" | |
echo "$VERSION_OUTPUT" | |
exit 0 |
Copilot uses AI. Check for mistakes.
# This is done before the sudo switchover so we have the actual | ||
# user persisted. | ||
if [[ -n "$OPERATOR" ]]; then | ||
if [[ "$OPERATOR" == "\$USER" ]]; then |
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.
The string comparison uses escaped dollar sign '$USER' but the test scenario uses '$USER' without escaping. This comparison will never match the actual input from scenarios.json.
if [[ "$OPERATOR" == "\$USER" ]]; then | |
if [[ "$OPERATOR" == '$USER' ]]; then |
Copilot uses AI. Check for mistakes.
operatorarg="--operator=${OPERATOR}" | ||
fi | ||
|
||
/usr/local/bin/tailscale up --accept-routes --authkey="$auth_key" $hostnamearg $operatorarg |
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.
The variables $hostnamearg and $operatorarg should be quoted to prevent word splitting and glob expansion issues if they contain spaces or special characters.
/usr/local/bin/tailscale up --accept-routes --authkey="$auth_key" $hostnamearg $operatorarg | |
/usr/local/bin/tailscale up --accept-routes --authkey="$auth_key" "$hostnamearg" "$operatorarg" |
Copilot uses AI. Check for mistakes.
f95bc2e
to
ee705c6
Compare
Gah, I remember debugging this awful test framework before, and I'm hitting an issue I experienced then I think, but it's so opaque and has no local execution story |
I feel that! I tried to see if I could run it locally and all but gave up. |
Is codespace always a single-user environment? Maybe we can just change this in tailscaled so setting |
I think this works?
I'd like to have my codespace user automatically set as a tailscale operator.