-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds support for region & customer_endpoint_dns_name in private…
…link (#1982)
- Loading branch information
1 parent
ab06421
commit f899b80
Showing
16 changed files
with
325 additions
and
141 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
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,25 @@ | ||
package validate | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/hashicorp/go-cty/cty" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func StringIsUppercase() schema.SchemaValidateDiagFunc { | ||
return func(v any, p cty.Path) diag.Diagnostics { | ||
value := v.(string) | ||
var diags diag.Diagnostics | ||
if value != strings.ToUpper(value) { | ||
diagError := diag.Diagnostic{ | ||
Severity: diag.Error, | ||
Summary: fmt.Sprintf("The provided string '%q' must be uppercase.", value), | ||
} | ||
diags = append(diags, diagError) | ||
} | ||
return diags | ||
} | ||
} |
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,40 @@ | ||
package validate_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate" | ||
) | ||
|
||
func TestStringIsUppercase(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
expectedError bool | ||
}{ | ||
{ | ||
name: "AWS", | ||
expectedError: false, | ||
}, | ||
{ | ||
name: "aws", | ||
expectedError: true, | ||
}, | ||
{ | ||
name: "", | ||
expectedError: false, | ||
}, | ||
{ | ||
name: "AwS", | ||
expectedError: true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
diag := validate.StringIsUppercase()(tc.name, nil) | ||
if diag.HasError() != tc.expectedError { | ||
t.Errorf("Case %s: Received unexpected error: %v", tc.name, diag[0].Summary) | ||
} | ||
}) | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.