From 9ef9902a103a6cd78ed580cc4fd72ab65d579f6d Mon Sep 17 00:00:00 2001 From: Paul Kirkwood Date: Wed, 25 Jan 2023 17:00:48 +0000 Subject: Resolve the 'panic: interface conversion: interface {} is nil, not map[string]interface {}' messages --- .../resource_serviceendpoint_artifactory.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/azuredevops/internal/service/serviceendpoint/resource_serviceendpoint_artifactory.go b/azuredevops/internal/service/serviceendpoint/resource_serviceendpoint_artifactory.go index c2156417..e07a01fe 100644 --- a/azuredevops/internal/service/serviceendpoint/resource_serviceendpoint_artifactory.go +++ b/azuredevops/internal/service/serviceendpoint/resource_serviceendpoint_artifactory.go @@ -144,9 +144,13 @@ func flattenServiceEndpointArtifactory(d *schema.ResourceData, serviceEndpoint * if len(authMap) > 0 { newHash, hashKey := tfhelper.HelpFlattenSecretNested(d, "authentication_token", authMap, "token") auth[hashKey] = newHash - auth["token"] = authMap["token"] } } + + if serviceEndpoint.Authorization != nil && serviceEndpoint.Authorization.Parameters != nil { + auth["token"] = (*serviceEndpoint.Authorization.Parameters)["apitoken"] + } + d.Set("authentication_token", []interface{}{auth}) } else if strings.EqualFold(*serviceEndpoint.Authorization.Scheme, "UsernamePassword") { auth := make(map[string]interface{}) @@ -157,11 +161,14 @@ func flattenServiceEndpointArtifactory(d *schema.ResourceData, serviceEndpoint * auth[hashKey] = newHash newHash, hashKey = tfhelper.HelpFlattenSecretNested(d, "authentication_basic", oldAuthList, "username") auth[hashKey] = newHash - - auth["password"] = oldAuthList["password"] - auth["username"] = oldAuthList["username"] } } + + if serviceEndpoint.Authorization != nil && serviceEndpoint.Authorization.Parameters != nil { + auth["password"] = (*serviceEndpoint.Authorization.Parameters)["password"] + auth["username"] = (*serviceEndpoint.Authorization.Parameters)["username"] + } + d.Set("authentication_basic", []interface{}{auth}) } else { panic(fmt.Errorf("inconsistent authorization scheme %s", *serviceEndpoint.Authorization.Scheme)) -- cgit v1.2.3