[kubernetes] bump to upstream d5377e4a394b4fc6e3088634729b538eac124b1b

Eric Paris eparis at fedoraproject.org
Mon Oct 20 15:06:14 UTC 2014


commit 4596a2657837858753e60f1d01a3e92c14b29574
Author: Eric Paris <eparis at redhat.com>
Date:   Mon Oct 20 11:05:02 2014 -0400

    bump to upstream d5377e4a394b4fc6e3088634729b538eac124b1b
    
    add bash completions for kubectl
    use systemd and environment variabled from in tree

 .gitignore                      |    1 +
 apiserver                       |   26 ----
 config                          |   23 ---
 controller-manager              |    7 -
 kube-apiserver.service          |   23 ---
 kube-controller-manager.service |   18 ---
 kube-proxy.service              |   16 --
 kube-scheduler.service          |   17 ---
 kubectl                         |  305 +++++++++++++++++++++++++++++++++++++++
 kubelet                         |   14 --
 kubelet.service                 |   22 ---
 kubernetes.spec                 |   29 ++---
 proxy                           |    7 -
 scheduler                       |    7 -
 sources                         |    2 +-
 15 files changed, 319 insertions(+), 198 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 76e5687..a2b9494 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 /kubernetes-98ac8e1.tar.gz
 /kubernetes-4452163.tar.gz
 /kubernetes-b011263.tar.gz
