Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat!: drop LegacyVariableName from coder parameter #8360

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 8 commits into from
Jul 7, 2023
Merged
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
3 changes: 0 additions & 3 deletions coderd/apidoc/docs.go

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

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

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

1 change: 0 additions & 1 deletion coderd/database/db2sdk/db2sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func TemplateVersionParameter(param database.TemplateVersionParameter) (codersdk
ValidationError: param.ValidationError,
ValidationMonotonic: codersdk.ValidationMonotonicOrder(param.ValidationMonotonic),
Required: param.Required,
LegacyVariableName: param.LegacyVariableName,
}, nil
}

Expand Down
1 change: 0 additions & 1 deletion coderd/database/dbfake/dbfake.go
Original file line number Diff line number Diff line change
Expand Up @@ -3966,7 +3966,6 @@ func (q *fakeQuerier) InsertTemplateVersionParameter(_ context.Context, arg data
ValidationMonotonic: arg.ValidationMonotonic,
Required: arg.Required,
DisplayOrder: arg.DisplayOrder,
LegacyVariableName: arg.LegacyVariableName,
}
q.templateVersionParameters = append(q.templateVersionParameters, param)
return param, nil
Expand Down
3 changes: 0 additions & 3 deletions 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,5 @@
-- Unfortunately we can't bring back deleted values.

ALTER TABLE template_version_parameters ADD COLUMN legacy_variable_name text NOT NULL DEFAULT '';

COMMENT ON COLUMN template_version_parameters.legacy_variable_name IS 'Name of the legacy variable for migration purposes';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE template_version_parameters DROP COLUMN legacy_variable_name;
Copy link
Member

@mafredri mafredri Jul 7, 2023

Choose a reason for hiding this comment

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

What could happen if legacy variables are still present when we upgrade? Should we somehow prevent this migration if any column has a non-empty value here?

I'm not sure what we should do, but perhaps something like this (granted the condition is needed).

DO $$
  BEGIN
    RAISE 'Bad things will happen!';
  END;
$$ LANGUAGE plpgsql;

Copy link
Member Author

Choose a reason for hiding this comment

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

Legacy variable names are not used since 2 minor releases (v0.24.0, v0.25.0). I would assume that we can just drop the column :) Users who forgot to migrate workspaces will not benefit from the legacy_variable_name property.

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

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

12 changes: 3 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.

4 changes: 1 addition & 3 deletions coderd/database/queries/templateversionparameters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ INSERT INTO
validation_error,
validation_monotonic,
required,
legacy_variable_name,
display_name,
display_order
)
Expand All @@ -36,8 +35,7 @@ VALUES
$13,
$14,
$15,
$16,
$17
$16
) RETURNING *;

-- name: GetTemplateVersionParameters :many
Expand Down
1 change: 0 additions & 1 deletion coderd/provisionerdserver/provisionerdserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,6 @@ func (server *Server) CompleteJob(ctx context.Context, completed *proto.Complete
ValidationMonotonic: richParameter.ValidationMonotonic,
Required: richParameter.Required,
DisplayOrder: richParameter.Order,
LegacyVariableName: richParameter.LegacyVariableName,
})
if err != nil {
return nil, xerrors.Errorf("insert parameter: %w", err)
Expand Down
1 change: 0 additions & 1 deletion coderd/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,6 @@ func convertTemplateVersionParameter(param database.TemplateVersionParameter) (c
ValidationError: param.ValidationError,
ValidationMonotonic: codersdk.ValidationMonotonicOrder(param.ValidationMonotonic),
Required: param.Required,
LegacyVariableName: param.LegacyVariableName,
}, nil
}

Expand Down
1 change: 0 additions & 1 deletion codersdk/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ type TemplateVersionParameter struct {
ValidationMax *int32 `json:"validation_max,omitempty"`
ValidationMonotonic ValidationMonotonicOrder `json:"validation_monotonic,omitempty" enums:"increasing,decreasing"`
Required bool `json:"required"`
LegacyVariableName string `json:"legacy_variable_name,omitempty"`
}

// TemplateVersionParameterOption represents a selectable option for a template parameter.
Expand Down
2 changes: 0 additions & 2 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -4201,7 +4201,6 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
"description_plaintext": "string",
"display_name": "string",
"icon": "string",
"legacy_variable_name": "string",
"mutable": true,
"name": "string",
"options": [
Expand Down Expand Up @@ -4231,7 +4230,6 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
| `description_plaintext` | string | false | | |
| `display_name` | string | false | | |
| `icon` | string | false | | |
| `legacy_variable_name` | string | false | | |
| `mutable` | boolean | false | | |
| `name` | string | false | | |
| `options` | array of [codersdk.TemplateVersionParameterOption](#codersdktemplateversionparameteroption) | false | | |
Expand Down
2 changes: 0 additions & 2 deletions docs/api/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -2240,7 +2240,6 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/r
"description_plaintext": "string",
"display_name": "string",
"icon": "string",
"legacy_variable_name": "string",
"mutable": true,
"name": "string",
"options": [
Expand Down Expand Up @@ -2280,7 +2279,6 @@ Status Code **200**
| `» description_plaintext` | string | false | | |
| `» display_name` | string | false | | |
| `» icon` | string | false | | |
| `» legacy_variable_name` | string | false | | |
| `» mutable` | boolean | false | | |
| `» name` | string | false | | |
| `» options` | array | false | | |
Expand Down
10 changes: 8 additions & 2 deletions go.mod
Original file line number Diff line number Diff 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.9.0
github.com/coder/terraform-provider-coder v0.11.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 Down Expand Up @@ -358,4 +358,10 @@ require (
inet.af/peercred v0.0.0-20210906144145-0893ea02156a // indirect
)

require github.com/bep/godartsass/v2 v2.0.0 // indirect
require (
github.com/bep/godartsass/v2 v2.0.0 // indirect
github.com/hashicorp/go-plugin v1.4.4 // indirect
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/oklog/run v1.0.0 // indirect
)
Loading