From cba7b5f308bc7bd9dc9af4759019862881ea43ca Mon Sep 17 00:00:00 2001 From: Munif Tanjim Date: Tue, 5 Mar 2024 00:07:18 +0600 Subject: [PATCH] update ncd --- completions/_ncd | 7 +++ ncd | 135 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 112 insertions(+), 30 deletions(-) diff --git a/completions/_ncd b/completions/_ncd index 2e7e718..4a78f5e 100644 --- a/completions/_ncd +++ b/completions/_ncd @@ -98,6 +98,12 @@ __ncd_arguments() { ec2_ip) _message "Enter pattern for EC2 name" && ret=0 ;; + es) + _ncd_es_commands=() + _ncd_es_commands+=("aqs") + _describe -t commands "commands" _ncd_es_commands \ + && ret=0 + ;; dc) local curcontext="${curcontext}" state @@ -185,6 +191,7 @@ __ncd_commands() { _ncd_commands+=("git" "list") _ncd_commands+=("dc" "repo") _ncd_commands+=("py" "k8s") + _ncd_commands+=("es") _ncd_commands+=("workspace") _describe -t ncd-commands "commands" _ncd_commands diff --git a/ncd b/ncd index 88b2636..7490033 100755 --- a/ncd +++ b/ncd @@ -33,11 +33,13 @@ assert_func() { } ncd_config() { + assert_command rq local blob="$(cat ~/.newscred.yaml | rq --input-yaml | jq -r '.ncd')" echo "${blob}" | jq -r ".${1:-""}" } ncd_workspace() { + assert_command rq local dir="$(cat ~/.newscred.yaml | rq --input-yaml | jq -r '.workspace')" dir="${dir/#\~/${HOME}}" echo "${dir}" @@ -178,7 +180,7 @@ ncd_on_vpn() { echo "Checking VPN Connection..." local -r openvpn_connect="/Applications/OpenVPN Connect/OpenVPN Connect.app/contents/MacOS/OpenVPN Connect" - local -r profile_name="vpn.newscred.com [newscred]" + local -r profile_name="vpn.cmp.optimizely.com" osascript >/dev/null < /tmp/ncd_es_aqs_script +#!/bin/bash + +rm -f /tmp/ncd_es_aqs_script + +if ! type curl >/dev/null 2>&1; then + apt-get -qq update >/dev/null 2>&1 + apt-get -qq install curl >/dev/null 2>&1 +fi + +export ES_HOST=\$(cat /opt/article-query/conf/article-query.json | grep ELASTICSEARCH_7_HOST | cut -d'"' -f4) + +curl "http://\${ES_HOST}/${endpoint}" ${@} +EOF + + chmod +x /tmp/ncd_es_aqs_script + + export NCD_K8S_NAMESPACE=article-query NCD_K8S_POD=article-query- NCD_K8S_CONTAINER=article-query + + ncd k8s cp /tmp/ncd_es_aqs_script to /tmp/ncd_es_aqs_script + + NCD_K8S_EXEC_CMD="/tmp/ncd_es_aqs_script" ncd k8s exec +} + +# ncd es +ncd_es() { + __ncd_cmd "es" $@ +} + # ncd git pr-sync ncd_git_pr-sync() { local -r pr_link="${1:-}" @@ -791,6 +867,5 @@ ncd() { assert_command aws assert_command fzf assert_command jq -assert_command rq ncd $@ -- knotmirror 0.0.1