Search in sources :

Example 1 with Pubsubs

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

the class PubsubService method getPubsub.

public Pubsub getPubsub(String deploymentName, String pubsubName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setPubsub(pubsubName);
    List<Pubsub> matching = lookupService.getMatchingNodesOfType(filter, Pubsub.class);
    switch(matching.size()) {
        case 0:
            throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No pubsub with name \"" + pubsubName + "\" could be found").setRemediation("Create a new pubsub with name \"" + pubsubName + "\"").build());
        case 1:
            return matching.get(0);
        default:
            throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "More than one pubsub with name \"" + pubsubName + "\" found").setRemediation("Manually delete or rename duplicate pubsubs with name \"" + pubsubName + "\" in your halconfig file").build());
    }
}
Also used : Pubsub(com.netflix.spinnaker.halyard.config.model.v1.node.Pubsub) GooglePubsub(com.netflix.spinnaker.halyard.config.model.v1.pubsub.google.GooglePubsub) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) IllegalConfigException(com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 2 with Pubsubs

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

the class EchoProfileFactory method setProfile.

@Override
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
    super.setProfile(profile, deploymentConfiguration, endpoints);
    List<String> files = new ArrayList<>();
    profile.appendContents("global.spinnaker.timezone: " + deploymentConfiguration.getTimezone());
    profile.appendContents("spinnaker.baseUrl: " + endpoints.getServices().getDeck().getBaseUrl());
    Notifications notifications = deploymentConfiguration.getNotifications();
    if (notifications != null) {
        files.addAll(backupRequiredFiles(notifications, deploymentConfiguration.getName()));
        profile.appendContents(yamlToString(notifications));
    }
    Pubsubs pubsubs = deploymentConfiguration.getPubsub();
    if (pubsubs != null) {
        files.addAll(backupRequiredFiles(pubsubs, deploymentConfiguration.getName()));
        profile.appendContents(yamlToString(new PubsubWrapper(pubsubs)));
    }
    profile.appendContents(profile.getBaseContents()).setRequiredFiles(files);
}
Also used : Pubsubs(com.netflix.spinnaker.halyard.config.model.v1.node.Pubsubs) ArrayList(java.util.ArrayList) Notifications(com.netflix.spinnaker.halyard.config.model.v1.node.Notifications)

Example 3 with Pubsubs

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

the class PubsubService method setPubsub.

public void setPubsub(String deploymentName, Pubsub pubsub) {
    DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName);
    Pubsubs pubsubs = deploymentConfiguration.getPubsub();
    switch(pubsub.pubsubType()) {
        case GOOGLE:
            pubsubs.setGoogle((GooglePubsub) pubsub);
            break;
        default:
            throw new IllegalArgumentException("Unknown pubsub type " + pubsub.pubsubType());
    }
}
Also used : Pubsubs(com.netflix.spinnaker.halyard.config.model.v1.node.Pubsubs) DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)

Example 4 with Pubsubs

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

the class PubsubService method getAllPubsubs.

public List<Pubsub> getAllPubsubs(String deploymentName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).withAnyPubsub();
    List<Pubsub> matching = lookupService.getMatchingNodesOfType(filter, Pubsub.class);
    if (matching.size() == 0) {
        throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No pubsubs could be found").build());
    } else {
        return matching;
    }
}
Also used : Pubsub(com.netflix.spinnaker.halyard.config.model.v1.node.Pubsub) GooglePubsub(com.netflix.spinnaker.halyard.config.model.v1.pubsub.google.GooglePubsub) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Aggregations

ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)2 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)2 Pubsub (com.netflix.spinnaker.halyard.config.model.v1.node.Pubsub)2 Pubsubs (com.netflix.spinnaker.halyard.config.model.v1.node.Pubsubs)2 GooglePubsub (com.netflix.spinnaker.halyard.config.model.v1.pubsub.google.GooglePubsub)2 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)2 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)1 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)1 Notifications (com.netflix.spinnaker.halyard.config.model.v1.node.Notifications)1 ArrayList (java.util.ArrayList)1