Add missing gke-gcloud-auth-plugin component for Google Cloud SDK#167
Conversation
Co-authored-by: paolomainardi <8747+paolomainardi@users.noreply.github.com>
Co-authored-by: paolomainardi <8747+paolomainardi@users.noreply.github.com>
|
/describe |
|
/review |
|
/improve |
PR Code Suggestions ✨Latest suggestions up to c6b009e
Previous suggestionsSuggestions up to commit c6b009e
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds automated installation and configuration of the gke-gcloud-auth-plugin component for Google Cloud SDK to resolve GKE authentication issues after fresh Sparkdock provisioning.
- Adds Ansible automation to install the GKE auth plugin component when Google Cloud SDK is provisioned
- Implements a manual reconfiguration task via SparkJust for troubleshooting scenarios
- Updates documentation with Google Cloud SDK configuration instructions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ansible/macos/macos/base.yml | Adds Ansible block to automatically install gke-gcloud-auth-plugin component and configure .zshrc when google-cloud-sdk cask is installed |
| sjust/recipes/00-default.just | Implements system-gcloud-reconfigure task for manual Google Cloud SDK setup and component installation |
| README.md | Documents Google Cloud SDK configuration capabilities and usage instructions |
| lineinfile: | ||
| path: "{{ ansible_env.HOME }}/.zshrc" | ||
| line: "{{ item }}" | ||
| create: yes | ||
| backup: yes | ||
| loop: | ||
| - "# The next line updates PATH for the Google Cloud SDK." | ||
| - "if [ -f '{{ homebrew_prefix }}/share/google-cloud-sdk/path.zsh.inc' ]; then . '{{ homebrew_prefix }}/share/google-cloud-sdk/path.zsh.inc'; fi" | ||
| - "" | ||
| - "# The next line enables shell command completion for gcloud." | ||
| - "if [ -f '{{ homebrew_prefix }}/share/google-cloud-sdk/completion.zsh.inc' ]; then . '{{ homebrew_prefix }}/share/google-cloud-sdk/completion.zsh.inc'; fi" |
There was a problem hiding this comment.
Using lineinfile with a loop to add multiple related lines can result in non-idempotent behavior and scattered placement if the file is modified externally. Consider using blockinfile instead to manage these Google Cloud SDK configuration lines as a single block, which ensures they remain together and can be updated atomically.
| lineinfile: | |
| path: "{{ ansible_env.HOME }}/.zshrc" | |
| line: "{{ item }}" | |
| create: yes | |
| backup: yes | |
| loop: | |
| - "# The next line updates PATH for the Google Cloud SDK." | |
| - "if [ -f '{{ homebrew_prefix }}/share/google-cloud-sdk/path.zsh.inc' ]; then . '{{ homebrew_prefix }}/share/google-cloud-sdk/path.zsh.inc'; fi" | |
| - "" | |
| - "# The next line enables shell command completion for gcloud." | |
| - "if [ -f '{{ homebrew_prefix }}/share/google-cloud-sdk/completion.zsh.inc' ]; then . '{{ homebrew_prefix }}/share/google-cloud-sdk/completion.zsh.inc'; fi" | |
| blockinfile: | |
| path: "{{ ansible_env.HOME }}/.zshrc" | |
| create: yes | |
| backup: yes | |
| marker: "# {mark} ANSIBLE MANAGED BLOCK: Google Cloud SDK" | |
| block: | | |
| # The next line updates PATH for the Google Cloud SDK. | |
| if [ -f '{{ homebrew_prefix }}/share/google-cloud-sdk/path.zsh.inc' ]; then . '{{ homebrew_prefix }}/share/google-cloud-sdk/path.zsh.inc'; fi | |
| # The next line enables shell command completion for gcloud. | |
| if [ -f '{{ homebrew_prefix }}/share/google-cloud-sdk/completion.zsh.inc' ]; then . '{{ homebrew_prefix }}/share/google-cloud-sdk/completion.zsh.inc'; fi |
| # Check if Google Cloud SDK lines are already in zshrc | ||
| if ! grep -q "google-cloud-sdk/path.zsh.inc" "${ZSHRC_FILE}"; then | ||
| { | ||
| echo "" | ||
| echo "# The next line updates PATH for the Google Cloud SDK." | ||
| echo "if [ -f '${HOMEBREW_PREFIX}/share/google-cloud-sdk/path.zsh.inc' ]; then . '${HOMEBREW_PREFIX}/share/google-cloud-sdk/path.zsh.inc'; fi" | ||
| echo "" | ||
| echo "# The next line enables shell command completion for gcloud." | ||
| echo "if [ -f '${HOMEBREW_PREFIX}/share/google-cloud-sdk/completion.zsh.inc' ]; then . '${HOMEBREW_PREFIX}/share/google-cloud-sdk/completion.zsh.inc'; fi" | ||
| } >> "${ZSHRC_FILE}" | ||
| echo "✅ Added Google Cloud SDK configuration to ${ZSHRC_FILE}" | ||
| else | ||
| echo "✅ Google Cloud SDK configuration already present in ${ZSHRC_FILE}" | ||
| fi |
There was a problem hiding this comment.
This code includes an unnecessary else branch that only provides informational output. According to the project shell script standards, when checking if things exist, avoid using else branches unless necessary. Remove the else block and keep only the if condition for adding the configuration.
|
PR Description updated to latest commit (c6b009e) |
PR Reviewer Guide 🔍(Review updated until commit c6b009e)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit c6b009e |
User description
This PR resolves the issue where the
gke-gcloud-auth-plugincomponent was missing after fresh Sparkdock provisioning, preventing proper GKE authentication.Changes Made
Ansible Integration
gke-gcloud-auth-plugincomponent after Google Cloud SDK cask installation.zshrcconfiguration using Ansible'slineinfilemodule to include Google Cloud SDK paths and shell completionSparkJust Task
system-gcloud-reconfiguretask in the 'system' group for manual reconfigurationDocumentation
Usage
After provisioning, users can verify the plugin is installed:
For manual reconfiguration:
The implementation ensures that both fresh installations and existing setups can properly authenticate with GKE clusters without manual intervention.
Fixes #166.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
PR Type
Enhancement
Description
Add automated
gke-gcloud-auth-plugininstallation during provisioningImplement manual reconfiguration task for Google Cloud SDK
Configure shell environment with proper PATH and completion
Add comprehensive documentation for Google Cloud SDK setup
Changes walkthrough 📝
README.md
Document Google Cloud SDK configurationREADME.md
system-gcloud-reconfigurecommand and verification stepsbase.yml
Automate Google Cloud SDK plugin installationansible/macos/macos/base.yml
gke-gcloud-auth-plugincomponent.zshrcconfiguration with PATH and completion setup00-default.just
Add manual Google Cloud SDK reconfiguration tasksjust/recipes/00-default.just
system-gcloud-reconfiguretask for manual Google Cloud SDKsetup
.zshrcupdates for PATH and completion integration