use of org.eclipse.che.api.workspace.server.devfile.URLFileContentProvider in project devspaces-images by redhat-developer.
the class DefaultFactoryParameterResolver method createFactory.
/**
* Creates factory based on provided parameters. Presumes url parameter as direct URL to a devfile
* content.
*
* @param factoryParameters map containing factory data parameters provided through URL
*/
@Override
public FactoryMetaDto createFactory(@NotNull final Map<String, String> factoryParameters) throws ApiException {
// This should never be null, because our contract in #accept prohibits that
String devfileLocation = factoryParameters.get(URL_PARAMETER_NAME);
URI devfileURI;
try {
devfileURI = new URL(devfileLocation).toURI();
} catch (MalformedURLException | URISyntaxException e) {
throw new BadRequestException(format("Unable to process provided factory URL. Please check its validity and try again. Parser message: %s", e.getMessage()));
}
return urlFactoryBuilder.createFactoryFromDevfile(new DefaultFactoryUrl().withDevfileFileLocation(devfileLocation), new URLFileContentProvider(devfileURI, urlFetcher), extractOverrideParams(factoryParameters)).orElse(null);
}
use of org.eclipse.che.api.workspace.server.devfile.URLFileContentProvider in project devspaces-images by redhat-developer.
the class KubernetesComponentToWorkspaceApplierTest method shouldUseReferenceContentAsRecipeIfPresent.
@Test
public void shouldUseReferenceContentAsRecipeIfPresent() throws Exception {
String yamlRecipeContent = getResource("devfile/petclinic.yaml");
doReturn(toK8SList(yamlRecipeContent).getItems()).when(k8sRecipeParser).parse(anyString());
ComponentImpl component = new ComponentImpl();
component.setType(KUBERNETES_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setReferenceContent(yamlRecipeContent);
component.setAlias(COMPONENT_NAME);
applier.apply(workspaceConfig, component, new URLFileContentProvider(null, null));
KubernetesList list = toK8SList(yamlRecipeContent);
replaceImagePullPolicy(list, "Always");
verify(k8sEnvProvisioner).provision(eq(workspaceConfig), eq(KubernetesEnvironment.TYPE), eq(list.getItems()), anyMap());
}
use of org.eclipse.che.api.workspace.server.devfile.URLFileContentProvider in project che-server by eclipse-che.
the class DefaultFactoryParameterResolver method createFactory.
/**
* Creates factory based on provided parameters. Presumes url parameter as direct URL to a devfile
* content.
*
* @param factoryParameters map containing factory data parameters provided through URL
*/
@Override
public FactoryMetaDto createFactory(@NotNull final Map<String, String> factoryParameters) throws ApiException {
// This should never be null, because our contract in #accept prohibits that
String devfileLocation = factoryParameters.get(URL_PARAMETER_NAME);
URI devfileURI;
try {
devfileURI = new URL(devfileLocation).toURI();
} catch (MalformedURLException | URISyntaxException e) {
throw new BadRequestException(format("Unable to process provided factory URL. Please check its validity and try again. Parser message: %s", e.getMessage()));
}
return urlFactoryBuilder.createFactoryFromDevfile(new DefaultFactoryUrl().withDevfileFileLocation(devfileLocation), new URLFileContentProvider(devfileURI, urlFetcher), extractOverrideParams(factoryParameters)).orElse(null);
}
use of org.eclipse.che.api.workspace.server.devfile.URLFileContentProvider in project che-server by eclipse-che.
the class KubernetesComponentToWorkspaceApplierTest method shouldUseReferenceContentAsRecipeIfPresent.
@Test
public void shouldUseReferenceContentAsRecipeIfPresent() throws Exception {
String yamlRecipeContent = getResource("devfile/petclinic.yaml");
doReturn(toK8SList(yamlRecipeContent).getItems()).when(k8sRecipeParser).parse(anyString());
ComponentImpl component = new ComponentImpl();
component.setType(KUBERNETES_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setReferenceContent(yamlRecipeContent);
component.setAlias(COMPONENT_NAME);
applier.apply(workspaceConfig, component, new URLFileContentProvider(null, null));
KubernetesList list = toK8SList(yamlRecipeContent);
replaceImagePullPolicy(list, "Always");
verify(k8sEnvProvisioner).provision(eq(workspaceConfig), eq(KubernetesEnvironment.TYPE), eq(list.getItems()), anyMap());
}
Aggregations