When using command completion, errors will appear in bash command completion due to oc-cluster.bash using the absolute and hard coded path from the user who executed oc-cluster completion bash.
For example, as root:
# ./oc-cluster completion bash
...
commands="up down destroy list status show ssh console plugin-list plugin-install plugin-uninstall -h --help"
profiles=$(ls -d /root/.oc/profiles/*/ | xargs -L1 basename)
boolean_args="--create-machine= --forward-ports= --metrics= --skip-registry-check= --use-existing-config="
...
This is because the assignment of profiles in the heredoc of the completion function uses the following assignment:
$OPENSHIFT_PROFILES_DIR/*/ is expanded to the value of the variable as it is defined by the oc-cluster command itself. By default, this is the user's home directory.
If the profiles directory is empty, the ls command will fail and xargs will pass 0 arguments to basename.
The profiles assignment should instead define OPENSHIFT_PROFILES_DIR in the same manner that oc-cluster does so that it is more generic along with setting profiles to an empty string in the event that no profiles are found. For example:
When using command completion, errors will appear in bash command completion due to oc-cluster.bash using the absolute and hard coded path from the user who executed
oc-cluster completion bash
.For example, as root:
This is because the assignment of profiles in the heredoc of the completion function uses the following assignment:
This assignment carries 2 problems.
The profiles assignment should instead define OPENSHIFT_PROFILES_DIR in the same manner that oc-cluster does so that it is more generic along with setting profiles to an empty string in the event that no profiles are found. For example:
I submitted #96 to address both of these problem.