Skip to content

Commit

Permalink
fix(CI): add the job to run go test on the KubeArmor/KubeArmor direct…
Browse files Browse the repository at this point in the history
…ory 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 <[email protected]>
  • Loading branch information
haytok committed Jun 23, 2023
1 parent 7f767ba commit 87f99c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .github/workflows/ci-test-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion KubeArmor/core/karmorprobedata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

}

0 comments on commit 87f99c9

Please sign in to comment.