Skip to content

Commit 66b6d55

Browse files
mdbenjamtuckerchapinwendorf
authored
Workflows Feature Branch (#215)
* Implement task orchestration api in the cli (#205) * Generate task server * Generate Render API types * Generate workflow API client * Add local task store * Add client wrapper * Add port finder * Add coordinator * Add callback server * Add API server * Add command * add chi as dependency * Make tasks and task runs internal * [ref CAP-6689] Workflows & workflow versions (#209) * Generated api schema * List workflows and workflow versions, deploy new versions - Logs are broken so deploying a new version shows broken logs - Lots of todos incoming in next commit * Updated todos with more actionable details and tickets * Update reference to deploys as version * Task listing * added comment * [CAP-7312] Implement TUI for starting a task (#208) * [EXP-3146] Invalid timestamp message suggests a valid timestamp (#207) `time.RFC3339` is not itself a valid timestamp, but only a valid format string for timestamp parsing. I've chosen to emit time.Now() in RFC-3339 rather than a fixed timestamp because it will 1) emit in the user's timezone and 2) have an increased chance of being closer to the time the user wants and therefore be easier to edit. * Add generated types * Add command * Add input-file * Update generated types * Integrate with task list CLI commands --------- Co-authored-by: Dan Wendorf <github@danwendorf.com> * [CAP-7471] Update cli to use updated sdk protocol (#212) * Use unix sockets * Update task server API * Fix API server * Exec user's command * Get task by id or slug/name * Update task command * Intake input and output as any, but transmit them as json.RawMessage * [CAP-7311] List task runs (#210) * Added task runs * clean up comments * Remove local hack, can now list tasks * [CAP-7542] Refactor CLI workflow commands (#213) * Fix task run list * Start dependencies * stop using default client in workflow cmds * move into workflow view folder * Split out loader and types * Move one more default client * Move type * Move interactive commands into flow package * Move RunE into struct * Update workflow prefix * Force version selection * Fix dependencies * Fix task run list * Only initialize once * Update dependencies * Update DI * Move flows * Remove Flow suffix * Delete unused init code * Clean up dependencies * Comment remaining usage of dependencies in context * [CAP-7542] Make CLI commands work with local dev server (#214) * Add local flag * Use the new `/tasks` endpoint * Fix runs query * [CAP-7489] CLI task run logs (#216) * Move logs to flow * Split out log loader * Move set workspace into flow * Handle options * Use dependencies for loading resources * Move resource selector out of log view * Add logs to workflow CLI commands * [CAP-7489] Local task run logs (#217) * Keep logs in memory in dev mode * Update apiserver to respond with logs * Update local tasks to work with logs * [CAP-7611] Task run details view (#218) * Add task run result view * Update task details styling * [CAP-7619] Implement subtasking in the cli (#219) * Add task run result view * Update task details styling * Implement subtasks in CLI * [CAP-7622] Improve tailing logs locally (#222) * Ensure old logs are delivered * Specify start time before now to ensure we get all the logs for this task run * Clean up channels when websocket is closed * Update breadcrumbs (#220) * Fix tests (#223) * Better cli error handling for apiserver (#225) * [CAP-7561] Update CLI to allow specifying ports (#226) * Add SSE streaming * Allow specifying port * Update types * Add logs in task run palette (#227) * Put commands under early access (#228) * Fix test * Add login only client * Fix for windows * Fix logs in local mode --------- Co-authored-by: Tucker Chapin <tuckerchapin@gmail.com> Co-authored-by: Dan Wendorf <github@danwendorf.com>
1 parent 66e0827 commit 66b6d55

108 files changed

Lines changed: 10279 additions & 1916 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/deploycreate.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import (
1010

1111
"github.com/render-oss/cli/pkg/client"
1212
"github.com/render-oss/cli/pkg/command"
13+
"github.com/render-oss/cli/pkg/dependencies"
1314
"github.com/render-oss/cli/pkg/deploy"
1415
"github.com/render-oss/cli/pkg/resource"
1516
"github.com/render-oss/cli/pkg/text"
17+
"github.com/render-oss/cli/pkg/tui/flows"
1618
"github.com/render-oss/cli/pkg/tui/views"
1719
"github.com/render-oss/cli/pkg/types"
1820
)
@@ -30,13 +32,14 @@ var deployCreateCmd = &cobra.Command{
3032
}
3133

3234
var InteractiveDeployCreate = func(ctx context.Context, input types.DeployInput, breadcrumb string) tea.Cmd {
35+
deps := dependencies.GetFromContext(ctx)
3336
return command.AddToStackFunc(
3437
ctx,
3538
deployCreateCmd,
3639
breadcrumb,
3740
&input,
3841
views.NewDeployCreateView(ctx, input, func(d *client.Deploy) tea.Cmd {
39-
return TailResourceLogs(ctx, input.ServiceID)
42+
return flows.NewLogFlow(deps).TailLogsFlow(ctx, input.ServiceID)
4043
}))
4144
}
4245

cmd/deploylist.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import (
1010
"github.com/render-oss/cli/pkg/client"
1111
"github.com/render-oss/cli/pkg/command"
1212
"github.com/render-oss/cli/pkg/dashboard"
13+
"github.com/render-oss/cli/pkg/dependencies"
1314
"github.com/render-oss/cli/pkg/deploy"
1415
"github.com/render-oss/cli/pkg/resource"
1516
"github.com/render-oss/cli/pkg/text"
17+
"github.com/render-oss/cli/pkg/tui/flows"
1618
"github.com/render-oss/cli/pkg/tui/views"
1719
)
1820

@@ -23,11 +25,12 @@ var deployListCmd = &cobra.Command{
2325
}
2426

2527
var InteractiveDeployList = func(ctx context.Context, input views.DeployListInput, r resource.Resource, breadcrumb string) tea.Cmd {
28+
deps := dependencies.GetFromContext(ctx)
2629
return command.AddToStackFunc(ctx, deployListCmd, breadcrumb, &input, views.NewDeployListView(
2730
ctx,
2831
input,
2932
func(c *client.Deploy) tea.Cmd {
30-
return InteractivePalette(ctx, commandsForDeploy(c, r.ID(), r.Type()), c.Id)
33+
return InteractivePalette(ctx, commandsForDeploy(deps, c, r.ID(), r.Type()), c.Id)
3134
},
3235
))
3336
}
@@ -55,7 +58,7 @@ func interactiveDeployList(cmd *cobra.Command, input views.DeployListInput) tea.
5558
return InteractiveDeployList(ctx, input, service, "Deploys for "+resource.BreadcrumbForResource(service))
5659
}
5760

58-
func commandsForDeploy(dep *client.Deploy, serviceID, serviceType string) []views.PaletteCommand {
61+
func commandsForDeploy(deps *dependencies.Dependencies, dep *client.Deploy, serviceID, serviceType string) []views.PaletteCommand {
5962
var startTime *command.TimeOrRelative
6063
if dep.CreatedAt != nil {
6164
startTime = &command.TimeOrRelative{T: dep.CreatedAt}
@@ -71,15 +74,14 @@ func commandsForDeploy(dep *client.Deploy, serviceID, serviceType string) []view
7174
Name: "logs",
7275
Description: "View deploy logs",
7376
Action: func(ctx context.Context, args []string) tea.Cmd {
74-
return InteractiveLogs(
77+
return flows.NewLogFlow(deps).LogsFlow(
7578
ctx,
7679
views.LogInput{
7780
ResourceIDs: []string{serviceID},
7881
StartTime: startTime,
7982
EndTime: endTime,
8083
Direction: "forward",
8184
},
82-
"Logs",
8385
)
8486
},
8587
},

cmd/earlyaccess.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package cmd
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
var EarlyAccessCmd = &cobra.Command{
8+
Use: "ea",
9+
Short: "Early access commands",
10+
Long: `These commands are in early access and are subject to change.`,
11+
}
12+
13+
func init() {
14+
rootCmd.AddCommand(EarlyAccessCmd)
15+
}

cmd/environment.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/render-oss/cli/pkg/project"
1212
"github.com/render-oss/cli/pkg/text"
1313
"github.com/render-oss/cli/pkg/tui"
14+
"github.com/render-oss/cli/pkg/tui/flows"
1415
"github.com/render-oss/cli/pkg/tui/views"
1516
)
1617

@@ -31,8 +32,8 @@ var InteractiveEnvironment = func(ctx context.Context, input views.EnvironmentIn
3132
}, e.Name)
3233
},
3334
tui.WithCustomOptions[*client.Environment]([]tui.CustomOption{
34-
WithCopyID(ctx, servicesCmd),
35-
WithWorkspaceSelection(ctx),
35+
flows.WithCopyID(ctx, servicesCmd),
36+
flows.WithWorkspaceSelection(ctx),
3637
}),
3738
))
3839
}

cmd/jobcreate.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import (
1010
"github.com/render-oss/cli/pkg/client"
1111
clientjob "github.com/render-oss/cli/pkg/client/jobs"
1212
"github.com/render-oss/cli/pkg/command"
13+
"github.com/render-oss/cli/pkg/dependencies"
1314
"github.com/render-oss/cli/pkg/resource"
1415
"github.com/render-oss/cli/pkg/text"
16+
"github.com/render-oss/cli/pkg/tui/flows"
1517
"github.com/render-oss/cli/pkg/tui/views"
1618
)
1719

@@ -22,16 +24,17 @@ var JobCreateCmd = &cobra.Command{
2224
}
2325

2426
var InteractiveJobCreate = func(ctx context.Context, input *views.JobCreateInput, breadcrumb string) tea.Cmd {
27+
deps := dependencies.GetFromContext(ctx)
2528
return command.AddToStackFunc(
2629
ctx,
2730
JobCreateCmd,
2831
breadcrumb,
2932
input,
3033
views.NewJobCreateView(ctx, input, JobCreateCmd, views.CreateJob, func(j *clientjob.Job) tea.Cmd {
31-
return InteractiveLogs(ctx, views.LogInput{
34+
return flows.NewLogFlow(deps).LogsFlow(ctx, views.LogInput{
3235
ResourceIDs: []string{j.Id},
3336
Tail: true,
34-
}, "Logs")
37+
})
3538
}),
3639
)
3740
}

cmd/joblist.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import (
1010
"github.com/render-oss/cli/pkg/client"
1111
clientjob "github.com/render-oss/cli/pkg/client/jobs"
1212
"github.com/render-oss/cli/pkg/command"
13+
"github.com/render-oss/cli/pkg/dependencies"
1314
"github.com/render-oss/cli/pkg/job"
1415
"github.com/render-oss/cli/pkg/resource"
1516
"github.com/render-oss/cli/pkg/text"
17+
"github.com/render-oss/cli/pkg/tui/flows"
1618
"github.com/render-oss/cli/pkg/tui/views"
1719
)
1820

@@ -23,10 +25,11 @@ var jobListCmd = &cobra.Command{
2325
}
2426

2527
var InteractiveJobList = func(ctx context.Context, input views.JobListInput, breadcrumb string) tea.Cmd {
28+
deps := dependencies.GetFromContext(ctx)
2629
return command.AddToStackFunc(ctx, jobListCmd, breadcrumb, &views.ProjectInput{}, views.NewJobListView(ctx,
2730
&input,
2831
func(j *clientjob.Job) tea.Cmd {
29-
return InteractivePalette(ctx, commandsForJob(j), j.Id)
32+
return InteractivePalette(ctx, commandsForJob(deps, j), j.Id)
3033
},
3134
))
3235
}
@@ -58,7 +61,7 @@ func interactiveJobList(cmd *cobra.Command, input views.JobListInput) tea.Cmd {
5861
return InteractiveJobList(ctx, input, "Jobs for "+resource.BreadcrumbForResource(service))
5962
}
6063

61-
func commandsForJob(j *clientjob.Job) []views.PaletteCommand {
64+
func commandsForJob(deps *dependencies.Dependencies, j *clientjob.Job) []views.PaletteCommand {
6265
var startTime *command.TimeOrRelative
6366
if j.StartedAt != nil {
6467
startTime = &command.TimeOrRelative{T: j.StartedAt}
@@ -74,14 +77,13 @@ func commandsForJob(j *clientjob.Job) []views.PaletteCommand {
7477
Name: "logs",
7578
Description: "View job logs",
7679
Action: func(ctx context.Context, args []string) tea.Cmd {
77-
return InteractiveLogs(
80+
return flows.NewLogFlow(deps).LogsFlow(
7881
ctx,
7982
views.LogInput{
8083
ResourceIDs: []string{j.Id},
8184
StartTime: startTime,
8285
EndTime: endTime,
8386
},
84-
"Logs",
8587
)
8688
},
8789
},

cmd/kvcli.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/render-oss/cli/pkg/command"
1111
"github.com/render-oss/cli/pkg/keyvalue"
1212
"github.com/render-oss/cli/pkg/tui"
13+
"github.com/render-oss/cli/pkg/tui/flows"
1314
"github.com/render-oss/cli/pkg/tui/views"
1415
)
1516

@@ -34,9 +35,9 @@ func InteractiveKeyValueCLIView(ctx context.Context, input *views.RedisCLIInput)
3435

3536
func getRedisTableOptions(ctx context.Context, input *views.RedisCLIInput) []tui.CustomOption {
3637
return []tui.CustomOption{
37-
WithCopyID(ctx, servicesCmd),
38-
WithWorkspaceSelection(ctx),
39-
WithProjectFilter(ctx, redisCLICmd, "redisCLI", input, func(ctx context.Context, project *client.Project) tea.Cmd {
38+
flows.WithCopyID(ctx, servicesCmd),
39+
flows.WithWorkspaceSelection(ctx),
40+
flows.WithProjectFilter(ctx, redisCLICmd, "redisCLI", input, func(ctx context.Context, project *client.Project) tea.Cmd {
4041
if project != nil {
4142
input.EnvironmentIDs = project.EnvironmentIds
4243
}

0 commit comments

Comments
 (0)