@SuppressWarnings("unchecked") DockerRegistryAccountReverseIndex(Providers providers) { super(); NodeIterator providerNodes = providers.getChildren(); Provider provider; while ((provider = (Provider) providerNodes.getNext()) != null) { for (Account a : (List<? extends Account>) provider.getAccounts()) { if (a instanceof ContainerAccount) { ContainerAccount account = (ContainerAccount) a; List<DockerRegistryReference> registries = account.getDockerRegistries(); registries.forEach(reg -> this.computeIfAbsent(reg.getAccountName(), ignored -> new HashSet<>()).add(account)); } } } } }
@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; }
@Override public void makeBootstrappingAccount(ArtifactSourcesConfig artifactSourcesConfig) { super.makeBootstrappingAccount(artifactSourcesConfig); DeploymentConfiguration deploymentConfiguration = parentOfType(DeploymentConfiguration.class); String location = StringUtils.isEmpty(deploymentConfiguration.getDeploymentEnvironment().getLocation()) ? "spinnaker" : deploymentConfiguration.getDeploymentEnvironment().getLocation(); // These changes are only surfaced in the account used by the bootstrapping clouddriver, // the user's clouddriver will be unchanged. if (!namespaces.isEmpty() && !namespaces.contains(location)) { namespaces.add(location); } if (!omitNamespaces.isEmpty() && omitNamespaces.contains(location)) { omitNamespaces.remove(location); } }
@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; }
@SuppressWarnings("unchecked") DockerRegistryAccountReverseIndex(Providers providers) { super(); NodeIterator providerNodes = providers.getChildren(); Provider provider; while ((provider = (Provider) providerNodes.getNext()) != null) { for (Account a : (List<? extends Account>) provider.getAccounts()) { if (a instanceof ContainerAccount) { ContainerAccount account = (ContainerAccount) a; List<DockerRegistryReference> registries = account.getDockerRegistries(); registries.forEach(reg -> this.computeIfAbsent(reg.getAccountName(), ignored -> new HashSet<>()).add(account)); } } } } }
@Override public void makeBootstrappingAccount(ArtifactSourcesConfig artifactSourcesConfig) { super.makeBootstrappingAccount(artifactSourcesConfig); DeploymentConfiguration deploymentConfiguration = parentOfType(DeploymentConfiguration.class); String location = StringUtils.isEmpty(deploymentConfiguration.getDeploymentEnvironment().getLocation()) ? "spinnaker" : deploymentConfiguration.getDeploymentEnvironment().getLocation(); // These changes are only surfaced in the account used by the bootstrapping clouddriver, // the user's clouddriver will be unchanged. if (!namespaces.isEmpty() && !namespaces.contains(location)) { namespaces.add(location); } if (!omitNamespaces.isEmpty() && omitNamespaces.contains(location)) { omitNamespaces.remove(location); } }
removeDockerRegistry) .stream() .map(s -> new DockerRegistryReference().setAccountName(s)) .collect(Collectors.toList());
@SuppressWarnings("unchecked") private void removeBootstrapOnlyAccount(Providers providers, String deploymentName, String bootstrapAccountName) { Account bootstrapAccount = accountService.getAnyProviderAccount(deploymentName, bootstrapAccountName); Provider bootstrapProvider = ((Provider) bootstrapAccount.getParent()); bootstrapProvider.getAccounts().remove(bootstrapAccount); if (bootstrapProvider.getAccounts().isEmpty()) { bootstrapProvider.setEnabled(false); if (bootstrapAccount instanceof ContainerAccount) { ContainerAccount containerAccount = (ContainerAccount) bootstrapAccount; DockerRegistryAccountReverseIndex revIndex = new DockerRegistryAccountReverseIndex(providers); containerAccount.getDockerRegistries().forEach(reg -> { Set<Account> dependentAccounts = revIndex.get(reg.getAccountName()); if (dependentAccounts == null || dependentAccounts.isEmpty()) { DockerRegistryAccount regAcct = (DockerRegistryAccount) accountService.getAnyProviderAccount(deploymentName, reg.getAccountName()); ((DockerRegistryProvider) regAcct.getParent()).getAccounts().remove(regAcct); } }); if (providers.getDockerRegistry().getAccounts().isEmpty()) { providers.getDockerRegistry().setEnabled(false); } } } }
removeDockerRegistry) .stream() .map(s -> new DockerRegistryReference().setAccountName(s)) .collect(Collectors.toList());
@SuppressWarnings("unchecked") private void removeBootstrapOnlyAccount(Providers providers, String deploymentName, String bootstrapAccountName) { Account bootstrapAccount = accountService.getAnyProviderAccount(deploymentName, bootstrapAccountName); Provider bootstrapProvider = ((Provider) bootstrapAccount.getParent()); bootstrapProvider.getAccounts().remove(bootstrapAccount); if (bootstrapProvider.getAccounts().isEmpty()) { bootstrapProvider.setEnabled(false); if (bootstrapAccount instanceof ContainerAccount) { ContainerAccount containerAccount = (ContainerAccount) bootstrapAccount; DockerRegistryAccountReverseIndex revIndex = new DockerRegistryAccountReverseIndex(providers); containerAccount.getDockerRegistries().forEach(reg -> { Set<Account> dependentAccounts = revIndex.get(reg.getAccountName()); if (dependentAccounts == null || dependentAccounts.isEmpty()) { DockerRegistryAccount regAcct = (DockerRegistryAccount) accountService.getAnyProviderAccount(deploymentName, reg.getAccountName()); ((DockerRegistryProvider) regAcct.getParent()).getAccounts().remove(regAcct); } }); if (providers.getDockerRegistry().getAccounts().isEmpty()) { providers.getDockerRegistry().setEnabled(false); } } } }
@Override protected Account buildAccount(String accountName) { KubernetesAccount account = (KubernetesAccount) new KubernetesAccount().setName(accountName); account.setContext(context); account.setKubeconfigFile(kubeconfigFile); account.setNamespaces(namespaces); account.setOmitNamespaces(omitNamespaces); account.setKinds(kinds); account.setOmitKinds(omitKinds); account.setConfigureImagePullSecrets(configureImagePullSecrets); account.setServiceAccount(serviceAccount); dockerRegistries.forEach(registryName -> account.getDockerRegistries().add(new DockerRegistryReference().setAccountName(registryName))); account.setOAuthServiceAccount(oAuthServiceAccount); account.setOAuthScopes(oAuthScopes); account.setNamingStrategy(namingStrategy); account.setSkin(skin); return account; }
ContainerAccount containerAccount = (ContainerAccount) bootstrapAccount; List<DockerRegistryAccount> bootstrapRegistries = containerAccount.getDockerRegistries() .stream() .map(ref -> (DockerRegistryAccount) accountService.getProviderAccount(deploymentName, DOCKER_REGISTRY, ref.getAccountName())) .collect(Collectors.toList());
@Override protected Account buildAccount(String accountName) { KubernetesAccount account = (KubernetesAccount) new KubernetesAccount().setName(accountName); account.setContext(context); account.setKubeconfigFile(kubeconfigFile); account.setNamespaces(namespaces); account.setOmitNamespaces(omitNamespaces); account.setKinds(kinds); account.setOmitKinds(omitKinds); account.setConfigureImagePullSecrets(configureImagePullSecrets); account.setServiceAccount(serviceAccount); dockerRegistries.forEach(registryName -> account.getDockerRegistries().add(new DockerRegistryReference().setAccountName(registryName))); account.setOAuthServiceAccount(oAuthServiceAccount); account.setOAuthScopes(oAuthScopes); account.setNamingStrategy(namingStrategy); account.setSkin(skin); account.setOnlySpinnakerManaged(onlySpinnakerManaged); account.setCheckPermissionsOnStartup(checkPermissionsOnStartup); return account; }
ContainerAccount containerAccount = (ContainerAccount) bootstrapAccount; List<DockerRegistryAccount> bootstrapRegistries = containerAccount.getDockerRegistries() .stream() .map(ref -> (DockerRegistryAccount) accountService.getProviderAccount(deploymentName, DOCKER_REGISTRY, ref.getAccountName())) .collect(Collectors.toList());
.map(s -> new DockerRegistryReference().setAccountName(s)) .collect(Collectors.toList());
.map(s -> new DockerRegistryReference().setAccountName(s)) .collect(Collectors.toList());