@Override public void validate(ConfigProblemSetBuilder p, DeploymentConfiguration n) { String timezone = n.getTimezone(); if (Arrays.stream(TimeZone.getAvailableIDs()).noneMatch(t -> t.equals(timezone))) { p.addProblem(Problem.Severity.ERROR, "Timezone " + timezone + " does not match any known canonical timezone ID") .setRemediation("Pick a timezone from those listed here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"); } }
@Override public void validate(ConfigProblemSetBuilder p, DeploymentConfiguration n) { String timezone = n.getTimezone(); if (Arrays.stream(TimeZone.getAvailableIDs()).noneMatch(t -> t.equals(timezone))) { p.addProblem(Problem.Severity.ERROR, "Timezone " + timezone + " does not match any known canonical timezone ID") .setRemediation("Pick a timezone from those listed here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"); } }
private void validateGitDeployment(ConfigProblemSetBuilder p, DeploymentEnvironment n) { if (StringUtils.isEmpty(n.getGitConfig().getOriginUser())) { p.addProblem(Problem.Severity.FATAL, "A git origin user must be supplied when deploying from git.") .setRemediation("Your github username is recommended."); } if (StringUtils.isEmpty(n.getGitConfig().getUpstreamUser())) { p.addProblem(Problem.Severity.FATAL, "A git upstream user must be supplied when deploying from git.") .setRemediation("The user 'spinnaker' is recommended (unless you have a fork maintained by the org you develop under)."); } }
private void validateGitDeployment(ConfigProblemSetBuilder p, DeploymentEnvironment n) { if (StringUtils.isEmpty(n.getGitConfig().getOriginUser())) { p.addProblem(Problem.Severity.FATAL, "A git origin user must be supplied when deploying from git.") .setRemediation("Your github username is recommended."); } if (StringUtils.isEmpty(n.getGitConfig().getUpstreamUser())) { p.addProblem(Problem.Severity.FATAL, "A git upstream user must be supplied when deploying from git.") .setRemediation("The user 'spinnaker' is recommended (unless you have a fork maintained by the org you develop under)."); } }
@Override public void validate(ConfigProblemSetBuilder p, AbstractCanaryAccount n) { if (n.getName() == null) { p.addProblem(Severity.FATAL, "Canary account name must be specified"); } else if (!Pattern.matches(namePattern, n.getName())) { p.addProblem(Severity.ERROR, "Canary account name must match pattern " + namePattern) .setRemediation("It must start and end with a lower-case character or number, and only contain lower-case characters, numbers, dashes, or underscores"); } } }
@Override public void validate(ConfigProblemSetBuilder p, AbstractCanaryAccount n) { if (n.getName() == null) { p.addProblem(Severity.FATAL, "Canary account name must be specified"); } else if (!Pattern.matches(namePattern, n.getName())) { p.addProblem(Severity.ERROR, "Canary account name must match pattern " + namePattern) .setRemediation("It must start and end with a lower-case character or number, and only contain lower-case characters, numbers, dashes, or underscores"); } } }
@Override public void validate(final ConfigProblemSetBuilder p, final DCOSProvider provider) { Set<String> clusters = new HashSet<>(); for (DCOSCluster cluster : provider.getClusters()) { if (clusters.contains(cluster.getName())) { p.addProblem(Problem.Severity.FATAL, "Account \"" + cluster.getName() + "\" appears more than once") .setRemediation("Change the name of the cluster in " + provider.getNodeName()); } else { clusters.add(cluster.getName()); } } } }
@Override public void validate(final ConfigProblemSetBuilder p, final DCOSProvider provider) { Set<String> clusters = new HashSet<>(); for (DCOSCluster cluster : provider.getClusters()) { if (clusters.contains(cluster.getName())) { p.addProblem(Problem.Severity.FATAL, "Account \"" + cluster.getName() + "\" appears more than once") .setRemediation("Change the name of the cluster in " + provider.getNodeName()); } else { clusters.add(cluster.getName()); } } } }
private BaseImage getBaseImage(NodeFilter filter, String baseImageName) { List<BaseImage> matchingBaseImages = lookupService.getMatchingNodesOfType(filter, BaseImage.class); switch (matchingBaseImages.size()) { case 0: throw new ConfigNotFoundException(new ConfigProblemBuilder( Severity.FATAL, "No base image with name \"" + baseImageName + "\" was found") .setRemediation("Check if this base image was defined in another provider, or create a new one").build()); case 1: return matchingBaseImages.get(0); default: throw new IllegalConfigException(new ConfigProblemBuilder( Severity.FATAL, "More than one base image named \"" + baseImageName + "\" was found") .setRemediation("Manually delete/rename duplicate base images with name \"" + baseImageName + "\" in your halconfig file").build()); } }
private Cluster getCluster(NodeFilter filter, String clusterName) { List<Cluster> matchingClusters = lookupService.getMatchingNodesOfType(filter, Cluster.class); switch (matchingClusters.size()) { case 0: throw new ConfigNotFoundException(new ConfigProblemBuilder( Problem.Severity.FATAL, "No cluster with name \"" + clusterName + "\" was found") .setRemediation("Check if this cluster was defined in another provider, or create a new one").build()); case 1: return matchingClusters.get(0); default: throw new IllegalConfigException(new ConfigProblemBuilder( Problem.Severity.FATAL, "More than one cluster named \"" + clusterName + "\" was found") .setRemediation("Manually delete/rename duplicate clusters with name \"" + clusterName + "\" in your halconfig file").build()); } }
private ArtifactAccount getArtifactAccount(NodeFilter filter, String accountName) { List<ArtifactAccount> matchingArtifactAccounts = lookupService.getMatchingNodesOfType(filter, ArtifactAccount.class); switch (matchingArtifactAccounts.size()) { case 0: throw new ConfigNotFoundException(new ConfigProblemBuilder( Severity.FATAL, "No account with name \"" + accountName + "\" was found") .setRemediation("Check if this artifact account was defined in another provider, or create a new one").build()); case 1: return matchingArtifactAccounts.get(0); default: throw new IllegalConfigException(new ConfigProblemBuilder( Severity.FATAL, "More than one account named \"" + accountName + "\" was found") .setRemediation("Manually delete/rename duplicate artifact accounts with name \"" + accountName + "\" in your halconfig file").build()); } }
private Master getMaster(NodeFilter filter, String masterName) { List<Master> matchingMasters = lookupService.getMatchingNodesOfType(filter, Master.class); switch (matchingMasters.size()) { case 0: throw new ConfigNotFoundException(new ConfigProblemBuilder( Severity.FATAL, "No master with name \"" + masterName + "\" was found") .setRemediation("Check if this master was defined in another Continuous Integration service, or create a new one").build()); case 1: return matchingMasters.get(0); default: throw new IllegalConfigException(new ConfigProblemBuilder( Severity.FATAL, "More than one master named \"" + masterName + "\" was found") .setRemediation("Manually delete/rename duplicate masters with name \"" + masterName + "\" in your halconfig file").build()); } }
private Account getAccount(NodeFilter filter, String accountName) { List<Account> matchingAccounts = lookupService.getMatchingNodesOfType(filter, Account.class); switch (matchingAccounts.size()) { case 0: throw new ConfigNotFoundException(new ConfigProblemBuilder( Severity.FATAL, "No account with name \"" + accountName + "\" was found") .setRemediation("Check if this account was defined in another provider, or create a new one").build()); case 1: return matchingAccounts.get(0); default: throw new IllegalConfigException(new ConfigProblemBuilder( Severity.FATAL, "More than one account named \"" + accountName + "\" was found") .setRemediation("Manually delete/rename duplicate accounts with name \"" + accountName + "\" in your halconfig file").build()); } }
private Cluster getCluster(NodeFilter filter, String clusterName) { List<Cluster> matchingClusters = lookupService.getMatchingNodesOfType(filter, Cluster.class); switch (matchingClusters.size()) { case 0: throw new ConfigNotFoundException(new ConfigProblemBuilder( Problem.Severity.FATAL, "No cluster with name \"" + clusterName + "\" was found") .setRemediation("Check if this cluster was defined in another provider, or create a new one").build()); case 1: return matchingClusters.get(0); default: throw new IllegalConfigException(new ConfigProblemBuilder( Problem.Severity.FATAL, "More than one cluster named \"" + clusterName + "\" was found") .setRemediation("Manually delete/rename duplicate clusters with name \"" + clusterName + "\" in your halconfig file").build()); } }
private Subscription getSubscription(NodeFilter filter, String subscriptionName) { List<Subscription> matchingSubscriptions = lookupService.getMatchingNodesOfType(filter, Subscription.class); switch (matchingSubscriptions.size()) { case 0: throw new ConfigNotFoundException(new ConfigProblemBuilder( Severity.FATAL, "No subscription with name \"" + subscriptionName + "\" was found") .setRemediation("Check if this subscription was defined in another pubsub, or create a new one").build()); case 1: return matchingSubscriptions.get(0); default: throw new IllegalConfigException(new ConfigProblemBuilder( Severity.FATAL, "More than one subscription named \"" + subscriptionName + "\" was found") .setRemediation("Manually delete/rename duplicate subscriptions with name \"" + subscriptionName + "\" in your halconfig file").build()); } }
@Override public void validate(ConfigProblemSetBuilder p, Account n) { if (n.getName() == null) { p.addProblem(Severity.FATAL, "Account name must be specified"); } else if (!Pattern.matches(namePattern, n.getName())) { p.addProblem(Severity.ERROR, "Account name must match pattern " + namePattern) .setRemediation("It must start and end with a lower-case character or number, and only contain lower-case characters, numbers, or dashes"); } if (n.getRequiredGroupMembership() != null && !n.getRequiredGroupMembership().isEmpty()) { p.addProblem(Problem.Severity.WARNING, "requiredGroupMembership has been " + "deprecated. Please consider moving to using permissions with the flags --read-permissions " + "and --write-permissions instead. Read more at https://www.spinnaker.io/setup/security/authorization." ); } } }
@Override public void validate(ConfigProblemSetBuilder p, Account n) { if (n.getName() == null) { p.addProblem(Severity.FATAL, "Account name must be specified"); } else if (!Pattern.matches(namePattern, n.getName())) { p.addProblem(Severity.ERROR, "Account name must match pattern " + namePattern) .setRemediation("It must start and end with a lower-case character or number, and only contain lower-case characters, numbers, or dashes"); } if (n.getRequiredGroupMembership() != null && !n.getRequiredGroupMembership().isEmpty()) { p.addProblem(Problem.Severity.WARNING, "requiredGroupMembership has been " + "deprecated. Please consider moving to using permissions with the flags --read-permissions " + "and --write-permissions instead. Read more at https://www.spinnaker.io/setup/security/authorization." ); } } }
public HaService getHaService(String deploymentName, String serviceName) { NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setDeploymentEnvironment().setHaService(serviceName); List<HaService> matching = lookupService.getMatchingNodesOfType(filter, HaService.class); switch (matching.size()) { case 0: throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No high availability service with name \"" + serviceName + "\" could be found") .setRemediation("Create a new high availability service with name \"" + serviceName + "\"").build()); case 1: return matching.get(0); default: throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "More than one high availability service with name \"" + serviceName + "\" found") .setRemediation("Manually delete or rename duplicate high availability services with name \"" + serviceName + "\" in your halconfig file").build()); } }
public ConfigProblemSetBuilder extend(HalException e) { e.getProblems() .getProblems() .forEach(p -> addProblem(p.getSeverity(), p.getMessage()) .setOptions(p.getOptions()) .setRemediation(p.getRemediation()) ); return this; }
public ConfigProblemSetBuilder extend(HalException e) { e.getProblems() .getProblems() .forEach(p -> addProblem(p.getSeverity(), p.getMessage()) .setOptions(p.getOptions()) .setRemediation(p.getRemediation()) ); return this; }