-
Notifications
You must be signed in to change notification settings - Fork 107
fix(ops): group OpenTelemetry module upgrades and sync semconv imports in Go files #2015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c5c876a
7b21619
6ac7c13
570505e
ad4d1c3
3a06cd9
cfd5c3b
23bcbd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,28 +143,54 @@ release-lib::gomod_vulnfix() { | |
| return 1 | ||
| fi | ||
|
|
||
| if [[ "${vuln_file}" != /* ]]; then | ||
| vuln_file="$(pwd)/${vuln_file}" | ||
| fi | ||
|
|
||
| # Read the vulnerability file line by line. | ||
| # The `|| [[ -n "$line" ]]` part handles the case where the last line doesn't have a newline. | ||
| pushd "${dir}" | ||
| while IFS= read -r line || [[ -n "$line" ]]; do | ||
| # Skip any empty lines in the input file. | ||
| if [ -z "$line" ]; then | ||
| continue | ||
| fi | ||
|
|
||
| mod=$(echo "$line" | awk '{print $2}') | ||
| mod=$(echo "$line" | awk '{print $1}') | ||
| mod_path=$(echo "${mod}" | cut -d'@' -f1) | ||
| desired_version=$(echo "${mod}" | cut -d'@' -f2) | ||
| desired_version=$(echo "${mod}" | cut -s -d'@' -f2) | ||
|
|
||
| if [[ -z "${mod_path}" ]] || [[ -z "${desired_version}" ]]; then | ||
| echo "⚠️ Skipping malformed line: $line" | ||
| continue | ||
| fi | ||
|
|
||
| echo "🔄 Updating module '${mod_path}' to version '${desired_version}'..." | ||
| ${SED} -i "s|\( ${mod_path} \).*|\1${desired_version}|" "${dir}/go.mod" | ||
| if [[ "${mod_path}" == go.opentelemetry.io/otel* ]]; then | ||
| # OpenTelemetry core API/SDK modules share versions and schema URLs across packages (e.g. otel, otel/sdk, otel/trace, otel/metric). | ||
| # Upgrade core otel modules present in the module graph together to avoid conflicting schema URL errors. | ||
| otel_mods=$(go list -m all 2>/dev/null | awk '/^go\.opentelemetry\.io\/otel($|\/)/ && !/^go\.opentelemetry\.io\/otel\/(contrib|semconv)/ {print $1}') | ||
| all_otel=$(echo "${mod_path} ${otel_mods}" | tr ' ' '\n' | sort -u) | ||
| otel_args="" | ||
| for m in $(echo "${all_otel}" | tr ' ' '\n'); do | ||
| if go list -m "${m}@${desired_version}" >/dev/null 2>&1; then | ||
| otel_args="${otel_args} ${m}@${desired_version}" | ||
| fi | ||
| done | ||
| if [[ -n "${otel_args// /}" ]]; then | ||
|
bwplotka marked this conversation as resolved.
|
||
| echo "🔄 Updating OpenTelemetry modules simultaneously:${otel_args}..." | ||
| go get ${otel_args} | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW: sed was on purpose here -- it limits the chained updates related to this dep. go mod tidy after sed-ing scopes updates only to things that truly are needed. e.g. client_golang update does not need latest 0.x common, and breaking changes on those occur. Something to keep in mind, but we could try with this, especially AI is forcing this all the time ;p |
||
| else | ||
| log_err "Could not resolve any OpenTelemetry modules matching version '${desired_version}'" | ||
| popd | ||
| return 1 | ||
| fi | ||
|
|
||
| else | ||
| echo "🔄 Updating module '${mod_path}' to version '${desired_version}'..." | ||
| go get "${mod_path}@${desired_version}" | ||
| fi | ||
| done <"${vuln_file}" | ||
| echo "🔄 Resolving ${dir}/go.mod..." | ||
| pushd "${dir}" | ||
| go mod tidy | ||
| popd | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.