+/kubernetes-d5377e4.tar.gz
diff --git a/kubectl b/kubectl
new file mode 100644
index 0000000..0a458a6
--- /dev/null
+++ b/kubectl
@@ -0,0 +1,305 @@
+#!bash
+#
+# bash completion file for core kubectl commands
+#
+# This script provides completion of non replication controller options
+#
+# To enable the completions either:
+#  - place this file in /etc/bash_completion.d
+#  or
+#  - copy this file and add the line below to your .bashrc after
+#    bash completion features are loaded
+#     . kubectl
+#
+# Note:
+# Currently, the completions will not work if the apiserver daemon is not
+# running on localhost on the standard port 8080
+
+__contains_word()
+{
+    local w word=$1; shift
+    for w in "$@"; do
+        [[ $w = "$word" ]] && return
+    done
+    return 1
+}
+
+__has_resource()
+{
+    local all_resources=(pod pods service services minion minions replicationController replicationControllers)
+    local i
+    for ((i=command_word; i < cword; i++)); do
+        local word=${words[i]}
+        if __contains_word "${word}" "${all_resources[@]}"; then
+            return 0
+        fi
+    done
+    return 1
+}
+
+# call kubectl get $1,
+# exclude blank lines
+# skip the header stuff kubectl prints on the first 2 lines
+# append $1/ to the first column and use that in compgen
+__kubectl_parse_get()
+{
+    local kubectl_output out
+    if kubectl_output=$(kubectl get --no-headers "$1" 2>/dev/null); then
+        out=($(echo "${kubectl_output}" | awk '{print $1}'))
+        COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) )
+    fi
+}
+
+__kubectl_pre_command()
+{
+    local flags=(
+            --api-version=
+            -a
+            --auth-path=
+            --certificate-authority=
+            --client-certificate=
+            --client-key=
+            --insecure-skip-tls-verify=
+            --match-server-version=
+            -s
+            --server=
+    )
+    local api_versions=(v1beta1 v1beta2 v1beta3)
+
+    case $prev in
+        --api-version)
+            COMPREPLY=( $(compgen -W "${api_versions[*]}" -- "$cur") )
+            return 0
+            ;;
+        -a | --auth-path | --certificate-authority | --client-certificate | --client-key)
+            _filedir
+            return 0
+            ;;
+        --insecure-skip-tls-verify | --match-server-version)
+            COMPREPLY=( $(compgen -W "true false" -- "$cur") )
+            return 0
+            ;;
+        -s | --server)
+            return 0
+            ;;
+        *)
+            ;;
+    esac
+
+    if [[ "$cur" = -* ]]; then
+        compopt -o nospace
+        COMPREPLY=( $(compgen -W "${flags[*]}" -- "$cur") )
+        [[ $COMPREPLY == *= ]] || compopt +o nospace
+        return 0
+    fi
+
+    COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
+    return 0
+}
+
+__kubectl_require_file()
+{
+    local i has_file=false
+    local flags=(-f)
+    for ((i=command_word; i < cword; i++)); do
+        local word=${words[i]}
+        if [[ $word == -f ]]; then
+            flags=()
+        fi
+    done
+
+    case $prev in 
+        -f)
+            _filedir '@(json|yml|yaml)'
+            return 0;
+            ;;
+    esac
+    COMPREPLY=( $( compgen -W "${flags[*]}" -- "$cur" ) )
+}
+
+__kubectl_handle_flags_resources()
+{
+    case $prev in
+        pod | pods)
+            __kubectl_parse_get pods
+            return 0
+            ;;
+        replicationController | replicationControllers)
+            __kubectl_parse_get replicationControllers
+            return 0
+            ;;
+        service | services)
+            __kubectl_parse_get services
+            return 0
+            ;;
+        minion | minions)
+            __kubectl_parse_get minions
+            return 0
+            ;;
+    esac
+
+    case $cur in
+        -*)
+            compopt -o nospace
+            COMPREPLY=( $(compgen -W "${flags[*]}" -- "$cur") )
+            [[ $COMPREPLY == *= ]] || compopt +o nospace
+            return 0;
+            ;;
+    esac
+
+    COMPREPLY=( $(compgen -W "${resources[*]}" -- "$cur") )
+}
+
+__kubectl_get()
+{
+    local resources=()
+    local flags=(-o --output=)
+
+    if __has_resource; then
+        resource=()
+    else
+        resources=(pods minions services replicationControllers)
+    fi
+
+    for ((i=command_word; i < cword; i++)); do
+        local word=${words[i]}
+        local next=$(( $i + 1 ))
+        case $word in
+            -o | --output)
+                if [[ $next -lt $(( $cword )) ]] &&
+                   [[ ${words[$next]} == "template" ]]; then
+                    resources+=(-t --template=)
+                    flags=(-t --template=)
+                else
+                    flags=()
+                fi
+                ;;
+            -t | --templtate)
+                resources=(${resources[@]/--template=})
+                resources=(${resources[@]/-t})
+                flags=()
+                ;;
+        esac
+    done
+
+    case $prev in
+        -o | --output)
+            COMPREPLY=( $(compgen -W "table json yaml template" -- "$cur") )
+            return 0
+            ;;
+        -t | --template)
+            _filedir
+            return 0
+            ;;
+    esac
+    __kubectl_handle_flags_resources
+}
+
+__kubectl_describe()
+{
+    local resources=()
+    local flags=()
+
+    if __has_resource; then
+        resource=()
+    else
+        resources=(pods minions services replicationControllers)
+    fi
+    local resources=(pods minions services replicationControllers)
+
+    __kubectl_handle_flags_resources
+}
+
+__kubectl_delete()
+{
+    local resources=()
+    local flags=()
+
+    if __has_resource; then
+        resource=()
+        flags=()
+    else
+        resources=(pods minions services replicationControllers -f)
+        flags=(-f)
+    fi
+
+    for ((i=command_word; i < cword; i++)); do
+        local word=${words[i]}
+        if [[ $word == -f ]]; then
+            resources=()
+            flags=()
+        fi
+    done
+
+    case $prev in
+        -f)
+            _filedir '@(json|yml|yaml)'
+            return 0
+            ;;
+    esac
+    __kubectl_handle_flags_resources
+}
+
+__kubectl_post_command()
+{
+    case $command in
+        create | update)
+            __kubectl_require_file
+            return 0
+            ;;
+        get)
+            __kubectl_get
+            return 0
+            ;;
+        describe)
+            __kubectl_describe
+            return 0
+            ;;
+        delete)
+            __kubectl_delete
+            return 0
+            ;;
+        *)
+            ;;
+    esac
+}
+
+_kubectl()
+{
+    local command command_word
+    local cur prev words cword split
+    _init_completion -s -n : || return 0
+    _expand || return 0
+    COMPREPLY=()
+
+    local commands=(version proxy get describe create update delete help)
+    local two_word_flags=(
+            -a
+            -s
+    )
+
+    # figure out which command they are running, remembering that arguments to
+    # options don't count as the command!  So a hostname named 'create' won't
+    # trip things up
+    local i
+    for ((i=0; i < cword; i++)); do
+        if __contains_word "${words[i]}" "${commands[@]}" &&
+           ! __contains_word "${words[i-1]}" "${two_word_flags[@]}"; then
+            command=${words[i]}
+            command_word=i
+            break
+        fi
+    done
+
+    if [[ -z $command ]]; then
+        __kubectl_pre_command
+        return 0
+    fi
+
+    __kubectl_post_command
+
+    return 0
+}
+
+complete -F _kubectl kubectl
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/kubernetes.spec b/kubernetes.spec
index 4de307e..cf5aab1 100644
--- a/kubernetes.spec
+++ b/kubernetes.spec
@@ -1,7 +1,7 @@
 #debuginfo not supported with Go
 %global debug_package	%{nil}
 %global import_path	github.com/GoogleCloudPlatform/kubernetes
