@Override protected Account buildAccount(String accountName) { DCOSAccount account = (DCOSAccount) new DCOSAccount().setName(accountName); dockerRegistries.forEach(registryName -> account.getDockerRegistries().add(new DockerRegistryReference().setAccountName(registryName))); if (!isNull(serviceKeyFile) && !isNull(password)) { throw new IllegalArgumentException("Only one of --service-key-file or --password may be set"); } account.setClusters(Lists.newArrayList(new ClusterCredential(cluster, uid, password, serviceKeyFile))); return account; }
account.removeCredential(removeCredential.get(0), removeCredential.get(1)); final String uid = updateUserCredential.get(1); final String password = updateUserCredential.get(2); account.removeCredential(clusterName, uid); final DCOSAccount.ClusterCredential credential = new DCOSAccount.ClusterCredential(clusterName, uid, password, null); account.getClusters().add(credential); final String serviceKeyFile = updateServiceCredential.get(2); account.removeCredential(clusterName, uid); final DCOSAccount.ClusterCredential credential = new DCOSAccount.ClusterCredential(clusterName, uid, null, serviceKeyFile); account.getClusters().add(credential); List<String> oldRegistries = account.getDockerRegistries() .stream() .map(DockerRegistryReference::getAccountName) .collect(Collectors.toList()); account.setDockerRegistries(newRegistries); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Set either --docker-registries or --[add/remove]-docker-registry");
Node parent = account.getParent(); while (!(parent instanceof DeploymentConfiguration)) { if (account.getClusters().isEmpty()) { problems.addProblem(ERROR, "Account does not have any clusters configured") .setRemediation("Edit the account with either --update-user-credential or --update-service-credential"); final List<String> dockerRegistryNames = account.getDockerRegistries().stream().map(DockerRegistryReference::getAccountName) .collect(Collectors.toList()); validateDockerRegistries(problems, deploymentConfiguration, dockerRegistryNames, Provider.ProviderType.DCOS);
private void validateClusters(final ConfigProblemSetBuilder problems, final DCOSAccount account) { final NodeIterator children = account.getParent().getChildren(); final Set<String> accountClusters = account.getClusters().stream().map(c -> c.getName()) .collect(Collectors.toSet()); accountClusters.removeAll(definedClusters); account.getClusters().forEach(c -> { final List<String> key = Lists.newArrayList(c.getName(), c.getUid()); if (credentials.contains(key)) {
@Override protected Account emptyAccount() { return new DCOSAccount(); } }
protected List<String> dockerRegistriesOptions(ConfigProblemSetBuilder psBuilder) { DeploymentConfiguration context = parentOfType(DeploymentConfiguration.class); DockerRegistryProvider dockerRegistryProvider = context.getProviders().getDockerRegistry(); if (dockerRegistryProvider != null) { return dockerRegistryProvider .getAccounts() .stream() .map(Account::getName) .collect(Collectors.toList()); } else { return null; } }
account.removeCredential(removeCredential.get(0), removeCredential.get(1)); final String uid = updateUserCredential.get(1); final String password = updateUserCredential.get(2); account.removeCredential(clusterName, uid); final DCOSAccount.ClusterCredential credential = new DCOSAccount.ClusterCredential(clusterName, uid, password, null); account.getClusters().add(credential); final String serviceKeyFile = updateServiceCredential.get(2); account.removeCredential(clusterName, uid); final DCOSAccount.ClusterCredential credential = new DCOSAccount.ClusterCredential(clusterName, uid, null, serviceKeyFile); account.getClusters().add(credential); List<String> oldRegistries = account.getDockerRegistries() .stream() .map(DockerRegistryReference::getAccountName) .collect(Collectors.toList()); account.setDockerRegistries(newRegistries); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Set either --docker-registries or --[add/remove]-docker-registry");
Node parent = account.getParent(); while (!(parent instanceof DeploymentConfiguration)) { if (account.getClusters().isEmpty()) { problems.addProblem(ERROR, "Account does not have any clusters configured") .setRemediation("Edit the account with either --update-user-credential or --update-service-credential"); final List<String> dockerRegistryNames = account.getDockerRegistries().stream().map(DockerRegistryReference::getAccountName) .collect(Collectors.toList()); validateDockerRegistries(problems, deploymentConfiguration, dockerRegistryNames, Provider.ProviderType.DCOS);
private void validateClusters(final ConfigProblemSetBuilder problems, final DCOSAccount account) { final NodeIterator children = account.getParent().getChildren(); final Set<String> accountClusters = account.getClusters().stream().map(c -> c.getName()) .collect(Collectors.toSet()); accountClusters.removeAll(definedClusters); account.getClusters().forEach(c -> { final List<String> key = Lists.newArrayList(c.getName(), c.getUid()); if (credentials.contains(key)) {
@Override protected Account emptyAccount() { return new DCOSAccount(); } }
protected List<String> dockerRegistriesOptions(ConfigProblemSetBuilder psBuilder) { DeploymentConfiguration context = parentOfType(DeploymentConfiguration.class); DockerRegistryProvider dockerRegistryProvider = context.getProviders().getDockerRegistry(); if (dockerRegistryProvider != null) { return dockerRegistryProvider .getAccounts() .stream() .map(Account::getName) .collect(Collectors.toList()); } else { return null; } }
@Override protected Account buildAccount(String accountName) { DCOSAccount account = (DCOSAccount) new DCOSAccount().setName(accountName); dockerRegistries.forEach(registryName -> account.getDockerRegistries().add(new DockerRegistryReference().setAccountName(registryName))); if (!isNull(serviceKeyFile) && !isNull(password)) { throw new IllegalArgumentException("Only one of --service-key-file or --password may be set"); } account.setClusters(Lists.newArrayList(new ClusterCredential(cluster, uid, password, serviceKeyFile))); return account; }