Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

CORTX-28885: Remove yq binary from project #240

Merged
merged 1 commit into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 77 additions & 65 deletions README.md

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions k8_cortx_cloud/deploy-cortx-cloud.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck disable=SC2312

# Check required dependencies
if ! ./parse_scripts/check_yq.sh; then
exit 1
fi

solution_yaml=${1:-'solution.yaml'}
storage_class='local-path'

Expand All @@ -24,7 +29,7 @@ function parseSolution()

function extractBlock()
{
./parse_scripts/yaml_extract_block.sh "${solution_yaml}" "$1"
yq ".$1" "${solution_yaml}"
}

#######################################
Expand Down
7 changes: 1 addition & 6 deletions k8_cortx_cloud/destroy-cortx-cloud.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck disable=SC2312

Expand Down Expand Up @@ -64,11 +64,6 @@ function parseSolution()
./parse_scripts/parse_yaml.sh ${solution_yaml} "$1"
}

function extractBlock()
{
./parse_scripts/yaml_extract_block.sh ${solution_yaml} "$1"
}

namespace=$(parseSolution 'solution.namespace' | cut -f2 -d'>')

readonly pvc_consul_filter="data-.*-consul-server-"
Expand Down
60 changes: 60 additions & 0 deletions k8_cortx_cloud/parse_scripts/check_yq.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash

# This script verifies that the yq command line tool is available and
# meets the minimum required version. yq is required to use the
# deployment scripts and is expected to be in the user's PATH.

set -euo pipefail

error() {
echo >&2 "$@"
}

die() {
echo >&2 "$@"
exit 1
}

check_yq() {
local -r req_major=4
local -r req_minor=25
local -r req_patch=1
local -r minimum_version="${req_major}.${req_minor}.${req_patch}"
local -r install_msg="The required version is ${minimum_version} or higher. See https://github.com/mikefarah/yq#install for installation instructions."

if ! command -v yq &>/dev/null; then
die "Missing required program 'yq'. ${install_msg}"
fi

# Require yq v4.25.1 or later. There are a number of bug fixes and
# features available in this version that we depend on.
if ! yq_version="$(yq --version)"; then
error "${yq_version}"
die "yq is installed but the version could not be determined. ${install_msg}"
fi

local -r incompatible="yq is installed but is not compatible. ${install_msg}"

# There is another yq utility, make sure this is the desired one.
# Older versions also lack the Github project name.
if [[ ${yq_version} != *"mikefarah/yq"* ]]; then
error "${yq_version}"
die "${incompatible}"
fi

# Extract the version number from the entire version output
yq_version_num=${yq_version##*version }

# Split the version number into its individual components
IFS=. read -r yq_major yq_minor yq_patch <<< "${yq_version_num}"
# Technically the patch version can be a string like "0-alpha1", so strip any suffixes to be safe.
yq_patch="${yq_patch%-*}"

# Assume any new major version is incompatible.
if (( yq_major != req_major )) || (( yq_minor < req_minor )) || (( yq_minor == 25 && yq_patch < req_patch)); then
error "${yq_version}"
die "${incompatible}"
fi
}

check_yq
47 changes: 0 additions & 47 deletions k8_cortx_cloud/parse_scripts/yaml_extract_block.sh

This file was deleted.

52 changes: 0 additions & 52 deletions k8_cortx_cloud/parse_scripts/yaml_insert_block.sh

This file was deleted.

49 changes: 0 additions & 49 deletions k8_cortx_cloud/parse_scripts/yaml_update_block.sh

This file was deleted.

Binary file removed k8_cortx_cloud/parse_scripts/yq_linux_amd64
Binary file not shown.
13 changes: 4 additions & 9 deletions k8_cortx_cloud/shutdown-cortx-cloud.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck disable=SC2312

Expand All @@ -16,13 +16,8 @@ function parseSolution()
./parse_scripts/parse_yaml.sh "${solution_yaml}" "$1"
}

function extractBlock()
{
./parse_scripts/yaml_extract_block.sh "${solution_yaml}" "$1"
}

namespace=$(parseSolution 'solution.namespace')
namespace=$(echo "${namespace}" | cut -f2 -d'>')
namespace=$(parseSolution 'solution.namespace' | cut -f2 -d'>')
readonly namespace

printf "########################################################\n"
printf "# Shutdown CORTX Control \n"
Expand Down Expand Up @@ -116,7 +111,7 @@ printf "\n\n"
printf "All CORTX HA pods have been shutdown"
printf "\n\n"

num_motr_client=$(extractBlock 'solution.common.motr.num_client_inst')
num_motr_client=$(parseSolution 'solution.common.motr.num_client_inst' | cut -f2 -d'>')

if [[ ${num_motr_client} -gt 0 ]]; then
printf "########################################################\n"
Expand Down
14 changes: 4 additions & 10 deletions k8_cortx_cloud/start-cortx-cloud.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck disable=SC2312

Expand All @@ -16,14 +16,8 @@ function parseSolution()
./parse_scripts/parse_yaml.sh "${solution_yaml}" "$1"
}

function extractBlock()
{
./parse_scripts/yaml_extract_block.sh "${solution_yaml}" "$1"
}

namespace=$(parseSolution 'solution.namespace')
namespace=$(echo "${namespace}" | cut -f2 -d'>')
deployment_type=$(extractBlock 'solution.deployment_type')
namespace=$(parseSolution 'solution.namespace' | cut -f2 -d'>')
deployment_type=$(parseSolution 'solution.deployment_type' | cut -f2 -d'>')

readonly namespace
readonly deployment_type
Expand Down Expand Up @@ -180,7 +174,7 @@ if [[ ${deployment_type} != "data-only" ]]; then
printf "\n\n"
fi

num_motr_client=$(extractBlock 'solution.common.motr.num_client_inst')
num_motr_client=$(parseSolution 'solution.common.motr.num_client_inst' | cut -f2 -d'>')

if [[ ${num_motr_client} -gt 0 ]]; then
printf "########################################################\n"
Expand Down
8 changes: 2 additions & 6 deletions k8_cortx_cloud/status-cortx-cloud.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck disable=SC2312

Expand Down Expand Up @@ -51,10 +51,6 @@ parseSolution() {
./parse_scripts/parse_yaml.sh "${solution_yaml}" "$1"
}

extractBlock() {
./parse_scripts/yaml_extract_block.sh "${solution_yaml}" "$1"
}

setup_colors

namespace=$(parseSolution 'solution.namespace' | cut -f2 -d'>')
Expand Down Expand Up @@ -662,7 +658,7 @@ else
fi


num_motr_client=$(extractBlock 'solution.common.motr.num_client_inst')
num_motr_client=$(parseSolution 'solution.common.motr.num_client_inst' | cut -f2 -d'>')

if [[ ${num_motr_client} -gt 0 ]]; then
#########################################################################################
Expand Down