diff --git a/go.mod b/go.mod index a332ee53acb9..be776d4d8f5a 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 5a217487033a..75dfc710b924 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/internal/services/datafactory/data_factory_credential_user_assigned_managed_identity_resource.go b/internal/services/datafactory/data_factory_credential_user_assigned_managed_identity_resource.go index c5fad3fb2be7..cfb8e9dba855 100644 --- a/internal/services/datafactory/data_factory_credential_user_assigned_managed_identity_resource.go +++ b/internal/services/datafactory/data_factory_credential_user_assigned_managed_identity_resource.go @@ -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{} @@ -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) }, @@ -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) } @@ -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) } @@ -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") { @@ -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) } @@ -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 diff --git a/internal/services/datafactory/data_factory_credential_user_assigned_managed_identity_resource_test.go b/internal/services/datafactory/data_factory_credential_user_assigned_managed_identity_resource_test.go index c7f8e6438c29..c89abbbfdea4 100644 --- a/internal/services/datafactory/data_factory_credential_user_assigned_managed_identity_resource_test.go +++ b/internal/services/datafactory/data_factory_credential_user_assigned_managed_identity_resource_test.go @@ -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 { diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/README.md index 91660d2118df..ecfef7836ec9 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/README.md +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/README.md @@ -26,7 +26,7 @@ client.Client.Authorizer = authorizer ctx := context.TODO() id := credentials.NewCredentialID("12345678-1234-9876-4563-123456789012", "example-resource-group", "factoryValue", "credentialValue") -payload := credentials.ManagedIdentityCredentialResource{ +payload := credentials.CredentialResource{ // ... } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/constants.go new file mode 100644 index 000000000000..f05d4ea3a93f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/constants.go @@ -0,0 +1,48 @@ +package credentials + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Type string + +const ( + TypeLinkedServiceReference Type = "LinkedServiceReference" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeLinkedServiceReference), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "linkedservicereference": TypeLinkedServiceReference, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/method_credentialoperationscreateorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/method_credentialoperationscreateorupdate.go index a53c9d2b6a04..aef9657a1db3 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/method_credentialoperationscreateorupdate.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/method_credentialoperationscreateorupdate.go @@ -15,7 +15,7 @@ import ( type CredentialOperationsCreateOrUpdateOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *ManagedIdentityCredentialResource + Model *CredentialResource } type CredentialOperationsCreateOrUpdateOperationOptions struct { @@ -46,7 +46,7 @@ func (o CredentialOperationsCreateOrUpdateOperationOptions) ToQuery() *client.Qu } // CredentialOperationsCreateOrUpdate ... -func (c CredentialsClient) CredentialOperationsCreateOrUpdate(ctx context.Context, id CredentialId, input ManagedIdentityCredentialResource, options CredentialOperationsCreateOrUpdateOperationOptions) (result CredentialOperationsCreateOrUpdateOperationResponse, err error) { +func (c CredentialsClient) CredentialOperationsCreateOrUpdate(ctx context.Context, id CredentialId, input CredentialResource, options CredentialOperationsCreateOrUpdateOperationOptions) (result CredentialOperationsCreateOrUpdateOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ @@ -76,7 +76,7 @@ func (c CredentialsClient) CredentialOperationsCreateOrUpdate(ctx context.Contex return } - var model ManagedIdentityCredentialResource + var model CredentialResource result.Model = &model if err = resp.Unmarshal(result.Model); err != nil { diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/method_credentialoperationsget.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/method_credentialoperationsget.go index dd8cf2c939ce..23d39f0b4647 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/method_credentialoperationsget.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/method_credentialoperationsget.go @@ -15,7 +15,7 @@ import ( type CredentialOperationsGetOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *ManagedIdentityCredentialResource + Model *CredentialResource } type CredentialOperationsGetOperationOptions struct { @@ -72,7 +72,7 @@ func (c CredentialsClient) CredentialOperationsGet(ctx context.Context, id Crede return } - var model ManagedIdentityCredentialResource + var model CredentialResource result.Model = &model if err = resp.Unmarshal(result.Model); err != nil { diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/method_credentialoperationslistbyfactory.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/method_credentialoperationslistbyfactory.go index 82c5b0cbb30f..791346862b14 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/method_credentialoperationslistbyfactory.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/method_credentialoperationslistbyfactory.go @@ -15,12 +15,12 @@ import ( type CredentialOperationsListByFactoryOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *[]ManagedIdentityCredentialResource + Model *[]CredentialResource } type CredentialOperationsListByFactoryCompleteResult struct { LatestHttpResponse *http.Response - Items []ManagedIdentityCredentialResource + Items []CredentialResource } // CredentialOperationsListByFactory ... @@ -50,7 +50,7 @@ func (c CredentialsClient) CredentialOperationsListByFactory(ctx context.Context } var values struct { - Values *[]ManagedIdentityCredentialResource `json:"value"` + Values *[]CredentialResource `json:"value"` } if err = resp.Unmarshal(&values); err != nil { return @@ -63,12 +63,12 @@ func (c CredentialsClient) CredentialOperationsListByFactory(ctx context.Context // CredentialOperationsListByFactoryComplete retrieves all the results into a single object func (c CredentialsClient) CredentialOperationsListByFactoryComplete(ctx context.Context, id FactoryId) (CredentialOperationsListByFactoryCompleteResult, error) { - return c.CredentialOperationsListByFactoryCompleteMatchingPredicate(ctx, id, ManagedIdentityCredentialResourceOperationPredicate{}) + return c.CredentialOperationsListByFactoryCompleteMatchingPredicate(ctx, id, CredentialResourceOperationPredicate{}) } // CredentialOperationsListByFactoryCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c CredentialsClient) CredentialOperationsListByFactoryCompleteMatchingPredicate(ctx context.Context, id FactoryId, predicate ManagedIdentityCredentialResourceOperationPredicate) (result CredentialOperationsListByFactoryCompleteResult, err error) { - items := make([]ManagedIdentityCredentialResource, 0) +func (c CredentialsClient) CredentialOperationsListByFactoryCompleteMatchingPredicate(ctx context.Context, id FactoryId, predicate CredentialResourceOperationPredicate) (result CredentialOperationsListByFactoryCompleteResult, err error) { + items := make([]CredentialResource, 0) resp, err := c.CredentialOperationsListByFactory(ctx, id) if err != nil { diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_azurekeyvaultsecretreference.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_azurekeyvaultsecretreference.go new file mode 100644 index 000000000000..879ab15d1638 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_azurekeyvaultsecretreference.go @@ -0,0 +1,43 @@ +package credentials + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SecretBase = AzureKeyVaultSecretReference{} + +type AzureKeyVaultSecretReference struct { + SecretName interface{} `json:"secretName"` + SecretVersion *interface{} `json:"secretVersion,omitempty"` + Store LinkedServiceReference `json:"store"` + + // Fields inherited from SecretBase +} + +var _ json.Marshaler = AzureKeyVaultSecretReference{} + +func (s AzureKeyVaultSecretReference) MarshalJSON() ([]byte, error) { + type wrapper AzureKeyVaultSecretReference + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureKeyVaultSecretReference: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureKeyVaultSecretReference: %+v", err) + } + decoded["type"] = "AzureKeyVaultSecret" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureKeyVaultSecretReference: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_credential.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_credential.go index 24c0af8199e5..7090ed3de239 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_credential.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_credential.go @@ -44,6 +44,14 @@ func unmarshalCredentialImplementation(input []byte) (Credential, error) { return out, nil } + if strings.EqualFold(value, "ServicePrincipal") { + var out ServicePrincipalCredential + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePrincipalCredential: %+v", err) + } + return out, nil + } + out := RawCredentialImpl{ Type: value, Values: temp, diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_credentialresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_credentialresource.go new file mode 100644 index 000000000000..84cb469911db --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_credentialresource.go @@ -0,0 +1,46 @@ +package credentials + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CredentialResource struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties Credential `json:"properties"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &CredentialResource{} + +func (s *CredentialResource) UnmarshalJSON(bytes []byte) error { + type alias CredentialResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into CredentialResource: %+v", err) + } + + s.Etag = decoded.Etag + s.Id = decoded.Id + s.Name = decoded.Name + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CredentialResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalCredentialImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'CredentialResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_linkedservicereference.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_linkedservicereference.go new file mode 100644 index 000000000000..fb18dcf3e26a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_linkedservicereference.go @@ -0,0 +1,10 @@ +package credentials + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedServiceReference struct { + Parameters *map[string]interface{} `json:"parameters,omitempty"` + ReferenceName string `json:"referenceName"` + Type Type `json:"type"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_managedidentitycredential.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_managedidentitycredential.go index e17dc212836f..40046682a18d 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_managedidentitycredential.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_managedidentitycredential.go @@ -11,7 +11,7 @@ import ( var _ Credential = ManagedIdentityCredential{} type ManagedIdentityCredential struct { - TypeProperties *ManagedIdentityTypeProperties `json:"typeProperties,omitempty"` + TypeProperties ManagedIdentityTypeProperties `json:"typeProperties"` // Fields inherited from Credential Annotations *[]interface{} `json:"annotations,omitempty"` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_managedidentitycredentialresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_managedidentitycredentialresource.go deleted file mode 100644 index d25df590a8ca..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_managedidentitycredentialresource.go +++ /dev/null @@ -1,12 +0,0 @@ -package credentials - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedIdentityCredentialResource struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties ManagedIdentityCredential `json:"properties"` - Type *string `json:"type,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_secretbase.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_secretbase.go new file mode 100644 index 000000000000..a88630a30c12 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_secretbase.go @@ -0,0 +1,61 @@ +package credentials + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretBase interface { +} + +// RawSecretBaseImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSecretBaseImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalSecretBaseImplementation(input []byte) (SecretBase, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SecretBase into map[string]interface: %+v", err) + } + + value, ok := temp["type"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureKeyVaultSecret") { + var out AzureKeyVaultSecretReference + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureKeyVaultSecretReference: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SecureString") { + var out SecureString + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SecureString: %+v", err) + } + return out, nil + } + + out := RawSecretBaseImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_securestring.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_securestring.go new file mode 100644 index 000000000000..ab62d8f5b5e0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_securestring.go @@ -0,0 +1,41 @@ +package credentials + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SecretBase = SecureString{} + +type SecureString struct { + Value string `json:"value"` + + // Fields inherited from SecretBase +} + +var _ json.Marshaler = SecureString{} + +func (s SecureString) MarshalJSON() ([]byte, error) { + type wrapper SecureString + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SecureString: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SecureString: %+v", err) + } + decoded["type"] = "SecureString" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SecureString: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_serviceprincipalcredential.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_serviceprincipalcredential.go new file mode 100644 index 000000000000..4cd767d3bd31 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_serviceprincipalcredential.go @@ -0,0 +1,43 @@ +package credentials + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Credential = ServicePrincipalCredential{} + +type ServicePrincipalCredential struct { + TypeProperties ServicePrincipalCredentialTypeProperties `json:"typeProperties"` + + // Fields inherited from Credential + Annotations *[]interface{} `json:"annotations,omitempty"` + Description *string `json:"description,omitempty"` +} + +var _ json.Marshaler = ServicePrincipalCredential{} + +func (s ServicePrincipalCredential) MarshalJSON() ([]byte, error) { + type wrapper ServicePrincipalCredential + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePrincipalCredential: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePrincipalCredential: %+v", err) + } + decoded["type"] = "ServicePrincipal" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePrincipalCredential: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_serviceprincipalcredentialtypeproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_serviceprincipalcredentialtypeproperties.go new file mode 100644 index 000000000000..8f1c7490f0d6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/model_serviceprincipalcredentialtypeproperties.go @@ -0,0 +1,10 @@ +package credentials + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServicePrincipalCredentialTypeProperties struct { + ServicePrincipalId *interface{} `json:"servicePrincipalId,omitempty"` + ServicePrincipalKey *AzureKeyVaultSecretReference `json:"servicePrincipalKey,omitempty"` + Tenant *interface{} `json:"tenant,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/predicates.go index b0f15d4d51bb..d5de549aba2e 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/predicates.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/credentials/predicates.go @@ -3,14 +3,14 @@ package credentials // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type ManagedIdentityCredentialResourceOperationPredicate struct { +type CredentialResourceOperationPredicate struct { Etag *string Id *string Name *string Type *string } -func (p ManagedIdentityCredentialResourceOperationPredicate) Matches(input ManagedIdentityCredentialResource) bool { +func (p CredentialResourceOperationPredicate) Matches(input CredentialResource) bool { if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { return false diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/clusters/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/clusters/README.md index 93ed14342a44..0ede8797bafb 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/clusters/README.md +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/clusters/README.md @@ -111,11 +111,7 @@ payload := clusters.ClusterPatch{ } -read, err := client.Update(ctx, id, payload) -if err != nil { +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { // handle the error } -if model := read.Model; model != nil { - // do something with the model/response object -} ``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/clusters/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/clusters/method_update.go index 80edce4b64fb..55fe35076020 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/clusters/method_update.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/clusters/method_update.go @@ -2,9 +2,12 @@ package clusters import ( "context" + "fmt" "net/http" "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" "github.com/hashicorp/go-azure-sdk/sdk/odata" ) @@ -12,6 +15,7 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type UpdateOperationResponse struct { + Poller pollers.Poller HttpResponse *http.Response OData *odata.OData Model *Cluster @@ -22,6 +26,7 @@ func (c ClustersClient) Update(ctx context.Context, id ClusterId, input ClusterP opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ + http.StatusAccepted, http.StatusOK, }, HttpMethod: http.MethodPatch, @@ -47,12 +52,24 @@ func (c ClustersClient) Update(ctx context.Context, id ClusterId, input ClusterP return } - var model Cluster - result.Model = &model - - if err = resp.Unmarshal(result.Model); err != nil { + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { return } return } + +// UpdateThenPoll performs Update then polls until it's completed +func (c ClustersClient) UpdateThenPoll(ctx context.Context, id ClusterId, input ClusterPatch) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/client.go b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/client.go index 48b577d899b1..8cb50b454168 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/client.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/client.go @@ -167,22 +167,33 @@ func (r *Response) Unmarshal(model interface{}) error { if model == nil { return fmt.Errorf("model was nil") } + if r.Response == nil { + return fmt.Errorf("could not unmarshal as the HTTP response was nil") + } + + var contentType string + if r.Response.Header != nil { + contentType = strings.ToLower(r.Response.Header.Get("Content-Type")) - contentType := strings.ToLower(r.Header.Get("Content-Type")) - if contentType == "" { - // some APIs (e.g. Storage Data Plane) don't return a content type... so we'll assume from the Accept header - acc, err := accept.FromString(r.Request.Header.Get("Accept")) - if err != nil { - if preferred := acc.FirstChoice(); preferred != nil { - contentType = preferred.ContentType - } - } if contentType == "" { - // fall back on request media type - contentType = strings.ToLower(r.Request.Header.Get("Content-Type")) + // some APIs (e.g. Storage Data Plane) don't return a content type... so we'll assume from the Accept header + acc, err := accept.FromString(r.Request.Header.Get("Accept")) + if err != nil { + if preferred := acc.FirstChoice(); preferred != nil { + contentType = preferred.ContentType + } + } + if contentType == "" { + // fall back on request media type + contentType = strings.ToLower(r.Request.Header.Get("Content-Type")) + } } } + if contentType == "" { + return fmt.Errorf("could not determine Content-Type for response") + } + // Some APIs (e.g. Maintenance) return 200 without a body, don't unmarshal these if r.ContentLength == 0 && (r.Body == nil || r.Body == http.NoBody) { return nil @@ -502,12 +513,23 @@ func (c *Client) Execute(ctx context.Context, req *Request) (*Response, error) { // Determine whether response status is valid if !containsStatusCode(req.ValidStatusCodes, resp.StatusCode) { - // The status code didn't match, but we also need to check the ValidStatusFUnc, if provided + // The status code didn't match, but we also need to check the ValidStatusFunc, if provided // Note that the odata argument here is a best-effort and may be nil if f := req.ValidStatusFunc; f != nil && f(resp.Response, resp.OData) { return resp, nil } + status := fmt.Sprintf("%d", resp.StatusCode) + + // Prefer the status text returned in the response, but fall back to predefined status if absent + statusText := resp.Status + if statusText == "" { + statusText = http.StatusText(resp.StatusCode) + } + if statusText != "" { + status = fmt.Sprintf("%s (%s)", status, statusText) + } + // Determine suitable error text var errText string switch { @@ -519,16 +541,16 @@ func (c *Client) Execute(ctx context.Context, req *Request) (*Response, error) { respBody, err := io.ReadAll(resp.Body) if err != nil { - return resp, fmt.Errorf("unexpected status %d, could not read response body", resp.StatusCode) + return resp, fmt.Errorf("unexpected status %s, could not read response body", status) } if len(respBody) == 0 { - return resp, fmt.Errorf("unexpected status %d received with no body", resp.StatusCode) + return resp, fmt.Errorf("unexpected status %s received with no body", status) } errText = fmt.Sprintf("response: %s", respBody) } - return resp, fmt.Errorf("unexpected status %d with %s", resp.StatusCode, errText) + return resp, fmt.Errorf("unexpected status %s with %s", status, errText) } return resp, nil diff --git a/vendor/modules.txt b/vendor/modules.txt index 5811401a4c8d..999dadf38339 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -153,7 +153,7 @@ github.com/hashicorp/go-azure-helpers/resourcemanager/tags github.com/hashicorp/go-azure-helpers/resourcemanager/zones github.com/hashicorp/go-azure-helpers/sender github.com/hashicorp/go-azure-helpers/storage -# github.com/hashicorp/go-azure-sdk/resource-manager v0.20240315.1103122 +# github.com/hashicorp/go-azure-sdk/resource-manager v0.20240321.1145953 ## explicit; go 1.21 github.com/hashicorp/go-azure-sdk/resource-manager/aad/2021-05-01/domainservices github.com/hashicorp/go-azure-sdk/resource-manager/aadb2c/2021-04-01-preview @@ -1071,7 +1071,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2023-04-01/saplands github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2023-04-01/saprecommendations github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2023-04-01/sapsupportedsku github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2023-04-01/sapvirtualinstances -# github.com/hashicorp/go-azure-sdk/sdk v0.20240315.1103122 +# github.com/hashicorp/go-azure-sdk/sdk v0.20240321.1145953 ## explicit; go 1.21 github.com/hashicorp/go-azure-sdk/sdk/auth github.com/hashicorp/go-azure-sdk/sdk/auth/autorest