10000 feat: add default autostart and ttl for new workspaces by johnstcn · Pull Request #1632 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: add default autostart and ttl for new workspaces #1632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
database: add autostart_schedule and ttl to InsertWorkspace; make gen
  • Loading branch information
johnstcn committed May 20, 2022
commit 391f5278ea53138b73bc2d98f141e9dadbf4ae71
16 changes: 9 additions & 7 deletions coderd/database/databasefake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -1456,13 +1456,15 @@ func (q *fakeQuerier) InsertWorkspace(_ context.Context, arg database.InsertWork

//nolint:gosimple
workspace := database.Workspace{
ID: arg.ID,
CreatedAt: arg.CreatedAt,
UpdatedAt: arg.UpdatedAt,
OwnerID: arg.OwnerID,
OrganizationID: arg.OrganizationID,
TemplateID: arg.TemplateID,
Name: arg.Name,
ID: arg.ID,
CreatedAt: arg.CreatedAt,
UpdatedAt: arg.UpdatedAt,
OwnerID: arg.OwnerID,
OrganizationID: arg.OrganizationID,
TemplateID: arg.TemplateID,
Name: arg.Name,
AutostartSchedule: arg.AutostartSchedule,
Ttl: arg.Ttl,
}
q.workspaces = append(q.workspaces, workspace)
return workspace, nil
Expand Down
24 changes: 15 additions & 9 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions coderd/database/queries/workspaces.sql
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ INSERT INTO
owner_id,
organization_id,
template_id,
name
name,
autostart_schedule,
ttl
)
VALUES
($1, $2, $3, $4, $5, $6, $7) RETURNING *;
($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING *;

-- name: UpdateWorkspaceDeletedByID :exec
UPDATE
Expand Down
6 changes: 4 additions & 2 deletions codersdk/organizations.go
8000
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ type CreateTemplateRequest struct {

// CreateWorkspaceRequest provides options for creating a new workspace.
type CreateWorkspaceRequest struct {
TemplateID uuid.UUID `json:"template_id" validate:"required"`
Name string `json:"name" validate:"username,required"`
TemplateID uuid.UUID `json:"template_id" validate:"required"`
Name string `json:"name" validate:"username,required"`
AutostartSchedule *string `json:"autostart_schedule" validate:""`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AutostartSchedule *string `json:"autostart_schedule" validate:""`
AutostartSchedule *string `json:"autostart_schedule"`

TTL *time.Duration `json:"ttl" validate:""`
// ParameterValues allows for additional parameters to be provided
// during the initial provision.
ParameterValues []CreateParameterRequest `json:"parameter_values,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ export interface CreateWorkspaceBuildRequest {
export interface CreateWorkspaceRequest {
readonly template_id: string
readonly name: string
readonly autostart_schedule?: string
// This is likely an enum in an external package ("time.Duration")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Emyrk Can we not have this happen for time.Duration?

readonly ttl?: number
readonly parameter_values?: CreateParameterRequest[]
}

Expand Down
0