Skip to content

Commit

Permalink
Conformity user issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
suraj committed Jun 24, 2022
1 parent a4b9a93 commit 22dd59a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
9 changes: 6 additions & 3 deletions conformity/resource_conformity_report_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,12 @@ func resourceConformityReportConfig() *schema.Resource {
},
},
"risk_levels": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"LOW", "MEDIUM", "HIGH", "VERY_HIGH", "EXTREME"}, false),
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"LOW", "MEDIUM", "HIGH", "VERY_HIGH", "EXTREME"}, false),
},
},
"rule_ids": {
Type: schema.TypeSet,
Expand Down
12 changes: 10 additions & 2 deletions conformity/resource_conformity_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"github.com/trendmicro/terraform-provider-conformity/pkg/cloudconformity"
"regexp"

"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
Expand Down Expand Up @@ -88,8 +88,16 @@ func resourceConformityUserCreate(ctx context.Context, d *schema.ResourceData, m
//invite a user to the non-cloudone platform
userId, err := client.InviteLegacyUser(payload)
if err != nil {
if strings.Contains(err.Error(), "Unable to call this endpoint, use Cloud One UI or API to invite users"){
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Unable to Invite Conformity Cloud One user",
Detail: "This Terraform service is not applicable to users who are part of the Cloud One Platform.\nPlease refer to Cloud One User Management Documentation - Add and manage users to invite new users. https://cloudone.trendmicro.com/docs/conformity/api-reference/tag/Users#paths/~1users/get",
})
return diags
}
return diag.FromErr(err)

return diag.FromErr(err)
}
d.SetId(userId)
resourceConformityUserRead(ctx, d, m)
Expand Down
6 changes: 0 additions & 6 deletions pkg/cloudconformity/invite_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ func (c *Client) InviteLegacyUser(userPayload UserDetails) (string, error) {

_, err = c.ClientRequest(Post{}, "/users/", strings.NewReader(string(rb)), "", &userDetails)
if err != nil {
if strings.Contains(string(err), "Unable to call this endpoint, use Cloud One UI or API to invite users"){
log_debug(`This Terraform service is not applicable to users who are part of the Cloud One Platform.
Please refer to Cloud One User Management Documentation - Add and manage users to invite new users.
https://cloudone.trendmicro.com/docs/conformity/api-reference/tag/Users#paths/~1users/get`)

}
return "", err
}

Expand Down

0 comments on commit 22dd59a

Please sign in to comment.