Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions pkg/object/objmetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ func ParseObjMetadata(s string) (ObjMetadata, error) {
// Finally, second field name. Name may contain colon transcoded as double underscore.
name := s[:index]
name = strings.ReplaceAll(name, colonTranscoded, ":")
// Check that there are no extra fields by search for fieldSeparator.
if strings.Contains(name, fieldSeparator) {
return NilObjMetadata, fmt.Errorf("too many fields within: %s", s)
}
// Create the ObjMetadata object from the four parsed fields.
id := ObjMetadata{
Namespace: namespace,
Expand Down
27 changes: 23 additions & 4 deletions pkg/object/objmetadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,29 @@ func TestParseObjMetadata(t *testing.T) {
inventory: &ObjMetadata{},
isError: true,
},
"Too many fields": {
invStr: "test-namespace_test-name_apps_foo_Deployment",
inventory: &ObjMetadata{},
isError: true,
"Name can contain underscores": {
invStr: "test-namespace_test_name_apps_Deployment",
inventory: &ObjMetadata{
Namespace: "test-namespace",
Name: "test_name",
GroupKind: schema.GroupKind{
Group: "apps",
Kind: "Deployment",
},
},
isError: false,
},
"Name can contain multiple underscores": {
invStr: "test-namespace_test_name_with_underscores_apps_Deployment",
inventory: &ObjMetadata{
Namespace: "test-namespace",
Name: "test_name_with_underscores",
GroupKind: schema.GroupKind{
Group: "apps",
Kind: "Deployment",
},
},
isError: false,
},
}

Expand Down