mirror of
https://github.com/hashicorp/terraform.git
synced 2026-04-22 14:51:50 -04:00
36 lines
1,016 B
Go
36 lines
1,016 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package stackruntime
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hashicorp/terraform/internal/stacks/stackconfig"
|
|
"github.com/hashicorp/terraform/internal/stacks/stackruntime/internal/stackeval"
|
|
"github.com/hashicorp/terraform/internal/tfdiags"
|
|
"go.opentelemetry.io/otel/codes"
|
|
)
|
|
|
|
// Validate performs static validation of a full stack configuration, returning
|
|
// diagnostics in case of any detected problems.
|
|
func Validate(ctx context.Context, req *ValidateRequest) tfdiags.Diagnostics {
|
|
ctx, span := tracer.Start(ctx, "validate stack configuration")
|
|
defer span.End()
|
|
|
|
main := stackeval.NewForValidating(req.Config, stackeval.ValidateOpts{})
|
|
diags := main.ValidateAll(ctx)
|
|
diags = diags.Append(
|
|
main.DoCleanup(ctx),
|
|
)
|
|
if diags.HasErrors() {
|
|
span.SetStatus(codes.Error, "validation returned errors")
|
|
}
|
|
return diags
|
|
}
|
|
|
|
type ValidateRequest struct {
|
|
Config *stackconfig.Config
|
|
|
|
// TODO: Provider factories and other similar such things
|
|
}
|