Skip to content

Commit

Permalink
resource/alicloud_fcv3_trigger: mark source_arn as Computed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenHanZhang committed Dec 27, 2024
1 parent 9490b93 commit 0be490b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
26 changes: 13 additions & 13 deletions alicloud/resource_alicloud_fcv3_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func resourceAliCloudFcv3Trigger() *schema.Resource {
"source_arn": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"status": {
Expand Down Expand Up @@ -129,20 +130,18 @@ func resourceAliCloudFcv3TriggerCreate(d *schema.ResourceData, meta interface{})
request = make(map[string]interface{})
request["triggerName"] = d.Get("trigger_name")

if v, ok := d.GetOk("description"); ok {
request["description"] = v
}
if v, ok := d.GetOk("invocation_role"); ok {
request["invocationRole"] = v
}
request["qualifier"] = d.Get("qualifier")
request["triggerConfig"] = d.Get("trigger_config")
request["triggerType"] = d.Get("trigger_type")
if v, ok := d.GetOk("description"); ok {
request["description"] = v
}
if v, ok := d.GetOk("source_arn"); ok {
request["sourceArn"] = v
}
if v, ok := d.GetOk("trigger_config"); ok {
request["triggerConfig"] = v
}
request["triggerType"] = d.Get("trigger_type")
request["qualifier"] = d.Get("qualifier")
body = request
runtime := util.RuntimeOptions{}
runtime.SetAutoretry(true)
Expand Down Expand Up @@ -252,6 +251,7 @@ func resourceAliCloudFcv3TriggerUpdate(d *schema.ResourceData, meta interface{})
var query map[string]*string
var body map[string]interface{}
update := false

parts := strings.Split(d.Id(), ":")
functionName := parts[0]
triggerName := parts[1]
Expand All @@ -264,11 +264,6 @@ func resourceAliCloudFcv3TriggerUpdate(d *schema.ResourceData, meta interface{})
query = make(map[string]*string)
body = make(map[string]interface{})

if d.HasChange("description") {
update = true
request["description"] = d.Get("description")
}

if d.HasChange("invocation_role") {
update = true
request["invocationRole"] = d.Get("invocation_role")
Expand All @@ -279,6 +274,11 @@ func resourceAliCloudFcv3TriggerUpdate(d *schema.ResourceData, meta interface{})
request["triggerConfig"] = d.Get("trigger_config")
}

if d.HasChange("description") {
update = true
request["description"] = d.Get("description")
}

body = request
if update {
runtime := util.RuntimeOptions{}
Expand Down
14 changes: 14 additions & 0 deletions alicloud/service_alicloud_fcv3_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ func (s *Fcv3ServiceV2) Fcv3FunctionStateRefreshFunc(id string, field string, fa
v, err := jsonpath.Get(field, object)
currentStatus := fmt.Sprint(v)

if strings.HasPrefix(field, "#") {
v, _ := jsonpath.Get(strings.TrimPrefix(field, "#"), object)
if v != nil {
currentStatus = "#CHECKSET"
}
}

for _, failState := range failStates {
if currentStatus == failState {
return object, currentStatus, WrapError(Error(FailedToReachTargetStatus, currentStatus))
Expand Down Expand Up @@ -492,6 +499,13 @@ func (s *Fcv3ServiceV2) Fcv3TriggerStateRefreshFunc(id string, field string, fai
v, err := jsonpath.Get(field, object)
currentStatus := fmt.Sprint(v)

if strings.HasPrefix(field, "#") {
v, _ := jsonpath.Get(strings.TrimPrefix(field, "#"), object)
if v != nil {
currentStatus = "#CHECKSET"
}
}

for _, failState := range failStates {
if currentStatus == failState {
return object, currentStatus, WrapError(Error(FailedToReachTargetStatus, currentStatus))
Expand Down

0 comments on commit 0be490b

Please sign in to comment.