-
Notifications
You must be signed in to change notification settings - Fork 77
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
[Feat] DDM: Add resource ddm v1 #2692
Conversation
5a988ab
to
95d5481
Compare
"log" | ||
"unicode" | ||
|
||
// "reflect" |
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.
remove comments
"region": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
ForceNew: true, | ||
}, |
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.
please move it to computed only, we don't use region in createOpts
func isValidateName(v interface{}, k string) (ws []string, errors []error) { | ||
value := v.(string) | ||
// Check length between 4 and 64 | ||
if len(value) > 64 || len(value) < 4 { | ||
errors = append(errors, fmt.Errorf("%q must contain more than 4 and less than 64 characters", k)) | ||
} | ||
|
||
// Check if contains invalid character | ||
pattern := `^[\-A-Za-z0-9]+$` | ||
if !regexp.MustCompile(pattern).MatchString(value) { | ||
errors = append(errors, fmt.Errorf("only alphanumeric characters, and hyphens allowed in %q", k)) | ||
} | ||
|
||
// Check if doesn't start with a letter | ||
if !unicode.IsLetter(rune(value[0])) { | ||
errors = append(errors, fmt.Errorf("%q must start with a letter", k)) | ||
} | ||
|
||
return | ||
} | ||
|
||
func isValidUTCOffset(v interface{}, k string) (ws []string, errors []error) { | ||
value := v.(string) | ||
// Regular expression pattern for matching UTC offsets from +12:00 to -12:00 | ||
pattern := `^(UTC([+-](0[1-9]|1[0-2]):00)|UTC)$` | ||
|
||
// Compile the regular expression | ||
re := regexp.MustCompile(pattern) | ||
if !re.MatchString(value) { | ||
errors = append(errors, fmt.Errorf("only valid utc offsets allowed in %q", k)) | ||
} | ||
|
||
return | ||
} | ||
|
||
// Checks if the admin username is valid. | ||
func isValidUsername(v interface{}, k string) (ws []string, errors []error) { | ||
value := v.(string) | ||
// Check length between 1 and 32 | ||
if len(value) > 32 || len(value) < 1 { | ||
errors = append(errors, fmt.Errorf("%q must contain more than 1 and less than 32 characters", k)) | ||
} | ||
|
||
// Check if contains invalid character | ||
pattern := `^[\_A-Za-z0-9]+$` | ||
if !regexp.MustCompile(pattern).MatchString(value) { | ||
errors = append(errors, fmt.Errorf("only alphanumeric characters, and underscores allowed in %q", k)) | ||
} | ||
|
||
// Check if doesn't start with a letter | ||
if !unicode.IsLetter(rune(value[0])) { | ||
errors = append(errors, fmt.Errorf("%q must start with a letter", k)) | ||
} | ||
|
||
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.
for all this validations we have opentelekomcloud/common/validators.go
if err := mErr.ErrorOrNil(); err != nil { | ||
return diag.FromErr(err) | ||
} | ||
return nil |
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.
you can also chage this to return diag.FromErr(mErr.ErrorOrNil())
deleteRdsData := d.Get("purge_rds_on_delete").(bool) | ||
_, err = ddmv1instances.Delete(client, d.Id(), deleteRdsData) | ||
if err != nil { | ||
return fmterr.Errorf("error deleting OpenTelekomCloud RDSv3 instance: %s", err) |
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.
DDM instance?
docs/resources/ddm_instance_v1.md
Outdated
|
||
The following arguments are supported: | ||
|
||
* `region` - (Optional, String, ForceNew) Specifies the region of the DDM instance. |
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.
move this to attributes
docs/resources/ddm_instance_v1.md
Outdated
Following attributes are not properly imported. | ||
* `availability_zones` | ||
* `flavor_id` | ||
* `engine_id` | ||
* `time_zone` | ||
* `password` | ||
* `param_group_id` | ||
* `purge_rds_on_delete` |
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.
Change for:
Notes
But due to some attributes missing from the API response, it's required to ignore changes as below:
resource "opentelekomcloud_ddm_instance_v1" "instance_1" {
# ...
lifecycle {
ignore_changes = [
availability_zones,
flavor_id,
engine_id,
time_zone,
password,
]
}
}
opentelekomcloud/services/ddm/resource_opentelekomcloud_ddm_instance_v1.go
Show resolved
Hide resolved
opentelekomcloud/services/ddm/resource_opentelekomcloud_ddm_instance_v1.go
Show resolved
Hide resolved
Build succeeded. ✔️ build-otc-releasenotes SUCCESS in 4m 08s |
Summary of the Pull Request
Adds DDM instance resource to OTC provider
PR Checklist
Acceptance Steps Performed