Fixed bash completions #6499

Merged
merged 2 commits into from Oct 26, 2016

Conversation

Projects
None yet
3 participants
Contributor

dimitern commented Oct 25, 2016

Makefile's install-etc was not installing juju-version
Changed the completions to work for a juju binary, built
from source, as well as the one from the juju-2.0 package.

See bug http://pad.lv/1622775 for more details
(PR was intended to fix it, but simply improves CLI UX)

QA steps:

  1. make install-etc && source /etc/bash_completion
  2. juju boo[tab]tstrap
  3. juju de[tab]p[tab]loy ubuntu
  4. juju status [tab]u[tab]buntu/0

Thanks! See comments for a couple of suggested changes.

Makefile
@@ -99,7 +99,8 @@ endif
# Install bash_completion
install-etc:
@echo Installing bash completion
- @sudo install -o root -g root -m 644 etc/bash_completion.d/juju2 /etc/bash_completion.d
+ @sudo install -o root -g root -m 644 etc/bash_completion.d/juju-2.0 /etc/bash_completion.d
+ @sudo install -o root -g root -m 644 etc/bash_completion.d/juju-version /etc/bash_completion.d
@bz2

bz2 Oct 25, 2016

Contributor

These locations should probably be updated to the new /usr/share/bash-completion/bash_completion location. The split between /etc and there is also the cause of much confusion.

@dimitern

dimitern Oct 25, 2016

Contributor

👍 Done.

etc/bash_completion.d/juju-2.0
+ for k, v in j.get("applications", {}).items():
+ all_units.extend(v.get("units", {}).keys())
+ print ("\n".join([unit + trail for unit in all_units]))
+except: pass
@bz2

bz2 Oct 25, 2016

Contributor

I think we don't want try:/except: pass - yes the kipple when things break is bad, but things being broken with no feedback as to why is worse I feel.

@dimitern

dimitern Oct 25, 2016

Contributor

👍 Dropped (all places).

+
+# Detect juju built from source (highest priority)
+if [ -x "$GOPATH/bin/juju" ]; then
+ export _juju_cmd_JUJU_2_0="$GOPATH/bin/juju"
@bz2

bz2 Oct 25, 2016

Contributor

This seems good. Might mean developers see packaging issues less, but in exchange will be catching their own problems instead.

@dimitern

dimitern Oct 25, 2016

Contributor

Yeah, and makes completions work for devs as well as other users :)

bz2 approved these changes Oct 25, 2016

Contributor

dimitern commented Oct 26, 2016

$$merge$$

Contributor

jujubot commented Oct 26, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit c51929f into juju:develop Oct 26, 2016

1 check passed

github-check-merge-juju Built PR, ran unit tests, and tested LXD deploy.
Details

@dimitern dimitern deleted the dimitern:lp-1622775-bash-completion-traceback branch Oct 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment