From d7dd453962dd02af811f9d373349251b9279221e Mon Sep 17 00:00:00 2001 From: david-ortiz Date: Tue, 31 Oct 2023 12:44:34 +0100 Subject: [PATCH] fix: retrocompatibility break when v0.62.3 was released --- ...arqube_qualityprofile_project_association.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sonarqube/resource_sonarqube_qualityprofile_project_association.go b/sonarqube/resource_sonarqube_qualityprofile_project_association.go index 703688e8..9425687b 100644 --- a/sonarqube/resource_sonarqube_qualityprofile_project_association.go +++ b/sonarqube/resource_sonarqube_qualityprofile_project_association.go @@ -97,7 +97,6 @@ func resourceSonarqubeQualityProfileProjectAssociationRead(d *schema.ResourceDat // Id is composed of qualityProfile name and project name idSlice := strings.Split(d.Id(), "/") - // Call api/qualityprofiles/search to return the qualityProfileID sonarQubeURL := m.(*ProviderConfiguration).sonarQubeURL sonarQubeURLSubPath := sonarQubeURL.Path @@ -124,10 +123,18 @@ func resourceSonarqubeQualityProfileProjectAssociationRead(d *schema.ResourceDat var qualityProfileID string for _, value := range getQualityProfileResponse.Profiles { - if idSlice[0] == value.Name && idSlice[2] == value.Language { - qualityProfileID = value.Key - language = value.Language - qualityProfile = value.Name + if len(idSlice) == 3 { + if idSlice[0] == value.Name && idSlice[2] == value.Language { + qualityProfileID = value.Key + language = value.Language + qualityProfile = value.Name + } + } else { + if idSlice[0] == value.Name && d.Get("language").(string) == value.Language { + qualityProfileID = value.Key + language = value.Language + qualityProfile = value.Name + } } }