mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Add deprecation warns during variables prompts
Signed-off-by: yottta <andrei.ciobanu@opentofu.org>
This commit is contained in:
@@ -446,7 +446,7 @@ func (b *Local) interactiveCollectVariables(ctx context.Context, existing map[st
|
||||
rawValue, err := uiInput.Input(ctx, &tofu.InputOpts{
|
||||
Id: fmt.Sprintf("var.%s", name),
|
||||
Query: fmt.Sprintf("var.%s", name),
|
||||
Description: vc.Description,
|
||||
Description: variableInputDescription(vc),
|
||||
Secret: vc.Sensitive,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -461,6 +461,21 @@ func (b *Local) interactiveCollectVariables(ctx context.Context, existing map[st
|
||||
return ret
|
||||
}
|
||||
|
||||
// variableInputDescription compiles a message for the description when the variable input is needed.
|
||||
// This is returning only the configs.Variable#Description if the variable is not deprecated,
|
||||
// or it returns both, the description and the deprecation message in one string to be able to
|
||||
// notify the user about the deprecation of the variable.
|
||||
func variableInputDescription(v *configs.Variable) string {
|
||||
switch {
|
||||
case v.Description != "" && v.DeprecatedSet:
|
||||
return fmt.Sprintf("%s.\nVariable deprecated: %s", v.Description, v.Deprecated)
|
||||
case v.DeprecatedSet:
|
||||
return fmt.Sprintf("Variable deprecated: %s", v.Deprecated)
|
||||
default:
|
||||
return v.Description
|
||||
}
|
||||
}
|
||||
|
||||
// stubUnsetVariables ensures that all required variables defined in the
|
||||
// configuration exist in the resulting map, by adding new elements as necessary.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user