Revert "validate if user assigned identity exists"

This reverts commit 9bd19df040.
This commit is contained in:
Feiyu Shi 2020-05-26 17:17:48 -07:00
parent 13a49f4655
commit fdb0b2ab03
2 changed files with 0 additions and 22 deletions

View File

@ -14,7 +14,6 @@ import (
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute"
newCompute "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute"
"github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2018-02-14/keyvault"
"github.com/Azure/azure-sdk-for-go/services/msi/mgmt/2018-11-30/msi"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-01-01/network"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-02-01/resources"
armStorage "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage"
@ -48,7 +47,6 @@ type AzureClient struct {
compute.SnapshotsClient
newCompute.GalleryImageVersionsClient
newCompute.GalleryImagesClient
msi.UserAssignedIdentitiesClient
InspectorMaxLength int
Template *CaptureTemplate
@ -242,13 +240,6 @@ func NewAzureClient(subscriptionID, resourceGroupName, storageAccountName string
azureClient.GalleryImagesClient.UserAgent = fmt.Sprintf("%s %s", useragent.String(), azureClient.GalleryImagesClient.UserAgent)
azureClient.GalleryImagesClient.Client.PollingDuration = PollingDuration
azureClient.UserAssignedIdentitiesClient = msi.NewUserAssignedIdentitiesClientWithBaseURI(cloud.ResourceManagerEndpoint, subscriptionID)
azureClient.UserAssignedIdentitiesClient.Authorizer = autorest.NewBearerAuthorizer(servicePrincipalToken)
azureClient.UserAssignedIdentitiesClient.RequestInspector = withInspection(maxlen)
azureClient.UserAssignedIdentitiesClient.ResponseInspector = byConcatDecorators(byInspecting(maxlen), errorCapture(azureClient))
azureClient.UserAssignedIdentitiesClient.UserAgent = fmt.Sprintf("%s %s", useragent.String(), azureClient.UserAssignedIdentitiesClient.UserAgent)
azureClient.UserAssignedIdentitiesClient.Client.PollingDuration = PollingDuration
keyVaultURL, err := url.Parse(cloud.KeyVaultEndpoint)
if err != nil {
return nil, err

View File

@ -16,7 +16,6 @@ import (
"github.com/dgrijalva/jwt-go"
"github.com/hashicorp/hcl/v2/hcldec"
packerAzureCommon "github.com/hashicorp/packer/builder/azure/common"
"github.com/hashicorp/packer/builder/azure/common/client"
"github.com/hashicorp/packer/builder/azure/common/constants"
"github.com/hashicorp/packer/builder/azure/common/lin"
packerCommon "github.com/hashicorp/packer/common"
@ -111,18 +110,6 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
return nil, fmt.Errorf("could not determine the ObjectID for the user, which is required for Windows builds")
}
if len(b.config.UserAssignedManagedIdentities) != 0 {
for _, rid := range b.config.UserAssignedManagedIdentities {
r, err := client.ParseResourceID(rid)
if err != nil {
return nil, err
}
if _, err = azureClient.UserAssignedIdentitiesClient.Get(ctx, r.ResourceGroup, r.ResourceName.String()); err != nil {
return nil, fmt.Errorf("Cannot locate user assigned managed identity %s", rid)
}
}
}
if b.config.isManagedImage() {
_, err := azureClient.GroupsClient.Get(ctx, b.config.ManagedImageResourceGroupName)
if err != nil {