]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-14334 update get_binding and set_azure_binding
authorPierre <pierre.guillot@sonarsource.com>
Mon, 18 Jan 2021 14:12:18 +0000 (15:12 +0100)
committersonartech <sonartech@sonarsource.com>
Mon, 25 Jan 2021 20:32:26 +0000 (20:32 +0000)
15 files changed:
server/sonar-db-dao/src/main/java/org/sonar/db/alm/setting/ProjectAlmSettingDto.java
server/sonar-db-dao/src/main/resources/org/sonar/db/alm/setting/ProjectAlmSettingMapper.xml
server/sonar-db-dao/src/schema/schema-sq.ddl
server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/ProjectAlmSettingDaoTest.java
server/sonar-db-dao/src/testFixtures/java/org/sonar/db/almsettings/AlmSettingsDbTester.java
server/sonar-db-dao/src/testFixtures/java/org/sonar/db/almsettings/AlmSettingsTesting.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/AddMonorepoColumnToProjectAlmSettingsTable.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/MakeMonorepoColumnInProjectAlmSettingsTableNotNullable.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/PopulateMonorepoColumnToProjectAlmSettingsTable.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/AddMonorepoColumnToProjectAlmSettingsTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/MakeMonorepoColumnInProjectAlmSettingsTableNotNullableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/PopulateMonorepoColumnToProjectAlmSettingsTableTest.java
sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/AlmSettingsService.java
sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/SetAzureBindingRequest.java
sonar-ws/src/main/protobuf/ws-alm_settings.proto

index 1670cd89e40dc612160d774654d26e6351cda9d3..9e3cdbe6a24129cf49cc419dde1dd64139d35eaa 100644 (file)
@@ -62,6 +62,13 @@ public class ProjectAlmSettingDto {
    */
   private Boolean summaryCommentEnabled;
 
+  /**
+   * Boolean to know if this SonarQube project is part of a monorepo
+   * Only valid for Azure
+   * It will be null when the ALM is other than Azure
+   */
+  private Boolean monorepo;
+
   private long updatedAt;
   private long createdAt;
 
@@ -120,6 +127,15 @@ public class ProjectAlmSettingDto {
     return this;
   }
 
+  public Boolean getMonorepo() {
+    return monorepo;
+  }
+
+  public ProjectAlmSettingDto setMonorepo(Boolean monorepo) {
+    this.monorepo = monorepo;
+    return this;
+  }
+
   long getUpdatedAt() {
     return updatedAt;
   }
index c66513baf08e554e0154f4c7f3bde4ed17fafefa..1b689a3c475a85c40757d81101ed5d32959c6f05 100644 (file)
@@ -10,6 +10,7 @@
     p.alm_repo as almRepo,
     p.alm_slug as almSlug,
     p.summary_comment_enabled as summaryCommentEnabled,
+    p.monorepo as monorepo,
     p.created_at as createdAt,
     p.updated_at as updatedAt
   </sql>
@@ -55,6 +56,7 @@
       alm_repo,
       alm_slug,
       summary_comment_enabled,
+      monorepo,
       created_at,
       updated_at
     )
@@ -65,6 +67,7 @@
       #{dto.almRepo, jdbcType=VARCHAR},
       #{dto.almSlug, jdbcType=VARCHAR},
       #{dto.summaryCommentEnabled, jdbcType=BOOLEAN},
+      #{dto.monorepo, jdbcType=BOOLEAN},
       #{now, jdbcType=BIGINT},
       #{now, jdbcType=BIGINT}
     )
@@ -80,6 +83,7 @@
       alm_repo,
       alm_slug,
       summary_comment_enabled,
+      monorepo,
       created_at,
       updated_at
     )
@@ -90,6 +94,7 @@
       #{dto.almRepo, jdbcType=VARCHAR},
       #{dto.almSlug, jdbcType=VARCHAR},
       #{dto.summaryCommentEnabled, jdbcType=NUMERIC},
+      #{dto.monorepo, jdbcType=NUMERIC},
       #{now, jdbcType=BIGINT},
       #{now, jdbcType=BIGINT}
     )
       alm_repo = #{dto.almRepo, jdbcType=VARCHAR},
       alm_slug = #{dto.almSlug, jdbcType=VARCHAR},
       summary_comment_enabled = #{dto.summaryCommentEnabled, jdbcType=BOOLEAN},
