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 "display_order" column to coder_parameter to keep parameters sorted in UI#8227

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 25 commits intomainfrom8193-order-parameters
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
25 commits
Select commitHold shift + click to select a range
3e9964f
WIP
mtojekJun 27, 2023
0d37f91
Merge branch 'main' into 8193-order-parameters
mtojekJun 27, 2023
bb709b6
proto
mtojekJun 27, 2023
18e7eb4
insert priority
mtojekJun 27, 2023
648d992
wiring spaghetti
mtojekJun 27, 2023
4261497
Sort params
mtojekJun 27, 2023
c896115
fix: migration
mtojekJun 27, 2023
c22c600
fmt
mtojekJun 27, 2023
626cfe4
fmt
mtojekJun 27, 2023
c42a731
make gen
mtojekJun 27, 2023
56f422f
fix gen
mtojekJun 27, 2023
dd4cc71
fix
mtojekJun 27, 2023
91fa3ec
Implement test
mtojekJun 27, 2023
a36f616
make gen
mtojekJun 27, 2023
8ab123b
Merge branch 'main' into 8193-order-parameters
mtojekJun 30, 2023
6ed37b5
Renamed priority to order
mtojekJun 30, 2023
269555e
Fix: order
mtojekJun 30, 2023
57a0fd4
remove orderedRichParameters
mtojekJun 30, 2023
1e54ace
Correct order
mtojekJun 30, 2023
091888b
Terraform tests ok
mtojekJun 30, 2023
1620758
fix: LOWER
mtojekJun 30, 2023
f97db90
fix
mtojekJun 30, 2023
0efc2ae
fmt proto
mtojekJun 30, 2023
8a0ac74
fix
mtojekJun 30, 2023
82b8b7b
fix: make gen
mtojekJun 30, 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
7 changes: 7 additions & 0 deletionscoderd/database/dbfake/dbfake.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2410,6 +2410,12 @@ func (q *fakeQuerier) GetTemplateVersionParameters(_ context.Context, templateVe
}
parameters = append(parameters, param)
}
sort.Slice(parameters, func(i, j int) bool {
if parameters[i].DisplayOrder != parameters[j].DisplayOrder {
return parameters[i].DisplayOrder < parameters[j].DisplayOrder
}
return strings.ToLower(parameters[i].Name) < strings.ToLower(parameters[j].Name)
})
return parameters, nil
}

Expand DownExpand Up@@ -3934,6 +3940,7 @@ func (q *fakeQuerier) InsertTemplateVersionParameter(_ context.Context, arg data
ValidationMax: arg.ValidationMax,
ValidationMonotonic: arg.ValidationMonotonic,
Required: arg.Required,
DisplayOrder: arg.DisplayOrder,
LegacyVariableName: arg.LegacyVariableName,
}
q.templateVersionParameters = append(q.templateVersionParameters, param)
Expand Down
3 changes: 3 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 @@
ALTER TABLE template_version_parameters DROP COLUMN display_order;
4 changes: 4 additions & 0 deletionscoderd/database/migrations/000132_parameters_order.up.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
ALTER TABLE template_version_parameters ADD COLUMN display_order integer NOT NULL DEFAULT 0;
Copy link
Member

Choose a reason for hiding this comment

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

It's possible to use a reserved word as a name via quoting, e.g.ADD COLUMN "order", but I prefer this approach 👍🏻.

mtojek reacted with thumbs up emoji

COMMENT ON COLUMN template_version_parameters.display_order
IS 'Specifies the order in which to display parameters in user interfaces.';
2 changes: 2 additions & 0 deletionscoderd/database/models.go
View file
Open in desktop

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

14 changes: 10 additions & 4 deletionscoderd/database/queries.sql.go
View file
Open in desktop

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

8 changes: 5 additions & 3 deletionscoderd/database/queries/templateversionparameters.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,8 @@ INSERT INTO
validation_monotonic,
required,
legacy_variable_name,
display_name
display_name,
display_order
)
VALUES
(
Expand All@@ -35,8 +36,9 @@ VALUES
$13,
$14,
$15,
$16
$16,
$17
) RETURNING *;

-- name: GetTemplateVersionParameters :many
SELECT * FROM template_version_parameters WHERE template_version_id = $1;
SELECT * FROM template_version_parameters WHERE template_version_id = $1 ORDER BY display_order ASC, LOWER(name) ASC;
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for using explicitASC, helps to convey the intent.☺️

mtojek reacted with thumbs up emoji
1 change: 1 addition & 0 deletionscoderd/provisionerdserver/provisionerdserver.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -825,6 +825,7 @@ func (server *Server) CompleteJob(ctx context.Context, completed *proto.Complete
ValidationMax: validationMax,
ValidationMonotonic: richParameter.ValidationMonotonic,
Required: richParameter.Required,
DisplayOrder: richParameter.Order,
LegacyVariableName: richParameter.LegacyVariableName,
})
if err != nil {
Expand Down
90 changes: 90 additions & 0 deletionscoderd/templateversions_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1291,3 +1291,93 @@ func TestTemplateVersionPatch(t *testing.T) {
require.Error(t, err)
})
}

func TestTemplateVersionParameters_Order(t *testing.T) {
t.Parallel()

const (
firstParameterName = "first_parameter"
firstParameterType = "string"
firstParameterValue = "aaa"
// no order

secondParameterName = "Second_parameter"
secondParameterType = "number"
secondParameterValue = "2"
secondParameterOrder = 3

thirdParameterName = "third_parameter"
thirdParameterType = "number"
thirdParameterValue = "3"
thirdParameterOrder = 3

fourthParameterName = "Fourth_parameter"
fourthParameterType = "number"
fourthParameterValue = "3"
fourthParameterOrder = 2

fifthParameterName = "Fifth_parameter"
fifthParameterType = "string"
fifthParameterValue = "aaa"
// no order
)

client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
ProvisionPlan: []*proto.Provision_Response{
{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
Parameters: []*proto.RichParameter{
{
Name: firstParameterName,
Type: firstParameterType,
// No order
},
{
Name: secondParameterName,
Type: secondParameterType,
Order: secondParameterOrder,
},
{
Name: thirdParameterName,
Type: thirdParameterType,
Order: thirdParameterOrder,
},
{
Name: fourthParameterName,
Type: fourthParameterType,
Order: fourthParameterOrder,
},
{
Name: fifthParameterName,
Type: fifthParameterType,
// No order
},
},
},
},
},
},
ProvisionApply: []*proto.Provision_Response{{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{},
},
}},
})
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()

