Skip to content

Commit

Permalink
If both number and numeric are present check that the values are matc…
Browse files Browse the repository at this point in the history
…hing (#299)
  • Loading branch information
bendbennett committed Aug 31, 2022
1 parent 1c105e8 commit 13d74cb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internal/planmodifiers/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ func (d *numberNumericAttributePlanModifier) Modify(ctx context.Context, req tfs
return
}

if !numberConfig.Null && !numericConfig.Null {
if !numberConfig.Null && !numericConfig.Null && (numberConfig.Value != numericConfig.Value) {
resp.Diagnostics.AddError(
"Number numeric attribute plan modifier failed",
"Cannot specify both number and numeric in config",
"Number and numeric are both present and have different values",
"Number is deprecated, use numeric instead",
)
return
}
Expand All @@ -131,14 +131,14 @@ func (d *numberNumericAttributePlanModifier) Modify(ctx context.Context, req tfs
return
}

// Default to using value for numeric if number is null
if numberConfig.Null && !numericConfig.Null {
// Default to using value for numeric if number is null.
if numberConfig.IsNull() && !numericConfig.IsNull() {
resp.AttributePlan = numericConfig
return
}

// Default to using value for number if numeric is null
if !numberConfig.Null && numericConfig.Null {
// Default to using value for number if numeric is null.
if !numberConfig.IsNull() && numericConfig.IsNull() {
resp.AttributePlan = numberConfig
return
}
Expand Down

0 comments on commit 13d74cb

Please sign in to comment.