upgrade-telegraf

作者: microsoft

在 dalec-build-defs 仓库中将 Telegraf 升级到新版本。创建新的 spec 文件,更新版本/提交/变更日志,并准备用于 PR 的分支。使用…

npx skills add https://github.com/microsoft/docker-provider --skill upgrade-telegraf

Upgrade Telegraf Version

This skill creates a new DALEC spec file for a new Telegraf release in the dalec-build-defs repository.

Overview

Telegraf specs live at specs/telegraf-agent/telegraf-agent-<VERSION>.yml. Each version is a standalone file copied from the latest existing spec with updated version-specific fields.

Step-by-step procedure

Step 1: Determine the target version

If the user did NOT provide a specific version, fetch the latest release from GitHub:

curl -sL https://api.github.com/repos/influxdata/telegraf/releases/latest | jq -r '.tag_name'

The tag is in the format v1.XX.Y. Strip the leading v to get the VERSION (e.g. 1.38.0).

If the user provided a version, use that directly.

Step 2: Get the commit SHA for the release tag

curl -sL https://api.github.com/repos/influxdata/telegraf/git/refs/tags/v<VERSION> | jq -r '.object.sha'

IMPORTANT: If the tag object type is "tag" (annotated tag), you must dereference it to get the actual commit SHA:

# First get the tag object
TAG_SHA=$(curl -sL https://api.github.com/repos/influxdata/telegraf/git/refs/tags/v<VERSION> | jq -r '.object.sha')
TAG_TYPE=$(curl -sL https://api.github.com/repos/influxdata/telegraf/git/refs/tags/v<VERSION> | jq -r '.object.type')

# If it's an annotated tag, dereference to get the commit
if [ "$TAG_TYPE" = "tag" ]; then
  COMMIT=$(curl -sL https://api.github.com/repos/influxdata/telegraf/git/tags/$TAG_SHA | jq -r '.object.sha')
else
  COMMIT=$TAG_SHA
fi

Verify the commit SHA is a full 40-character hex string.

Step 3: Verify the version doesn't already exist

Check that the file specs/telegraf-agent/telegraf-agent-<VERSION>.yml does NOT already exist in the workspace. If it does, inform the user and stop.

Step 4: Identify the latest existing spec file

Find the latest (highest version) existing spec file in specs/telegraf-agent/:

ls specs/telegraf-agent/telegraf-agent-*.yml | sort -V | tail -1

Read this file — it will be used as the template for the new spec.

Step 5: Create the new spec file

Copy the latest spec and update these fields:

FieldOld valueNew value
args.VERSIONold version<VERSION> (e.g. 1.38.0)
args.COMMITold commit SHAnew commit SHA from Step 2
args.REVISIONany value"1" (always reset to 1 for new versions)
tests[].steps[].stdout.contains[]old version string"<VERSION>"
changelogold entriesReplace with a single new entry. Each spec file should only contain a changelog entry for its own version — do NOT carry forward changelog entries from the previous spec file.

Changelog entry format

changelog:
  - date: "<TODAY in YYYY-MM-DD format>"
    author: "<git user.name> <<git user.email>>"
    changes:
      - Upgrade telegraf package version to <VERSION>

Get the author info from git config:

GIT_NAME=$(git config user.name)
GIT_EMAIL=$(git config user.email)

Do NOT change any other fields — keep the same #syntax frontend version (copied from the latest existing spec file), build targets, dependencies, build steps, LDFLAGS pattern, artifact paths, test structure, etc.

NOTE on #syntax version: The #syntax=ghcr.io/azure/dalec/frontend:X.XX line changes over time. Do NOT hardcode it. Always copy it verbatim from the latest existing spec file found in Step 4.

Step 6: Pull latest main, create a git branch and commit

IMPORTANT: Always fetch and rebase onto the latest origin/main before creating the branch. This ensures the new spec is based on the current state of the repository and avoids conflicts with specs already merged to main.

git fetch origin main
git checkout main
git rebase origin/main
git checkout -b copilot/upgrade-telegraf-<VERSION>
git add specs/telegraf-agent/telegraf-agent-<VERSION>.yml
git commit -m "Upgrade telegraf package version to <VERSION>"

Step 7: Push branch, create PR

Push the branch and create the PR automatically — no user confirmation needed.

git push origin copilot/upgrade-telegraf-<VERSION>

Create the PR using the GitHub REST API via curl. Extract the auth token from the git credential helper:

TOKEN=$(echo "protocol=https
host=github.com" | git credential fill 2>/dev/null | grep password | cut -d= -f2)

Then create the PR:

curl -s -X POST \
  -H "Authorization: token $TOKEN" \
  -H "Accept: application/vnd.github+json" \
  https://api.github.com/repos/Azure/dalec-build-defs/pulls \
  -d '{
  "title": "Upgrade telegraf package version to <VERSION>",
  "head": "copilot/upgrade-telegraf-<VERSION>",
  "base": "main",
  "body": "<PR_BODY>"
}'

Why not gh CLI? In this environment, gh CLI installation requires sudo (which may not be available or may block on a password prompt), and even when installed, gh auth login fails because the git credential manager token typically lacks the read:org scope that gh requires. The curl approach works reliably with the existing git credentials.

Use the following PR body (with proper JSON escaping — \n for newlines, \\ for backslashes in shell):

**What this PR does / why we need it**:
Telegraf upgrade to resolve CVE

**Which issue(s) this PR fixes** *(optional, using `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when the PR gets merged)*:

Fixes #

**Checklist**:

- [x] Is this contribution for a third-party (non-Microsoft) open-source CNCF (Cloud Native Computing Foundation) or Kubernetes-related project.
- [x] You are willing to maintain the contributed DALEC specs and update it when necessary.
- [x] Have the corresponding test requirements been met?
  - [x] Are there baseline tests within the test section of the spec(s) that validate the artifact is being built?
  - [x] Is there a test.sh script that performs some level of E2E testing?
  - [x] Are there unit tests for any patches/code changes?
- [ ] In addition to a spec PR for this repo, you will have to submit corresponding PRs for MCR Onboarding for `oss/v2` repository.
  - [ ] [MCR](https://github.com/microsoft/mcr/blob/main/teams/oss/azurecontainerupstream-v2.yml) PR
  - [ ] [mcrdocs](https://github.com/microsoft/mcrdocs/tree/main/teams/oss) PR
- [x] Have you deconflicted the package name with existing packages?
  - [ ] [Azure Linux 3.0 packages](https://github.com/microsoft/azurelinux/tree/3.0/SPECS)
- [x] If these images already exist in [`mcr.microsoft.com/oss`](https://mcr.microsoft.com/en-us/catalog?search=/oss), have you checked the repository and image name is kept the same?
- [x] Have you updated the [CODEOWNERS file](https://github.com/Azure/dalec-build-defs/blob/main/.github/CODEOWNERS)?
- [ ] Have you updated the [upstream_mapping.yml file](https://github.com/Azure/dalec-build-defs/blob/main/upstream_mapping.yml)?

**Special notes for your reviewer**:

Parse the PR URL from the JSON response:

curl ... | jq -r '.html_url'

Step 8: Summary

After all steps, print a summary:

  • New file path
  • Version and commit SHA used
  • Branch name
  • PR URL (from gh pr create output)

Reference: Spec file template

Here is the general structure of a telegraf spec file for reference. The #syntax line below is an example only — always copy the actual value from the latest existing spec file (Step 4).

#syntax=ghcr.io/azure/dalec/frontend:<COPY_FROM_LATEST_SPEC>

args:
  VERSION: <VERSION>
  COMMIT: <COMMIT_SHA>
  REVISION: "1"

name: telegraf-agent
packager: Azure Container Upstream
vendor: Microsoft Corporation
license: MIT
website: https://github.com/influxdata/telegraf
description: telegraf
version: ${VERSION}
revision: ${REVISION}
x-build-extensions:
  build-targets:
    - azlinux3/rpm

sources:
  telegraf-agent:
    git:
      url: https://github.com/influxdata/telegraf.git
      commit: ${COMMIT}
    generate:
      - gomod: {}

dependencies:
  build:
    msft-golang:
  runtime:
    openssl-libs:

build:
  env:
    VERSION: ${VERSION}
    COMMIT: ${COMMIT}
    GOPROXY: direct
    GOEXPERIMENT: systemcrypto
    CGO_ENABLED: "1"
    INTERNAL_PKG: github.com/influxdata/telegraf/internal
  steps:
    - command: |
        cd telegraf-agent
        export LDFLAGS="-s -w -X ${INTERNAL_PKG}.Commit=${COMMIT} -X ${INTERNAL_PKG}.Version=${VERSION}-${COMMIT}"
        go build -o telegraf-agent -ldflags "${LDFLAGS}" ./cmd/telegraf

artifacts:
  binaries:
    telegraf-agent/telegraf-agent: {}
  licenses:
    telegraf-agent/LICENSE: {}

tests:
  - name: Check permissions
    files:
      /usr/bin/telegraf-agent:
        permissions: 0755
  - name: Validate telegraf version
    steps:
      - command: /usr/bin/telegraf-agent --version
        stdout:
          contains:
            - "<VERSION>"

changelog:
  - date: "<YYYY-MM-DD>"
    author: "Copilot on behalf of <Name> <<email>>"
    changes:
      - Upgrade telegraf package version to <VERSION>

Important rules

  • REVISION is always "1" for a new version file.
  • Dates must be ISO 8601 format: YYYY-MM-DD.
  • Do NOT modify any existing spec files.
  • Do NOT update index.yml or upstream_mapping.yml — telegraf-agent is not listed there.
  • Do NOT change build dependencies, build steps, or artifact paths unless the upstream project changed its structure.
  • Always dereference annotated tags to get the actual commit SHA.
  • The #syntax frontend version is NOT fixed — always copy it from the latest existing spec file (Step 4). Never hardcode a specific version.

来自 microsoft 的更多技能

oss-growth
microsoft
OSS增长黑客角色
agent-framework-azure-ai-py
microsoft
使用Microsoft Agent Framework Python SDK(agent-framework-azure-ai)构建Azure AI Foundry代理。在创建使用AzureAIAgentsProvider的持久化代理、使用托管工具(代码解释器、文件搜索、网络搜索)、集成MCP服务器、管理对话线程或实现流式响应时使用。涵盖函数工具、结构化输出和多工具代理。
development
airunway-aks-setup
microsoft
在AKS上设置AI Runway——从裸集群到运行模型。涵盖集群验证、控制器安装、GPU评估、提供商设置和首次部署。适用场景:“设置AI Runway”、“接入AKS集群”、“安装AI Runway”、“airunway设置”、“将模型部署到AKS”、“在AKS上进行GPU推理”、“在AKS上配置KAITO”、“在AKS上运行LLM”、“在AKS上使用vLLM”、“在AKS上设置模型服务”、“AI Runway控制器”。
devops
appinsights-instrumentation
microsoft
使用Azure Application Insights对Web应用进行插桩的指南。提供遥测模式、SDK设置和配置参考。适用场景:如何对应用进行插桩、App Insights SDK、遥测模式、什么是App Insights、Application Insights指南、插桩示例、APM最佳实践。
devops
applicationinsights-web-ts
microsoft
使用Application Insights JavaScript SDK(@microsoft/applicationinsights-web)为浏览器/Web应用添加检测。用于真实用户监控(RUM)——页面视图、点击、AJAX/fetch依赖项、异常、自定义事件,以及与后端OpenTelemetry追踪关联的浏览器端GenAI代理追踪。涵盖SDK加载器脚本和npm设置、框架扩展(React、React Native、Angular)、点击分析、遥测初始化器,以及从浏览器发出的代理/工具/模型跨度所遵循的OTel GenAI语义约定。
devops
azure-ai-anomalydetector-java
microsoft
使用适用于 Java 的 Azure AI 异常检测器 SDK 构建异常检测应用程序。在实现单变量/多变量异常检测、时间序列分析或 AI 驱动的监控时使用。
development
azure-ai-language-conversations-py
microsoft
使用azure-ai-language-conversations Python SDK实现对话语言理解(CLU)。当使用ConversationAnalysisClient分析对话意图和实体、构建NLP功能或将语言理解集成到应用程序中时使用。
development
azure-ai-ml-py
microsoft
Azure Machine Learning SDK v2 for Python。用于机器学习工作区、作业、模型、数据集、计算资源和管道。 触发词:“azure-ai-ml”、“MLClient”、“工作区”、“模型注册表”、“训练作业”、“数据集”。
development