Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pkg/discovery/injector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,14 @@ func TestDefaultInjector_InjectEnv(t *testing.T) {
Name: "RBG_GROUP_NAME",
Value: "test-rbg",
},
{
Name: "RBG_ROLE_INDEX",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve maintainability and consistency with the production code, please use the constants.EnvRBGRoleIndex constant instead of the hardcoded string "RBG_ROLE_INDEX".

I also noticed this new environment variable block is duplicated on lines 562-569. You might consider refactoring to a shared variable to avoid this duplication.

Suggested change
Name: "RBG_ROLE_INDEX",
Name: constants.EnvRBGRoleIndex,

ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.labels['apps.kubernetes.io/pod-index']",
},
},
},
{
Name: "RBG_ROLE_NAME",
Value: "worker",
Expand Down Expand Up @@ -551,6 +559,14 @@ func TestDefaultInjector_InjectEnv(t *testing.T) {
Name: "RBG_GROUP_NAME",
Value: "test-rbg",
},
{
Name: "RBG_ROLE_INDEX",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to my other comment, please use the constants.EnvRBGRoleIndex constant here to avoid using a hardcoded string.

Suggested change
Name: "RBG_ROLE_INDEX",
Name: constants.EnvRBGRoleIndex,

ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.labels['apps.kubernetes.io/pod-index']",
},
},
},
{
Name: "RBG_ROLE_NAME",
Value: "worker",
Expand Down
Loading