Skip to content

Commit

Permalink
refactor(smn): remove unnecessary validate funcs and codes (#5237)
Browse files Browse the repository at this point in the history
  • Loading branch information
luoping-12345 authored Jul 23, 2024
1 parent 0ae0832 commit 4521c8b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ func resourceSmnLogtankDelete(_ context.Context, d *schema.ResourceData, meta in
if err = logtank.Delete(client, topicUrn, logtankID).ExtractErr(); err != nil {
return common.CheckDeletedDiag(d, err, "error deleting SMN logtank")
}
d.SetId("")

return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ func resourceSmnMessageTemplateUpdate(ctx context.Context, d *schema.ResourceDat

updateMessageTemplateOpt := golangsdk.RequestOpts{
KeepResponseBody: true,
OkCodes: []int{
200,
},
}
updateMessageTemplateOpt.JSONBody = utils.RemoveNil(buildUpdateMessageTemplateBodyParams(d))
_, err = updateMessageTemplateClient.Request("PUT", updateMessageTemplatePath, &updateMessageTemplateOpt)
Expand Down Expand Up @@ -192,9 +189,6 @@ func resourceSmnMessageTemplateRead(_ context.Context, d *schema.ResourceData, m

getMessageTemplateOpt := golangsdk.RequestOpts{
KeepResponseBody: true,
OkCodes: []int{
200,
},
}
getMessageTemplateResp, err := getMessageTemplateClient.Request("GET",
getMessageTemplatePath, &getMessageTemplateOpt)
Expand Down Expand Up @@ -242,9 +236,6 @@ func resourceSmnMessageTemplateDelete(_ context.Context, d *schema.ResourceData,

deleteMessageTemplateOpt := golangsdk.RequestOpts{
KeepResponseBody: true,
OkCodes: []int{
200,
},
}
_, err = deleteMessageTemplateClient.Request("DELETE", deleteMessageTemplatePath, &deleteMessageTemplateOpt)
if err != nil {
Expand Down
13 changes: 2 additions & 11 deletions huaweicloud/services/smn/resource_huaweicloud_smn_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import (
"context"
"encoding/json"
"log"
"regexp"
"strings"
"time"

"github.com/hashicorp/go-multierror"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

"github.com/chnsz/golangsdk"
"github.com/chnsz/golangsdk/openstack/common/tags"
Expand Down Expand Up @@ -52,17 +50,10 @@ func ResourceTopic() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.All(
validation.StringMatch(regexp.MustCompile(`^[A-Za-z0-9][\w-]*$`),
"The name must start with a letter or digit, and can only contain "+
"letters, digits, underscores (_), and hyphens (-)."),
validation.StringLenBetween(1, 255),
),
},
"display_name": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringLenBetween(0, 192),
Type: schema.TypeString,
Optional: true,
},
"enterprise_project_id": {
Type: schema.TypeString,
Expand Down

0 comments on commit 4521c8b

Please sign in to comment.