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());
}
}
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;
}
}
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");
}
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()));
}
}
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());
}
}
Aggregations