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

New acc test and update Identity agency support duration param and doc #946

Merged
merged 4 commits into from
Feb 27, 2021
Merged

New acc test and update Identity agency support duration param and doc #946

merged 4 commits into from
Feb 27, 2021

Conversation

Lance52259
Copy link
Collaborator

@Lance52259 Lance52259 commented Feb 26, 2021

What this PR does / why we need it:

  • Identity agency supports duration setting and updating, valid value is 'ONEDAY', 'FOREVER' and null (null will set duration with 'FOREVER'). In provider, make "FOREVER" become default value (Only use 'ONEDAY' and 'FOREVER' ), because of 'null' equal with 'FOREVER' and null cannot be set into terraform state.
    • Only agency createOpts and updateOpts need contains duration parameter, the resource can set and update in create and update function.
  • Identity agency supports the assignment of delegates to designated users and HUAWEI CLOUD service.
  • Identity agency missing acc test.
  • Identity agency document description is Incompleted.
    • missing cloud service delegated example .
    • missing import example.
    • missing whiteline at the end of the document.

Which issue this PR fixes:
(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged)
fixes #xxx

Special notes for your reviewer:

Release note:

1. Duration can updating with three value, contains 'ONEDAY' and 'FOREVER'.
2. Split the delegation method into domain_name and service_name. 
  a. Add regex match to check which delegate_service_name or delegate_domain_name input.
  b. Add delegate_service_name description and update delegate_domain_name description.
3. New Identity agency acc test.
4. update document such as txt description and example.

PR Checklist

  • Tests added/passed.
  • Documentation updated.
  • Schema updated.

Acceptance Steps Performed

Delegate another HUAWEI CLOUD account to perform operations on your resources.

make testacc TEST='./huaweicloud' TESTARGS='-run=TestAccIdentityAgency_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./huaweicloud -v -run=TestAccIdentityAgency_basic -timeout 360m -parallel 4
=== RUN   TestAccIdentityAgency_basic
=== PAUSE TestAccIdentityAgency_basic
=== CONT  TestAccIdentityAgency_basic
--- PASS: TestAccIdentityAgency_basic (98.09s)
PASS
ok      github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud       98.133s

Delegate a cloud service to access your resources in other cloud services.

make testacc TEST='./huaweicloud' TESTARGS='-run=TestAccIdentityAgency_service'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./huaweicloud -v -run=TestAccIdentityAgency_service -timeout 360m -parallel 4
=== RUN   TestAccIdentityAgency_service
=== PAUSE TestAccIdentityAgency_service
=== CONT  TestAccIdentityAgency_service
--- PASS: TestAccIdentityAgency_service (102.56s)
PASS
ok      github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud       102.610s

@Lance52259 Lance52259 changed the title Identity agency patch New acc test and update Identity agency support duration param and doc Feb 26, 2021
Config: testAccIdentityAgency_basic(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckIdentityAgencyExists(resourceName, &agency),
resource.TestCheckResourceAttr(resourceName, "name", rName),
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggest to add more attr check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

now we have five attribute check in acc test.

@@ -27,6 +28,25 @@ resource "huaweicloud_identity_agency" "agency" {
}
```

### Delegate the operation authority of the resources in the account to Huaweicloud service
Copy link
Collaborator

Choose a reason for hiding this comment

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

Delegate a cloud service to access your resources in other cloud services.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks for suggestion, it's updated at document.

@@ -9,6 +9,7 @@ This is an alternative to `huaweicloud_iam_agency_v3`

## Example Usage

### Delegate the operation authority of the resources in the account to other Huaweicloud accounts
Copy link
Collaborator

Choose a reason for hiding this comment

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

Delegate another HUAWEI CLOUD account to perform operations on your resources.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks for suggestion, it's updated at document.

@@ -38,6 +58,11 @@ The following arguments are supported:
agency. The value is a string of 0 to 255 characters.

* `delegated_domain_name` - (Required, String) The name of delegated domain.
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add a new parameter named delegated_service_name ?

Copy link
Collaborator Author

@Lance52259 Lance52259 Feb 27, 2021

Choose a reason for hiding this comment

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

new parameter delegated_service_name and update param create, update and read operation in identity agency. please help reviewing code.

@@ -437,10 +459,15 @@ func resourceIAMAgencyV3Update(d *schema.ResourceData, meta interface{}) error {

agencyID := d.Id()

if d.HasChanges("delegated_domain_name", "description") {
if d.HasChanges("delegated_domain_name", "description", "duration") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should put "delegated_service_name" in the list

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks, 'delegated_service_name' is putting into the list

d.Set("description", a.Description)
d.Set("duration", a.Duration)
d.Set("expire_time", a.ExpireTime)
d.Set("create_time", a.CreateTime)

if ok, err := regexp.MatchString("^op_svc_[A-Za-z]+$", a.DelegatedDomainName); err != nil {
fmt.Printf("regexp error, err= %s", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

did you mean log.Printf ?

Copy link
Collaborator Author

@Lance52259 Lance52259 Feb 27, 2021

Choose a reason for hiding this comment

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

It's updated using fmt.Errorf return.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks, there need log.Printf actually.

@ShiChangkuo ShiChangkuo merged commit 321f297 into huaweicloud:master Feb 27, 2021
@Lance52259 Lance52259 deleted the IdentityAgencyPatch branch March 1, 2021 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants