-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cert-manager): improve logging (#2279)
- Loading branch information
1 parent
e2c5583
commit 859459d
Showing
3 changed files
with
43 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package common | ||
|
||
import ctrl "sigs.k8s.io/controller-runtime" | ||
|
||
// GetRequestInfo extracts name and namespace from a controller request. | ||
func GetRequestInfo(req ctrl.Request) map[string]string { | ||
return map[string]string{ | ||
"name": req.Name, | ||
"namespace": req.Namespace, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package common | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"k8s.io/apimachinery/pkg/types" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
) | ||
|
||
func TestGetRequestInfo(t *testing.T) { | ||
req := ctrl.Request{ | ||
NamespacedName: types.NamespacedName{ | ||
Name: "example", | ||
Namespace: "test-namespace", | ||
}} | ||
|
||
info := GetRequestInfo(req) | ||
expected := map[string]string{ | ||
"name": "example", | ||
"namespace": "test-namespace", | ||
} | ||
require.Equal(t, expected, info) | ||
} |