+      monorepo = #{dto.monorepo, jdbcType=BOOLEAN},
       updated_at = #{now, jdbcType=BIGINT}
     WHERE
       project_uuid = #{dto.projectUuid, jdbcType=VARCHAR}
       alm_repo = #{dto.almRepo, jdbcType=VARCHAR},
       alm_slug = #{dto.almSlug, jdbcType=VARCHAR},
       summary_comment_enabled = #{dto.summaryCommentEnabled, jdbcType=NUMERIC},
+      monorepo = #{dto.monorepo, jdbcType=NUMERIC},
       updated_at = #{now, jdbcType=BIGINT}
     WHERE
       project_uuid = #{dto.projectUuid, jdbcType=VARCHAR}
index f34734a7cf3b0c7c1e9af46407abb7c93a1890c0..cda3c17c248a69e80f655e0a46feb3821cf70bfc 100644 (file)
@@ -572,7 +572,8 @@ CREATE TABLE "PROJECT_ALM_SETTINGS"(
     "ALM_SLUG" VARCHAR(256),
     "UPDATED_AT" BIGINT NOT NULL,
     "CREATED_AT" BIGINT NOT NULL,
-    "SUMMARY_COMMENT_ENABLED" BOOLEAN
+    "SUMMARY_COMMENT_ENABLED" BOOLEAN,
+    "MONOREPO" BOOLEAN NOT NULL
 );
 ALTER TABLE "PROJECT_ALM_SETTINGS" ADD CONSTRAINT "PK_PROJECT_ALM_SETTINGS" PRIMARY KEY("UUID");
 CREATE UNIQUE INDEX "UNIQ_PROJECT_ALM_SETTINGS" ON "PROJECT_ALM_SETTINGS"("PROJECT_UUID");
index 627b088caa5a98297d7eb152c2f5fa102bed664b..c62745d63dcde1a5669c71d19162213e47c0d114 100644 (file)
@@ -63,10 +63,10 @@ public class ProjectAlmSettingDaoTest {
       .extracting(ProjectAlmSettingDto::getUuid, ProjectAlmSettingDto::getAlmSettingUuid, ProjectAlmSettingDto::getProjectUuid,
         ProjectAlmSettingDto::getAlmRepo, ProjectAlmSettingDto::getAlmSlug,
         ProjectAlmSettingDto::getCreatedAt, ProjectAlmSettingDto::getUpdatedAt,
-        ProjectAlmSettingDto::getSummaryCommentEnabled)
+        ProjectAlmSettingDto::getSummaryCommentEnabled, ProjectAlmSettingDto::getMonorepo)
       .containsExactly(A_UUID, githubAlmSettingDto.getUuid(), project.getUuid(),
         githubProjectAlmSettingDto.getAlmRepo(), githubProjectAlmSettingDto.getAlmSlug(),
-        A_DATE, A_DATE, githubProjectAlmSettingDto.getSummaryCommentEnabled());
+        A_DATE, A_DATE, githubProjectAlmSettingDto.getSummaryCommentEnabled(), false);
 
     assertThat(underTest.selectByProject(dbSession, anotherProject)).isNotPresent();
   }
index 71dc10faec743f6e2a9304e9e103e225b3d42f29..63df89088d4c44442c84ada7f9239d02c7df4da1 100644 (file)
@@ -72,6 +72,10 @@ public class AlmSettingsDbTester {
     return insertProjectAlmSetting(newAzureProjectAlmSettingDto(azureAlmSetting, project));
   }
 
+  public ProjectAlmSettingDto insertAzureMonoRepoProjectAlmSetting(AlmSettingDto azureAlmSetting, ProjectDto project) {
+    return insertProjectAlmSetting(newAzureProjectAlmSettingDto(azureAlmSetting, project), d -> d.setMonorepo(true));
+  }
+
   public ProjectAlmSettingDto insertGitlabProjectAlmSetting(AlmSettingDto gitlabAlmSetting, ProjectDto project) {
     return insertProjectAlmSetting(newGitlabProjectAlmSettingDto(gitlabAlmSetting, project));
   }
