-
Notifications
You must be signed in to change notification settings - Fork 7
Add missing gke-gcloud-auth-plugin component for Google Cloud SDK #167
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
Changes from all commits
0c0df31
a504347
1a6570e
c6b009e
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 |
|---|---|---|
|
|
@@ -142,6 +142,71 @@ system-install-mkcert: | |
| mkcert -install | ||
| echo "mkcert installed successfully!" | ||
|
|
||
| # Configure Google Cloud SDK and install required components. | ||
| [group('system')] | ||
| system-gcloud-reconfigure: | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| echo "Configuring Google Cloud SDK..." | ||
|
|
||
| # Install gcloud-cli via Homebrew if not already installed | ||
| if ! brew list --cask google-cloud-sdk >/dev/null 2>&1; then | ||
| echo "Installing Google Cloud SDK via Homebrew..." | ||
| brew install --cask google-cloud-sdk | ||
| fi | ||
|
|
||
| # Get the Homebrew prefix | ||
| HOMEBREW_PREFIX=$(brew --prefix) | ||
|
|
||
| # Source the gcloud environment | ||
| if [[ -f "${HOMEBREW_PREFIX}/share/google-cloud-sdk/path.zsh.inc" ]]; then | ||
| echo "Sourcing Google Cloud SDK environment..." | ||
| # shellcheck source=/dev/null | ||
| source "${HOMEBREW_PREFIX}/share/google-cloud-sdk/path.zsh.inc" | ||
| else | ||
| echo "❌ Google Cloud SDK path script not found at ${HOMEBREW_PREFIX}/share/google-cloud-sdk/path.zsh.inc" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Install gke-gcloud-auth-plugin component | ||
| echo "Installing gke-gcloud-auth-plugin component..." | ||
| gcloud components install gke-gcloud-auth-plugin --quiet | ||
|
|
||
| # Verify installation | ||
| echo "Verifying gke-gcloud-auth-plugin installation..." | ||
| if gke-gcloud-auth-plugin --version >/dev/null 2>&1; then | ||
| echo "✅ gke-gcloud-auth-plugin installed successfully!" | ||
| gke-gcloud-auth-plugin --version | ||
| else | ||
| echo "❌ Failed to verify gke-gcloud-auth-plugin installation" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Add Google Cloud SDK paths to zshrc if not already present | ||
| ZSHRC_FILE="${HOME}/.zshrc" | ||
| echo "Updating ${ZSHRC_FILE} with Google Cloud SDK configuration..." | ||
|
|
||
| # Create zshrc if it doesn't exist | ||
| touch "${ZSHRC_FILE}" | ||
|
|
||
| # 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 | ||
|
Comment on lines
+192
to
+205
|
||
|
|
||
| echo "🎉 Google Cloud SDK reconfiguration completed successfully!" | ||
| echo "💡 You may need to restart your terminal or run 'source ~/.zshrc' to use the updated PATH" | ||
|
|
||
| # System cleanup to free up disk space (Homebrew and Docker). | ||
| [group('system')] | ||
| system-cleanup: | ||
|
|
||
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.
Using
lineinfilewith a loop to add multiple related lines can result in non-idempotent behavior and scattered placement if the file is modified externally. Consider usingblockinfileinstead to manage these Google Cloud SDK configuration lines as a single block, which ensures they remain together and can be updated atomically.