use of com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount in project halyard by spinnaker.
the class AbstractAddArtifactAccountCommand method executeThis.
@Override
protected void executeThis() {
String accountName = getArtifactAccountName();
ArtifactAccount account = buildArtifactAccount(accountName);
String providerName = getArtifactProviderName();
String currentDeployment = getCurrentDeployment();
new OperationHandler<Void>().setFailureMesssage("Failed to add artifact account " + accountName + " for artifact provider " + providerName + ".").setSuccessMessage("Successfully added artifact account " + accountName + " for artifact provider " + providerName + ".").setOperation(Daemon.addArtifactAccount(currentDeployment, providerName, !noValidate, account)).get();
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount in project halyard by spinnaker.
the class GitHubAddArtifactAccountCommand method buildArtifactAccount.
@Override
protected ArtifactAccount buildArtifactAccount(String accountName) {
GitHubArtifactAccount artifactAccount = new GitHubArtifactAccount().setName(accountName);
artifactAccount.setUsername(username).setPassword(password).setUsernamePasswordFile(usernamePasswordFile).setToken(token).setTokenFile(tokenFile);
return artifactAccount;
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount in project halyard by spinnaker.
the class ArtifactAccountController method setArtifactAccount.
@RequestMapping(value = "/account/{accountName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setArtifactAccount(@PathVariable String deploymentName, @PathVariable String providerName, @PathVariable String accountName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawArtifactAccount) {
ArtifactAccount account = objectMapper.convertValue(rawArtifactAccount, Artifacts.translateArtifactAccountType(providerName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> account.stageLocalFiles(configPath));
builder.setUpdate(() -> accountService.setArtifactAccount(deploymentName, providerName, accountName, account));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> accountService.validateArtifactAccount(deploymentName, providerName, account.getName());
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit the " + accountName + " artifact account");
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount in project halyard by spinnaker.
the class ArtifactAccountController method addArtifactAccount.
@RequestMapping(value = "/", method = RequestMethod.POST)
DaemonTask<Halconfig, Void> addArtifactAccount(@PathVariable String deploymentName, @PathVariable String providerName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawArtifactAccount) {
ArtifactAccount account = objectMapper.convertValue(rawArtifactAccount, Artifacts.translateArtifactAccountType(providerName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> account.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> accountService.addArtifactAccount(deploymentName, providerName, account));
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> accountService.validateArtifactAccount(deploymentName, providerName, account.getName());
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Add the " + account.getName() + " artifact account");
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount in project halyard by spinnaker.
the class ArtifactAccountService method getAllArtifactAccounts.
public List<ArtifactAccount> getAllArtifactAccounts(String deploymentName, String providerName) {
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setArtifactProvider(providerName).withAnyArtifactAccount();
List<ArtifactAccount> matchingArtifactAccounts = lookupService.getMatchingNodesOfType(filter, ArtifactAccount.class);
if (matchingArtifactAccounts.size() == 0) {
throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No accounts could be found").build());
} else {
return matchingArtifactAccounts;
}
}
Aggregations