Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable azure_binding for sonarqube community edition #209

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 1 addition & 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,7 @@ func TestAccSonarqubeAzureBindingName(t *testing.T) {
name := "sonarqube_azure_binding." + rnd

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