use of com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob in project vespa by vespa-engine.
the class ApplicationApiHandler method deploy.
private HttpResponse deploy(String tenantName, String applicationName, String instanceName, String environment, String region, HttpRequest request) {
ApplicationId applicationId = ApplicationId.from(tenantName, applicationName, instanceName);
ZoneId zone = ZoneId.from(environment, region);
Map<String, byte[]> dataParts = new MultipartParser().parse(request);
if (!dataParts.containsKey("deployOptions"))
return ErrorResponse.badRequest("Missing required form part 'deployOptions'");
Inspector deployOptions = SlimeUtils.jsonToSlime(dataParts.get("deployOptions")).get();
Optional<ApplicationPackage> applicationPackage = Optional.ofNullable(dataParts.get("applicationZip")).map(ApplicationPackage::new);
verifyApplicationIdentityConfiguration(tenantName, applicationPackage);
// TODO: get rid of the json object
DeployOptions deployOptionsJsonClass = new DeployOptions(screwdriverBuildJobFromSlime(deployOptions.field("screwdriverBuildJob")), optional("vespaVersion", deployOptions).map(Version::new), deployOptions.field("ignoreValidationErrors").asBool(), deployOptions.field("deployCurrentVersion").asBool());
ActivateResult result = controller.applications().deployApplication(applicationId, zone, applicationPackage, deployOptionsJsonClass);
return new SlimeJsonResponse(toSlime(result));
}
use of com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob in project vespa by vespa-engine.
the class DeployOptionsTest method it_serializes_version.
@Test
public void it_serializes_version() throws IOException {
DeployOptions options = new DeployOptions(Optional.empty(), Optional.of(new Version("6.98.227")), false, false);
final ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).registerModule(new Jdk8Module());
String string = objectMapper.writeValueAsString(options);
assertEquals("{\"screwdriverBuildJob\":null,\"vespaVersion\":\"6.98.227\",\"ignoreValidationErrors\":false,\"deployCurrentVersion\":false}", string);
}
use of com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob in project vespa by vespa-engine.
the class ControllerTest method testDeploymentOfNewInstanceWithIllegalApplicationName.
@Test
public void testDeploymentOfNewInstanceWithIllegalApplicationName() {
ControllerTester tester = new ControllerTester();
String application = "this_application_name_is_far_too_long_and_has_underscores";
ZoneId zone = ZoneId.from("test", "us-east-1");
DeployOptions options = new DeployOptions(Optional.of(new ScrewdriverBuildJob(new ScrewdriverId("123"), null)), Optional.empty(), false, false);
tester.createTenant("tenant", "domain", null);
// Deploy an application which doesn't yet exist, and which has an illegal application name.
try {
tester.controller().applications().deployApplication(ApplicationId.from("tenant", application, "123"), zone, Optional.empty(), options);
fail("Illegal application name should cause validation exception.");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("Invalid id"));
}
// Sneak an illegal application in the back door.
tester.createApplication(new ApplicationSerializer().toSlime(new Application(ApplicationId.from("tenant", application, "default"))));
// Deploy a PR instance for the application, with no NToken.
tester.controller().applications().deployApplication(ApplicationId.from("tenant", application, "456"), zone, Optional.empty(), options);
assertTrue(tester.controller().applications().get(ApplicationId.from("tenant", application, "456")).isPresent());
}
use of com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob in project vespa by vespa-engine.
the class ControllerTester method deploy.
public void deploy(Application application, ZoneId zone, Optional<ApplicationPackage> applicationPackage, boolean deployCurrentVersion) {
ScrewdriverId app1ScrewdriverId = new ScrewdriverId(String.valueOf(application.deploymentJobs().projectId().get()));
GitRevision app1RevisionId = new GitRevision(new GitRepository("repo"), new GitBranch("master"), new GitCommit("commit1"));
controller().applications().deployApplication(application.id(), zone, applicationPackage, new DeployOptions(Optional.of(new ScrewdriverBuildJob(app1ScrewdriverId, app1RevisionId)), Optional.empty(), false, deployCurrentVersion));
}
use of com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob in project vespa by vespa-engine.
the class ContainerControllerTester method deploy.
public Application deploy(Application application, ApplicationPackage applicationPackage, ZoneId zone, long projectId) {
ScrewdriverId app1ScrewdriverId = new ScrewdriverId(String.valueOf(projectId));
GitRevision app1RevisionId = new GitRevision(new GitRepository("repo"), new GitBranch("master"), new GitCommit("commit1"));
controller().applications().deployApplication(application.id(), zone, Optional.of(applicationPackage), new DeployOptions(Optional.of(new ScrewdriverBuildJob(app1ScrewdriverId, app1RevisionId)), Optional.empty(), false, false));
return application;
}
Aggregations