|
@@ -36,7 +36,6 @@ import (
|
|
|
corev1 "k8s.io/api/core/v1"
|
|
corev1 "k8s.io/api/core/v1"
|
|
|
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
|
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
- "k8s.io/utils/ptr"
|
|
|
|
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
|
|
clientfake "sigs.k8s.io/controller-runtime/pkg/client/fake"
|
|
clientfake "sigs.k8s.io/controller-runtime/pkg/client/fake"
|
|
|
|
|
|
|
@@ -462,8 +461,8 @@ func TestSetSecret(t *testing.T) {
|
|
|
Value: &externalSecrets,
|
|
Value: &externalSecrets,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- Key: ptr.To("taname1"),
|
|
|
|
|
- Value: ptr.To("tagvalue1"),
|
|
|
|
|
|
|
+ Key: new("taname1"),
|
|
|
|
|
+ Value: new("tagvalue1"),
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1014,14 +1013,14 @@ func TestSetSecret(t *testing.T) {
|
|
|
ARN: &arn,
|
|
ARN: &arn,
|
|
|
Tags: []types.Tag{
|
|
Tags: []types.Tag{
|
|
|
{Key: &managedBy, Value: &externalSecrets},
|
|
{Key: &managedBy, Value: &externalSecrets},
|
|
|
- {Key: ptr.To("team"), Value: ptr.To("paradox")},
|
|
|
|
|
|
|
+ {Key: new("team"), Value: new("paradox")},
|
|
|
},
|
|
},
|
|
|
}, nil),
|
|
}, nil),
|
|
|
PutSecretValueFn: fakesm.NewPutSecretValueFn(putSecretOutput, nil),
|
|
PutSecretValueFn: fakesm.NewPutSecretValueFn(putSecretOutput, nil),
|
|
|
TagResourceFn: fakesm.NewTagResourceFn(&awssm.TagResourceOutput{}, nil, func(input *awssm.TagResourceInput) {
|
|
TagResourceFn: fakesm.NewTagResourceFn(&awssm.TagResourceOutput{}, nil, func(input *awssm.TagResourceInput) {
|
|
|
assert.Len(t, input.Tags, 2)
|
|
assert.Len(t, input.Tags, 2)
|
|
|
assert.Contains(t, input.Tags, types.Tag{Key: &managedBy, Value: &externalSecrets})
|
|
assert.Contains(t, input.Tags, types.Tag{Key: &managedBy, Value: &externalSecrets})
|
|
|
- assert.Contains(t, input.Tags, types.Tag{Key: ptr.To("env"), Value: ptr.To("sandbox")})
|
|
|
|
|
|
|
+ assert.Contains(t, input.Tags, types.Tag{Key: new("env"), Value: new("sandbox")})
|
|
|
}),
|
|
}),
|
|
|
UntagResourceFn: fakesm.NewUntagResourceFn(&awssm.UntagResourceOutput{}, nil, func(input *awssm.UntagResourceInput) {
|
|
UntagResourceFn: fakesm.NewUntagResourceFn(&awssm.UntagResourceOutput{}, nil, func(input *awssm.UntagResourceInput) {
|
|
|
assert.Len(t, input.TagKeys, 1)
|
|
assert.Len(t, input.TagKeys, 1)
|
|
@@ -1557,7 +1556,7 @@ func TestSecretsManagerGetAllSecrets(t *testing.T) {
|
|
|
Name: &esv1.FindName{
|
|
Name: &esv1.FindName{
|
|
|
RegExp: secretName,
|
|
RegExp: secretName,
|
|
|
},
|
|
},
|
|
|
- Path: ptr.To(secretPath),
|
|
|
|
|
|
|
+ Path: new(secretPath),
|
|
|
},
|
|
},
|
|
|
secretName: secretName,
|
|
secretName: secretName,
|
|
|
secretVersion: secretVersion,
|
|
secretVersion: secretVersion,
|
|
@@ -1569,7 +1568,7 @@ func TestSecretsManagerGetAllSecrets(t *testing.T) {
|
|
|
return &awssm.BatchGetSecretValueOutput{
|
|
return &awssm.BatchGetSecretValueOutput{
|
|
|
SecretValues: []types.SecretValueEntry{
|
|
SecretValues: []types.SecretValueEntry{
|
|
|
{
|
|
{
|
|
|
- Name: ptr.To(secretName),
|
|
|
|
|
|
|
+ Name: new(secretName),
|
|
|
VersionStages: []string{secretVersion},
|
|
VersionStages: []string{secretVersion},
|
|
|
SecretBinary: []byte(secretValue),
|
|
SecretBinary: []byte(secretValue),
|
|
|
},
|
|
},
|
|
@@ -1587,7 +1586,7 @@ func TestSecretsManagerGetAllSecrets(t *testing.T) {
|
|
|
Name: &esv1.FindName{
|
|
Name: &esv1.FindName{
|
|
|
RegExp: secretName,
|
|
RegExp: secretName,
|
|
|
},
|
|
},
|
|
|
- Path: ptr.To(secretPath),
|
|
|
|
|
|
|
+ Path: new(secretPath),
|
|
|
},
|
|
},
|
|
|
secretName: secretName,
|
|
secretName: secretName,
|
|
|
secretVersion: secretVersion,
|
|
secretVersion: secretVersion,
|
|
@@ -1596,7 +1595,7 @@ func TestSecretsManagerGetAllSecrets(t *testing.T) {
|
|
|
return &awssm.BatchGetSecretValueOutput{
|
|
return &awssm.BatchGetSecretValueOutput{
|
|
|
SecretValues: []types.SecretValueEntry{
|
|
SecretValues: []types.SecretValueEntry{
|
|
|
{
|
|
{
|
|
|
- Name: ptr.To(secretName),
|
|
|
|
|
|
|
+ Name: new(secretName),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
}, errBoom
|
|
}, errBoom
|
|
@@ -1628,7 +1627,7 @@ func TestSecretsManagerGetAllSecrets(t *testing.T) {
|
|
|
return &awssm.ListSecretsOutput{
|
|
return &awssm.ListSecretsOutput{
|
|
|
SecretList: []types.SecretListEntry{
|
|
SecretList: []types.SecretListEntry{
|
|
|
{
|
|
{
|
|
|
- Name: ptr.To("other-secret"),
|
|
|
|
|
|
|
+ Name: new("other-secret"),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
}, nil
|
|
}, nil
|
|
@@ -1637,7 +1636,7 @@ func TestSecretsManagerGetAllSecrets(t *testing.T) {
|
|
|
return &awssm.BatchGetSecretValueOutput{
|
|
return &awssm.BatchGetSecretValueOutput{
|
|
|
SecretValues: []types.SecretValueEntry{
|
|
SecretValues: []types.SecretValueEntry{
|
|
|
{
|
|
{
|
|
|
- Name: ptr.To("other-secret"),
|
|
|
|
|
|
|
+ Name: new("other-secret"),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
}, nil
|
|
}, nil
|
|
@@ -1673,7 +1672,7 @@ func TestSecretsManagerGetAllSecrets(t *testing.T) {
|
|
|
return &awssm.BatchGetSecretValueOutput{
|
|
return &awssm.BatchGetSecretValueOutput{
|
|
|
SecretValues: []types.SecretValueEntry{
|
|
SecretValues: []types.SecretValueEntry{
|
|
|
{
|
|
{
|
|
|
- Name: ptr.To(secretName),
|
|
|
|
|
|
|
+ Name: new(secretName),
|
|
|
VersionStages: []string{secretVersion},
|
|
VersionStages: []string{secretVersion},
|
|
|
SecretBinary: []byte(secretValue),
|
|
SecretBinary: []byte(secretValue),
|
|
|
},
|
|
},
|
|
@@ -1696,18 +1695,18 @@ func TestSecretsManagerGetAllSecrets(t *testing.T) {
|
|
|
listSecretsFn: func(_ context.Context, input *awssm.ListSecretsInput, _ ...func(*awssm.Options)) (*awssm.ListSecretsOutput, error) {
|
|
listSecretsFn: func(_ context.Context, input *awssm.ListSecretsInput, _ ...func(*awssm.Options)) (*awssm.ListSecretsOutput, error) {
|
|
|
allSecrets := []types.SecretListEntry{
|
|
allSecrets := []types.SecretListEntry{
|
|
|
{
|
|
{
|
|
|
- Name: ptr.To(secretName),
|
|
|
|
|
|
|
+ Name: new(secretName),
|
|
|
Tags: []types.Tag{
|
|
Tags: []types.Tag{
|
|
|
- {Key: ptr.To("foo"), Value: ptr.To("bar")},
|
|
|
|
|
|
|
+ {Key: new("foo"), Value: new("bar")},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- Name: ptr.To(fmt.Sprintf("%ssomeothertext", secretName)),
|
|
|
|
|
|
|
+ Name: new(fmt.Sprintf("%ssomeothertext", secretName)),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- Name: ptr.To("unmatched-secret"),
|
|
|
|
|
|
|
+ Name: new("unmatched-secret"),
|
|
|
Tags: []types.Tag{
|
|
Tags: []types.Tag{
|
|
|
- {Key: ptr.To("foo"), Value: ptr.To("bar")},
|
|
|
|
|
|
|
+ {Key: new("foo"), Value: new("bar")},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
@@ -1759,20 +1758,20 @@ func TestSecretsManagerGetAllSecrets(t *testing.T) {
|
|
|
getSecretValueFn: func(_ context.Context, input *awssm.GetSecretValueInput, _ ...func(*awssm.Options)) (*awssm.GetSecretValueOutput, error) {
|
|
getSecretValueFn: func(_ context.Context, input *awssm.GetSecretValueInput, _ ...func(*awssm.Options)) (*awssm.GetSecretValueOutput, error) {
|
|
|
if *input.SecretId == secretName {
|
|
if *input.SecretId == secretName {
|
|
|
return &awssm.GetSecretValueOutput{
|
|
return &awssm.GetSecretValueOutput{
|
|
|
- Name: ptr.To(secretName),
|
|
|
|
|
|
|
+ Name: new(secretName),
|
|
|
VersionStages: []string{secretVersion},
|
|
VersionStages: []string{secretVersion},
|
|
|
SecretBinary: []byte(secretValue),
|
|
SecretBinary: []byte(secretValue),
|
|
|
}, nil
|
|
}, nil
|
|
|
}
|
|
}
|
|
|
if *input.SecretId == "unmatched-secret" {
|
|
if *input.SecretId == "unmatched-secret" {
|
|
|
return &awssm.GetSecretValueOutput{
|
|
return &awssm.GetSecretValueOutput{
|
|
|
- Name: ptr.To("unmatched-secret"),
|
|
|
|
|
|
|
+ Name: new("unmatched-secret"),
|
|
|
VersionStages: []string{secretVersion},
|
|
VersionStages: []string{secretVersion},
|
|
|
SecretBinary: []byte("othervalue"),
|
|
SecretBinary: []byte("othervalue"),
|
|
|
}, nil
|
|
}, nil
|
|
|
}
|
|
}
|
|
|
return &awssm.GetSecretValueOutput{
|
|
return &awssm.GetSecretValueOutput{
|
|
|
- Name: ptr.To(fmt.Sprintf("%ssomeothertext", secretName)),
|
|
|
|
|
|
|
+ Name: new(fmt.Sprintf("%ssomeothertext", secretName)),
|
|
|
VersionStages: []string{secretVersion},
|
|
VersionStages: []string{secretVersion},
|
|
|
SecretBinary: []byte("someothervalue"),
|
|
SecretBinary: []byte("someothervalue"),
|
|
|
}, nil
|
|
}, nil
|
|
@@ -1794,7 +1793,7 @@ func TestSecretsManagerGetAllSecrets(t *testing.T) {
|
|
|
return &awssm.BatchGetSecretValueOutput{
|
|
return &awssm.BatchGetSecretValueOutput{
|
|
|
SecretValues: []types.SecretValueEntry{
|
|
SecretValues: []types.SecretValueEntry{
|
|
|
{
|
|
{
|
|
|
- Name: ptr.To(secretName),
|
|
|
|
|
|
|
+ Name: new(secretName),
|
|
|
VersionStages: []string{secretVersion},
|
|
VersionStages: []string{secretVersion},
|
|
|
SecretBinary: []byte(secretValue),
|
|
SecretBinary: []byte(secretValue),
|
|
|
},
|
|
},
|
|
@@ -2106,8 +2105,8 @@ func TestComputeTagsToUpdate(t *testing.T) {
|
|
|
"key2": "value2",
|
|
"key2": "value2",
|
|
|
},
|
|
},
|
|
|
expected: []types.Tag{
|
|
expected: []types.Tag{
|
|
|
- {Key: ptr.To("key1"), Value: ptr.To("value1")},
|
|
|
|
|
- {Key: ptr.To("key2"), Value: ptr.To("value2")},
|
|
|
|
|
|
|
+ {Key: new("key1"), Value: new("value1")},
|
|
|
|
|
+ {Key: new("key2"), Value: new("value2")},
|
|
|
},
|
|
},
|
|
|
modified: false,
|
|
modified: false,
|
|
|
},
|
|
},
|
|
@@ -2123,9 +2122,9 @@ func TestComputeTagsToUpdate(t *testing.T) {
|
|
|
managedBy: externalSecrets,
|
|
managedBy: externalSecrets,
|
|
|
},
|
|
},
|
|
|
expected: []types.Tag{
|
|
expected: []types.Tag{
|
|
|
- {Key: ptr.To("key1"), Value: ptr.To("value1")},
|
|
|
|
|
- {Key: ptr.To("key2"), Value: ptr.To("value2")},
|
|
|
|
|
- {Key: ptr.To(managedBy), Value: ptr.To(externalSecrets)},
|
|
|
|
|
|
|
+ {Key: new("key1"), Value: new("value1")},
|
|
|
|
|
+ {Key: new("key2"), Value: new("value2")},
|
|
|
|
|
+ {Key: new(managedBy), Value: new(externalSecrets)},
|
|
|
},
|
|
},
|
|
|
modified: false,
|
|
modified: false,
|
|
|
},
|
|
},
|
|
@@ -2139,8 +2138,8 @@ func TestComputeTagsToUpdate(t *testing.T) {
|
|
|
"key2": "value2",
|
|
"key2": "value2",
|
|
|
},
|
|
},
|
|
|
expected: []types.Tag{
|
|
expected: []types.Tag{
|
|
|
- {Key: ptr.To("key1"), Value: ptr.To("value1")},
|
|
|
|
|
- {Key: ptr.To("key2"), Value: ptr.To("value2")},
|
|
|
|
|
|
|
+ {Key: new("key1"), Value: new("value1")},
|
|
|
|
|
+ {Key: new("key2"), Value: new("value2")},
|
|
|
},
|
|
},
|
|
|
modified: true,
|
|
modified: true,
|
|
|
},
|
|
},
|
|
@@ -2153,7 +2152,7 @@ func TestComputeTagsToUpdate(t *testing.T) {
|
|
|
"key1": "newValue",
|
|
"key1": "newValue",
|
|
|
},
|
|
},
|
|
|
expected: []types.Tag{
|
|
expected: []types.Tag{
|
|
|
- {Key: ptr.To("key1"), Value: ptr.To("newValue")},
|
|
|
|
|
|
|
+ {Key: new("key1"), Value: new("newValue")},
|
|
|
},
|
|
},
|
|
|
modified: true,
|
|
modified: true,
|
|
|
},
|
|
},
|
|
@@ -2171,7 +2170,7 @@ func TestComputeTagsToUpdate(t *testing.T) {
|
|
|
"key1": "value1",
|
|
"key1": "value1",
|
|
|
},
|
|
},
|
|
|
expected: []types.Tag{
|
|
expected: []types.Tag{
|
|
|
- {Key: ptr.To("key1"), Value: ptr.To("value1")},
|
|
|
|
|
|
|
+ {Key: new("key1"), Value: new("value1")},
|
|
|
},
|
|
},
|
|
|
modified: true,
|
|
modified: true,
|
|
|
},
|
|
},
|
|
@@ -2220,8 +2219,8 @@ func TestPatchTags(t *testing.T) {
|
|
|
expectUntag: false,
|
|
expectUntag: false,
|
|
|
expectTag: true,
|
|
expectTag: true,
|
|
|
assertsTag: func(input *awssm.TagResourceInput) {
|
|
assertsTag: func(input *awssm.TagResourceInput) {
|
|
|
- assert.Contains(t, input.Tags, types.Tag{Key: ptr.To(managedBy), Value: ptr.To(externalSecrets)})
|
|
|
|
|
- assert.Contains(t, input.Tags, types.Tag{Key: ptr.To("a"), Value: ptr.To("2")})
|
|
|
|
|
|
|
+ assert.Contains(t, input.Tags, types.Tag{Key: new(managedBy), Value: new(externalSecrets)})
|
|
|
|
|
+ assert.Contains(t, input.Tags, types.Tag{Key: new("a"), Value: new("2")})
|
|
|
},
|
|
},
|
|
|
assertsUntag: func(input *awssm.UntagResourceInput) {
|
|
assertsUntag: func(input *awssm.UntagResourceInput) {
|
|
|
assert.Fail(t, "Expected UntagResource to not be called")
|
|
assert.Fail(t, "Expected UntagResource to not be called")
|
|
@@ -2247,9 +2246,9 @@ func TestPatchTags(t *testing.T) {
|
|
|
expectUntag: false,
|
|
expectUntag: false,
|
|
|
expectTag: true,
|
|
expectTag: true,
|
|
|
assertsTag: func(input *awssm.TagResourceInput) {
|
|
assertsTag: func(input *awssm.TagResourceInput) {
|
|
|
- assert.Contains(t, input.Tags, types.Tag{Key: ptr.To(managedBy), Value: ptr.To(externalSecrets)})
|
|
|
|
|
- assert.Contains(t, input.Tags, types.Tag{Key: ptr.To("a"), Value: ptr.To("1")})
|
|
|
|
|
- assert.Contains(t, input.Tags, types.Tag{Key: ptr.To("b"), Value: ptr.To("2")})
|
|
|
|
|
|
|
+ assert.Contains(t, input.Tags, types.Tag{Key: new(managedBy), Value: new(externalSecrets)})
|
|
|
|
|
+ assert.Contains(t, input.Tags, types.Tag{Key: new("a"), Value: new("1")})
|
|
|
|
|
+ assert.Contains(t, input.Tags, types.Tag{Key: new("b"), Value: new("2")})
|
|
|
},
|
|
},
|
|
|
assertsUntag: func(input *awssm.UntagResourceInput) {
|
|
assertsUntag: func(input *awssm.UntagResourceInput) {
|
|
|
assert.Fail(t, "Expected UntagResource to not be called")
|
|
assert.Fail(t, "Expected UntagResource to not be called")
|
|
@@ -2272,10 +2271,10 @@ func TestPatchTags(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
sm := &SecretsManager{client: fakeClient}
|
|
sm := &SecretsManager{client: fakeClient}
|
|
|
- metaMap := map[string]interface{}{
|
|
|
|
|
|
|
+ metaMap := map[string]any{
|
|
|
"apiVersion": "kubernetes.external-secrets.io/v1alpha1",
|
|
"apiVersion": "kubernetes.external-secrets.io/v1alpha1",
|
|
|
"kind": "PushSecretMetadata",
|
|
"kind": "PushSecretMetadata",
|
|
|
- "spec": map[string]interface{}{
|
|
|
|
|
|
|
+ "spec": map[string]any{
|
|
|
"description": "adding managed-by tag explicitly",
|
|
"description": "adding managed-by tag explicitly",
|
|
|
"tags": tt.metaTags,
|
|
"tags": tt.metaTags,
|
|
|
},
|
|
},
|