-%global commit		b01126322b826a15db06f6eeefeeb56dc06db7af
+%global commit		d5377e4a394b4fc6e3088634729b538eac124b1b
 %global shortcommit	%(c=%{commit}; echo ${c:0:7})
 
 #binaries which should be called kube-*
@@ -18,26 +18,14 @@
 
 Name:		kubernetes
 Version:	0.4
-Release:	0.1.git%{shortcommit}%{?dist}
+Release:	0.2.git%{shortcommit}%{?dist}
 Summary:	Container cluster management
 License:	ASL 2.0
 URL:		https://github.com/GoogleCloudPlatform/kubernetes
 ExclusiveArch:	x86_64
 Source0:	https://github.com/GoogleCloudPlatform/kubernetes/archive/%{commit}/kubernetes-%{shortcommit}.tar.gz
 
-#config files
-Source10:	config
-Source11:	apiserver
-Source12:	controller-manager
-Source13:	proxy
-Source14:	kubelet
-Source15:	scheduler
-#service files
-Source20:	kube-apiserver.service
-Source21:	kube-controller-manager.service
-Source22:	kube-proxy.service
-Source23:	kubelet.service
-Source24:	kube-scheduler.service
+Source10:	kubectl
 
 Patch1:		0001-remove-all-third-party-software.patch
 
@@ -152,15 +140,16 @@ done
 
 # install the bash completion
 install -d -m 0755 %{buildroot}%{_datadir}/bash-completion/completions/
+install -t %{buildroot}%{_datadir}/bash-completion/completions/ %{SOURCE10}
 install -t %{buildroot}%{_datadir}/bash-completion/completions/ contrib/completions/bash/kubecfg
 
 # install config files
 install -d -m 0755 %{buildroot}%{_sysconfdir}/%{name}
-install -m 644 -t %{buildroot}%{_sysconfdir}/%{name} %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} %{SOURCE15}
+install -m 644 -t %{buildroot}%{_sysconfdir}/%{name} contrib/init/systemd/environ/*
 
 # install service files
 install -d -m 0755 %{buildroot}%{_unitdir}
-install -m 0644 -t %{buildroot}%{_unitdir} %{SOURCE20} %{SOURCE21} %{SOURCE22} %{SOURCE23} %{SOURCE24}
+install -m 0644 -t %{buildroot}%{_unitdir} contrib/init/systemd/*.service
 
 # install manpages
 install -d %{buildroot}%{_mandir}/man1
@@ -185,6 +174,7 @@ install -d %{buildroot}/var/lib/kubelet
 %{_unitdir}/kube-proxy.service
 %dir %{_sysconfdir}/%{name}
 %{_datadir}/bash-completion/completions/kubecfg
+%{_datadir}/bash-completion/completions/kubectl
 %dir /var/lib/kubelet
 %config(noreplace) %{_sysconfdir}/%{name}/config
 %config(noreplace) %{_sysconfdir}/%{name}/apiserver
@@ -207,6 +197,11 @@ getent passwd kube >/dev/null || useradd -r -g kube -d / -s /sbin/nologin \
 %systemd_postun
 
 %changelog
+* Mon Oct 20 2014 Eric Paris <eparis at redhat.com - 0.4-0.2.gitd5377e4
+- Bump to upstream d5377e4a394b4fc6e3088634729b538eac124b1b
+- Use in tree systemd unit and Environment files
+- Include kubectl bash completion from outside tree
+
 * Fri Oct 17 2014 Eric Paris <eparis at redhat.com - 0.4-0.1.gitb011263
 - Bump to upstream b01126322b826a15db06f6eeefeeb56dc06db7af
 - This is a major non backward compatible change.
diff --git a/sources b/sources
index 996d449..2ad5ecd 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-6dfac48ac66d5752dacdc8c24c37702d  kubernetes-b011263.tar.gz
+02e09314698d8ddf51932d70e173065a  kubernetes-d5377e4.tar.gz


More information about the scm-commits mailing list