-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: mssql_elasticpool max_size_bytes to max_size_gb #2695
Merged
Merged
Changes from 9 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
6c4a9c0
WIP: Initial check-in for max_size_gb
WodansSon e6a2bd3
Finished adding validation for Elasticpool max_size_gb
WodansSon 615fd79
Added additional SKU check and updated docs
WodansSon 8fcfb4a
Updated tests to use max_size_gb
WodansSon 6ba0752
fix lint errors
WodansSon 3ccc0b4
Added additional Standard and Premium size check
WodansSon 706e7a7
Switched logic to use maps instead
WodansSon 541ee9e
Added values to error msgs
WodansSon 92cd03a
fix format casing
WodansSon 8289782
Addressed PR comments and updated some func names
WodansSon 028c5b1
Fixed lint errors and remove helper function
WodansSon ee38137
Fixed test issue
WodansSon 9635e5c
Had to special case Basic tier for setting max_size_gb
WodansSon 4b2a43f
Added Name Tier combo validation
WodansSon 9b5352e
Updated to auto-fill tier based of name attribute
WodansSon 0b5dd6d
Added auto-fill attributes for Tier and Family
WodansSon 8a86194
Added Test cases for DTU and vCore autofill
WodansSon 2c4cb79
Update for lint errors
WodansSon a589be8
Update tests
WodansSon 41f04b5
Fixed test cases
WodansSon 0507be0
Fix Lint error
WodansSon 08522c4
Updated GetOkExists to GetOk
WodansSon 70d8638
Revert Auto-fill functionality
WodansSon 807aa42
Merge branch 'master' into refactor-elasticpool-maxsize
WodansSon dd7d968
Fixing up after merge from master
WodansSon eb2f5d2
Fix lint errors
WodansSon faf2c8e
Removed commented code
WodansSon 39f4113
Exposed max_size_bytes, updated documentation, and added test case
WodansSon 0ab8771
Update azurerm/resource_arm_mssql_elasticpool.go
katbyte f4b805c
Fixes for PR comments
WodansSon 544b19a
Updated GetTierFromSKUName to use map
WodansSon 347f83d
Updated error msg for clarity
WodansSon 3421bff
Switch to using nested maps
WodansSon ab9c67a
Updated errors to be dynamically generated
WodansSon 66ac53b
Added descriptions of maps
WodansSon 98eb1d3
Unifying func signatures
WodansSon d397373
Removed unneeded validation check
WodansSon 5994856
Updated name and family validation
WodansSon be8580b
Fixed issue due to code editor auto-complete
WodansSon 2e3809b
Changed to Errorf
WodansSon 6933c4b
Update for edge case
WodansSon 0bd9ea7
Updated map to get better code reuse
WodansSon 321139f
Missed a space
WodansSon 56ecf29
Fix lint error
WodansSon 857797e
broke doSKUValidation into two seperate functions
katbyte 9d69371
fix linting
katbyte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,197 @@ | ||
package azure | ||
|
||
import ( | ||
"math" | ||
"strings" | ||
) | ||
|
||
var basicMaxSize = map[int]float64{ | ||
50: 4.8828125, | ||
100: 9.765625, | ||
200: 19.53125, | ||
300: 29.296875, | ||
400: 39.0625, | ||
800: 78.125, | ||
1200: 117.1875, | ||
1600: 156.25, | ||
} | ||
|
||
var standardMaxSize = map[int]float64{ | ||
50: 500, | ||
100: 750, | ||
200: 1024, | ||
300: 1280, | ||
400: 1536, | ||
800: 2048, | ||
1200: 2560, | ||
1600: 3072, | ||
2000: 3584, | ||
2500: 4096, | ||
3000: 4096, | ||
} | ||
|
||
var premiumMaxSize = map[int]float64{ | ||
125: 1024, | ||
250: 1024, | ||
500: 1024, | ||
1000: 1024, | ||
1500: 1536, | ||
2000: 2048, | ||
2500: 2560, | ||
3000: 3072, | ||
3500: 3584, | ||
4000: 4096, | ||
} | ||
|
||
var supportedDTUMaxGBValues = map[float64]bool{ | ||
50: true, | ||
100: true, | ||
150: true, | ||
200: true, | ||
250: true, | ||
300: true, | ||
400: true, | ||
500: true, | ||
750: true, | ||
800: true, | ||
1024: true, | ||
1200: true, | ||
1280: true, | ||
1536: true, | ||
1600: true, | ||
1792: true, | ||
2000: true, | ||
2048: true, | ||
2304: true, | ||
2500: true, | ||
2560: true, | ||
2816: true, | ||
3000: true, | ||
3072: true, | ||
3328: true, | ||
3584: true, | ||
3840: true, | ||
4096: true, | ||
} | ||
|
||
var generalPurposeGen4MaxGB = map[int]float64{ | ||
1: 512, | ||
2: 756, | ||
3: 1536, | ||
4: 1536, | ||
5: 1536, | ||
6: 2048, | ||
7: 2048, | ||
8: 2048, | ||
9: 2048, | ||
10: 2048, | ||
16: 3584, | ||
24: 4096, | ||
} | ||
|
||
var generalPurposeGen5MaxGB = map[int]float64{ | ||
2: 512, | ||
4: 756, | ||
6: 1536, | ||
8: 1536, | ||
10: 1536, | ||
12: 2048, | ||
14: 2048, | ||
16: 2048, | ||
18: 3072, | ||
20: 3072, | ||
24: 3072, | ||
32: 4096, | ||
40: 4096, | ||
80: 4096, | ||
} | ||
|
||
var businessCriticalGen4MaxGB = map[int]float64{ | ||
2: 1024, | ||
3: 1024, | ||
4: 1024, | ||
5: 1024, | ||
6: 1024, | ||
7: 1024, | ||
8: 1024, | ||
9: 1024, | ||
10: 1024, | ||
16: 1024, | ||
24: 1024, | ||
} | ||
|
||
var businessCriticalGen5MaxGB = map[int]float64{ | ||
4: 1024, | ||
6: 1536, | ||
8: 1536, | ||
10: 1536, | ||
12: 3072, | ||
14: 3072, | ||
16: 3072, | ||
18: 3072, | ||
20: 3072, | ||
24: 4096, | ||
32: 4096, | ||
40: 4096, | ||
80: 4096, | ||
} | ||
|
||
func BasicGetMaxSizeGB(DTUs int) float64 { | ||
return basicMaxSize[DTUs] | ||
} | ||
|
||
func StandardGetMaxSizeGB(DTUs int) float64 { | ||
return standardMaxSize[DTUs] | ||
} | ||
|
||
func PremiumGetMaxSizeGB(DTUs int) float64 { | ||
return premiumMaxSize[DTUs] | ||
} | ||
|
||
func StantardPremiumMaxGBValid(gb float64) bool { | ||
tombuildsstuff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return supportedDTUMaxGBValues[gb] | ||
} | ||
|
||
func GeneralPurposeGetMaxSizeGB(vCores int, family string) float64 { | ||
|
||
if family == "gen4" { | ||
return generalPurposeGen4MaxGB[vCores] | ||
} | ||
|
||
if family == "gen5" { | ||
tombuildsstuff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return generalPurposeGen5MaxGB[vCores] | ||
} | ||
|
||
// Invalid family | ||
return -1 | ||
tombuildsstuff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
func BusinessCriticalGetMaxSizeGB(vCores int, family string) float64 { | ||
|
||
if family == "gen4" { | ||
return businessCriticalGen4MaxGB[vCores] | ||
} | ||
|
||
if family == "gen5" { | ||
return businessCriticalGen5MaxGB[vCores] | ||
} | ||
|
||
// Invalid family | ||
return -1 | ||
tombuildsstuff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
func IsIntAsBytes(maxSizeGB float64) bool { | ||
// Get the maxSizeGB for the value in bytes | ||
max := 1073741824 * maxSizeGB | ||
|
||
// Check to see if the resulting max_size_bytes value is an integral value | ||
if max != math.Trunc(max) { | ||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
func NameFamilyValid(name string, family string) bool { | ||
return strings.Contains(strings.ToLower(name), strings.ToLower(family)) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a bit more specific of name:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.