Skip to content

Commit

Permalink
Merge pull request #96 from trickest/url-input
Browse files Browse the repository at this point in the history
Add URL input for specifying platform objects
  • Loading branch information
mhmdiaa authored Nov 7, 2023
2 parents 0e96fce + 3dc1a3e commit 93864fa
Show file tree
Hide file tree
Showing 13 changed files with 353 additions and 358 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ trickest list

#### Spaces

Use the **list** command with the **--space** flag to list the content of your particular space; its projects and workflows, and their descriptions.
Use the **list** command with the **--space** or **--url** flag to list the content of your particular space; its projects and workflows, and their descriptions.

```
trickest list --space <space_name>
Expand All @@ -73,22 +73,24 @@ trickest list --space <space_name>
|---------|--------|---------|-------------------------------------|
| --space | string | / | The name of the space to be listed |
| --json | boolean| / | Display output in JSON format |
| --url | string | / | URL for referencing a space |



#### Projects

Use the **list** command with the **--project** option to list the content of your particular project; its workflows, along with their descriptions.
Use the **list** command with the **--project** or **--url** option to list the content of your particular project; its workflows, along with their descriptions.

```
trickest list --project <project_name> --space <space_name>
```

| Flag | Type | Default | Description |
|-----------|--------|---------|----------------------------------------------------|
| --project | string | / | The name of the project to be listed. |
| --space | string | / | The name of the space to which the project belongs |
| --json | boolean | / | Display output in JSON format |
| Flag | Type | Default | Description |
|-----------|---------|---------|----------------------------------------------------|
| --project | string | / | The name of the project to be listed. |
| --space | string | / | The name of the space to which the project belongs |
| --json | boolean | / | Display output in JSON format |
| --url | string | / | URL for referencing a space |


##### Note: When passing values that have spaces in their names (e.g. "Alpine Testing"), they need to be double-quoted.
Expand All @@ -109,6 +111,7 @@ trickest get --workflow <workflow_name> --space <space_name> [--watch]
| --run | string | / | Get the status of a specific run |
| --watch | boolean | / | Option to track execution status in case workflow is in running state |
| --json | boolean | / | Display output in JSON format |
| --url | string | / | URL for referencing a space |

##### If the supplied workflow has a running execution, you can jump in and watch it running with the `--watch` flag!

Expand Down Expand Up @@ -192,6 +195,7 @@ trickest output --workflow <workflow_name> --space <space_name> [--nodes <comma_
| ---------- | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| --workflow | string | / | The name of the workflow. |
| --space | string | / | The name of the space to which workflow belongs |
| --url | string | / | URL for referencing a space |
| --config | file | / | YAML file for run configuration |
| --run | string | / | Download output data of a specific run |
| --runs | integer | 1 | The number of executions to be downloaded sorted by newest |
Expand Down
5 changes: 2 additions & 3 deletions cmd/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/google/uuid"
"github.com/trickest/trickest-cli/client/request"
"github.com/trickest/trickest-cli/cmd/delete"
"github.com/trickest/trickest-cli/cmd/list"
"github.com/trickest/trickest-cli/types"
"github.com/trickest/trickest-cli/util"

Expand Down Expand Up @@ -85,7 +84,7 @@ func createSpace(name string, description string) {
}

func CreateProject(name string, description string, spaceName string) *types.Project {
space := list.GetSpaceByName(spaceName)
space := util.GetSpaceByName(spaceName)
if space == nil {
fmt.Println("The space \"" + spaceName + "\" doesn't exist. Would you like to create it? (Y/N)")
var answer string
Expand Down Expand Up @@ -153,7 +152,7 @@ func CreateWorkflow(name, description string, spaceID, projectID uuid.UUID, dele
workflow.ProjectID = &projectID
}

workflows := list.GetWorkflows(projectID, spaceID, name, false)
workflows := util.GetWorkflows(projectID, spaceID, name, false)
if workflows != nil {
for _, wf := range workflows {
if wf.Name == name {
Expand Down
20 changes: 2 additions & 18 deletions cmd/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import (
"fmt"
"net/http"
"os"
"strings"

"github.com/google/uuid"
"github.com/trickest/trickest-cli/client/request"
"github.com/trickest/trickest-cli/cmd/list"
"github.com/trickest/trickest-cli/util"

"github.com/spf13/cobra"
Expand All @@ -20,21 +18,7 @@ var DeleteCmd = &cobra.Command{
Short: "Deletes an object on the Trickest platform",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
path := util.FormatPath()
if path == "" {
if len(args) == 0 {
fmt.Println("You must specify the path of the object to be deleted!")
return
}
path = strings.Trim(args[0], "/")
} else {
if len(args) > 0 {
fmt.Println("Please use either path or flag syntax for the platform objects.")
return
}
}

space, project, workflow, found := list.ResolveObjectPath(path, false, util.WorkflowName == "")
space, project, workflow, found := util.GetObjects(args)
if !found {
return
}
Expand All @@ -51,7 +35,7 @@ var DeleteCmd = &cobra.Command{

func deleteSpace(name string, id uuid.UUID) {
if id == uuid.Nil {
space := list.GetSpaceByName(name)
space := util.GetSpaceByName(name)
if space == nil {
fmt.Println("Couldn't find space named " + name + "!")
os.Exit(0)
Expand Down
12 changes: 6 additions & 6 deletions cmd/execute/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func readWorkflowYAMLandCreateVersion(fileName string, workflowName string, obje
workflowName = wf.Name
}

space, project, workflow, _ := list.ResolveObjectPath(objectPath, true, false)
space, project, workflow, _ := util.ResolveObjectPath(objectPath, true, false)
if space == nil {
fmt.Println("Space " + strings.Split(objectPath, "/")[0] + " doesn't exist!")
os.Exit(0)
Expand Down Expand Up @@ -922,9 +922,9 @@ func prepareForExec(objectPath string) *types.WorkflowVersionDetailed {
var primitiveNodes map[string]*types.PrimitiveNode
projectCreated := false

space, project, workflow, _ := list.ResolveObjectPath(objectPath, false, false)
if space == nil {
os.Exit(0)
space, project, workflow, _ := util.ResolveObjectPath(objectPath, false, false)
if workflow == nil {
space, project, workflow, _ = util.ResolveObjectURL(util.URL)
}

if workflow != nil && newWorkflowName == "" {
Expand All @@ -943,7 +943,7 @@ func prepareForExec(objectPath string) *types.WorkflowVersionDetailed {
} else {
// Executing from library
wfName := pathSplit[len(pathSplit)-1]
libraryWorkflows := list.GetWorkflows(uuid.Nil, uuid.Nil, wfName, true)
libraryWorkflows := util.GetWorkflows(uuid.Nil, uuid.Nil, wfName, true)
if libraryWorkflows != nil && len(libraryWorkflows) > 0 {
// Executing from library
for _, wf := range libraryWorkflows {
Expand Down Expand Up @@ -976,7 +976,7 @@ func prepareForExec(objectPath string) *types.WorkflowVersionDetailed {
os.Exit(0)
}

newWorkflow := list.GetWorkflowByID(newWorkflowID)
newWorkflow := util.GetWorkflowByID(newWorkflowID)
if newWorkflow.Name != newWorkflowName {
newWorkflow.Name = newWorkflowName
updateWorkflow(newWorkflow, projectCreated)
Expand Down
17 changes: 1 addition & 16 deletions cmd/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strings"

"github.com/trickest/trickest-cli/cmd/execute"
"github.com/trickest/trickest-cli/cmd/list"
"github.com/trickest/trickest-cli/types"
"github.com/trickest/trickest-cli/util"

Expand Down Expand Up @@ -40,21 +39,7 @@ var ExportCmd = &cobra.Command{
Short: "Exports a workflow to a YAML file",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
path := util.FormatPath()
if path == "" {
if len(args) == 0 {
fmt.Println("Workflow path must be specified!")
return
}
path = strings.Trim(args[0], "/")
} else {
if len(args) > 0 {
fmt.Println("Please use either path or flag syntax for the platform objects.")
return
}
}

_, _, workflow, found := list.ResolveObjectPath(path, false, false)
_, _, workflow, found := util.GetObjects(args)
if !found {
return
}
Expand Down
24 changes: 3 additions & 21 deletions cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

"github.com/trickest/trickest-cli/cmd/execute"
"github.com/trickest/trickest-cli/cmd/list"
"github.com/trickest/trickest-cli/cmd/output"
"github.com/trickest/trickest-cli/types"
"github.com/trickest/trickest-cli/util"
Expand All @@ -29,27 +28,10 @@ var GetCmd = &cobra.Command{
Short: "Displays status of a workflow",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
path := util.FormatPath()
if path == "" {
if len(args) == 0 {
fmt.Println("Workflow path must be specified!")
return
}
path = strings.Trim(args[0], "/")
} else {
if len(args) > 0 {
fmt.Println("Please use either path or flag syntax for the platform objects.")
return
}
}

_, _, workflow, found := list.ResolveObjectPath(path, false, false)
if !found {
return
}
_, _, workflow, found := util.GetObjects(args)

if workflow == nil {
fmt.Println("Error: You need to specify the full location of the workflow with the --space and --project flags")
if !found || workflow == nil {
fmt.Println("Error: Workflow not found")
return
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/library/libraryListWorkflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/google/uuid"
"github.com/spf13/cobra"
"github.com/trickest/trickest-cli/cmd/list"
"github.com/trickest/trickest-cli/types"
"github.com/trickest/trickest-cli/util"
"github.com/xlab/treeprint"
)

Expand All @@ -17,7 +17,7 @@ var libraryListWorkflowsCmd = &cobra.Command{
Short: "List workflows from the Trickest library",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
workflows := list.GetWorkflows(uuid.Nil, uuid.Nil, "", true)
workflows := util.GetWorkflows(uuid.Nil, uuid.Nil, "", true)
if len(workflows) > 0 {
printWorkflows(workflows, jsonOutput)
} else {
Expand Down
3 changes: 2 additions & 1 deletion cmd/library/librarySearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/google/uuid"
"github.com/spf13/cobra"
"github.com/trickest/trickest-cli/cmd/list"
"github.com/trickest/trickest-cli/util"
)

// librarySearchCmd represents the librarySearch command
Expand All @@ -21,7 +22,7 @@ var librarySearchCmd = &cobra.Command{
search = args[0]
}
tools := list.GetTools(math.MaxInt, search, "")
workflows := list.GetWorkflows(uuid.Nil, uuid.Nil, search, true)
workflows := util.GetWorkflows(uuid.Nil, uuid.Nil, search, true)
if jsonOutput {
results := map[string]interface{}{
"tools": tools,
Expand Down
Loading

0 comments on commit 93864fa

Please sign in to comment.