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

dependencies: bump go-azure-sdk to v0.20240321.1145953 #25332

Merged
merged 3 commits into from
Mar 21, 2024
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: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ require (
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.4.0
github.com/hashicorp/go-azure-helpers v0.66.2
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240315.1103122
github.com/hashicorp/go-azure-sdk/sdk v0.20240315.1103122
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240321.1145953
github.com/hashicorp/go-azure-sdk/sdk v0.20240321.1145953
github.com/hashicorp/go-hclog v1.5.0
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-uuid v1.0.3
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-azure-helpers v0.66.2 h1:+Pzuo7pdKl0hBXXr5ymmhs4Q40tHAo2nAvHq4WgSjx8=
github.com/hashicorp/go-azure-helpers v0.66.2/go.mod h1:kJxXrFtJKJdOEqvad8pllAe7dhP4DbN8J6sqFZe47+4=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240315.1103122 h1:cBuhqUvm59V6Na2GvC2WhuW2exShMy7mlYfJq5RdiKo=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240315.1103122/go.mod h1:Bqyftfx+hmU/CAUixSsO6JG8iAnYZfZCsTplJxWVkVE=
github.com/hashicorp/go-azure-sdk/sdk v0.20240315.1103122 h1:Ufy2m3h4a0kAiVHzffpuqLEYNFiE+rFbTfOPXd6m7YI=
github.com/hashicorp/go-azure-sdk/sdk v0.20240315.1103122/go.mod h1:POOjeoqNp+mvlLBuibJTziUAkBZ7FxXGeGestwemL/w=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240321.1145953 h1:eoU9iMmWgufB441trZJ45TsZ+0vJ79vGKdBuVVYUXwI=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240321.1145953/go.mod h1:zvsDltRIRr58vA0EpSmY+a6NcgGirQE/u02Ag+D8jmM=
github.com/hashicorp/go-azure-sdk/sdk v0.20240321.1145953 h1:WAcSZL5+H9Z/DjUZ0x0sluNoEno/mD4b+NWpY04vJrw=
github.com/hashicorp/go-azure-sdk/sdk v0.20240321.1145953/go.mod h1:POOjeoqNp+mvlLBuibJTziUAkBZ7FxXGeGestwemL/w=
github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)

type DataFactoryCredentialUserAssignedManagedIdentityResource struct{}

// user managed identities only have one type
const IDENTITY_TYPE = "ManagedIdentity"

var _ sdk.Resource = DataFactoryCredentialUserAssignedManagedIdentityResource{}
var _ sdk.ResourceWithUpdate = DataFactoryCredentialUserAssignedManagedIdentityResource{}

Expand Down Expand Up @@ -98,35 +94,41 @@ func (DataFactoryCredentialUserAssignedManagedIdentityResource) Read() sdk.Resou
d := metadata.ResourceData
client := metadata.Client.DataFactory.Credentials

credentialId, err := credentials.ParseCredentialID(d.Id())
id, err := credentials.ParseCredentialID(d.Id())
if err != nil {
return err
}

