Search in sources :

Example 41 with Halconfig

use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.

the class MasterController method setMaster.

@RequestMapping(value = "/{masterName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setMaster(@PathVariable String deploymentName, @PathVariable String ciName, @PathVariable String masterName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMaster) {
    Master master = objectMapper.convertValue(rawMaster, Cis.translateMasterType(ciName));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> master.stageLocalFiles(configPath));
    builder.setUpdate(() -> masterService.setMaster(deploymentName, ciName, masterName, master));
    builder.setSeverity(severity);
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> masterService.validateMaster(deploymentName, ciName, master.getName());
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit the " + masterName + " master");
}
Also used : Master(com.netflix.spinnaker.halyard.config.model.v1.node.Master) Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 42 with Halconfig

use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.

the class NotificationController method setNotification.

@RequestMapping(value = "/{notificationName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setNotification(@PathVariable String deploymentName, @PathVariable String notificationName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawNotification) {
    Notification notification = objectMapper.convertValue(rawNotification, Notifications.translateNotificationType(notificationName));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> notification.stageLocalFiles(configPath));
    builder.setUpdate(() -> notificationService.setNotification(deploymentName, notification));
    builder.setSeverity(severity);
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> notificationService.validateNotification(deploymentName, notificationName);
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit the " + notificationName + " notification");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) Notification(com.netflix.spinnaker.halyard.config.model.v1.node.Notification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 43 with Halconfig

use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.

the class ProviderController method setProvider.

@RequestMapping(value = "/{providerName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setProvider(@PathVariable String deploymentName, @PathVariable String providerName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawProvider) {
    Provider provider = objectMapper.convertValue(rawProvider, Providers.translateProviderType(providerName));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> provider.stageLocalFiles(configPath));
    builder.setUpdate(() -> providerService.setProvider(deploymentName, provider));
    builder.setSeverity(severity);
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> providerService.validateProvider(deploymentName, providerName);
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit the " + providerName + " provider");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) Provider(com.netflix.spinnaker.halyard.config.model.v1.node.Provider) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 44 with Halconfig

use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.

the class SecurityController method setGroupMembership.

@RequestMapping(value = "/authz/groupMembership", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setGroupMembership(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMembership) {
    GroupMembership membership = objectMapper.convertValue(rawMembership, GroupMembership.class);
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> membership.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> securityService.setGroupMembership(deploymentName, membership));
    builder.setValidate(ProblemSet::new);
    if (validate) {
        builder.setValidate(() -> securityService.validateAuthz(deploymentName));
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit group membership settings");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) GroupMembership(com.netflix.spinnaker.halyard.config.model.v1.security.GroupMembership) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 45 with Halconfig

use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.

the class SecurityController method setSpringSSl.

@RequestMapping(value = "/api/ssl/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setSpringSSl(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawSpringSsl) {
    SpringSsl apacheSsl = objectMapper.convertValue(rawSpringSsl, SpringSsl.class);
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> apacheSsl.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> securityService.setSpringSsl(deploymentName, apacheSsl));
    builder.setValidate(ProblemSet::new);
    if (validate) {
        builder.setValidate(() -> securityService.validateSpringSsl(deploymentName));
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit API SSL settings");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) SpringSsl(com.netflix.spinnaker.halyard.config.model.v1.security.SpringSsl) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)36 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)35 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)33 Path (java.nio.file.Path)33 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)11 Halconfig (com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig)10 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)9 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)7 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)6 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)5 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)5 IOException (java.io.IOException)5 Node (com.netflix.spinnaker.halyard.config.model.v1.node.Node)4 AbstractCanaryAccount (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)3 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)3 List (java.util.List)3 ParseConfigException (com.netflix.spinnaker.halyard.config.error.v1.ParseConfigException)2 ArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)2 ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)2 BaseImage (com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage)2