Skip to content

Commit

Permalink
Guard against nil owners in testcommon
Browse files Browse the repository at this point in the history
  • Loading branch information
matthchr committed Oct 2, 2023
1 parent 2583722 commit 2ab5ab9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions v2/internal/testcommon/kube_test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,30 @@ type KubeBaseTestContext struct {
}

func AsOwner(obj client.Object) *genruntime.KnownResourceReference {
if obj.GetName() == "" {
panic("cannot use AsOwner() with empty name")
}

return &genruntime.KnownResourceReference{
Name: obj.GetName(),
}
}

func AsKubernetesOwner(obj client.Object) *genruntime.KubernetesOwnerReference {
if obj.GetName() == "" {
panic("cannot use AsKubernetesOwner() with empty name")
}

return &genruntime.KubernetesOwnerReference{
Name: obj.GetName(),
}
}

func AsARMIDOwner(id string) *genruntime.KnownResourceReference {
if id == "" {
panic("cannot use AsARMIDOwner() with empty ID")
}

return &genruntime.KnownResourceReference{
ARMID: id,
}
Expand Down

0 comments on commit 2ab5ab9

Please sign in to comment.