var state DataFactoryCredentialUserAssignedManagedIdentityResourceSchema
existing, err := client.CredentialOperationsGet(ctx, *id, credentials.DefaultCredentialOperationsGetOperationOptions())
if err != nil {
if response.WasNotFound(existing.HttpResponse) {
return metadata.MarkAsGone(id)
}

existing, err := client.CredentialOperationsGet(ctx, *credentialId, credentials.CredentialOperationsGetOperationOptions{})
if err != nil && !response.WasNotFound(existing.HttpResponse) {
return fmt.Errorf("checking for presence of existing %s: %+v", d.Id(), err)
return fmt.Errorf("retrieving %s: %+v", *id, err)
}

state.Name = credentialId.CredentialName
state := DataFactoryCredentialUserAssignedManagedIdentityResourceSchema{
Name: id.CredentialName,
DataFactoryId: factories.NewFactoryID(id.SubscriptionId, id.ResourceGroupName, id.FactoryName).ID(),
}

if existing.Model != nil {
if existing.Model.Properties.Description != nil {
state.Description = *existing.Model.Properties.Description
if model := existing.Model; model != nil {
props, ok := model.Properties.(credentials.ManagedIdentityCredential)
if !ok {
return fmt.Errorf("retrieving %s: expected `credentials.ManagedIdentityCredential` but got %+v", id, model.Properties)
}

if existing.Model.Properties.TypeProperties != nil && existing.Model.Properties.TypeProperties.ResourceId != nil {
state.IdentityId = *existing.Model.Properties.TypeProperties.ResourceId
if props.Description != nil {
state.Description = *props.Description
}

if existing.Model.Properties.Annotations != nil {
state.Annotations = flattenDataFactoryAnnotations(existing.Model.Properties.Annotations)
if props.TypeProperties.ResourceId != nil {
state.IdentityId = *props.TypeProperties.ResourceId
}
}

state.DataFactoryId = factories.NewFactoryID(credentialId.SubscriptionId, credentialId.ResourceGroupName, credentialId.FactoryName).ID()
state.Annotations = flattenDataFactoryAnnotations(props.Annotations)
}

return metadata.Encode(&state)
},
Expand All @@ -149,14 +151,8 @@ func (r DataFactoryCredentialUserAssignedManagedIdentityResource) Create() sdk.R
return err
}

id := credentials.CredentialId{
SubscriptionId: dataFactoryId.SubscriptionId,
ResourceGroupName: dataFactoryId.ResourceGroupName,
FactoryName: dataFactoryId.FactoryName,
CredentialName: data.Name,
}

existing, err := client.CredentialOperationsGet(ctx, id, credentials.CredentialOperationsGetOperationOptions{})
id := credentials.NewCredentialID(dataFactoryId.SubscriptionId, dataFactoryId.ResourceGroupName, dataFactoryId.FactoryName, data.Name)
existing, err := client.CredentialOperationsGet(ctx, id, credentials.DefaultCredentialOperationsGetOperationOptions())
if err != nil && !response.WasNotFound(existing.HttpResponse) {
return fmt.Errorf("checking for presence of existing %s: %+v", id, err)
}
Expand All @@ -165,29 +161,26 @@ func (r DataFactoryCredentialUserAssignedManagedIdentityResource) Create() sdk.R
return tf.ImportAsExistsError("azurerm_data_factory_dataset_http", id.ID())
}

credential := credentials.ManagedIdentityCredentialResource{
Type: utils.String(IDENTITY_TYPE),
Properties: credentials.ManagedIdentityCredential{
TypeProperties: &credentials.ManagedIdentityTypeProperties{
ResourceId: &data.IdentityId,
},
props := credentials.ManagedIdentityCredential{
TypeProperties: credentials.ManagedIdentityTypeProperties{
ResourceId: &data.IdentityId,
},
}

if len(data.Annotations) > 0 {
annotations := make([]interface{}, len(data.Annotations))
for i, v := range data.Annotations {
annotations[i] = v
}
credential.Properties.Annotations = &annotations
props.Annotations = &annotations
}

if data.Description != "" {
credential.Properties.Description = &data.Description
props.Description = &data.Description
}

_, err = client.CredentialOperationsCreateOrUpdate(ctx, id, credential, credentials.CredentialOperationsCreateOrUpdateOperationOptions{})
if err != nil {
payload := credentials.CredentialResource{
Properties: props,
}
if _, err = client.CredentialOperationsCreateOrUpdate(ctx, id, payload, credentials.DefaultCredentialOperationsCreateOrUpdateOperationOptions()); err != nil {
return fmt.Errorf("creating %s: %+v", id, err)
}

Expand All @@ -213,19 +206,22 @@ func (r DataFactoryCredentialUserAssignedManagedIdentityResource) Update() sdk.R
return fmt.Errorf("decoding: %+v", err)
}

existing, err := client.CredentialOperationsGet(ctx, *id, credentials.CredentialOperationsGetOperationOptions{})
existing, err := client.CredentialOperationsGet(ctx, *id, credentials.DefaultCredentialOperationsGetOperationOptions())
if err != nil {
return fmt.Errorf("checking for presence of existing %s: %+v", id.ID(), err)
}

if existing.Model == nil {
return fmt.Errorf("model was nil for %s", id)
return fmt.Errorf("retrieving %s: `model` was nil", *id)
}

credential := *existing.Model
props, ok := existing.Model.Properties.(credentials.ManagedIdentityCredential)
if !ok {
return fmt.Errorf("retrieving %s: expected `credentials.ManagedIdentityCredential` but got %+v", id, existing.Model.Properties)
}

if metadata.ResourceData.HasChange("description") {
credential.Properties.Description = &data.Description
props.Description = &data.Description
}

if metadata.ResourceData.HasChange("annotations") {
Expand All @@ -234,14 +230,16 @@ func (r DataFactoryCredentialUserAssignedManagedIdentityResource) Update() sdk.R
for i, v := range data.Annotations {
annotations[i] = v
}
credential.Properties.Annotations = &annotations
props.Annotations = &annotations
} else {
credential.Properties.Annotations = nil
props.Annotations = nil
}
}

_, err = client.CredentialOperationsCreateOrUpdate(ctx, *id, credential, credentials.CredentialOperationsCreateOrUpdateOperationOptions{})
if err != nil {
payload := credentials.CredentialResource{
Properties: props,
}
if _, err = client.CredentialOperationsCreateOrUpdate(ctx, *id, payload, credentials.DefaultCredentialOperationsCreateOrUpdateOperationOptions()); err != nil {
return fmt.Errorf("updating %s: %+v", id, err)
}

Expand All @@ -256,17 +254,15 @@ func (DataFactoryCredentialUserAssignedManagedIdentityResource) Delete() sdk.Res
return sdk.ResourceFunc{
Timeout: 5 * time.Minute,
Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {
d := metadata.ResourceData
client := metadata.Client.DataFactory.Credentials

credentialId, err := credentials.ParseCredentialID(d.Id())
id, err := credentials.ParseCredentialID(metadata.ResourceData.Id())
if err != nil {
return err
}

_, err = client.CredentialOperationsDelete(ctx, *credentialId)
if err != nil {
return err
if _, err = client.CredentialOperationsDelete(ctx, *id); err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
}

return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (t CredentialUserAssignedManagedIdentityResource) Exists(ctx context.Contex
return nil, fmt.Errorf("retrieving %s: %+v", *id, err)
}

return utils.Bool(resp.Model.Id != nil), nil
return utils.Bool(resp.Model != nil), nil
}

func templateBase(data acceptance.TestData) string {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading