Skip to content

Commit

Permalink
chore: Update Manifests script (#1799)
Browse files Browse the repository at this point in the history
* shell formatter

* wip

* working script

* polish script, add cleanup option

* add license to new script

* add yq install comment

* typo
  • Loading branch information
dpaasman00 authored Aug 21, 2024
1 parent 8ef84e2 commit 0346fab
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 18 deletions.
6 changes: 2 additions & 4 deletions scripts/update-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


TARGET_VERSION=$1
if [ -z "$TARGET_VERSION" ]; then
echo "Must specify a target version"
Expand All @@ -26,7 +25,7 @@ if [ -z "$CONTRIB_TARGET_VERSION" ]; then
exit 1
fi

read -r -d '' DOC_FILES << EOF
read -r -d '' DOC_FILES <<EOF
docs/processors.md
docs/extensions.md
docs/connectors.md
Expand All @@ -40,8 +39,7 @@ exporter/googlecloudexporter/README.md
exporter/googlemanagedprometheusexporter/README.md
EOF

for doc in $DOC_FILES
do
for doc in $DOC_FILES; do
echo "$doc"
# Point contrib links to new version
sed -i '' -Ee \
Expand Down
49 changes: 49 additions & 0 deletions scripts/update-manifest-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
# Copyright observIQ, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Check if we are cleaning up
if [ "$#" -eq 1 ] && [ "$1" == "--cleanup" ]; then
find manifests -type f -name "manifest.yaml.bak" -exec rm {} \;
echo "Backup files cleaned up successfully."
exit 0
fi

# Check if the correct number of arguments are provided
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <new_version_opentelemetry_contrib> <new_version_opentelemetry_collector> <new_version_bindplane_agent>"
exit 1
fi

# Assign arguments to variables
new_version_opentelemetry_contrib="$1"
new_version_opentelemetry_collector="$2"
new_version_bindplane_agent="$3"

# Find all manifest.yaml files in the manifests directory and its subdirectories
find manifests -type f -name "manifest.yaml" | while read -r file; do
# Create a backup of the original file
cp "$file" "${file}.bak"

# Update the dist.otelcol_version value using yq
# Easy install using `brew install yq`
yq eval -i ".dist.otelcol_version = \"$new_version_opentelemetry_collector\"" "$file"

# Use sed to update the version for matching lines
sed -i '' -E "s|(github.com/open-telemetry/opentelemetry-collector-contrib[^ ]*) v[0-9]+\.[0-9]+\.[0-9]+|\1 $new_version_opentelemetry_contrib|g" "$file"
sed -i '' -E "s|(go.opentelemetry.io/collector[^ ]*) v[0-9]+\.[0-9]+\.[0-9]+|\1 $new_version_opentelemetry_collector|g" "$file"
sed -i '' -E "s|(github.com/observiq/bindplane-agent[^ ]*) v[0-9]+\.[0-9]+\.[0-9]+|\1 $new_version_bindplane_agent|g" "$file"

echo "Versions updated successfully in $file."
done
7 changes: 2 additions & 5 deletions scripts/update-module-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.


TARGET_VERSION=$1
if [ -z "$TARGET_VERSION" ]; then
echo "Must specify a target version"
exit 1
fi

LOCAL_MODULES=$(find . -type f -name "go.mod" -exec dirname {} \; | sort)
for local_mod in $LOCAL_MODULES
do
for local_mod in $LOCAL_MODULES; do
# Run in a subshell so that the CD doesn't change this shell's current directory
(
echo "Updating version in $local_mod"
cd "$local_mod" || exit 1
OTEL_MODULES=$(go list -m -f '{{if not (or .Indirect .Main)}}{{.Path}}{{end}}' all |
grep -E -e '^github.com/observiq/bindplane-agent')

for mod in $OTEL_MODULES
do
for mod in $OTEL_MODULES; do
echo "$local_mod: $mod@$TARGET_VERSION"
go mod edit -require "$mod@$TARGET_VERSION"
done
Expand Down
14 changes: 5 additions & 9 deletions scripts/update-otel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


TARGET_VERSION=$1
if [ -z "$TARGET_VERSION" ]; then
echo "Must specify a target version"
Expand All @@ -27,30 +26,27 @@ if [ -z "$CONTRIB_TARGET_VERSION" ]; then
fi

PDATA_TARGET_VERSION=$3

if [ -z "$PDATA_TARGET_VERSION" ]; then
echo "Must specify a target pdata version"
exit 1
fi

LOCAL_MODULES=$(find . -type f -name "go.mod" -exec dirname {} \; | sort)
for local_mod in $LOCAL_MODULES
do
for local_mod in $LOCAL_MODULES; do
# Run in a subshell so that the CD doesn't change this shell's current directory
(
echo "Updating deps in $local_mod"
cd "$local_mod" || exit 1
OTEL_MODULES=$(go list -m -f '{{if not (or .Indirect .Main)}}{{.Path}}{{end}}' all |
grep -E -e '(?:^github.com/open-telemetry/opentelemetry-collector-contrib)|(?:^go.opentelemetry.io/collector)')

for mod in $OTEL_MODULES
do
case $mod in
for mod in $OTEL_MODULES; do
case $mod in
go.opentelemetry.io/collector/pdata* | go.opentelemetry.io/collector/config/configtls* | go.opentelemetry.io/collector/config/configretry*)
# pdata package is versioned separately
echo "$local_mod: $mod@$PDATA_TARGET_VERSION"
go mod edit -require "$mod@$PDATA_TARGET_VERSION"
;;
;;
github.com/open-telemetry/opentelemetry-collector-contrib*)
echo "$local_mod: $mod@$CONTRIB_TARGET_VERSION"
go mod edit -require "$mod@$CONTRIB_TARGET_VERSION"
Expand All @@ -59,7 +55,7 @@ do
echo "$local_mod: $mod@$TARGET_VERSION"
go mod edit -require "$mod@$TARGET_VERSION"
;;
esac;
esac
done
)
done

0 comments on commit 0346fab

Please sign in to comment.