Commit 9d005412 authored by nimrod's avatar nimrod
Browse files

Updates to binaries, vendored filed.

- Add toolbox script, bash completion.
- Better ansible-local in Makefile (match shell alias).
- Delete gcloud SDK bash completion, the mirror in github is gone.
- Update to newer version of binaries and vendored files.
parent 639bb2d4
Loading
Loading
Loading
Loading
+0 −82
Original line number Diff line number Diff line
_python_argcomplete() {
    local IFS=''
    local prefix=
    typeset -i n
    (( lastw=${#COMP_WORDS[@]} -1))
    if [[ ${COMP_WORDS[lastw]} == --*=* ]]; then
        # for bash version 3.2
        flag=${COMP_WORDS[lastw]%%=*}
        set -- "$1" "$2" '='
    elif [[ $3 == '=' ]]; then
      flag=${COMP_WORDS[-3]}
    fi
    if [[ $3 == ssh  && $2 == *@* ]] ;then
        # handle ssh user@instance specially
        prefix=${2%@*}@
        COMP_LINE=${COMP_LINE%$2}"${2#*@}"
    elif [[ $3 == '=' ]] ; then
        # handle --flag=value
        prefix=$flag=$2
        line=${COMP_LINE%$prefix};
        COMP_LINE=$line${prefix/=/ };
        prefix=
    fi
    if [[ $2 == *,* ]]; then
          # handle , separated list
          prefix=${2%,*},
          set -- "$1" "${2#$prefix}" "$3"
          COMP_LINE==${COMP_LINE%$prefix*}$2
    fi
    # Treat --flag=<TAB> as --flag <TAB> to work around bash 4.x bug
    if [[ ${COMP_LINE} == *=  && ${COMP_WORDS[-2]} == --* ]]; then
        COMP_LINE=${COMP_LINE%=}' '
    fi
    COMPREPLY=( $(IFS="$IFS"                   COMP_LINE="$COMP_LINE"                   COMP_POINT="$COMP_POINT"                   _ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS"                   _ARGCOMPLETE=1                   "$1" 8>&1 9>&2 1>/dev/null 2>/dev/null) )
    if [[ $? != 0 ]]; then
        unset COMPREPLY
        return
    fi
    if [[ $prefix != '' ]]; then
        for ((n=0; n < ${#COMPREPLY[@]}; n++)); do
            COMPREPLY[$n]=$prefix${COMPREPLY[$n]}
        done
    fi
    for ((n=0; n < ${#COMPREPLY[@]}; n++)); do
        match=${COMPREPLY[$n]%' '}
        if [[ $match != '' ]]; then
            COMPREPLY[$n]=${match//? /' '}' '
        fi
    done
    # if flags argument has a single completion and ends in  '= ', delete ' '
    if [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} == -* &&
          ${COMPREPLY[0]} == *'= ' ]]; then
        COMPREPLY[0]=${COMPREPLY[0]%' '}
    fi
}
complete -o nospace -F _python_argcomplete "gcloud"

_completer() {
    command=$1
    name=$2
    eval '[[ "$'"${name}"'_COMMANDS" ]] || '"${name}"'_COMMANDS="$('"${command}"')"'
    set -- $COMP_LINE
    shift
    while [[ $1 == -* ]]; do
          shift
    done
    [[ $2 ]] && return
    grep -q "${name}\s*$" <<< $COMP_LINE &&
        eval 'COMPREPLY=($'"${name}"'_COMMANDS)' &&
        return
    [[ "$COMP_LINE" == *" " ]] && return
    [[ $1 ]] &&
        eval 'COMPREPLY=($(echo "$'"${name}"'_COMMANDS" | grep ^'"$1"'))'
}

unset bq_COMMANDS
_bq_completer() {
    _completer "CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK=1 bq help | grep '^[^ ][^ ]*  ' | sed 's/ .*//'" bq
}

complete -F _bq_completer bq
complete -o nospace -F _python_argcomplete gsutil
+1 −0
Original line number Diff line number Diff line
@@ -87,3 +87,4 @@ repos:
    rev: v0.13.0
    hooks:
      - id: detect-secrets
        exclude: rabbitmqadmin
+10 −10
Original line number Diff line number Diff line
@@ -531,6 +531,12 @@ class Management:
    def delete(self, path):
        return self.http("DELETE", "%s/api%s" % (self.options.path_prefix, path), "")

    def __initialize_connection(self, hostname, port):
        if self.options.ssl:
            return self.__initialize_https_connection(hostname, port)
        else:
            return httplib.HTTPConnection(hostname, port, timeout=self.options.request_timeout)

    def __initialize_https_connection(self, hostname, port):
        # Python 2.7.9+
        if hasattr(ssl, 'create_default_context'):
@@ -564,13 +570,7 @@ class Management:
        return ssl_ctx

    def http(self, method, path, body):
        if self.options.ssl:
            conn = self.__initialize_https_connection(self.options.hostname,
                                                      self.options.port)
        else:
            conn = httplib.HTTPConnection(self.options.hostname,
                                          self.options.port,
                                          timeout=self.options.request_timeout)
        conn = self.__initialize_connection(self.options.hostname, self.options.port)
        auth = (self.options.username + ":" + self.options.password)

        headers = {"Authorization": "Basic " + b64(auth)}
@@ -605,8 +605,8 @@ class Management:
            self.options.hostname = host
            self.options.port = int(port)
            return self.http(method, url.path + '?' + url.query, body)
        if resp.status < 200 or resp.status > 400:
            raise Exception("Received %d %s for path %s\n%s"
        if resp.status > 400:
            raise Exception("Received response %d %s for path %s\n%s"
                            % (resp.status, resp.reason, path, resp.read()))
        return resp.read().decode('utf-8')

@@ -686,7 +686,7 @@ class Management:
        if self.options.vhost:
            uri += "/%s" % quote_plus(self.options.vhost)
        self.post(uri, definitions)
        self.verbose("Imported definitions for %s from \"%s\""
        self.verbose("Uploaded definitions from \"%s\" to %s. The import process may take some time. Consult server logs to track progress."
                     % (self.options.hostname, path))

    def invoke_list(self):

Documents/bin/toolbox

0 → 100755
+2498 −0

File added.

Preview size limit exceeded, changes collapsed.

+28 −23
Original line number Diff line number Diff line
@@ -8,9 +8,10 @@ goarch != go env GOARCH
ssh_configs != find ".ssh/config.d/" -type f \! -name '.*' | sort
curl = curl --location --silent --fail
download = $(curl) --output $@
ansible-local = ansible localhost -c local -i localhost, -e "ansible_python_interpreter=$$(which python3)"

all: binaries vendored generated
vendored: .config/pythonrc.py .bash_completion.d/aws .bash_completion.d/docker-compose .bash_completion.d/docker-machine.bash .bash_completion.d/docker-machine.bash .travis/travis.sh .bash_completion.d/molecule Documents/bin/rabbitmqadmin .bash_completion.d/google-cloud-sdk
vendored: .config/pythonrc.py .bash_completion.d/aws .bash_completion.d/docker-compose .bash_completion.d/docker-machine.bash .bash_completion.d/docker-machine.bash .travis/travis.sh .bash_completion.d/molecule Documents/bin/rabbitmqadmin Documents/bin/toolbox .bash_completion.d/toolbox
generated: .ssh/config .bash_completion.d/helm .bash_completion.d/kops .bash_completion.d/kubectl .bash_completion.d/kompose .bash_completion.d/minikube .bash_completion.d/pipenv .bash_completion.d/pandoc .bash_completion.d/skaffold .bash_completion.d/rabbitmqadmin .ssh/localhost .ssh/localhost.pub .ssh/authorized_keys .bash_completion.d/minishift .bash_completion.d/oc .bash_completion.d/poetry
binaries: $(DESTDIR)/share/bfg/bfg.jar $(DESTDIR)/bin/rke $(DESTDIR)/bin/docker-machine $(DESTDIR)/bin/packer $(DESTDIR)/bin/terraform $(DESTDIR)/bin/vault $(DESTDIR)/bin/kubectl $(DESTDIR)/bin/kops $(DESTDIR)/bin/kompose $(DESTDIR)/bin/minikube $(DESTDIR)/bin/docker-machine-driver-kvm2 $(DESTDIR)/bin/kustomize $(DESTDIR)/bin/pack $(DESTDIR)/bin/skaffold $(DESTDIR)/bin/minishift $(DESTDIR)/bin/oc $(DESTDIR)/bin/docker-machine-driver-kvm $(HELM_HOME)/plugins/helm-diff/bin/diff $(DESTDIR)/bin/gomplate $(DESTDIR)/bin/envconsul

@@ -23,17 +24,17 @@ $(DESTDIR)/share/bfg/bfg.jar:

$(DESTDIR)/bin/rke:
	mkdir -p $$(dirname $@)
	-$(download) https://github.com/rancher/rke/releases/download/v0.2.2/rke_$(os)-$(goarch)
	-$(download) https://github.com/rancher/rke/releases/download/v0.3.2/rke_$(os)-$(goarch)
	-chmod +x $@

$(DESTDIR)/bin/docker-machine:
	mkdir -p $$(dirname $@)
	-$(download) "https://github.com/docker/machine/releases/download/v0.16.1/docker-machine-$(os)-$(arch)"
	-$(download) "https://github.com/docker/machine/releases/download/v0.16.2/docker-machine-$(os)-$(arch)"
	-chmod +x $@

$(DESTDIR)/bin/packer:
	mkdir -p $$(dirname $@)
	$(curl) https://releases.hashicorp.com/packer/1.4.1/packer_1.4.1_$(os)_$(goarch).zip --output $(tempdir)/packer.zip
	$(curl) https://releases.hashicorp.com/packer/1.4.5/packer_1.4.5_$(os)_$(goarch).zip --output $(tempdir)/packer.zip
	unzip -d $(tempdir) $(tempdir)/packer.zip
	install -m 755 $(tempdir)/packer $@
	rm $(tempdir)/packer*
@@ -47,24 +48,24 @@ $(DESTDIR)/bin/terraform:

$(DESTDIR)/bin/vault:
	mkdir -p $$(dirname $@)
	$(curl) https://releases.hashicorp.com/vault/1.1.1/vault_1.1.1_$(os)_$(goarch).zip --output $(tempdir)/vault.zip
	$(curl) https://releases.hashicorp.com/vault/1.2.3/vault_1.2.3_$(os)_$(goarch).zip --output $(tempdir)/vault.zip
	unzip -d $(tempdir) $(tempdir)/vault.zip
	install -m 755 $(tempdir)/vault $@
	rm $(tempdir)/vault*

$(DESTDIR)/bin/kubectl:
	mkdir -p $$(dirname $@)
	-$(download) "https://storage.googleapis.com/kubernetes-release/release/v1.14.2/bin/$(os)/$(goarch)/kubectl"
	-$(download) "https://storage.googleapis.com/kubernetes-release/release/v1.16.2/bin/$(os)/$(goarch)/kubectl"
	-chmod +x $@

$(DESTDIR)/bin/kops:
	mkdir -p $$(dirname $@)
	-$(download) "https://github.com/kubernetes/kops/releases/download/1.12.1/kops-$(os)-$(goarch)"
	-$(download) "https://github.com/kubernetes/kops/releases/download/1.14.1/kops-$(os)-$(goarch)"
	-chmod +x $@

$(DESTDIR)/bin/kompose:
	mkdir -p $$(dirname $@)
	-$(download) https://github.com/kubernetes/kompose/releases/download/v1.18.0/kompose-$(os)-$(goarch)
	-$(download) https://github.com/kubernetes/kompose/releases/download/v1.19.0/kompose-$(os)-$(goarch)
	-chmod +x $@

$(DESTDIR)/bin/minikube:
@@ -74,7 +75,7 @@ $(DESTDIR)/bin/minikube:

$(DESTDIR)/bin/kustomize:
	mkdir -p $$(dirname $@)
	-$(download) https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.3/kustomize_2.0.3_$(os)_$(goarch)
	-$(download) https://github.com/kubernetes-sigs/kustomize/releases/download/v3.3.0/kustomize_3.3.0_$(os)_$(goarch)
	-chmod +x $@

$(DESTDIR)/bin/docker-machine-driver-kvm2:
@@ -85,22 +86,22 @@ $(DESTDIR)/bin/docker-machine-driver-kvm2:
$(DESTDIR)/bin/helm:
	mkdir -p $$(dirname $@)
	mkdir -p $(tempdir)/helm
	-$(curl) https://storage.googleapis.com/kubernetes-helm/helm-v2.14.0-$(os)-$(goarch).tar.gz | tar -zxf - -C $(tempdir)/helm/
	-$(curl) https://storage.googleapis.com/kubernetes-helm/helm-v2.16.0-$(os)-$(goarch).tar.gz | tar -zxf - -C $(tempdir)/helm/
	-install -m 755 $(tempdir)/helm/$(os)-$(goarch)/helm $@
	rm -r $(tempdir)/helm

$(DESTDIR)/bin/pack:
	mkdir -p $$(dirname $@)
	-$(curl) https://github.com/buildpack/pack/releases/download/v0.2.0/pack-v0.s.0-$(os).tgz | tar -xzC $(DESTDIR)/bin/
	-$(curl) https://github.com/buildpack/pack/releases/download/v0.5.0/pack-v0.5.0-$(os).tgz | tar -xzC $(DESTDIR)/bin/

$(DESTDIR)/bin/skaffold:
	mkdir -p $$(dirname $@)
	-$(download) https://storage.googleapis.com/skaffold/releases/v0.29.0/skaffold-$(os)-$(goarch)
	-$(download) https://storage.googleapis.com/skaffold/releases/v0.41.0/skaffold-$(os)-$(goarch)
	-chmod +x $@

$(DESTDIR)/bin/minishift:
	mkdir -p $$(dirname $@)
	-$(curl) https://github.com/minishift/minishift/releases/download/v1.33.0/minishift-1.33.0-$(goos)-$(goarch).tgz | tar -xzC $(tempdir)
	-$(curl) https://github.com/minishift/minishift/releases/download/v1.34.1/minishift-1.34.1-$(goos)-$(goarch).tgz | tar -xzC $(tempdir)
	-install -m 755 $(tempdir)/minishift-*/minishift $@
	-rm -r $(tempdir)/minishift-*

@@ -122,23 +123,23 @@ $(HELM_HOME)/plugins/helm-diff/bin/diff: $(DESTDIR)/bin/helm

$(DESTDIR)/bin/gomplate:
	mkdir -p $$(dirname $@)
	-$(download) https://github.com/hairyhenderson/gomplate/releases/download/v3.4.1/gomplate_$(goos)-$(goarch)
	-$(download) https://github.com/hairyhenderson/gomplate/releases/download/v3.5.0/gomplate_$(goos)-$(goarch)
	-chmod +x $@

$(DESTDIR)/bin/envconsul:
	mkdir -p $$(dirname $@)
	-$(curl) https://releases.hashicorp.com/envconsul/0.8.0/envconsul_0.8.0_$(goos)_$(goarch).tgz | tar -xzC $$(dirname $@) -f -
	-$(curl) https://releases.hashicorp.com/envconsul/0.9.0/envconsul_0.9.0_$(goos)_$(goarch).tgz | tar -xzC $$(dirname $@) -f -


## Vendored files

.bash_completion.d/docker-compose:
	mkdir -p $$(dirname $@)
	$(download) https://raw.githubusercontent.com/docker/compose/1.24.0/contrib/completion/bash/docker-compose
	$(download) https://raw.githubusercontent.com/docker/compose/1.24.1/contrib/completion/bash/docker-compose

.bash_completion.d/docker-machine.bash:
	mkdir -p $$(dirname $@)
	$(download) https://raw.githubusercontent.com/docker/machine/v0.16.1/contrib/completion/bash/docker-machine.bash
	$(download) https://raw.githubusercontent.com/docker/machine/v0.16.2/contrib/completion/bash/docker-machine.bash

.bash_completion.d/fabric-completion.bash:
	mkdir -p $$(dirname $@)
@@ -161,12 +162,13 @@ Documents/bin/rabbitmqadmin:
	$(download) https://raw.githubusercontent.com/rabbitmq/rabbitmq-management/master/bin/rabbitmqadmin
	chmod +x $@

.bash_completion.d/google-cloud-sdk:
	mkdir -p $$(dirname $@)
	$(download) https://raw.githubusercontent.com/google-cloud-sdk/google-cloud-sdk/master/completion.bash.inc
.bash_completion.d/toolbox:
	$(download) https://raw.githubusercontent.com/containers/toolbox/0.0.16/completion/bash/toolbox

.bash_completion.d/poetry:
	poetry completions bash > $@
Documents/bin/toolbox:
	mkdir -p $$(dirname $@)
	$(download) https://raw.githubusercontent.com/containers/toolbox/0.0.16/toolbox
	chmod +x $@


## Generated files
@@ -218,7 +220,7 @@ Documents/bin/rabbitmqadmin:
	ssh-keygen -y -f $< > $@

.ssh/authorized_keys: .ssh/localhost.pub
	ansible localhost -c local -i localhost, -m authorized_key -a "user=$$(whoami) key='$$(cat .ssh/localhost.pub)' key_options='from=\"127.0.0.1/8\"'"
	$(ansible-local) -m authorized_key -a "user=$$(whoami) key='$$(cat .ssh/localhost.pub)' key_options='from=\"127.0.0.1/8\"'"

.bash_completion.d/minishift: $(DESTDIR)/bin/minishift
	mkdir -p $$(dirname $@)
@@ -227,3 +229,6 @@ Documents/bin/rabbitmqadmin:
.bash_completion.d/oc: $(DESTDIR)/bin/oc
	mkdir -p $$(dirname $@)
	-$$(basename $@) completion bash > $@

.bash_completion.d/poetry:
	poetry completions bash > $@