diff --git a/internal/pkg/rpaas/extra_files.go b/internal/pkg/rpaas/extra_files.go
index 1df17cdd9..ddf5b9513 100644
--- a/internal/pkg/rpaas/extra_files.go
+++ b/internal/pkg/rpaas/extra_files.go
@@ -181,7 +181,7 @@ func (m *k8sRpaasManager) getConfigMapByFileName(ctx context.Context, i *v1alpha
var cms corev1.ConfigMapList
if err := m.cli.List(ctx, &cms, &client.ListOptions{
Namespace: i.Namespace,
- LabelSelector: labels.SelectorFromSet(labels.Set(labelsSelectorForFile(filename))),
+ LabelSelector: labels.SelectorFromSet(labels.Set(labelsSelectorForFile(i.Name, filename))),
}); err != nil {
return nil, err
}
@@ -215,7 +215,7 @@ func newConfigMapForFile(i *v1alpha1.RpaasInstance, f File) *corev1.ConfigMap {
ObjectMeta: metav1.ObjectMeta{
GenerateName: fmt.Sprintf("%s-extra-files-", i.Name),
Namespace: i.Namespace,
- Labels: labelsSelectorForFile(f.Name),
+ Labels: labelsSelectorForFile(i.Name, f.Name),
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(i, schema.GroupVersionKind{
Group: v1alpha1.GroupVersion.Group,
@@ -228,11 +228,11 @@ func newConfigMapForFile(i *v1alpha1.RpaasInstance, f File) *corev1.ConfigMap {
}
}
-func labelsSelectorForFile(filename string) map[string]string {
- return map[string]string{
+func labelsSelectorForFile(instance, filename string) map[string]string {
+ return mergeMap(labelsForRpaasInstance(instance), map[string]string{
fmt.Sprintf("%s/is-file", defaultKeyLabelPrefix): "true",
fmt.Sprintf("%s/file-name", defaultKeyLabelPrefix): filename,
- }
+ })
}
func validateFiles(fs []File) error {
diff --git a/internal/pkg/rpaas/extra_files_test.go b/internal/pkg/rpaas/extra_files_test.go
index 1f62b5a4b..c76b2caae 100644
--- a/internal/pkg/rpaas/extra_files_test.go
+++ b/internal/pkg/rpaas/extra_files_test.go
@@ -46,8 +46,12 @@ func Test_k8sRpaasManager_GetExtraFiles(t *testing.T) {
Name: "my-instance-extra-file-123456",
Namespace: "rpaasv2",
Labels: map[string]string{
- "rpaas.extensions.tsuru.io/is-file": "true",
- "rpaas.extensions.tsuru.io/file-name": "index.html",
+ "rpaas.extensions.tsuru.io/instance-name": "my-instance",
+ "rpaas.extensions.tsuru.io/service-name": "rpaasv2",
+ "rpaas_instance": "my-instance",
+ "rpaas_service": "rpaasv2",
+ "rpaas.extensions.tsuru.io/is-file": "true",
+ "rpaas.extensions.tsuru.io/file-name": "index.html",
},
},
BinaryData: map[string][]byte{"index.html": []byte(`
Hello world!
`)},
@@ -57,8 +61,12 @@ func Test_k8sRpaasManager_GetExtraFiles(t *testing.T) {
Name: "my-instance-extra-file-abcde",
Namespace: "rpaasv2",
Labels: map[string]string{
- "rpaas.extensions.tsuru.io/is-file": "true",
- "rpaas.extensions.tsuru.io/file-name": "binary.exe",
+ "rpaas.extensions.tsuru.io/instance-name": "my-instance",
+ "rpaas.extensions.tsuru.io/service-name": "rpaasv2",
+ "rpaas_instance": "my-instance",
+ "rpaas_service": "rpaasv2",
+ "rpaas.extensions.tsuru.io/is-file": "true",
+ "rpaas.extensions.tsuru.io/file-name": "binary.exe",
},
},
BinaryData: map[string][]byte{"binary.exe": {66, 55, 10, 00, 20}},
@@ -131,8 +139,12 @@ func Test_k8sRpaasManager_DeleteExtraFiles(t *testing.T) {
Name: "my-instance-extra-files-1",
Namespace: "rpaasv2",
Labels: map[string]string{
- "rpaas.extensions.tsuru.io/is-file": "true",
- "rpaas.extensions.tsuru.io/file-name": "index.html",
+ "rpaas.extensions.tsuru.io/instance-name": "my-instance",
+ "rpaas.extensions.tsuru.io/service-name": "rpaasv2",
+ "rpaas_instance": "my-instance",
+ "rpaas_service": "rpaasv2",
+ "rpaas.extensions.tsuru.io/is-file": "true",
+ "rpaas.extensions.tsuru.io/file-name": "index.html",
},
},
BinaryData: map[string][]byte{"index.html": []byte("Hello world!
")},
@@ -142,8 +154,12 @@ func Test_k8sRpaasManager_DeleteExtraFiles(t *testing.T) {
Name: "my-instance-extra-files-2",
Namespace: "rpaasv2",
Labels: map[string]string{
- "rpaas.extensions.tsuru.io/is-file": "true",
- "rpaas.extensions.tsuru.io/file-name": "binary.exe",
+ "rpaas.extensions.tsuru.io/instance-name": "my-instance",
+ "rpaas.extensions.tsuru.io/service-name": "rpaasv2",
+ "rpaas_instance": "my-instance",
+ "rpaas_service": "rpaasv2",
+ "rpaas.extensions.tsuru.io/is-file": "true",
+ "rpaas.extensions.tsuru.io/file-name": "binary.exe",
},
},
BinaryData: map[string][]byte{"binary.exe": {66, 55, 00, 10}},
@@ -222,8 +238,12 @@ func Test_k8sRpaasManager_CreateExtraFiles(t *testing.T) {
assert.Equal(t, "my-instance-extra-files-", cm.GenerateName)
assert.Equal(t, map[string]string{
- "rpaas.extensions.tsuru.io/is-file": "true",
- "rpaas.extensions.tsuru.io/file-name": "index.html",
+ "rpaas.extensions.tsuru.io/instance-name": "my-instance",
+ "rpaas.extensions.tsuru.io/service-name": "rpaasv2",
+ "rpaas_instance": "my-instance",
+ "rpaas_service": "rpaasv2",
+ "rpaas.extensions.tsuru.io/is-file": "true",
+ "rpaas.extensions.tsuru.io/file-name": "index.html",
}, cm.Labels)
assert.Equal(t, map[string][]byte{"index.html": []byte("Hello world!
")}, cm.BinaryData)
@@ -291,8 +311,12 @@ func Test_k8sRpaasManager_UpdateExtraFiles(t *testing.T) {
Name: "my-instance-extra-files-abcde",
Namespace: "rpaasv2",
Labels: map[string]string{
- "rpaas.extensions.tsuru.io/is-file": "true",
- "rpaas.extensions.tsuru.io/file-name": "index.html",
+ "rpaas.extensions.tsuru.io/instance-name": "my-instance",
+ "rpaas.extensions.tsuru.io/service-name": "rpaasv2",
+ "rpaas_instance": "my-instance",
+ "rpaas_service": "rpaasv2",
+ "rpaas.extensions.tsuru.io/is-file": "true",
+ "rpaas.extensions.tsuru.io/file-name": "index.html",
},
},
BinaryData: map[string][]byte{"index.html": []byte("Hello world!
")},
@@ -319,8 +343,12 @@ func Test_k8sRpaasManager_UpdateExtraFiles(t *testing.T) {
Name: "my-instance-extra-files-abcde",
Namespace: "rpaasv2",
Labels: map[string]string{
- "rpaas.extensions.tsuru.io/is-file": "true",
- "rpaas.extensions.tsuru.io/file-name": "index.html",
+ "rpaas.extensions.tsuru.io/instance-name": "my-instance",
+ "rpaas.extensions.tsuru.io/service-name": "rpaasv2",
+ "rpaas_instance": "my-instance",
+ "rpaas_service": "rpaasv2",
+ "rpaas.extensions.tsuru.io/is-file": "true",
+ "rpaas.extensions.tsuru.io/file-name": "index.html",
},
},
BinaryData: map[string][]byte{"index.html": []byte("Hello world!
")},
diff --git a/internal/pkg/rpaas/k8s_test.go b/internal/pkg/rpaas/k8s_test.go
index 61f60a019..8cb40fd88 100644
--- a/internal/pkg/rpaas/k8s_test.go
+++ b/internal/pkg/rpaas/k8s_test.go
@@ -4493,8 +4493,12 @@ func Test_k8sRpaasManager_GetInstanceInfo(t *testing.T) {
Name: "my-instance-extra-files-1",
Namespace: "rpaasv2",
Labels: map[string]string{
- "rpaas.extensions.tsuru.io/is-file": "true",
- "rpaas.extensions.tsuru.io/file-name": "waf.cfg",
+ "rpaas.extensions.tsuru.io/instance-name": "my-instance",
+ "rpaas.extensions.tsuru.io/service-name": "rpaasv2",
+ "rpaas_instance": "my-instance",
+ "rpaas_service": "rpaasv2",
+ "rpaas.extensions.tsuru.io/is-file": "true",
+ "rpaas.extensions.tsuru.io/file-name": "waf.cfg",
},
},
BinaryData: map[string][]byte{
@@ -4506,8 +4510,12 @@ func Test_k8sRpaasManager_GetInstanceInfo(t *testing.T) {
Name: "my-instance-extra-files-2",
Namespace: "rpaasv2",
Labels: map[string]string{
- "rpaas.extensions.tsuru.io/is-file": "true",
- "rpaas.extensions.tsuru.io/file-name": "binary.exe",
+ "rpaas.extensions.tsuru.io/instance-name": "my-instance",
+ "rpaas.extensions.tsuru.io/service-name": "rpaasv2",
+ "rpaas_instance": "my-instance",
+ "rpaas_service": "rpaasv2",
+ "rpaas.extensions.tsuru.io/is-file": "true",
+ "rpaas.extensions.tsuru.io/file-name": "binary.exe",
},
},
BinaryData: map[string][]byte{