Skip to content

Commit

Permalink
Fix bug with eating up secret type
Browse files Browse the repository at this point in the history
  • Loading branch information
dee-kryvenko committed Mar 5, 2024
1 parent b4f9a93 commit e003216
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions k8s/secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ func TestGetLabeledSecrets(t *testing.T) {
},
},
},
&corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "labeled-pull-secret",
Namespace: "my-test-namespace",
Labels: map[string]string{
types.ReplicatorLabel: "true",
},
},
Type: corev1.SecretTypeDockerConfigJson,
},
&corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "labeled-secret-for-current-namespace",
Expand Down Expand Up @@ -289,13 +299,14 @@ func TestGetLabeledSecrets(t *testing.T) {
secrets, err := client.GetLabeledSecrets(context.TODO(), "my-test-namespace", "")
require.NoError(t, err)

require.Len(t, secrets.Items, 6)
require.Len(t, secrets.Items, 7)
secretKeys := make([]string, 0, len(secrets.Items))
for _, secret := range secrets.Items {
secretKeys = append(secretKeys, fmt.Sprintf("%s/%s", secret.Namespace, secret.Name))
}
require.ElementsMatch(t, []string{
"my-test-namespace/labeled-secret",
"my-test-namespace/labeled-pull-secret",
"my-test-namespace/labeled-secret-for-current-namespace",
"my-test-namespace/labeled-secret-for-current-namespace-explicitly",
"some-other-namespace/labeled-secret-in-another-namespace-for-any-namespace",
Expand All @@ -318,6 +329,17 @@ func TestGetLabeledSecrets(t *testing.T) {
},
},
},
&corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "labeled-pull-secret",
Namespace: "my-test-namespace",
Labels: map[string]string{
types.ReplicatorLabelAlternative: "true",
"alternative-label": "alternative-label-value",
},
},
Type: corev1.SecretTypeDockerConfigJson,
},
&corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "labeled-secret-for-current-namespace",
Expand Down Expand Up @@ -464,13 +486,14 @@ func TestGetLabeledSecrets(t *testing.T) {
secrets, err := client.GetLabeledSecrets(context.TODO(), "my-test-namespace", "alternative-label=alternative-label-value")
require.NoError(t, err)

require.Len(t, secrets.Items, 6)
require.Len(t, secrets.Items, 7)
secretKeys := make([]string, 0, len(secrets.Items))
for _, secret := range secrets.Items {
secretKeys = append(secretKeys, fmt.Sprintf("%s/%s", secret.Namespace, secret.Name))
}
require.ElementsMatch(t, []string{
"my-test-namespace/labeled-secret",
"my-test-namespace/labeled-pull-secret",
"my-test-namespace/labeled-secret-for-current-namespace",
"my-test-namespace/labeled-secret-for-current-namespace-explicitly",
"some-other-namespace/labeled-secret-in-another-namespace-for-any-namespace",
Expand Down

0 comments on commit e003216

Please sign in to comment.