Skip to content

Commit f073952

Browse files
Merge pull request migtools#61 from shubham-pampattiwar/install-ux
Enhance installation experience with improved PATH handling
2 parents b5a75f0 + 072c6df commit f073952

File tree

2 files changed

+62
-12
lines changed

2 files changed

+62
-12
lines changed

Makefile

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,37 +102,58 @@ install: build ## Build and install the kubectl plugin to ~/.local/bin (no sudo
102102
cp $$binary_name $(INSTALL_PATH)/
103103
@echo "✅ Installed to $(INSTALL_PATH)"
104104
@echo ""
105-
@PATH_UPDATED=false; \
105+
@echo "🔍 Checking PATH configuration..."
106+
@PATH_NEEDS_UPDATE=false; \
107+
PATH_UPDATED=false; \
106108
PATH_IN_CONFIG=false; \
109+
CURRENT_SESSION_NEEDS_UPDATE=false; \
110+
\
107111
if [[ ":$$PATH:" != *":$(INSTALL_PATH):"* ]]; then \
112+
PATH_NEEDS_UPDATE=true; \
113+
CURRENT_SESSION_NEEDS_UPDATE=true; \
114+
echo "⚠️ $(INSTALL_PATH) is not in your current PATH"; \
115+
\
108116
if [[ "$$SHELL" == */zsh* ]] && [[ -f "$$HOME/.zshrc" ]]; then \
109-
if ! grep -q "/.local/bin" "$$HOME/.zshrc" 2>/dev/null; then \
117+
if ! grep -q '^[[:space:]]*export[[:space:]]*PATH.*\.local/bin' "$$HOME/.zshrc" 2>/dev/null; then \
110118
echo 'export PATH="$$HOME/.local/bin:$$PATH"' >> "$$HOME/.zshrc"; \
111-
echo "✅ Added to ~/.zshrc"; \
119+
echo "✅ Added PATH export to ~/.zshrc"; \
112120
PATH_UPDATED=true; \
113121
else \
114-
echo "ℹ️ Already configured in ~/.zshrc"; \
122+
echo "ℹ️ PATH export already exists in ~/.zshrc"; \
115123
PATH_IN_CONFIG=true; \
116124
fi; \
117125
elif [[ "$$SHELL" == */bash* ]] && [[ -f "$$HOME/.bashrc" ]]; then \
118-
if ! grep -q "/.local/bin" "$$HOME/.bashrc" 2>/dev/null; then \
126+
if ! grep -q '^[[:space:]]*export[[:space:]]*PATH.*\.local/bin' "$$HOME/.bashrc" 2>/dev/null; then \
119127
echo 'export PATH="$$HOME/.local/bin:$$PATH"' >> "$$HOME/.bashrc"; \
120-
echo "✅ Added to ~/.bashrc"; \
128+
echo "✅ Added PATH export to ~/.bashrc"; \
121129
PATH_UPDATED=true; \
122130
else \
123-
echo "ℹ️ Already configured in ~/.bashrc"; \
131+
echo "ℹ️ PATH export already exists in ~/.bashrc"; \
124132
PATH_IN_CONFIG=true; \
125133
fi; \
126134
else \
127-
echo "⚠️ Add to your shell config: export PATH=\"$(INSTALL_PATH):$$PATH\""; \
135+
echo "⚠️ Unsupported shell or config file not found"; \
136+
echo " Manually add to your shell config: export PATH=\"$(INSTALL_PATH):$$PATH\""; \
128137
PATH_UPDATED=true; \
129138
fi; \
130139
else \
131-
echo "PATH already configured"; \
140+
echo "$(INSTALL_PATH) is already in PATH"; \
132141
fi; \
142+
\
133143
echo ""; \
134-
if [[ "$$PATH_UPDATED" == "true" ]] || [[ "$$PATH_IN_CONFIG" == "true" ]]; then \
135-
echo "🔄 Restart terminal or run: source ~/.zshrc"; \
144+
if [[ "$$CURRENT_SESSION_NEEDS_UPDATE" == "true" ]]; then \
145+
echo "🔧 To use kubectl oadp in this terminal session:"; \
146+
echo " export PATH=\"$(INSTALL_PATH):$$PATH\""; \
147+
echo ""; \
148+
echo "🔄 For future sessions:"; \
149+
if [[ "$$PATH_UPDATED" == "true" ]]; then \
150+
echo " Restart your terminal or run: source ~/.zshrc"; \
151+
elif [[ "$$PATH_IN_CONFIG" == "true" ]]; then \
152+
echo " Restart your terminal or run: source ~/.zshrc"; \
153+
echo " (PATH export exists but may need shell restart)"; \
154+
else \
155+
echo " Add the PATH export to your shell configuration file"; \
156+
fi; \
136157
fi; \
137158
echo ""; \
138159
echo "📋 Configuration:"; \
@@ -189,6 +210,35 @@ install: build ## Build and install the kubectl plugin to ~/.local/bin (no sudo
189210
$(INSTALL_PATH)/$$binary_name client config set namespace=$$NAMESPACE 2>/dev/null || true; \
190211
echo "✅ Client config initialized"; \
191212
echo ""; \
213+
echo "🧪 Verifying installation..."; \
214+
if [[ "$$CURRENT_SESSION_NEEDS_UPDATE" == "true" ]]; then \
215+
echo " Temporarily updating PATH for verification"; \
216+
if PATH="$(INSTALL_PATH):$$PATH" command -v kubectl >/dev/null 2>&1; then \
217+
if PATH="$(INSTALL_PATH):$$PATH" kubectl plugin list 2>/dev/null | grep -q "kubectl-oadp"; then \
218+
echo "✅ Installation verified: kubectl oadp plugin is accessible"; \
219+
PATH="$(INSTALL_PATH):$$PATH" kubectl oadp version 2>/dev/null || echo " (Note: version command requires cluster access)"; \
220+
else \
221+
echo "❌ Installation verification failed: kubectl oadp plugin not found"; \
222+
echo " Try running: export PATH=\"$(INSTALL_PATH):$$PATH\""; \
223+
fi; \
224+
else \
225+
echo "⚠️ kubectl not found - cannot verify plugin accessibility"; \
226+
echo " Plugin installed to: $(INSTALL_PATH)/$$binary_name"; \
227+
fi; \
228+
else \
229+
if command -v kubectl >/dev/null 2>&1; then \
230+
if kubectl plugin list 2>/dev/null | grep -q "kubectl-oadp"; then \
231+
echo "✅ Installation verified: kubectl oadp plugin is accessible"; \
232+
kubectl oadp version 2>/dev/null || echo " (Note: version command requires cluster access)"; \
233+
else \
234+
echo "❌ Installation verification failed: kubectl oadp plugin not found"; \
235+
fi; \
236+
else \
237+
echo "⚠️ kubectl not found - cannot verify plugin accessibility"; \
238+
echo " Plugin installed to: $(INSTALL_PATH)/$$binary_name"; \
239+
fi; \
240+
fi; \
241+
echo ""; \
192242
echo "📋 Next steps:"; \
193243
echo " 1. Test admin commands: kubectl oadp backup get"; \
194244
echo " 2. Test non-admin commands: kubectl oadp nonadmin backup get"; \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ make install ASSUME_DEFAULT=true # Use default namespace (no detection)
6262
make install VELERO_NAMESPACE=custom # Use specific namespace (no detection)
6363
```
6464

65-
**💡 Important:** After installation, you may need to refresh your terminal or run `source ~/.zshrc` (or `~/.bashrc`) for the `kubectl oadp` command to work.
65+
**💡 Path Setup:** The installer will automatically check your PATH and guide you through any necessary setup. If `kubectl oadp` doesn't work immediately after installation, follow the on-screen instructions to update your PATH for the current session or restart your terminal.
6666

6767
You can set the velero namespace afterwards using the oadp client command
6868

0 commit comments

Comments
 (0)