Open c-bordon opened 3 days ago
I have changed the logic of choosing the repository for the assistant. However, after this change, the builder script does not know about the chosen repository, so the change of the Filebeat template URL must be migrated too.
The following logic must be added:
source_branch
variable specified in the variables file contains a -
, then we are using development for testing purposes. For example, if using v4.9.1-rc1 packages, v4.9.1-rc1 tag will be used (the v
must not be deleted from the source_branch
variable.source_branch
variable specified in the variables file does not contain a -
, then we are using development for development purposes. For example, if using v4.9.1 packages, 4.9.1 branch will be used (the v
must be deleted from the source_branch
variable.This was worked in https://github.com/wazuh/wazuh-packages/issues/3092, but it must be redone.
In order to perform a proof of concept of the migrated checkFilebeatURL builder function, the following snippet has been tested:
#!/bin/bash
readonly wazuh_version="4.10.0"
source_branch="v${wazuh_version}"
filebeat_wazuh_template="https://raw.githubusercontent.com/wazuh/wazuh/${source_branch}/extensions/elasticsearch/7.x/wazuh-template.json"
if [[ ! "${source_branch}" =~ "-" ]]; then
source_branch="${source_branch#v}"
filebeat_wazuh_template="https://raw.githubusercontent.com/wazuh/wazuh/${source_branch}/extensions/elasticsearch/7.x/wazuh-template.json"
fi
new_filebeat_url="${filebeat_wazuh_template/${source_branch}/master}"
# Get the response of the URL and check it
response=$(curl -I --write-out '%{http_code}' --silent --output /dev/null $filebeat_wazuh_template)
if [ "${response}" != "200" ]; then
response=$(curl -I --write-out '%{http_code}' --silent --output /dev/null $new_filebeat_url)
# Display error if both URLs do not get the resource
if [ "${response}" != "200" ]; then
echo -e "Error: Could not get the Filebeat Wazuh template. "
# If matches, replace the variable of installVariables to the new one
else
echo "Changing Filebeat URL..."
filebeat_wazuh_template="${new_filebeat_url}"
fi
fi
Case 1: using branch of a not tested version (development case)
➜ ~ bash -x test_url_filebeat.sh
readonly wazuh_version=4.10.0
wazuh_version=4.10.0
source_branch=v4.10.0
filebeat_wazuh_template=https://raw.githubusercontent.com/wazuh/wazuh/v4.10.0/extensions/elasticsearch/7.x/wazuh-template.json
[[ ! v4.10.0 =~ - ]]
source_branch=4.10.0
filebeat_wazuh_template=https://raw.githubusercontent.com/wazuh/wazuh/4.10.0/extensions/elasticsearch/7.x/wazuh-template.json
new_filebeat_url=https://raw.githubusercontent.com/wazuh/wazuh/master/extensions/elasticsearch/7.x/wazuh-template.json ++ curl -I --write-out '%{http_code}' --silent --output /dev/null https://raw.githubusercontent.com/wazuh/wazuh/4.10.0/extensions/elasticsearch/7.x/wazuh-template.json
response=200
'[' 200 '!=' 200 ']' ➜ ~
Case 2: using branch of a tested version (stage testing case)
➜ ~ bash -x test_url_filebeat.sh
readonly wazuh_version=4.10.0
wazuh_version=4.10.0
source_branch=v4.10.0-rc2
filebeat_wazuh_template=https://raw.githubusercontent.com/wazuh/wazuh/v4.10.0-rc2/extensions/elasticsearch/7.x/wazuh-template.json
[[ ! v4.10.0-rc2 =~ - ]]
new_filebeat_url=https://raw.githubusercontent.com/wazuh/wazuh/master/extensions/elasticsearch/7.x/wazuh-template.json ++ curl -I --write-out '%{http_code}' --silent --output /dev/null https://raw.githubusercontent.com/wazuh/wazuh/v4.10.0-rc2/extensions/elasticsearch/7.x/wazuh-template.json
response=404
'[' 404 '!=' 200 ']' ++ curl -I --write-out '%{http_code}' --silent --output /dev/null https://raw.githubusercontent.com/wazuh/wazuh/master/extensions/elasticsearch/7.x/wazuh-template.json
response=200
'[' 200 '!=' 200 ']'
echo 'Changing Filebeat URL...' Changing Filebeat URL...
filebeat_wazuh_template=https://raw.githubusercontent.com/wazuh/wazuh/master/extensions/elasticsearch/7.x/wazuh-template.json
> [!IMPORTANT]
> Although the Filebeat template is being fetched using the `master` branch, the `source_branch` variable is not being modified because it does not have a `-` in its value, to the behavior is correct. It is using the `master` branch because the v4.10.0 version is not being tested yet, so there is no stage tag available yet.
The following testing has been performed:
After adapting the workflows, the following testing has been performed to ensure that the GHAs work as expected after the adaptation:
Description
As part of packages redesign tier 2, it is necessary to migrate the configuration functionality of the repositories from
builder.sh
towazuh-install.sh
, with this it is expected that through the parameter it will be possible to select from which repository to install the packages.Related
DRI