index 39c48e85a5c86e28810d195d16d40b778c5c7737..654dd0b61fffd4ef2033eaf3ace99dd29b3271a9 100644 (file)
@@ -67,13 +67,15 @@ public class AlmSettingsTesting {
       .setAlmSettingUuid(githubAlmSetting.getUuid())
       .setProjectUuid(project.getUuid())
       .setAlmRepo(randomAlphanumeric(256))
-      .setSummaryCommentEnabled(true);
+      .setSummaryCommentEnabled(true)
+      .setMonorepo(false);
   }
 
   static ProjectAlmSettingDto newGitlabProjectAlmSettingDto(AlmSettingDto gitlabAlmSetting, ProjectDto project) {
     return new ProjectAlmSettingDto()
       .setAlmSettingUuid(gitlabAlmSetting.getUuid())
-      .setProjectUuid(project.getUuid());
+      .setProjectUuid(project.getUuid())
+      .setMonorepo(false);
   }
 
   static ProjectAlmSettingDto newAzureProjectAlmSettingDto(AlmSettingDto azureAlmSetting, ProjectDto project) {
@@ -81,7 +83,8 @@ public class AlmSettingsTesting {
       .setAlmSettingUuid(azureAlmSetting.getUuid())
       .setProjectUuid(project.getUuid())
       .setAlmSlug(randomAlphanumeric(256))
-      .setAlmRepo(randomAlphanumeric(256));
+      .setAlmRepo(randomAlphanumeric(256))
+      .setMonorepo(false);
   }
 
   public static ProjectAlmSettingDto newBitbucketProjectAlmSettingDto(AlmSettingDto githubAlmSetting, ProjectDto project) {
@@ -89,6 +92,7 @@ public class AlmSettingsTesting {
       .setAlmSettingUuid(githubAlmSetting.getUuid())
       .setProjectUuid(project.getUuid())
       .setAlmRepo(randomAlphanumeric(256))
-      .setAlmSlug(randomAlphanumeric(256));
+      .setAlmSlug(randomAlphanumeric(256))
+      .setMonorepo(false);
   }
 }
index f7c673c1b3be48aa817f29cf2c216598a0746fa4..2392273d4dfddbc4b301ff40ab4edb44e6f03fe5 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
 package org.sonar.server.platform.db.migration.version.v87;
 
 import java.sql.SQLException;
index 8fe101c6861caaee481e6a8f6abc5cde61a91889..416c467bc58e45a5a37d22483e7fd9df6a3d53c0 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
 package org.sonar.server.platform.db.migration.version.v87;
 
 import java.sql.SQLException;
index 6d0660c7ab39d6d2ba0614743db7fe0bd491378a..e7c0b1f5465cebb4ebaa1539ea2f8596451646b8 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
 package org.sonar.server.platform.db.migration.version.v87;
 
 import java.sql.SQLException;
index 100b22fdbb19cd8b9c3d92b00f0124403d2dc3fe..39084cbacb82a68a49c8d1f5bde0dc221e8da3ee 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
 package org.sonar.server.platform.db.migration.version.v87;
 
 import java.sql.SQLException;
index 26fad4d8a8c1e8130c96e439483350f4ecb727a7..47dfc60336dfa6340e71d34672c550f015e024cb 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
 package org.sonar.server.platform.db.migration.version.v87;
 
 import java.sql.SQLException;
index bfc7647a38412c0616b28ecda3308269c2790535..006895d400b3bbf4cbbc54fdee0971e47b61f99a 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
 package org.sonar.server.platform.db.migration.version.v87;
 
 import java.sql.SQLException;
index 27b7a5d46f23b7e3b3fabdc2e99717eb86a52641..2996c11475a1d4ed992b1b3d25881857e29f8e31 100644 (file)
@@ -198,6 +198,7 @@ public class AlmSettingsService extends BaseService {
         .setParam("project", request.getProject())
         .setParam("projectName", request.getProjectName())
         .setParam("repositoryName", request.getRepositoryName())
+        .setParam("monorepo", request.getMonorepo())
         .setMediaType(MediaTypes.JSON)).content();
   }
 
index d611ec2982d850c694fa6d45c92667609ec4297e..c0a1a257ab8634172ba917a5dbd4c424006904c8 100644 (file)
@@ -33,6 +33,7 @@ public class SetAzureBindingRequest {
   private String project;
   private String repositoryName;
   private String projectName;
+  private String monorepo;
 
   /**
    * This is a mandatory parameter.
@@ -83,4 +84,13 @@ public class SetAzureBindingRequest {
     this.projectName = projectName;
     return this;
   }
+
+  public String getMonorepo() {
+    return monorepo;
+  }
+
+  public SetAzureBindingRequest setMonorepo(String monorepo) {
+    this.monorepo = monorepo;
+    return this;
+  }
 }
index db102506a6cf7098d2a3229ada2d8e5c8b0dd6c6..57de78e8170732bdbc7fd3afc4299df93dd5c3cf 100644 (file)
@@ -67,6 +67,7 @@ message GetBindingWsResponse {
   optional string url = 4;
   optional string slug = 5;
   optional bool summaryCommentEnabled = 6;
+  optional bool monorepo = 7;
 }
 
 enum Alm {