Search in sources :

Example 1 with ArtifactProvider

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

the class ArtifactAccountService method deleteArtifactAccount.

public void deleteArtifactAccount(String deploymentName, String providerName, String accountName) {
    ArtifactProvider provider = artifactProviderService.getArtifactProvider(deploymentName, providerName);
    boolean removed = provider.getAccounts().removeIf(account -> ((ArtifactAccount) account).getName().equals(accountName));
    if (!removed) {
        throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Artifact account \"" + accountName + "\" wasn't found").build());
    }
}
Also used : ArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) ArtifactAccount(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)

Example 2 with ArtifactProvider

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

the class ArtifactProviderService method getAllArtifactProviders.

public List<ArtifactProvider> getAllArtifactProviders(String deploymentName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).withAnyArtifactProvider();
    List<ArtifactProvider> matching = lookupService.getMatchingNodesOfType(filter, ArtifactProvider.class);
    if (matching.size() == 0) {
        throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No providers could be found").build());
    } else {
        return matching;
    }
}
Also used : GitHubArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.artifacts.github.GitHubArtifactProvider) ArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider) HttpArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.artifacts.http.HttpArtifactProvider) GcsArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.artifacts.gcs.GcsArtifactProvider) 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)

Example 3 with ArtifactProvider

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

the class ArtifactProviderController method setArtifactProvider.

@RequestMapping(value = "/{providerName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setArtifactProvider(@PathVariable String deploymentName, @PathVariable String providerName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawArtifactProvider) {
    ArtifactProvider provider = objectMapper.convertValue(rawArtifactProvider, Artifacts.translateArtifactProviderType(providerName));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> provider.stageLocalFiles(configPath));
    builder.setUpdate(() -> providerService.setArtifactProvider(deploymentName, provider));
    builder.setSeverity(severity);
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> providerService.validateArtifactProvider(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) ArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider) 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 4 with ArtifactProvider

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

the class AbstractListArtifactAccountsCommand method executeThis.

@Override
protected void executeThis() {
    ArtifactProvider provider = getArtifactProvider();
    List<ArtifactAccount> accounts = provider.getAccounts();
    if (accounts.isEmpty()) {
        AnsiUi.success("No configured artifact accounts for " + getArtifactProviderName() + ".");
    } else {
        AnsiUi.success("Artifact accounts for " + getArtifactProviderName() + ":");
        accounts.forEach(account -> AnsiUi.listItem(account.getName()));
    }
}
Also used : ArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider) ArtifactAccount(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)

Example 5 with ArtifactProvider

use of com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider 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

ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)7 GcsArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.artifacts.gcs.GcsArtifactProvider)3 GitHubArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.artifacts.github.GitHubArtifactProvider)3 HttpArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.artifacts.http.HttpArtifactProvider)3 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)3 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)2 ArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)2 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)2 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)1 Artifacts (com.netflix.spinnaker.halyard.config.model.v1.node.Artifacts)1 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)1 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)1 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)1 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)1 Path (java.nio.file.Path)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1