Skip to content

Commit 8cda1f9

Browse files
authored
test(controllers): migrate runtime controller tests to Ginkgo (#5680)
* test(controllers): migrate runtime controller tests Signed-off-by: Harsh <harshmastic@gmail.com> * address review Signed-off-by: Harsh <harshmastic@gmail.com> * ci: pin staticcheck toolchain setup Signed-off-by: Harsh <harshmastic@gmail.com> --------- Signed-off-by: Harsh <harshmastic@gmail.com>
1 parent bdc4ab0 commit 8cda1f9

3 files changed

Lines changed: 709 additions & 1 deletion

File tree

.github/workflows/project-check.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ jobs:
1717
staticcheck:
1818
runs-on: ubuntu-latest
1919
steps:
20+
- name: Set up Go
21+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
22+
with:
23+
go-version: ${{ env.GO_VERSION }}
2024
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
21-
- uses: dominikh/staticcheck-action@9716614d4101e79b4340dd97b10e54d68234e431 # v1.4.1
25+
- uses: dominikh/staticcheck-action@024238d2898c874f26d723e7d0ff4308c35589a2 # v1
26+
with:
27+
install-go: false
28+
version: "2025.1.1"
2229

2330
lint:
2431
runs-on: ubuntu-latest

pkg/controllers/runtime_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,11 @@ func (r *RuntimeReconciler) AddOwnerAndRequeue(ctx cruntime.ReconcileRequestCont
361361

362362
// GetRuntimeObjectMeta gets runtime object meta
363363
func (r *RuntimeReconciler) GetRuntimeObjectMeta(ctx cruntime.ReconcileRequestContext) (objectMeta metav1.Object, err error) {
364+
if ctx.Runtime == nil || reflect.ValueOf(ctx.Runtime).IsNil() {
365+
err = fmt.Errorf("runtime is nil")
366+
return
367+
}
368+
364369
objectMetaAccessor, isOM := ctx.Runtime.(metav1.ObjectMetaAccessor)
365370
if !isOM {
366371
// return utils.RequeueIfError(fmt.Errorf("object is not ObjectMetaAccessor"))

0 commit comments

Comments
 (0)