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

Fix: Revisions handling #18305

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -295,18 +295,18 @@ func resourceApiManagementApiCreateUpdate(d *pluginsdk.ResourceData, meta interf
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

id := parse.NewApiID(subscriptionId, d.Get("resource_group_name").(string), d.Get("api_management_name").(string), d.Get("name").(string))

revision := d.Get("revision").(string)
path := d.Get("path").(string)
apiId := fmt.Sprintf("%s;rev=%s", id.Name, revision)
apiId := fmt.Sprintf("%s;rev=%s", d.Get("name").(string), revision)
Comment on lines -302 to +300
Copy link
Collaborator

Choose a reason for hiding this comment

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

how come id.Name doesn't work here?

Copy link
Author

Choose a reason for hiding this comment

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

Not specifying an exact revision as part of the tracked ID will lead to an unstable state, due to the way the ARM API works.
As such, I define apiID locally and moved the call to parse.NewApiID afterwards to use this apiID

Copy link
Contributor

Choose a reason for hiding this comment

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

since this is a Required field, users will always have to specify a Revision, so can you explain the problem?

version := d.Get("version").(string)
versionSetId := d.Get("version_set_id").(string)
displayName := d.Get("display_name").(string)
protocolsRaw := d.Get("protocols").(*pluginsdk.Set).List()
protocols := expandApiManagementApiProtocols(protocolsRaw)
sourceApiId := d.Get("source_api_id").(string)

id := parse.NewApiID(subscriptionId, d.Get("resource_group_name").(string), d.Get("api_management_name").(string), apiId)

if version != "" && versionSetId == "" {
return fmt.Errorf("setting `version` without the required `version_set_id`")
}
Expand Down Expand Up @@ -361,6 +361,7 @@ func resourceApiManagementApiCreateUpdate(d *pluginsdk.ResourceData, meta interf
Format: apimanagement.ContentFormat(contentFormat),
Value: utils.String(contentValue),
Path: utils.String(path),
APIRevision: utils.String(revision),
APIVersion: utils.String(version),
},
}
Expand Down Expand Up @@ -422,6 +423,7 @@ func resourceApiManagementApiCreateUpdate(d *pluginsdk.ResourceData, meta interf
Protocols: protocols,
ServiceURL: utils.String(serviceUrl),
SubscriptionKeyParameterNames: subscriptionKeyParameterNames,
APIRevision: utils.String(revision),
APIVersion: utils.String(version),
SubscriptionRequired: &subscriptionRequired,
AuthenticationSettings: authenticationSettings,
Expand Down