parent
6e7e96873f
commit
426718a495
3
pom.xml
3
pom.xml
|
|
@ -662,7 +662,7 @@
|
||||||
<artifactId>che-core-api-auth-bitbucket</artifactId>
|
<artifactId>che-core-api-auth-bitbucket</artifactId>
|
||||||
<version>${che.version}</version>
|
<version>${che.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.che.core</groupId>
|
<groupId>org.eclipse.che.core</groupId>
|
||||||
<artifactId>che-core-api-auth-github</artifactId>
|
<artifactId>che-core-api-auth-github</artifactId>
|
||||||
<version>${che.version}</version>
|
<version>${che.version}</version>
|
||||||
|
|
@ -1409,7 +1409,6 @@
|
||||||
<version>${junit.junit.version}</version>
|
<version>${junit.junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.plugin-testing</groupId>
|
<groupId>org.apache.maven.plugin-testing</groupId>
|
||||||
<artifactId>maven-plugin-testing-harness</artifactId>
|
<artifactId>maven-plugin-testing-harness</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,10 @@
|
||||||
<groupId>org.eclipse.che.core</groupId>
|
<groupId>org.eclipse.che.core</groupId>
|
||||||
<artifactId>che-core-api-workspace</artifactId>
|
<artifactId>che-core-api-workspace</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.che.core</groupId>
|
||||||
|
<artifactId>che-core-api-workspace-shared</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.che.core</groupId>
|
<groupId>org.eclipse.che.core</groupId>
|
||||||
<artifactId>che-core-commons-lang</artifactId>
|
<artifactId>che-core-commons-lang</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@ import static org.eclipse.che.api.factory.shared.Constants.URL_PARAMETER_NAME;
|
||||||
import static org.eclipse.che.dto.server.DtoFactory.newDto;
|
import static org.eclipse.che.dto.server.DtoFactory.newDto;
|
||||||
import static org.eclipse.che.security.oauth1.OAuthAuthenticationService.ERROR_QUERY_NAME;
|
import static org.eclipse.che.security.oauth1.OAuthAuthenticationService.ERROR_QUERY_NAME;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
@ -32,6 +34,10 @@ import org.eclipse.che.api.factory.shared.dto.FactoryMetaDto;
|
||||||
import org.eclipse.che.api.factory.shared.dto.FactoryVisitor;
|
import org.eclipse.che.api.factory.shared.dto.FactoryVisitor;
|
||||||
import org.eclipse.che.api.factory.shared.dto.ScmInfoDto;
|
import org.eclipse.che.api.factory.shared.dto.ScmInfoDto;
|
||||||
import org.eclipse.che.api.workspace.server.devfile.URLFetcher;
|
import org.eclipse.che.api.workspace.server.devfile.URLFetcher;
|
||||||
|
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto;
|
||||||
|
import org.eclipse.che.api.workspace.shared.dto.SourceStorageDto;
|
||||||
|
import org.eclipse.che.api.workspace.shared.dto.devfile.ProjectDto;
|
||||||
|
import org.eclipse.che.api.workspace.shared.dto.devfile.SourceDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Factory Parameters resolver for Azure DevOps repositories.
|
* Provides Factory Parameters resolver for Azure DevOps repositories.
|
||||||
|
|
@ -113,8 +119,40 @@ public class AzureDevOpsFactoryParametersResolver extends DefaultFactoryParamete
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FactoryDto visit(FactoryDto factory) {
|
public FactoryDto visit(FactoryDto factory) {
|
||||||
// Should never happen
|
if (factory.getWorkspace() != null) {
|
||||||
throw new UnsupportedOperationException();
|
return projectConfigDtoMerger.merge(
|
||||||
|
factory,
|
||||||
|
() -> {
|
||||||
|
// Compute project configuration
|
||||||
|
return newDto(ProjectConfigDto.class)
|
||||||
|
.withSource(buildWorkspaceConfigSource(azureDevOpsUrl))
|
||||||
|
.withName(azureDevOpsUrl.getRepository())
|
||||||
|
.withPath("/".concat(azureDevOpsUrl.getRepository()));
|
||||||
|
});
|
||||||
|
} else if (factory.getDevfile() == null) {
|
||||||
|
factory.setDevfile(urlFactoryBuilder.buildDefaultDevfile(azureDevOpsUrl.getRepository()));
|
||||||
|
}
|
||||||
|
|
||||||
|
updateProjects(
|
||||||
|
factory.getDevfile(),
|
||||||
|
() ->
|
||||||
|
newDto(ProjectDto.class)
|
||||||
|
.withSource(
|
||||||
|
newDto(SourceDto.class)
|
||||||
|
.withLocation(azureDevOpsUrl.getRepositoryLocation())
|
||||||
|
.withType("git")
|
||||||
|
.withBranch(azureDevOpsUrl.getBranch())
|
||||||
|
.withTag(azureDevOpsUrl.getTag()))
|
||||||
|
.withName(azureDevOpsUrl.getRepository()),
|
||||||
|
project -> {
|
||||||
|
final String location = project.getSource().getLocation();
|
||||||
|
if (location.equals(azureDevOpsUrl.getRepositoryLocation())) {
|
||||||
|
project.getSource().setBranch(azureDevOpsUrl.getBranch());
|
||||||
|
project.getSource().setTag(azureDevOpsUrl.getTag());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return factory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,4 +160,19 @@ public class AzureDevOpsFactoryParametersResolver extends DefaultFactoryParamete
|
||||||
public RemoteFactoryUrl parseFactoryUrl(String factoryUrl) throws ApiException {
|
public RemoteFactoryUrl parseFactoryUrl(String factoryUrl) throws ApiException {
|
||||||
return azureDevOpsURLParser.parse(factoryUrl);
|
return azureDevOpsURLParser.parse(factoryUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SourceStorageDto buildWorkspaceConfigSource(AzureDevOpsUrl azureDevOpsUrl) {
|
||||||
|
Map<String, String> parameters = new HashMap<>(1);
|
||||||
|
if (!Strings.isNullOrEmpty(azureDevOpsUrl.getBranch())) {
|
||||||
|
parameters.put("branch", azureDevOpsUrl.getBranch());
|
||||||
|
}
|
||||||
|
if (!Strings.isNullOrEmpty(azureDevOpsUrl.getTag())) {
|
||||||
|
parameters.put("tag", azureDevOpsUrl.getTag());
|
||||||
|
}
|
||||||
|
|
||||||
|
return newDto(SourceStorageDto.class)
|
||||||
|
.withLocation(azureDevOpsUrl.getRepositoryLocation())
|
||||||
|
.withType("git")
|
||||||
|
.withParameters(parameters);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue