Search in sources :

Example 46 with DeploymentConfiguration

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

the class MetricStoresService method setMetricStores.

public void setMetricStores(String deploymentName, MetricStores newMetricStores) {
    DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName);
    deploymentConfiguration.setMetricStores(newMetricStores);
}
Also used : DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)

Example 47 with DeploymentConfiguration

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

the class SecurityService method setSecurity.

public void setSecurity(String deploymentName, Security newSecurity) {
    DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName);
    deploymentConfiguration.setSecurity(newSecurity);
}
Also used : DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)

Example 48 with DeploymentConfiguration

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

the class DeploymentConfigurationValidator method validate.

@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");
    }
    String version = n.getVersion();
    Versions versions = versionsService.getVersions();
    boolean localGit = n.getDeploymentEnvironment().getType() == DeploymentType.LocalGit;
    if (StringUtils.isEmpty(version)) {
        p.addProblem(Problem.Severity.WARNING, "You have not yet selected a version of Spinnaker to deploy.", "version");
        return;
    }
    Optional<Versions.IllegalVersion> illegalVersion = versions.getIllegalVersions().stream().filter(v -> v.getVersion().equals(version)).findAny();
    if (illegalVersion.isPresent()) {
        p.addProblem(Problem.Severity.ERROR, "Version \"" + version + "\" may no longer be deployed with Halyard: " + illegalVersion.get().getReason());
        return;
    }
    if (Versions.isBranch(version) && !localGit) {
        p.addProblem(Problem.Severity.FATAL, "You can't run Spinnaker from a branch when your deployment type isn't \"LocalGit\".").setRemediation("Either pick a version (hal version list) or set a different deployment type (hal config deploy edit --type <t>).");
        return;
    }
    try {
        if (!Versions.isBranch(version)) {
            versionsService.getBillOfMaterials(version);
        }
    } catch (HalException e) {
        if (localGit) {
            p.addProblem(Problem.Severity.FATAL, "Could not fetch your desired version.").setRemediation("Is it possible that you're trying to checkout a branch? Prefix the version with \"" + Versions.BRANCH_PREFIX + "\".");
            return;
        }
        p.extend(e);
        return;
    } catch (Exception e) {
        p.addProblem(Problem.Severity.FATAL, "Unexpected error trying to validate version \"" + version + "\": " + e.getMessage(), "version");
        return;
    }
    Optional<Versions.Version> releasedVersion = versions.getVersions().stream().filter(v -> Objects.equals(v.getVersion(), version)).findFirst();
    boolean isReleased = releasedVersion.isPresent();
    String runningVersion = versionsService.getRunningHalyardVersion();
    boolean halyardSnapshotRelease = runningVersion.endsWith("SNAPSHOT");
    if (isReleased && !localGit) {
        String minimumHalyardVersion = releasedVersion.get().getMinimumHalyardVersion();
        if (!halyardSnapshotRelease && !StringUtils.isEmpty(minimumHalyardVersion) && Versions.lessThan(runningVersion, minimumHalyardVersion)) {
            p.addProblem(Problem.Severity.ERROR, "Halyard version \"" + runningVersion + "\" is less than Halyard version \"" + minimumHalyardVersion + "\" required for Spinnaker \"" + version + "\"");
        }
    } else {
        // Checks if version is of the form X.Y.Z
        if (version.matches("\\d+\\.\\d+\\.\\d+")) {
            String majorMinor = Versions.toMajorMinor(version);
            Optional<Versions.Version> patchVersion = versions.getVersions().stream().map(v -> new ImmutablePair<>(v, Versions.toMajorMinor(v.getVersion()))).filter(v -> v.getRight() != null).filter(v -> v.getRight().equals(majorMinor)).map(ImmutablePair::getLeft).findFirst();
            if (patchVersion.isPresent()) {
                p.addProblem(Problem.Severity.WARNING, "Version \"" + version + "\" was patched by \"" + patchVersion.get().getVersion() + "\". Please upgrade when possible.").setRemediation("https://spinnaker.io/setup/install/upgrades/");
            } else {
                p.addProblem(Problem.Severity.WARNING, "Version \"" + version + "\" is no longer supported by the Spinnaker team. Please upgrade when possible.").setRemediation("https://spinnaker.io/setup/install/upgrades/");
            }
        } else {
            p.addProblem(Problem.Severity.WARNING, "Version \"" + version + "\" is not a released (validated) version of Spinnaker.", "version");
        }
    }
}
Also used : DeploymentEnvironment(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment) Arrays(java.util.Arrays) TimeZone(java.util.TimeZone) Autowired(org.springframework.beans.factory.annotation.Autowired) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) DeploymentType(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment.DeploymentType) DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration) ConfigProblemSetBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemSetBuilder) StringUtils(org.apache.commons.lang3.StringUtils) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Objects(java.util.Objects) Component(org.springframework.stereotype.Component) Validator(com.netflix.spinnaker.halyard.config.model.v1.node.Validator) Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) Problem(com.netflix.spinnaker.halyard.core.problem.v1.Problem) Optional(java.util.Optional) VersionsService(com.netflix.spinnaker.halyard.config.services.v1.VersionsService) Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException)

Example 49 with DeploymentConfiguration

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

the class FieldValidator method validateFieldForSpinnakerVersion.

private void validateFieldForSpinnakerVersion(ConfigProblemSetBuilder p, Node n) {
    DeploymentConfiguration deploymentConfiguration = n.parentOfType(DeploymentConfiguration.class);
    String spinnakerVersion = deploymentConfiguration.getVersion();
    if (spinnakerVersion == null) {
        return;
    }
    Class clazz = n.getClass();
    while (clazz != Object.class) {
        Class finalClazz = clazz;
        Arrays.stream(clazz.getDeclaredFields()).forEach(field -> {
            ValidForSpinnakerVersion annotation = field.getDeclaredAnnotation(ValidForSpinnakerVersion.class);
            try {
                field.setAccessible(true);
                Object v = field.get(n);
                boolean fieldNotValid = v != null && annotation != null && Versions.lessThan(spinnakerVersion, annotation.lowerBound());
                // If the field was set to false, it's assumed it's not enabling a restricted feature
                if (fieldNotValid && (v instanceof Boolean) && !((Boolean) v)) {
                    fieldNotValid = false;
                }
                if (fieldNotValid) {
                    p.addProblem(Problem.Severity.WARNING, "Field " + finalClazz.getSimpleName() + "." + field.getName() + " not supported for Spinnaker version " + spinnakerVersion + ": " + annotation.message()).setRemediation("Use at least " + annotation.lowerBound() + " (It may not have been released yet).");
                }
            } catch (NumberFormatException e) {
                log.info("Nightly builds do not contain version information.");
            } catch (IllegalAccessException e) {
                log.warn("Error validating field " + finalClazz.getSimpleName() + "." + field.getName() + ": ", e);
            }
        });
        clazz = clazz.getSuperclass();
    }
}
Also used : DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration) ValidForSpinnakerVersion(com.netflix.spinnaker.halyard.config.model.v1.node.ValidForSpinnakerVersion)

Example 50 with DeploymentConfiguration

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

the class ArtifactProviderService method setArtifactProvider.

public void setArtifactProvider(String deploymentName, ArtifactProvider provider) {
    DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName);
    Artifacts artifacts = deploymentConfiguration.getArtifacts();
    switch(provider.providerType()) {
        case GCS:
            artifacts.setGcs((GcsArtifactProvider) provider);
            break;
        case GITHUB:
            artifacts.setGithub((GitHubArtifactProvider) provider);
            break;
        case HTTP:
            artifacts.setHttp((HttpArtifactProvider) provider);
            break;
        default:
            throw new IllegalArgumentException("Unknown provider type " + provider.providerType());
    }
}
Also used : Artifacts(com.netflix.spinnaker.halyard.config.model.v1.node.Artifacts) DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)

Aggregations

DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)39 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)9 SpinnakerRuntimeSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings)9 DeploymentDetails (com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails)7 DeploymentEnvironment (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment)6 AccountDeploymentDetails (com.netflix.spinnaker.halyard.deploy.deployment.v1.AccountDeploymentDetails)6 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)5 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)5 SpinnakerService (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService)5 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)4 Notifications (com.netflix.spinnaker.halyard.config.model.v1.node.Notifications)4 Provider (com.netflix.spinnaker.halyard.config.model.v1.node.Provider)4 Providers (com.netflix.spinnaker.halyard.config.model.v1.node.Providers)4 RemoteAction (com.netflix.spinnaker.halyard.core.RemoteAction)4 BakeDeployer (com.netflix.spinnaker.halyard.deploy.deployment.v1.BakeDeployer)4 Deployer (com.netflix.spinnaker.halyard.deploy.deployment.v1.Deployer)4 DistributedDeployer (com.netflix.spinnaker.halyard.deploy.deployment.v1.DistributedDeployer)4 KubectlDeployer (com.netflix.spinnaker.halyard.deploy.deployment.v1.KubectlDeployer)4 LocalDeployer (com.netflix.spinnaker.halyard.deploy.deployment.v1.LocalDeployer)4 LocalGitDeployer (com.netflix.spinnaker.halyard.deploy.deployment.v1.LocalGitDeployer)4