Skip to content

Commit

Permalink
Enable azure_binding for sonarqube community edition
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyrine Gamoudi committed Oct 12, 2023
1 parent 9348b9a commit a36c97f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
19 changes: 0 additions & 19 deletions sonarqube/resource_sonarqube_azure_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,7 @@ func resourceSonarqubeAzureBinding() *schema.Resource {
}
}

func checkAzureBindingSupport(conf *ProviderConfiguration) error {
if strings.ToLower(conf.sonarQubeEdition) == "community" {
return fmt.Errorf("Azure Devops Bindings are not supported in the Community edition of SonarQube. You are using: SonarQube %s version %s", conf.sonarQubeEdition, conf.sonarQubeVersion)
}
return nil
}

func resourceSonarqubeAzureBindingCreate(d *schema.ResourceData, m interface{}) error {
if err := checkAzureBindingSupport(m.(*ProviderConfiguration)); err != nil {
return err
}

sonarQubeURL := m.(*ProviderConfiguration).sonarQubeURL
sonarQubeURL.Path = strings.TrimSuffix(sonarQubeURL.Path, "/") + "/api/alm_settings/set_azure_binding"

Expand Down Expand Up @@ -114,10 +103,6 @@ func resourceSonarqubeAzureBindingCreate(d *schema.ResourceData, m interface{})
}

func resourceSonarqubeAzureBindingRead(d *schema.ResourceData, m interface{}) error {
if err := checkAzureBindingSupport(m.(*ProviderConfiguration)); err != nil {
return err
}

// id consists of "project/project_name/repository"
idSlice := strings.SplitN(d.Id(), "/", 3)
sonarQubeURL := m.(*ProviderConfiguration).sonarQubeURL
Expand Down Expand Up @@ -160,10 +145,6 @@ func resourceSonarqubeAzureBindingRead(d *schema.ResourceData, m interface{}) er
}

func resourceSonarqubeAzureBindingDelete(d *schema.ResourceData, m interface{}) error {
if err := checkAzureBindingSupport(m.(*ProviderConfiguration)); err != nil {
return err
}

sonarQubeURL := m.(*ProviderConfiguration).sonarQubeURL
sonarQubeURL.Path = strings.TrimSuffix(sonarQubeURL.Path, "/") + "/api/alm_settings/delete_binding"
sonarQubeURL.RawQuery = url.Values{
Expand Down
6 changes: 0 additions & 6 deletions sonarqube/resource_sonarqube_azure_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ func init() {
func testSweepSonarqubeAzureBinding(r string) error {
return nil
}
func testAccPreCheckAzureBindingSupport(t *testing.T) {
if err := checkAzureBindingSupport(testAccProvider.Meta().(*ProviderConfiguration)); err != nil {
t.Skipf("Skipping test of unsupported feature (Azure Binding)")
}
}

func testAccSonarqubeAzureBindingName(rnd string, projKey string, almSetting string, projName string, repoName string) string {
return fmt.Sprintf(`
Expand Down Expand Up @@ -52,7 +47,6 @@ func TestAccSonarqubeAzureBindingName(t *testing.T) {
name := "sonarqube_azure_binding." + rnd

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAzureBindingSupport(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down

0 comments on commit a36c97f

Please sign in to comment.