-
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
[Bug Fix] Fixes PostgreSQL collation issues #396 and #760 #1255
Changes from 14 commits
5eb4b43
372ab79
20b7519
f34a388
5554dc5
e3fdb64
d0a8d76
546261c
a5ac0b6
ae15c97
7ab1dad
931abb0
7fbfbf1
bfdf30c
08e8f36
a1109b7
fd93d56
4b887bd
ab74fc2
7855a6b
b471948
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -372,6 +372,8 @@ func expandAzureRmPostgreSQLServerSku(d *schema.ResourceData) *postgresql.Sku { | |
skus := d.Get("sku").([]interface{}) | ||
sku := skus[0].(map[string]interface{}) | ||
|
||
fmt.Printf("[SKU]: %s", sku) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor can we remove this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DOH! Sorry, that was part of my debug code... I forgot to remove it thanks for spotting it! :) |
||
|
||
name := sku["name"].(string) | ||
capacity := sku["capacity"].(int) | ||
tier := sku["tier"].(string) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package utils | ||
|
||
import "strings" | ||
|
||
func Bool(input bool) *bool { | ||
return &input | ||
} | ||
|
@@ -15,3 +17,8 @@ func Int64(input int64) *int64 { | |
func String(input string) *string { | ||
return &input | ||
} | ||
|
||
func AzureRMNormalizeCollation(input string, find string, replace string, count int) *string { | ||
collation := strings.Replace(input, find, replace, count) | ||
return &collation | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (which means we don't need this method) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import ( | |
"fmt" | ||
"math" | ||
"regexp" | ||
"strings" | ||
"time" | ||
|
||
"github.com/Azure/go-autorest/autorest/date" | ||
|
@@ -99,3 +100,20 @@ func validateIntBetweenDivisibleBy(min, max, divisor int) schema.SchemaValidateF | |
return | ||
} | ||
} | ||
|
||
func validateCollation() schema.SchemaValidateFunc { | ||
return func(i interface{}, k string) (s []string, es []error) { | ||
v, ok := i.(string) | ||
if !ok { | ||
es = append(es, fmt.Errorf("expected type of %s to be string", k)) | ||
return | ||
} | ||
|
||
if strings.Contains(v, "-") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO we'd be better using a Regex match here, it appears |
||
es = append(es, fmt.Errorf("%s contains invalid characters, only underscores are supported, got %s", k, v)) | ||
return | ||
} | ||
|
||
return | ||
} | ||
} |
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.
providing we split this out to a separate line (to make it more readable) - we should be able to just use a string replacement directly? e.g.
note: in general we shouldn't be retrieving any properties from the schema in the Read function - since they won't exist during Import and can lead to crashes.