templateRichParameters, err := client.TemplateVersionRichParameters(ctx, version.ID)
require.NoError(t, err)
require.Len(t, templateRichParameters, 5)
require.Equal(t, fifthParameterName, templateRichParameters[0].Name)
require.Equal(t, firstParameterName, templateRichParameters[1].Name)
require.Equal(t, fourthParameterName, templateRichParameters[2].Name)
require.Equal(t, secondParameterName, templateRichParameters[3].Name)
require.Equal(t, thirdParameterName, templateRichParameters[4].Name)
}
5 changes: 2 additions & 3 deletionsgo.mod
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,7 +75,7 @@ require (
github.com/codeclysm/extract v2.2.0+incompatible
github.com/coder/flog v1.1.0
github.com/coder/retry v1.4.0
github.com/coder/terraform-provider-coder v0.8.2
github.com/coder/terraform-provider-coder v0.9.0
github.com/coder/wgtunnel v0.1.5
github.com/coreos/go-oidc/v3 v3.6.0
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
Expand DownExpand Up@@ -126,7 +126,7 @@ require (
github.com/mitchellh/go-wordwrap v1.0.1
github.com/mitchellh/mapstructure v1.5.0
github.com/moby/moby v24.0.1+incompatible
github.com/muesli/reflow v0.3.0
github.com/muesli/reflow v0.3.0 // indirect
github.com/open-policy-agent/opa v0.51.0
github.com/ory/dockertest/v3 v3.10.0
github.com/pion/udp v0.1.2
Expand DownExpand Up@@ -218,7 +218,6 @@ require (
github.com/docker/docker v23.0.3+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1
github.com/elastic/go-windows v1.0.0 // indirect
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
Expand Down
5 changes: 2 additions & 3 deletionsgo.sum
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -193,8 +193,8 @@ github.com/coder/ssh v0.0.0-20230621095435-9a7e23486f1c h1:TI7TzdFI0UvQmwgyQhtI1
github.com/coder/ssh v0.0.0-20230621095435-9a7e23486f1c/go.mod h1:aGQbuCLyhRLMzZF067xc84Lh7JDs1FKwCmF1Crl9dxQ=
github.com/coder/tailscale v0.0.0-20230522123520-74712221d00f h1:F0Xr1d8h8dAHn7tab1HXuzYFkcjmCydnEfdMbkOhlVk=
github.com/coder/tailscale v0.0.0-20230522123520-74712221d00f/go.mod h1:jpg+77g19FpXL43U1VoIqoSg1K/Vh5CVxycGldQ8KhA=
github.com/coder/terraform-provider-coder v0.8.2 h1:EPhkdpsNd8fcg6eqpAQr+W1eRrEAMtugoqujoTK4O6o=
github.com/coder/terraform-provider-coder v0.8.2/go.mod h1:UIfU3bYNeSzJJvHyJ30tEKjD6Z9utloI+HUM/7n94CY=
github.com/coder/terraform-provider-coder v0.9.0 h1:OJazaeBz6O2h7tDDUyUWgNW71lTPbvbI2raX1CGuBzI=
github.com/coder/terraform-provider-coder v0.9.0/go.mod h1:UIfU3bYNeSzJJvHyJ30tEKjD6Z9utloI+HUM/7n94CY=
github.com/coder/wgtunnel v0.1.5 h1:WP3sCj/3iJ34eKvpMQEp1oJHvm24RYh0NHbj1kfUKfs=
github.com/coder/wgtunnel v0.1.5/go.mod h1:bokoUrHnUFY4lu9KOeSYiIcHTI2MO1KwqumU4DPDyJI=
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
Expand DownExpand Up@@ -238,7 +238,6 @@ github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/elastic/go-sysinfo v1.11.0 h1:QW+6BF1oxBoAprH3w2yephF7xLkrrSXj7gl2xC2BM4w=
github.com/elastic/go-sysinfo v1.11.0/go.mod h1:6KQb31j0QeWBDF88jIdWSxE8cwoOB9tO4Y4osN7Q70E=
github.com/elastic/go-windows v1.0.0 h1:qLURgZFkkrYyTTkvYpsZIgf83AUsdIHfvlJaqaZ7aSY=
Expand Down
26 changes: 9 additions & 17 deletionsprovisioner/terraform/executor.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,12 +280,7 @@ func (e *executor) planResources(ctx, killCtx context.Context, planfilePath stri
}
modules = append(modules, plan.PlannedValues.RootModule)

rawParameterNames, err := rawRichParameterNames(e.workdir)
if err != nil {
return nil, xerrors.Errorf("raw rich parameter names: %w", err)
}

state, err := ConvertState(modules, rawGraph, rawParameterNames)
state, err := ConvertState(modules, rawGraph)
if err != nil {
return nil, err
}
Expand DownExpand Up@@ -410,18 +405,15 @@ func (e *executor) stateResources(ctx, killCtx context.Context) (*State, error)
return nil, xerrors.Errorf("get terraform graph: %w", err)
}
converted := &State{}
if state.Values != nil {
rawParameterNames, err := rawRichParameterNames(e.workdir)
if err != nil {
return nil, xerrors.Errorf("raw rich parameter names: %w", err)
}
if state.Values == nil {
return converted, nil
}

converted, err = ConvertState([]*tfjson.StateModule{
state.Values.RootModule,
}, rawGraph, rawParameterNames)
if err != nil {
return nil, err
}
converted, err = ConvertState([]*tfjson.StateModule{
state.Values.RootModule,
}, rawGraph)
if err != nil {
return nil, err
}
return converted, nil
}
Expand Down
70 changes: 0 additions & 70 deletionsprovisioner/terraform/parameters.go
View file
Open in desktop

This file was deleted.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp