-
Notifications
You must be signed in to change notification settings - Fork 10
Kcna26/customgadget teo #724
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
2ff0a8d
52af940
306782e
4e08946
4639e09
cd2ef91
9316ab6
8e6a60c
8a33ce1
ac13916
b25dea4
9a82d0e
63c5b29
a7100c4
8337c3b
98edbd2
05dbfb9
ca4eb18
5759e2a
c9e5da3
33851a4
a4e307f
971a25e
abbdb7b
a196d5b
d40f97c
ea8c722
03b92a8
066a0a7
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 |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| name: build-image | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| IMAGE_TAG: | ||
| required: true | ||
| type: string | ||
| description: "Image tag for the node-agent image" | ||
| STORAGE_REF: | ||
| required: false | ||
| type: string | ||
| default: "" | ||
| description: "Storage image tag to resolve (maps to go/<tag> Git tag). Leave empty to auto-detect latest." | ||
| PLATFORMS: | ||
| type: boolean | ||
| required: false | ||
| default: false | ||
| description: "Build for both amd64 and arm64" | ||
| push: | ||
| branches: | ||
| - test/localtestbuild | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write | ||
| packages: write | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Resolve build parameters | ||
| id: params | ||
| env: | ||
| REPO_OWNER: ${{ github.repository_owner }} | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
| echo "image_tag=${{ inputs.IMAGE_TAG }}" >> "$GITHUB_OUTPUT" | ||
| STORAGE_REF="${{ inputs.STORAGE_REF }}" | ||
| else | ||
| # Push trigger: derive tag from short commit SHA | ||
| echo "image_tag=dev-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" | ||
| STORAGE_REF="" | ||
| fi | ||
|
|
||
| # If no STORAGE_REF given, auto-detect the most recent go/ tag on storage | ||
| if [ -z "$STORAGE_REF" ]; then | ||
| echo "Auto-detecting latest storage go/ tag..." | ||
| STORAGE_REF=$(git ls-remote --tags "https://github.com/${REPO_OWNER}/storage.git" 'refs/tags/go/*' \ | ||
| | awk '{print $2}' | sed 's|refs/tags/go/||' | sort -V | tail -1) | ||
| if [ -n "$STORAGE_REF" ]; then | ||
| echo "Auto-detected storage ref: ${STORAGE_REF}" | ||
| else | ||
| echo "No go/ tags found on storage — will use default go.mod dependency" | ||
| fi | ||
| fi | ||
| echo "storage_ref=${STORAGE_REF}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: "1.25" | ||
|
|
||
| - name: Resolve storage commit hash | ||
| if: ${{ steps.params.outputs.storage_ref != '' }} | ||
| id: resolve-storage | ||
| env: | ||
| STORAGE_REF: ${{ steps.params.outputs.storage_ref }} | ||
| REPO_OWNER: ${{ github.repository_owner }} | ||
| run: | | ||
| # The storage build.yaml creates a git tag "go/<IMAGE_TAG>" specifically | ||
| # for Go module resolution. Try that first, then fall back to raw ref. | ||
| GO_TAG="go/${STORAGE_REF}" | ||
| echo "Looking up git tag '${GO_TAG}' on ${REPO_OWNER}/storage..." | ||
| COMMIT=$(git ls-remote "https://github.com/${REPO_OWNER}/storage.git" "refs/tags/${GO_TAG}" | awk '{print $1}') | ||
|
|
||
| if [ -z "$COMMIT" ]; then | ||
| echo "Tag '${GO_TAG}' not found, trying raw ref '${STORAGE_REF}'..." | ||
| COMMIT=$(git ls-remote "https://github.com/${REPO_OWNER}/storage.git" "refs/tags/${STORAGE_REF}" "refs/heads/${STORAGE_REF}" | head -1 | awk '{print $1}') | ||
| fi | ||
|
|
||
| if [ -z "$COMMIT" ]; then | ||
| echo "::error::Could not resolve '${STORAGE_REF}' to a commit. Make sure the storage build ran first (it creates the go/ tag)." | ||
| exit 1 | ||
| fi | ||
|
|
||
| SHORT=$(echo "$COMMIT" | cut -c1-12) | ||
| echo "Resolved to commit ${COMMIT} (${SHORT})" | ||
| echo "commit=${COMMIT}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Update storage dependency | ||
| if: ${{ steps.params.outputs.storage_ref != '' }} | ||
| env: | ||
| COMMIT: ${{ steps.resolve-storage.outputs.commit }} | ||
| REPO_OWNER: ${{ github.repository_owner }} | ||
| run: | | ||
| echo "Replacing github.com/kubescape/storage with github.com/${REPO_OWNER}/storage@${COMMIT}" | ||
| go mod edit -replace "github.com/kubescape/storage=github.com/${REPO_OWNER}/storage@${COMMIT}" | ||
| GONOSUMDB=github.com/k8sstormcenter/*,github.com/matthyx/* GONOSUMCHECK=github.com/k8sstormcenter/*,github.com/matthyx/* go mod tidy | ||
| echo "Resolved storage version:" | ||
| grep "${REPO_OWNER}/storage" go.sum | head -1 | ||
|
|
||
| - name: Ensure ig is installed | ||
| run: | | ||
| curl -L https://github.com/inspektor-gadget/inspektor-gadget/releases/download/v0.45.0/ig_0.45.0_amd64.deb -O | ||
| sudo dpkg -i ig_0.45.0_amd64.deb | ||
|
|
||
| - name: Build gadgets | ||
| run: make gadgets | ||
|
|
||
| - name: Set up QEMU | ||
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.PLATFORMS }} | ||
| uses: docker/setup-qemu-action@v3 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Login to GitHub Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build and push | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| file: build/Dockerfile | ||
| tags: ghcr.io/${{ github.repository_owner }}/node-agent:${{ steps.params.outputs.image_tag }} | ||
| build-args: image_version=${{ steps.params.outputs.image_tag }} | ||
| platforms: ${{ (github.event_name == 'workflow_dispatch' && inputs.PLATFORMS) && 'linux/amd64,linux/arm64' || 'linux/amd64' }} | ||
| push: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -459,3 +459,5 @@ require ( | |
| ) | ||
|
|
||
| replace github.com/inspektor-gadget/inspektor-gadget => github.com/matthyx/inspektor-gadget v0.0.0-20260203101533-6ef87216d3dd | ||
|
|
||
| replace github.com/kubescape/storage => ../storage | ||
|
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. Remove the local
Either:
🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comma in YAML flow sequence — workflow will fail to parse.
In YAML flow sequences (bracket notation), items must be comma-separated. There's no comma after
Test_24_ProcessTreeDepthTeston line 87 beforeTest_27_RegexFileOpenMatchTeston line 88.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents