Skip to content

feat: add icon and description to preset #18977

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions coderd/apidoc/docs.go

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

6 changes: 6 additions & 0 deletions coderd/apidoc/swagger.json

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

2 changes: 2 additions & 0 deletions coderd/database/dbfake/dbfake.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ func (t TemplateVersionBuilder) Do() TemplateVersionResponse {
InvalidateAfterSecs: preset.InvalidateAfterSecs,
SchedulingTimezone: preset.SchedulingTimezone,
IsDefault: false,
Description: preset.Description,
Icon: preset.Icon,
})
}

Expand Down
2 changes: 2 additions & 0 deletions coderd/database/dbgen/dbgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,8 @@ func Preset(t testing.TB, db database.Store, seed database.InsertPresetParams) d
InvalidateAfterSecs: seed.InvalidateAfterSecs,
SchedulingTimezone: seed.SchedulingTimezone,
IsDefault: seed.IsDefault,
Description: seed.Description,
Icon: seed.Icon,
})
require.NoError(t, err, "insert preset")
return preset
Expand Down
4 changes: 3 additions & 1 deletion coderd/database/dump.sql

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE template_version_presets
DROP COLUMN IF EXISTS description,
DROP COLUMN IF EXISTS icon;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE template_version_presets
ADD COLUMN IF NOT EXISTS description VARCHAR(128) NOT NULL DEFAULT '',
ADD COLUMN IF NOT EXISTS icon VARCHAR(256) NOT NULL DEFAULT '';
Comment on lines +2 to +3
Copy link
Contributor Author

Choose a reason for hiding this comment

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

2 changes: 2 additions & 0 deletions coderd/database/models.go

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

30 changes: 24 additions & 6 deletions coderd/database/queries.sql.go

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

8 changes: 6 additions & 2 deletions coderd/database/queries/presets.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ INSERT INTO template_version_presets (
desired_instances,
invalidate_after_secs,
scheduling_timezone,
is_default
is_default,
description,
icon
)
VALUES (
@id,
Expand All @@ -17,7 +19,9 @@ VALUES (
@desired_instances,
@invalidate_after_secs,
@scheduling_timezone,
@is_default
@is_default,
@description,
@icon
) RETURNING *;

-- name: InsertPresetParameters :many
Expand Down
2 changes: 2 additions & 0 deletions coderd/presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func (api *API) templateVersionPresets(rw http.ResponseWriter, r *http.Request)
Name: preset.Name,
Default: preset.IsDefault,
DesiredPrebuildInstances: convertPrebuildInstances(preset.DesiredInstances),
Description: preset.Description,
Icon: preset.Icon,
}
for _, presetParam := range presetParams {
if presetParam.TemplateVersionPresetID != preset.ID {
Expand Down
3 changes: 3 additions & 0 deletions coderd/provisionerdserver/provisionerdserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2264,6 +2264,7 @@ func InsertWorkspacePresetAndParameters(ctx context.Context, db database.Store,
prebuildSchedules = protoPreset.Prebuild.Scheduling.Schedule
}
}

dbPreset, err := tx.InsertPreset(ctx, database.InsertPresetParams{
ID: uuid.New(),
TemplateVersionID: templateVersionID,
Expand All @@ -2273,6 +2274,8 @@ func InsertWorkspacePresetAndParameters(ctx context.Context, db database.Store,
InvalidateAfterSecs: ttl,
SchedulingTimezone: schedulingTimezone,
IsDefault: protoPreset.GetDefault(),
Description: protoPreset.Description,
Icon: protoPreset.Icon,
})
if err != nil {
return xerrors.Errorf("insert preset: %w", err)
Expand Down
2 changes: 2 additions & 0 deletions codersdk/presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Preset struct {
Parameters []PresetParameter
Default bool
DesiredPrebuildInstances *int
Description string
Icon string
}

type PresetParameter struct {
Expand Down
4 changes: 4 additions & 0 deletions docs/reference/api/schemas.md

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

4 changes: 4 additions & 0 deletions docs/reference/api/templates.md

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

4 changes: 3 additions & 1 deletion provisioner/terraform/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,9 @@ func ConvertState(ctx context.Context, modules []*tfjson.StateModule, rawGraph s
ExpirationPolicy: expirationPolicy,
Scheduling: scheduling,
},
Default: preset.Default,
Default: preset.Default,
Description: preset.Description,
Icon: preset.Icon,
}

if slice.Contains(duplicatedPresetNames, preset.Name) {
Expand Down
Loading
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy