-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ignore changes on qcow2 size if it is just qemu-img round up to secto…
…r size Co-authored-by: Duncan Mac-Vicar P <[email protected]> Closes: #741
- Loading branch information
1 parent
7d844fb
commit 9b39ff0
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package suppress | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"strconv" | ||
) | ||
|
||
const qcow2SectorSize = 512 | ||
|
||
// Suppress the diff if the specified volume size is qemu-img round up to sector size | ||
func Qcow2SizeDiffSuppressFunc(_, oldSizeStr, newSizeStr string, k *schema.ResourceData) bool { | ||
if format := k.Get("format"); format != "qcow2" { | ||
return false | ||
} | ||
|
||
// On first apply these are nil strings, so there's always a diff | ||
if oldSizeStr == "" { | ||
return false | ||
} | ||
|
||
oldSize, _ := strconv.ParseUint(oldSizeStr, 10, 64) | ||
newSize, _ := strconv.ParseUint(newSizeStr, 10, 64) | ||
|
||
if oldSize-newSize < qcow2SectorSize { | ||
return true | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters