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

Set the async type default to OpAsync #12730

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mmv1/api/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func NewOperation() *Operation {
return op
}

// It is only used in openapi-generate
func NewAsync() *Async {
oa := &Async{
Actions: []string{"create", "delete", "update"},
Expand Down Expand Up @@ -150,6 +151,9 @@ func (a *Async) UnmarshalYAML(unmarshal func(any) error) error {
return err
}

if a.Type == "" {
a.Type = "OpAsync"
}
if a.Type == "PollAsync" && a.TargetOccurrences == 0 {
a.TargetOccurrences = 1
}
Expand Down
10 changes: 5 additions & 5 deletions mmv1/templates/terraform/resource.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ func resource{{ $.ResourceName -}}Create(d *schema.ResourceData, meta interface{
d.SetId(id)

{{if and $.GetAsync ($.GetAsync.Allow "Create") -}}
{{if ($.GetAsync.IsA "OpAsync") -}}
{{if and $.GetAsync.Result.ResourceInsideResponse $.GetIdentity -}}
{{ if ($.GetAsync.IsA "OpAsync") -}}
{{ if and $.GetAsync.Result.ResourceInsideResponse $.GetIdentity -}}
// Use the resource in the operation response to populate
// identity fields and d.Id() before read
var opRes map[string]interface{}
Expand All @@ -330,7 +330,7 @@ func resource{{ $.ResourceName -}}Create(d *schema.ResourceData, meta interface{
// The resource didn't actually create
d.SetId("")

{{ end -}}
{{ end -}}
return fmt.Errorf("Error waiting to create {{ $.Name -}}: %s", err)
}

Expand Down Expand Up @@ -390,8 +390,8 @@ func resource{{ $.ResourceName -}}Create(d *schema.ResourceData, meta interface{
}

{{ end -}}
{{ end -}}
{{ end -}}
{{ end -}}{{/*if ($.GetAsync.IsA "OpAsync")*/}}
{{ end -}}{{/*if and $.GetAsync ($.GetAsync.Allow "Create")*/}}
{{if $.CustomCode.PostCreate -}}
{{- $.CustomTemplate $.CustomCode.PostCreate false -}}
{{- end}}
Expand Down
Loading