这是indexloc提供的服务,不要输入任何密码
Skip to content

Expose elastic_concurrent_builds on resource config #261

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

Closed
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
1 change: 1 addition & 0 deletions client/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ type Security struct {
type ResourceConfig struct {
FunctionDefaultMemoryType string `json:"functionDefaultMemoryType,omitempty"`
FunctionDefaultTimeout int64 `json:"functionDefaultTimeout,omitempty"`
ElasticConcurrencyEnabled bool `json:"elasticConcurrencyEnabled,omitempty"`
}

// GetProject retrieves information about an existing project from Vercel.
Expand Down
4 changes: 4 additions & 0 deletions vercel/data_source_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ For more detailed information, please see the [Vercel documentation](https://ver
Description: "The default timeout for Serverless Functions.",
Computed: true,
},
"elastic_concurrency_enabled": schema.BoolAttribute{
Description: "Whether to enable elastic builds on the project.",
Computed: true,
},
},
},
},
Expand Down
11 changes: 11 additions & 0 deletions vercel/resource_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,12 @@ At this time you cannot use a Vercel Project resource with in-line ` + "`environ
},
PlanModifiers: []planmodifier.Int64{SuppressDiffIfNotConfigured(), int64planmodifier.UseStateForUnknown()},
},
"elastic_concurrency_enabled": schema.BoolAttribute{
Description: "Whether to enable elastic builds on the project.",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()},
},
},
Default: objectdefault.StaticValue(types.ObjectValueMust(
map[string]attr.Type{
Expand Down Expand Up @@ -605,6 +611,7 @@ type Project struct {
PrioritiseProductionBuilds types.Bool `tfsdk:"prioritise_production_builds"`
DirectoryListing types.Bool `tfsdk:"directory_listing"`
SkewProtection types.String `tfsdk:"skew_protection"`
ElasticConcurrency types.Bool `tfsdk:"elastic_concurrency"`
ResourceConfig *ResourceConfig `tfsdk:"resource_config"`
}

Expand Down Expand Up @@ -992,6 +999,7 @@ func (o *OIDCTokenConfig) toUpdateProjectRequest() *client.OIDCTokenConfig {
type ResourceConfig struct {
FunctionDefaultMemoryType types.String `tfsdk:"function_default_cpu_type"`
FunctionDefaultTimeout types.Int64 `tfsdk:"function_default_timeout"`
ElasticConcurrencyEnabled types.Bool `tfsdk:"elastic_concurrency_enabled"`
}

func (r *ResourceConfig) toUpdateProjectRequest() *client.ResourceConfig {
Expand All @@ -1006,6 +1014,9 @@ func (r *ResourceConfig) toUpdateProjectRequest() *client.ResourceConfig {
if !r.FunctionDefaultTimeout.IsNull() {
resourceConfig.FunctionDefaultTimeout = r.FunctionDefaultTimeout.ValueInt64()
}
if !r.ElasticConcurrencyEnabled.IsNull() {
resourceConfig.ElasticConcurrencyEnabled = r.ElasticConcurrencyEnabled.ValueBool()
}
Comment on lines +1017 to +1019
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add tests to demonstrate that it works? 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, once I've validated it locally ✌️

return resourceConfig
}

Expand Down
Loading