8000 chore: pass previous values into terraform apply by Emyrk · Pull Request #17696 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: pass previous values into terraform apply #17696

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 23 commits into from
May 12, 2025
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
update versions
  • Loading branch information
Emyrk committed May 9, 2025
commit fd6cdf516b317e91b04955fff75864089fb6fb46
2 changes: 2 additions & 0 deletions
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
WorkspaceID: workspaceBuild.WorkspaceID,
BuildNumber: buildNum,
})

// If the error is ErrNoRows, then assume previous values are empty.
if err != nil && !xerrors.Is(err, sql.ErrNoRows) {
return nil, xerrors.Errorf("get last build with number=%d: %w", buildNum, err)
}
Expand Down
12 changes: 3 additions & 9 deletions codersdk/richparameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ fun 8000 c validateBuildParameter(richParameter TemplateVersionParameter, buildParamet
return xerrors.Errorf("parameter value is required")
}

if value == "" { // parameter is optional, so take the default value
value = richParameter.DefaultValue
if current == "" { // parameter is optional, so take the default value
current = richParameter.DefaultValue
}

if len(richParameter.Options) > 0 {
Expand Down Expand Up @@ -101,13 +101,7 @@ func validateBuildParameter(richParameter TemplateVersionParameter, buildParamet
Error: richParameter.ValidationError,
Monotonic: string(richParameter.ValidationMonotonic),
}
var prev *string
// Empty strings should be rejected, however the previous behavior was to
// accept the empty string ("") as a `nil` previous value.
if lastBuildParameter != nil && lastBuildParameter.Value != "" {
prev = &lastBuildParameter.Value
}
return validation.Valid(richParameter.Type, value, prev)
return validation.Valid(richParameter.Type, current, previous)
}

func findBuildParameter(params []WorkspaceBuildParameter, parameterName string) (*WorkspaceBuildParameter, bool) {
Expand Down
7 changes: 6 additions & 1 deletion provisionerd/proto/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ import "github.com/coder/coder/v2/apiversion"
//
// API v1.4:
// - Add new field named `devcontainers` in the Agent.
//
// API v1.5:
// - Add previous parameter values to 'WorkspaceBuild' jobs. Provisioner passes
// the previous values for the `terraform apply` to enforce monotonicity
// in the terraform provider.
Comment on lines +19 to +21
Copy link
Member

Choose a reason for hiding this comment

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

👍

const (
CurrentMajor = 1
CurrentMinor = 4
CurrentMinor = 5
)

// CurrentVersion is the current provisionerd API version.
Expand Down
8 changes: 1 addition & 7 deletions tailnet/proto/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,9 @@ import (
// PushResourcesMonitoringUsage RPCs on the Agent API.
// - Added support for reporting connection events for auditing via the
// ReportConnection RPC on the Agent API.
//
// API v2.5:
// - Shipped in Coder v2.{{placeholder}} // TODO Steven: Replace with the correct version
// - Add previous parameter values to 'WorkspaceBuild' jobs. Provisioner passes
// the previous values for the `terraform apply` to enforce monotonicity
// in the terraform provider.
const (
CurrentMajor = 2
CurrentMinor = 5
CurrentMinor = 4
)

var CurrentVersion = apiversion.New(CurrentMajor, CurrentMinor)
Loading
0