From 87f99c96f7634856bccc52760f863d20e2ba1aa4 Mon Sep 17 00:00:00 2001 From: Hayato Kiwata Date: Wed, 14 Jun 2023 17:09:16 +0000 Subject: [PATCH] fix(CI): add the job to run go test on the KubeArmor/KubeArmor directory and fix to pass the tests The current implementation does not have a job in CI to run tests for golang programs under the KubeArmor/KubeArmor directory. Therefore, this commit will add the job to ci-test-go.yml to run tests for golang programs under the KubeArmor/KubeArmor directory. On the other hand, in the current implementation, the following error occurs when go test is executed in the directory KubeArmor/KubeArmor/core. > go test # github.com/kubearmor/KubeArmor/KubeArmor/core ./karmorprobedata.go:61:3: (*github.com/kubearmor/KubeArmor/KubeArmor/feeder.Feeder).Errf format %s reads arg #1, but call has 0 args Thus, if test_kubearmor.sh or go test ./... on the kubearmor/kubeArmor are run, the test will fail. The test fails because dm.Logger.Errf(), which is called in the SetKarmorData function in the file core/karmorprobedata.go, is missing an argument for the format specifier. Therefore, this commit will fix it to add a variable for the format specifiers so that the test will succeed properly. Signed-off-by: Hayato Kiwata --- .github/workflows/ci-test-go.yml | 13 +++++++++++++ KubeArmor/core/karmorprobedata.go | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-test-go.yml b/.github/workflows/ci-test-go.yml index e4edb04a1f..f78b1e680a 100644 --- a/.github/workflows/ci-test-go.yml +++ b/.github/workflows/ci-test-go.yml @@ -61,6 +61,19 @@ jobs: run: make gosec working-directory: KubeArmor + go-test: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-go@v3 + with: + go-version: "v1.20" + + - name: Run go test on the KubeArmor/KubeArmor directory + run: go test ./... + working-directory: KubeArmor + license: runs-on: ubuntu-20.04 steps: diff --git a/KubeArmor/core/karmorprobedata.go b/KubeArmor/core/karmorprobedata.go index bfb898095a..169b421cea 100644 --- a/KubeArmor/core/karmorprobedata.go +++ b/KubeArmor/core/karmorprobedata.go @@ -58,7 +58,7 @@ func (dm *KubeArmorDaemon) SetKarmorData() { kd.HostVisibility = dm.Node.Annotations["kubearmor-visibility"] err := kl.WriteToFile(kd, "/tmp/karmorProbeData.cfg") if err != nil { - dm.Logger.Errf("Error writing karmor config data", err) + dm.Logger.Errf("Error writing karmor config data (%s)", err.Error()) } }