You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# The `check_package` function is a Bash script that checks if a specified command-line package is installed on the system. If the package is not installed, the function provides instructions on how to install it, depending on the package name.
103
+
#
104
+
### Parameters
105
+
# - `$1` (String): The name of the package to check.
106
+
#
107
+
### Usage
108
+
# ```bash
109
+
# check_package <package_name>
110
+
111
+
check_package() {
112
+
if!command -v $1&>/dev/null;then
113
+
echo -e "${YELLOW}WARN${NC} - Package $1 is not installed."
114
+
if [ "$1"=="yq" ];then
115
+
echo -e "You can download it from the GitHub page: ${CYAN}${UNDERLINE}https://github.com/mikefarah/yq?tab=readme-ov-file#install${NOUNDERLINE}${NC}"
116
+
elif [ "$1"=="kustomize" ];then
117
+
echo -e "You can download it from the GitHub page: ${CYAN}${UNDERLINE}https://github.com/kubernetes-sigs/kustomize${NOUNDERLINE}${NC}"
118
+
elif [ "$1"=="kubeconform" ];then
119
+
echo -e "You can download it from the GitHub page: ${CYAN}${UNDERLINE}https://github.com/yannh/kubeconform${NOUNDERLINE}${NC}"
120
+
else
121
+
echo -e "Please install ${YELLOW}${UNDERLINE}$1${NOUNDERLINE}${NC} and try again."
122
+
fi
123
+
exit 1
124
+
fi
125
+
}
126
+
127
+
## Function: get_git_diff_files
128
+
#
129
+
### Description
130
+
# The `get_git_diff_files` function is a Bash script that retrieves the list of modified files in a Git repository, filtered by a specified directory and pattern. This function is particularly useful for identifying specific types of files that have been staged for commit.
131
+
#
132
+
### Parameters
133
+
# - `dir` (String): The directory to filter the git diff output. This parameter limits the scope of the files to be checked within the specified directory.
134
+
# - `pattern` (String): The pattern to filter the file names using grep. This parameter allows you to specify a regular expression to match certain file types or naming conventions.
# The `download_schemas` function downloads the latest Flux OpenAPI schemas and extracts them to a specified directory. It also retrieves and stores the latest version tag of the schemas for future reference.
curl -sL $LATEST_VERSION_URL| grep '"tag_name":'| sed -E 's/.*"([^"]+)".*/\1/'>"$LATEST_VERSION_FILE"
167
+
}
168
+
169
+
## Function: check_latest_schemas
170
+
#
171
+
### Description
172
+
# The `check_latest_schemas` function checks if the downloaded Flux OpenAPI schemas are the latest available version. It compares the version tag of the currently downloaded schemas with the latest version available on GitHub.
173
+
#
174
+
### Usage
175
+
# ```bash
176
+
# check_latest_schemas
177
+
178
+
check_latest_schemas() {
179
+
local latest_version
180
+
latest_version=$(curl -sL $LATEST_VERSION_URL| grep '"tag_name":'| sed -E 's/.*"([^"]+)".*/\1/')
181
+
if [[ -f"$LATEST_VERSION_FILE" ]];then
182
+
local current_version
183
+
current_version=$(cat "$LATEST_VERSION_FILE")
184
+
if [[ "$latest_version"=="$current_version" ]];then
# The `validate_files` function is a Bash script that identifies and validates YAML files that have been modified and staged for commit in a Git repository.
223
+
# It uses the `yq` tool to check the syntax of each file.
# The `validate_clusters` function is a Bash script that validates YAML files related to clusters that have been modified and staged for commit in a Git repository.
250
+
# It uses the `kubeconform` tool to perform validation on these files.
# The `validate_kustomize` function is a Bash script that identifies and validates kustomize overlays that have been modified and staged for commit in a Git repository.
284
+
# It uses the `kustomize` and `kubeconform` tools to perform validation on these overlays.
0 commit comments