mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-01 07:42:40 +00:00
SHA256 encode compute_certificate's private keys (#2976)
Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
parent
856a977ddc
commit
69e445bd59
|
@ -49,10 +49,11 @@ func resourceComputeSslCertificate() *schema.Resource {
|
|||
Sensitive: true,
|
||||
},
|
||||
"private_key": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
Sensitive: true,
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DiffSuppressFunc: sha256DiffSuppress,
|
||||
Sensitive: true,
|
||||
},
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
package google
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
@ -179,6 +181,12 @@ func ipCidrRangeDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// sha256DiffSuppress
|
||||
// if old is the hex-encoded sha256 sum of new, treat them as equal
|
||||
func sha256DiffSuppress(_, old, new string, _ *schema.ResourceData) bool {
|
||||
return hex.EncodeToString(sha256.New().Sum([]byte(old))) == new
|
||||
}
|
||||
|
||||
func caseDiffSuppress(_, old, new string, _ *schema.ResourceData) bool {
|
||||
return strings.ToUpper(old) == strings.ToUpper(new)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user