Skip to content

Commit

Permalink
Merge pull request #746 from renuka-fernando/go-mod-update
Browse files Browse the repository at this point in the history
Update Go Mods related to the update in API Operator
  • Loading branch information
renuka-fernando authored May 13, 2021
2 parents 1618e2a + 7745ad4 commit 4c7bb77
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 15 deletions.
10 changes: 5 additions & 5 deletions import-export-cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.1.2
github.com/renstrom/dedent v1.0.0
github.com/spf13/cast v1.3.0
github.com/spf13/cobra v0.0.5
github.com/stretchr/testify v1.4.0
github.com/wso2/k8s-api-operator/api-operator v0.0.0-20210511124939-b092d086bf6b // indirect
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975
github.com/spf13/cast v1.3.1
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.5.1
github.com/wso2/k8s-api-operator/api-operator v0.0.0-20210511124939-b092d086bf6b
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904
gopkg.in/yaml.v2 v2.2.8
k8s.io/api v0.18.2
)
Expand Down
3 changes: 3 additions & 0 deletions import-export-cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ github.com/coreos/prometheus-operator v0.38.0/go.mod h1:xZC7/TgeC0/mBaJk+1H9dbHa
github.com/coreos/prometheus-operator v0.38.1-0.20200424145508-7e176fda06cc/go.mod h1:erio69w1R/aC14D5nfvAXSlE8FT8jt2Hnavc50Dp33A=
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4=
Expand Down Expand Up @@ -802,6 +803,7 @@ github.com/rubenv/sql-migrate v0.0.0-20191025130928-9355dd04f4b3/go.mod h1:WS0rl
github.com/rubenv/sql-migrate v0.0.0-20200212082348-64f95ea68aa3/go.mod h1:rtQlpHw+eR6UrqaS3kX1VYeaCxzCVdimDS7g5Ln4pPc=
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
Expand All @@ -816,6 +818,7 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/shurcooL/vfsgen v0.0.0-20180825020608-02ddb050ef6b/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
Expand Down
87 changes: 77 additions & 10 deletions import-export-cli/shell-completions/apictl_bash_completions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,71 @@ __apictl_contains_word()
return 1
}

__apictl_handle_go_custom_completion()
{
__apictl_debug "${FUNCNAME[0]}: cur is ${cur}, words[*] is ${words[*]}, #words[@] is ${#words[@]}"

local out requestComp lastParam lastChar comp directive args

# Prepare the command to request completions for the program.
# Calling ${words[0]} instead of directly apictl allows to handle aliases
args=("${words[@]:1}")
requestComp="${words[0]} __completeNoDesc ${args[*]}"

lastParam=${words[$((${#words[@]}-1))]}
lastChar=${lastParam:$((${#lastParam}-1)):1}
__apictl_debug "${FUNCNAME[0]}: lastParam ${lastParam}, lastChar ${lastChar}"

if [ -z "${cur}" ] && [ "${lastChar}" != "=" ]; then
# If the last parameter is complete (there is a space following it)
# We add an extra empty parameter so we can indicate this to the go method.
__apictl_debug "${FUNCNAME[0]}: Adding extra empty parameter"
requestComp="${requestComp} \"\""
fi

__apictl_debug "${FUNCNAME[0]}: calling ${requestComp}"
# Use eval to handle any environment variables and such
out=$(eval "${requestComp}" 2>/dev/null)

# Extract the directive integer at the very end of the output following a colon (:)
directive=${out##*:}
# Remove the directive
out=${out%:*}
if [ "${directive}" = "${out}" ]; then
# There is not directive specified
directive=0
fi
__apictl_debug "${FUNCNAME[0]}: the completion directive is: ${directive}"
__apictl_debug "${FUNCNAME[0]}: the completions are: ${out[*]}"

if [ $((directive & 1)) -ne 0 ]; then
# Error code. No completion.
__apictl_debug "${FUNCNAME[0]}: received error from custom completion go code"
return
else
if [ $((directive & 2)) -ne 0 ]; then
if [[ $(type -t compopt) = "builtin" ]]; then
__apictl_debug "${FUNCNAME[0]}: activating no space"
compopt -o nospace
fi
fi
if [ $((directive & 4)) -ne 0 ]; then
if [[ $(type -t compopt) = "builtin" ]]; then
__apictl_debug "${FUNCNAME[0]}: activating no file completion"
compopt +o default
fi
fi

while IFS='' read -r comp; do
COMPREPLY+=("$comp")
done < <(compgen -W "${out[*]}" -- "$cur")
fi
}

__apictl_handle_reply()
{
__apictl_debug "${FUNCNAME[0]}"
local comp
case $cur in
-*)
if [[ $(type -t compopt) = "builtin" ]]; then
Expand All @@ -50,7 +112,9 @@ __apictl_handle_reply()
else
allflags=("${flags[*]} ${two_word_flags[*]}")
fi
COMPREPLY=( $(compgen -W "${allflags[*]}" -- "$cur") )
while IFS='' read -r comp; do
COMPREPLY+=("$comp")
done < <(compgen -W "${allflags[*]}" -- "$cur")
if [[ $(type -t compopt) = "builtin" ]]; then
[[ "${COMPREPLY[0]}" == *= ]] || compopt +o nospace
fi
Expand Down Expand Up @@ -96,14 +160,22 @@ __apictl_handle_reply()
completions=("${commands[@]}")
if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then
completions=("${must_have_one_noun[@]}")
elif [[ -n "${has_completion_function}" ]]; then
# if a go completion function is provided, defer to that function
completions=()
__apictl_handle_go_custom_completion
fi
if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then
completions+=("${must_have_one_flag[@]}")
fi
COMPREPLY=( $(compgen -W "${completions[*]}" -- "$cur") )
while IFS='' read -r comp; do
COMPREPLY+=("$comp")
done < <(compgen -W "${completions[*]}" -- "$cur")

if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then
COMPREPLY=( $(compgen -W "${noun_aliases[*]}" -- "$cur") )
while IFS='' read -r comp; do
COMPREPLY+=("$comp")
done < <(compgen -W "${noun_aliases[*]}" -- "$cur")
fi

if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
Expand Down Expand Up @@ -138,7 +210,7 @@ __apictl_handle_filename_extension_flag()
__apictl_handle_subdirs_in_dir_flag()
{
local dir="$1"
pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1
pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return
}

__apictl_handle_flag()
Expand Down Expand Up @@ -590,12 +662,6 @@ _apictl_delete_api()
flags+=("--verbose")

must_have_one_flag=()
must_have_one_flag+=("--environment=")
must_have_one_flag+=("-e")
must_have_one_flag+=("--name=")
must_have_one_flag+=("-n")
must_have_one_flag+=("--version=")
must_have_one_flag+=("-v")
must_have_one_noun=()
noun_aliases=()
}
Expand Down Expand Up @@ -2019,6 +2085,7 @@ __start_apictl()
local commands=("apictl")
local must_have_one_flag=()
local must_have_one_noun=()
local has_completion_function
local last_command
local nouns=()

Expand Down

0 comments on commit 4c7bb77

Please sign in to comment.