diff options
| author | Paul Kirkwood <paul.kirkwood@vodafone.com> | 2023-01-25 17:00:48 +0000 |
|---|---|---|
| committer | Paul Kirkwood <paul.kirkwood@vodafone.com> | 2023-01-25 17:00:48 +0000 |
| commit | 9ef9902a103a6cd78ed580cc4fd72ab65d579f6d (patch) | |
| tree | 7e91971db76e28b9a7acddc370abaf28f17a63e0 | |
| parent | 387f7775c725d819289df88c52227a1a76631c3f (diff) | |
Resolve the 'panic: interface conversion: interface {} is nil, not map[string]interface {}' messages
| -rw-r--r-- | azuredevops/internal/service/serviceendpoint/resource_serviceendpoint_artifactory.go | 15 |
1 files 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)) |
