Skip to content
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

Merged
merged 16 commits into from
Oct 31, 2024
Merged

[Feat] DDM: Add resource ddm v1 #2692

merged 16 commits into from
Oct 31, 2024

Conversation

muneeb-jan
Copy link
Member

@muneeb-jan muneeb-jan commented Oct 24, 2024

Summary of the Pull Request

Adds DDM instance resource to OTC provider

PR Checklist

Acceptance Steps Performed

=== RUN   TestAccDdmInstancesV1_basic
--- PASS: TestAccDdmInstancesV1_basic (950.74s)
PASS

Process finished with exit code 0

@muneeb-jan muneeb-jan self-assigned this Oct 24, 2024
@muneeb-jan muneeb-jan marked this pull request as ready for review October 25, 2024 22:33
@muneeb-jan muneeb-jan force-pushed the add-ddm-instance-schema branch from 5a988ab to 95d5481 Compare October 25, 2024 22:38
"log"
"unicode"

// "reflect"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

Comment on lines 51 to 56
"region": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
Copy link
Member

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

Comment on lines 375 to 430
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
}
Copy link
Member

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

Comment on lines 282 to 285
if err := mErr.ErrorOrNil(); err != nil {
return diag.FromErr(err)
}
return nil
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DDM instance?


The following arguments are supported:

* `region` - (Optional, String, ForceNew) Specifies the region of the DDM instance.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this to attributes

Comment on lines 161 to 168
Following attributes are not properly imported.
* `availability_zones`
* `flavor_id`
* `engine_id`
* `time_zone`
* `password`
* `param_group_id`
* `purge_rds_on_delete`
Copy link
Member

@anton-sidelnikov anton-sidelnikov Oct 29, 2024

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,
    ]
  }
}

@anton-sidelnikov anton-sidelnikov added the gate Merge PR label Oct 31, 2024
Copy link

otc-zuul bot commented Oct 31, 2024

Build succeeded.
https://zuul.otc-service.com/t/eco/buildset/4a0bafa622c843e3aede0d8373373bf1

✔️ build-otc-releasenotes SUCCESS in 4m 08s
✔️ noop SUCCESS in 0s
✔️ otc-golangci-lint SUCCESS in 3m 20s
✔️ golang-make-test SUCCESS in 3m 56s
✔️ golang-make-vet SUCCESS in 2m 44s
✔️ tflint SUCCESS in 2m 39s
✔️ goreleaser-build SUCCESS in 7m 54s

@otc-zuul otc-zuul bot merged commit 6421821 into devel Oct 31, 2024
3 checks passed
@otc-zuul otc-zuul bot deleted the add-ddm-instance-schema branch October 31, 2024 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants