-
Notifications
You must be signed in to change notification settings - Fork 32
[enhanced builds] add build_machine_type option to project creation #319
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -393,6 +393,14 @@ For more detailed information, please see the [Vercel documentation](https://ver | |
Optional: true, | ||
Computed: true, | ||
}, | ||
"build_machine_type": schema.StringAttribute{ | ||
Description: "When `on_demand_concurrent_builds` is enabled, choose the build machine: `standard` (4 vCPU, 8 GB) or `enhanced` (8 vCPU, 16GB)", | ||
Optional: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't be optional on the data source. Only computed. (it's a read-only property here). |
||
Computed: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. edit: i'm a fool, this is the data source. |
||
Validators: []validator.String{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for validators on the data source. |
||
stringvalidator.OneOf("standard", "enhanced"), | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
@@ -437,6 +445,7 @@ type ProjectDataSource struct { | |
ResourceConfig types.Object `tfsdk:"resource_config"` | ||
NodeVersion types.String `tfsdk:"node_version"` | ||
OnDemandConcurrentBuilds types.Bool `tfsdk:"on_demand_concurrent_builds"` | ||
BuildMachineType types.String `tfsdk:"build_machine_type"` | ||
} | ||
|
||
func convertResponseToProjectDataSource(ctx context.Context, response client.ProjectResponse, plan Project, environmentVariables []client.EnvironmentVariable) (ProjectDataSource, error) { | ||
|
@@ -503,6 +512,7 @@ func convertResponseToProjectDataSource(ctx context.Context, response client.Pro | |
ResourceConfig: project.ResourceConfig, | ||
NodeVersion: project.NodeVersion, | ||
OnDemandConcurrentBuilds: project.OnDemandConcurrentBuilds, | ||
BuildMachineType: project.BuildMachineType, | ||
}, nil | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -579,6 +579,15 @@ At this time you cannot use a Vercel Project resource with in-line ` + "`environ | |
Computed: true, | ||
PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}, | ||
}, | ||
"build_machine_type": schema.StringAttribute{ | ||
Description: "When `on_demand_concurrent_builds` is enabled, choose the build machine: `standard` (4 vCPU, 8 GB) or `enhanced` (8 vCPU, 16GB)", | ||
Optional: true, | ||
Computed: true, | ||
Validators: []validator.String{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's figure out how to add a validator to make sure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have |
||
stringvalidator.OneOf("standard", "enhanced"), | ||
}, | ||
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if |
||
}, | ||
}, | ||
} | ||
} | ||
|
@@ -631,6 +640,7 @@ type Project struct { | |
SkewProtection types.String `tfsdk:"skew_protection"` | ||
ResourceConfig types.Object `tfsdk:"resource_config"` | ||
OnDemandConcurrentBuilds types.Bool `tfsdk:"on_demand_concurrent_builds"` | ||
BuildMachineType types.String `tfsdk:"build_machine_type"` | ||
} | ||
|
||
type GitComments struct { | ||
|
@@ -750,7 +760,7 @@ func (p *Project) toCreateProjectRequest(ctx context.Context, envs []Environment | |
PublicSource: p.PublicSource.ValueBoolPointer(), | ||
RootDirectory: p.RootDirectory.ValueStringPointer(), | ||
ServerlessFunctionRegion: p.ServerlessFunctionRegion.ValueString(), | ||
ResourceConfig: resourceConfig.toClientResourceConfig(p.OnDemandConcurrentBuilds), | ||
ResourceConfig: resourceConfig.toClientResourceConfig(p.OnDemandConcurrentBuilds, p.BuildMachineType), | ||
EnablePreviewFeedback: oneBoolPointer(p.EnablePreviewFeedback, p.PreviewComments), | ||
EnableProductionFeedback: p.EnableProductionFeedback.ValueBoolPointer(), | ||
}, diags | ||
|
@@ -831,7 +841,7 @@ func (p *Project) toUpdateProjectRequest(ctx context.Context, oldName string) (r | |
DirectoryListing: p.DirectoryListing.ValueBool(), | ||
SkewProtectionMaxAge: toSkewProtectionAge(p.SkewProtection), | ||
GitComments: gc.toUpdateProjectRequest(), | ||
ResourceConfig: resourceConfig.toClientResourceConfig(p.OnDemandConcurrentBuilds), | ||
ResourceConfig: resourceConfig.toClientResourceConfig(p.OnDemandConcurrentBuilds, p.BuildMachineType), | ||
NodeVersion: p.NodeVersion.ValueString(), | ||
}, nil | ||
} | ||
|
@@ -1083,7 +1093,7 @@ func (p *Project) resourceConfig(ctx context.Context) (rc *ResourceConfig, diags | |
return rc, diags | ||
} | ||
|
||
func (r *ResourceConfig) toClientResourceConfig(onDemandConcurrentBuilds types.Bool) *client.ResourceConfig { | ||
func (r *ResourceConfig) toClientResourceConfig(onDemandConcurrentBuilds types.Bool, buildMachineType types.String) *client.ResourceConfig { | ||
if r == nil { | ||
return nil | ||
} | ||
|
@@ -1101,6 +1111,11 @@ func (r *ResourceConfig) toClientResourceConfig(onDemandConcurrentBuilds types.B | |
if !onDemandConcurrentBuilds.IsUnknown() { | ||
resourceConfig.ElasticConcurrencyEnabled = onDemandConcurrentBuilds.ValueBoolPointer() | ||
} | ||
if !buildMachineType.IsUnknown() && *resourceConfig.ElasticConcurrencyEnabled { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need this logic here, we can just use a validator, and set |
||
// `build_machine_type` can only be set when `on_demand_concurrent_builds` | ||
// is enabled. | ||
resourceConfig.BuildMachineType = buildMachineType.ValueStringPointer() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget to convert |
||
} | ||
return resourceConfig | ||
} | ||
|
||
|
@@ -1472,6 +1487,7 @@ func convertResponseToProject(ctx context.Context, response client.ProjectRespon | |
ResourceConfig: resourceConfig, | ||
NodeVersion: types.StringValue(response.NodeVersion), | ||
OnDemandConcurrentBuilds: types.BoolValue(response.ResourceConfig.ElasticConcurrencyEnabled), | ||
BuildMachineType: types.StringValue(*response.ResourceConfig.BuildMachineType), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget to convert |
||
}, nil | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omitempty
here means we'll never actually sendnull
to the API. Probably want to remove that.