Skip to content
Draft
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
3 changes: 3 additions & 0 deletions cli/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ func buildForkRequest(targetName, targetType string, traffic, port, memory *int)
func parseForkArg(arg string) (resourceType, name string, err error) {
parts := strings.SplitN(arg, "/", 2)
if len(parts) == 1 {
if parts[0] == "" {
return "", "", fmt.Errorf("resource name must not be empty")
}
return "", parts[0], nil
}
name = parts[1]
Expand Down
1 change: 1 addition & 0 deletions cli/fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func TestParseForkArg(t *testing.T) {
{name: "untyped", arg: "source", resourceName: "source"},
{name: "sandbox", arg: "sbx/source", resourceType: "sandbox", resourceName: "source"},
{name: "application", arg: "application/target", resourceType: "application", resourceName: "target"},
{name: "empty name", arg: "", wantErr: "resource name must not be empty"},
{name: "missing name", arg: "sbx/", wantErr: "missing name"},
{name: "unknown type", arg: "agent/source", wantErr: "unknown resource type"},
{name: "nested path", arg: "sbx/foo/bar", wantErr: "must not contain '/'"},
Expand Down
Loading