Skip to content

Commit eee7566

Browse files
committed
add ephemeral containers to node profile
Signed-off-by: Matthias Bertschy <[email protected]>
1 parent 235a179 commit eee7566

File tree

5 files changed

+15
-20
lines changed

5 files changed

+15
-20
lines changed

.github/workflows/pr.yaml

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ jobs:
1515
- name: Set up Go
1616
uses: actions/setup-go@v4
1717
with:
18-
go-version: '1.21'
18+
go-version: '1.22'
1919

2020
- name: Test race
2121
run: go test -v -race ./...
22-
22+
2323
- name: Test units
2424
run: go test -v ./... -covermode=count -coverprofile=coverage.out
2525

2626
- name: Convert coverage to lcov
2727
uses: jandelgado/gcov2lcov-action@v1
28-
28+
2929
- name: Coveralls
3030
uses: coverallsapp/github-action@v1
3131
with:
@@ -42,5 +42,3 @@ jobs:
4242
version: latest
4343
args: --timeout 10m --build-tags=static
4444
only-new-issues: true
45-
46-

.github/workflows/release.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Release-Tag
22
on:
33
push:
4-
branches: [ main]
4+
branches: [ main]
55
paths-ignore:
66
# Do not run the pipeline if only Markdown files changed
77
- '**.md'
@@ -14,14 +14,14 @@ jobs:
1414
- name: Set up Go
1515
uses: actions/setup-go@v4
1616
with:
17-
go-version: '1.21'
17+
go-version: '1.22'
1818

1919
- name: Build
2020
run: go build -v ./...
2121

2222
- name: Test
2323
run: go test -v ./...
24-
24+
2525
- name: Create a release
2626
id: create_release
2727
uses: actions/create-release@v1
@@ -31,4 +31,4 @@ jobs:
3131
tag_name: v0.0.${{ github.run_number }}
3232
release_name: Release v0.0.${{ github.run_number }}
3333
draft: false
34-
prerelease: false
34+
prerelease: false

armotypes/nodesProfile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (nc *NodeStatus) CountRunningPodsContainers() int {
9696
var containersCount int
9797
runningPods := nc.GetRunningPods()
9898
for _, pod := range runningPods {
99-
containersCount += len(pod.Containers) + len(pod.InitContainers)
99+
containersCount += len(pod.Containers) + len(pod.InitContainers) + len(pod.EphemeralContainers)
100100
}
101101
return containersCount
102102
}

armotypes/podstatus.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package armotypes
22

3-
import "time"
3+
import (
4+
"slices"
5+
"time"
6+
)
47

58
type PodStatus struct {
69
CustomerGUID string `json:"customerGUID"`
@@ -22,6 +25,7 @@ type PodStatus struct {
2225
CreationTimestamp time.Time `json:"creationTimestamp"`
2326
Containers []PodContainer `json:"containers,omitempty"`
2427
InitContainers []PodContainer `json:"initContainers,omitempty"`
28+
EphemeralContainers []PodContainer `json:"ephemeralContainers,omitempty"`
2529

2630
HasFinalApplicationProfile bool `json:"hasFinalApplicationProfile"`
2731

@@ -42,18 +46,11 @@ type PodContainer struct {
4246
func (ps *PodStatus) GetMonitoredContainers() []PodContainer {
4347
var monitoredContainers []PodContainer
4448
if ps.IsKDRMonitored {
45-
for _, container := range ps.Containers {
49+
for _, container := range slices.Concat(ps.Containers, ps.InitContainers, ps.EphemeralContainers) {
4650
if container.IsKDRMonitored {
4751
monitoredContainers = append(monitoredContainers, container)
4852
}
4953
}
50-
51-
for _, container := range ps.InitContainers {
52-
if container.IsKDRMonitored {
53-
monitoredContainers = append(monitoredContainers, container)
54-
}
55-
}
56-
5754
}
5855
return monitoredContainers
5956
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/armosec/armoapi-go
22

3-
go 1.21.1
3+
go 1.22.2
44

55
require (
66
github.com/anchore/grype v0.74.2

0 commit comments

Comments
 (0)