Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Add basic support for rich parameters to coderd and provisionerd#5710

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mtojek merged 21 commits intocoder:mainfrommtojek:5574-new-parameter-data-source
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
21 commits
Select commitHold shift + click to select a range
95193b7
SQL migrations
mtojekJan 13, 2023
56ad006
SQL queries
mtojekJan 13, 2023
625ce80
databasefake
mtojekJan 13, 2023
053e320
Merge branch 'main' into 5574-new-parameter-data-source
mtojekJan 13, 2023
bb0d217
coderd API
mtojekJan 13, 2023
7d61b55
golint
mtojekJan 13, 2023
314d77a
Fix: migration
mtojekJan 13, 2023
0724b10
golint
mtojekJan 13, 2023
6af91e2
Fix: proto version
mtojekJan 13, 2023
f726eda
Fix
mtojekJan 13, 2023
3320b3a
proto
mtojekJan 13, 2023
f73c633
fix
mtojekJan 13, 2023
bfbe271
Merge branch 'main' into 5574-new-parameter-data-source
mtojekJan 13, 2023
b5470b7
workaround: fixtures
mtojekJan 13, 2023
9dfc0c5
TDD: unit test
mtojekJan 16, 2023
2401c7c
WIP: proto files
mtojekJan 16, 2023
e032a36
fix: proto
mtojekJan 16, 2023
c1012d2
Fix: echo provisioner
mtojekJan 16, 2023
f228b34
Terraform provisioner
mtojekJan 16, 2023
7fbf8ba
Fix: missing input
mtojekJan 16, 2023
e0cb2dc
Fix: debugging purposes
mtojekJan 16, 2023
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
38 changes: 38 additions & 0 deletionscoderd/apidoc/docs.go
View file
Open in desktop

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

34 changes: 34 additions & 0 deletionscoderd/apidoc/swagger.json
View file
Open in desktop

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

1 change: 1 addition & 0 deletionscoderd/coderd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -435,6 +435,7 @@ func New(options *Options) *API {
r.Patch("/cancel", api.patchCancelTemplateVersion)
r.Get("/schema", api.templateVersionSchema)
r.Get("/parameters", api.templateVersionParameters)
r.Get("/rich-parameters", api.templateVersionRichParameters)
r.Get("/resources", api.templateVersionResources)
r.Get("/logs", api.templateVersionLogs)
r.Route("/dry-run", func(r chi.Router) {
Expand Down
4 changes: 4 additions & 0 deletionscoderd/coderdtest/authorize.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -177,6 +177,10 @@ func AGPLRoutes(a *AuthTester) (map[string]string, map[string]RouteCheck) {
AssertAction: rbac.ActionRead,
AssertObject: rbac.ResourceTemplate.InOrg(a.Template.OrganizationID),
},
"GET:/api/v2/templateversions/{templateversion}/rich-parameters": {
AssertAction: rbac.ActionRead,
AssertObject: rbac.ResourceTemplate.InOrg(a.Template.OrganizationID),
},
"GET:/api/v2/templateversions/{templateversion}/resources": {
AssertAction: rbac.ActionRead,
AssertObject: rbac.ResourceTemplate.InOrg(a.Template.OrganizationID),
Expand Down
66 changes: 66 additions & 0 deletionscoderd/database/databasefake/databasefake.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -111,10 +111,12 @@ type data struct {
provisionerJobs []database.ProvisionerJob
replicas []database.Replica
templateVersions []database.TemplateVersion
templateVersionParameters []database.TemplateVersionParameter
templates []database.Template
workspaceAgents []database.WorkspaceAgent
workspaceApps []database.WorkspaceApp
workspaceBuilds []database.WorkspaceBuild
workspaceBuildParameters []database.WorkspaceBuildParameter
workspaceResourceMetadata []database.WorkspaceResourceMetadatum
workspaceResources []database.WorkspaceResource
workspaces []database.Workspace
Expand DownExpand Up@@ -1365,6 +1367,20 @@ func (q *fakeQuerier) GetWorkspaceBuildByWorkspaceIDAndBuildNumber(_ context.Con
return database.WorkspaceBuild{}, sql.ErrNoRows
}

func (q *fakeQuerier) GetWorkspaceBuildParameters(_ context.Context, workspaceBuildID uuid.UUID) ([]database.WorkspaceBuildParameter, error) {
q.mutex.RLock()
defer q.mutex.RUnlock()

params := make([]database.WorkspaceBuildParameter, 0)
for _, param := range params {
if param.WorkspaceBuildID != workspaceBuildID {
continue
}
params = append(params, param)
}
return params, nil
}

func (q *fakeQuerier) GetWorkspaceBuildsCreatedAfter(_ context.Context, after time.Time) ([]database.WorkspaceBuild, error) {
q.mutex.RLock()
defer q.mutex.RUnlock()
Expand DownExpand Up@@ -1656,6 +1672,20 @@ func (q *fakeQuerier) GetTemplateVersionByTemplateIDAndName(_ context.Context, a
return database.TemplateVersion{}, sql.ErrNoRows
}

func (q *fakeQuerier) GetTemplateVersionParameters(_ context.Context, templateVersionID uuid.UUID) ([]database.TemplateVersionParameter, error) {
q.mutex.RLock()
defer q.mutex.RUnlock()

parameters := make([]database.TemplateVersionParameter, 0)
for _, param := range q.templateVersionParameters {
if param.TemplateVersionID != templateVersionID {
continue
}
parameters = append(parameters, param)
}
return parameters, nil
}

func (q *fakeQuerier) GetTemplateVersionByOrganizationAndName(_ context.Context, arg database.GetTemplateVersionByOrganizationAndNameParams) (database.TemplateVersion, error) {
q.mutex.RLock()
defer q.mutex.RUnlock()
Expand DownExpand Up@@ -2398,6 +2428,28 @@ func (q *fakeQuerier) InsertTemplateVersion(_ context.Context, arg database.Inse
return version, nil
}

func (q *fakeQuerier) InsertTemplateVersionParameter(_ context.Context, arg database.InsertTemplateVersionParameterParams) (database.TemplateVersionParameter, error) {
q.mutex.Lock()
defer q.mutex.Unlock()

//nolint:gosimple
param := database.TemplateVersionParameter{
TemplateVersionID: arg.TemplateVersionID,
Name: arg.Name,
Description: arg.Description,
Type: arg.Type,
Mutable: arg.Mutable,
DefaultValue: arg.DefaultValue,
Icon: arg.Icon,
Options: arg.Options,
ValidationRegex: arg.ValidationRegex,
ValidationMin: arg.ValidationMin,
ValidationMax: arg.ValidationMax,
}
q.templateVersionParameters = append(q.templateVersionParameters, param)
return param, nil
}

func (q *fakeQuerier) InsertProvisionerJobLogs(_ context.Context, arg database.InsertProvisionerJobLogsParams) ([]database.ProvisionerJobLog, error) {
q.mutex.Lock()
defer q.mutex.Unlock()
Expand DownExpand Up@@ -2723,6 +2775,20 @@ func (q *fakeQuerier) InsertWorkspaceBuild(_ context.Context, arg database.Inser
return workspaceBuild, nil
}

func (q *fakeQuerier) InsertWorkspaceBuildParameters(_ context.Context, arg database.InsertWorkspaceBuildParametersParams) error {
q.mutex.Lock()
defer q.mutex.Unlock()

for index, name := range arg.Name {
q.workspaceBuildParameters = append(q.workspaceBuildParameters, database.WorkspaceBuildParameter{
WorkspaceBuildID: arg.WorkspaceBuildID,
Name: name,
Value: arg.Value[index],
})
}
return nil
}

func (q *fakeQuerier) InsertWorkspaceApp(_ context.Context, arg database.InsertWorkspaceAppParams) (database.WorkspaceApp, error) {
q.mutex.Lock()
defer q.mutex.Unlock()
Expand Down
56 changes: 56 additions & 0 deletionscoderd/database/dump.sql
View file
Open in desktop

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

View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
DROP TABLE template_version_parameters;

DROP TABLE workspace_build_parameters;
35 changes: 35 additions & 0 deletionscoderd/database/migrations/000089_rich_parameters.up.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
CREATE TABLE IF NOT EXISTS template_version_parameters (
template_version_id uuid not null references template_versions (id) on delete cascade,
name text not null,
description text not null,
type text not null,
mutable boolean not null,
default_value text not null,
icon text not null,
options jsonb not null default '[]'::jsonb,
validation_regex text not null,
validation_min integer not null,
validation_max integer not null,
unique (template_version_id, name)
);

COMMENT ON COLUMN template_version_parameters.name IS 'Parameter name';
COMMENT ON COLUMN template_version_parameters.description IS 'Parameter description';
COMMENT ON COLUMN template_version_parameters.type IS 'Parameter type';
COMMENT ON COLUMN template_version_parameters.mutable IS 'Is parameter mutable?';
COMMENT ON COLUMN template_version_parameters.default_value IS 'Default value';
COMMENT ON COLUMN template_version_parameters.icon IS 'Icon';
COMMENT ON COLUMN template_version_parameters.options IS 'Additional options';
COMMENT ON COLUMN template_version_parameters.validation_regex IS 'Validation: regex pattern';
COMMENT ON COLUMN template_version_parameters.validation_min IS 'Validation: minimum length of value';
COMMENT ON COLUMN template_version_parameters.validation_max IS 'Validation: maximum length of value';

CREATE TABLE IF NOT EXISTS workspace_build_parameters (
workspace_build_id uuid not null references workspace_builds (id) on delete cascade,
name text not null,
value text not null,
unique (workspace_build_id, name)
);

COMMENT ON COLUMN workspace_build_parameters.name IS 'Parameter name';
COMMENT ON COLUMN workspace_build_parameters.value IS 'Parameter value';
2 changes: 2 additions & 0 deletionscoderd/database/migrations/migrate_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -239,6 +239,8 @@ func TestMigrateUpWithFixtures(t *testing.T) {
"group_members",
"licenses",
"replicas",
"template_version_parameters",
"workspace_build_parameters",
}
s := &tableStats{s: make(map[string]int)}

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp