use of org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.DockerAuthConfigs in project che-server by eclipse-che.
the class ImagePullSecretProvisioner method provision.
@Override
@Traced
public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity) throws InfrastructureException {
TracingTags.WORKSPACE_ID.set(identity::getWorkspaceId);
DockerAuthConfigs credentials = credentialsProvider.getCredentials();
if (credentials == null) {
return;
}
Map<String, DockerAuthConfig> authConfigs = credentials.getConfigs();
if (authConfigs == null || authConfigs.isEmpty()) {
return;
}
String encodedConfig = Base64.getEncoder().encodeToString(generateDockerCfg(authConfigs).getBytes());
Secret secret = new SecretBuilder().addToData(".dockercfg", encodedConfig).withType("kubernetes.io/dockercfg").withNewMetadata().withName(identity.getWorkspaceId() + SECRET_NAME_SUFFIX).endMetadata().build();
k8sEnv.getSecrets().put(secret.getMetadata().getName(), secret);
k8sEnv.getPodsData().values().forEach(p -> addImagePullSecret(secret.getMetadata().getName(), p.getSpec()));
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.DockerAuthConfigs in project che-server by eclipse-che.
the class UserSpecificDockerRegistryCredentialsProviderTest method shouldParseCredentialsFromUserPreferences.
@Test
public void shouldParseCredentialsFromUserPreferences() throws ServerException {
String base64encodedCredentials = "eyJyZWdpc3RyeS5jb206NTAwMCI6eyJ1c2VybmFtZSI6ImxvZ2luIiwicGFzc3dvcmQiOiJwYXNzIn19";
setCredentialsIntoPreferences(base64encodedCredentials);
String registry = "registry.com:5000";
DockerAuthConfig dockerAuthConfig = DtoFactory.newDto(DockerAuthConfig.class).withUsername("login").withPassword("pass");
DockerAuthConfigs parsedDockerAuthConfigs = dockerCredentials.getCredentials();
DockerAuthConfig parsedDockerAuthConfig = parsedDockerAuthConfigs.getConfigs().get(registry);
assertNotNull(parsedDockerAuthConfig);
assertEquals(parsedDockerAuthConfig.getUsername(), dockerAuthConfig.getUsername());
assertEquals(parsedDockerAuthConfig.getPassword(), dockerAuthConfig.getPassword());
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.DockerAuthConfigs in project che-server by eclipse-che.
the class UserSpecificDockerRegistryCredentialsProviderTest method shouldReturnNullIfDataFormatIsCorruptedInPreferences.
@Test
public void shouldReturnNullIfDataFormatIsCorruptedInPreferences() throws ServerException {
String base64encodedCredentials = "sdJfpwJwkek59kafj239lFfkHjhek5l1";
setCredentialsIntoPreferences(base64encodedCredentials);
DockerAuthConfigs parsedDockerAuthConfigs = dockerCredentials.getCredentials();
assertNull(parsedDockerAuthConfigs);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.DockerAuthConfigs in project che-server by eclipse-che.
the class UserSpecificDockerRegistryCredentialsProviderTest method shouldReturnNullIfDataFormatIsWrong.
@Test
public void shouldReturnNullIfDataFormatIsWrong() throws ServerException {
String base64encodedCredentials = "eyJpbnZhbGlkIjoianNvbiJ9";
setCredentialsIntoPreferences(base64encodedCredentials);
DockerAuthConfigs parsedDockerAuthConfigs = dockerCredentials.getCredentials();
assertNull(parsedDockerAuthConfigs);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.DockerAuthConfigs in project devspaces-images by redhat-developer.
the class UserSpecificDockerRegistryCredentialsProviderTest method shouldReturnNullIfDataFormatIsWrong.
@Test
public void shouldReturnNullIfDataFormatIsWrong() throws ServerException {
String base64encodedCredentials = "eyJpbnZhbGlkIjoianNvbiJ9";
setCredentialsIntoPreferences(base64encodedCredentials);
DockerAuthConfigs parsedDockerAuthConfigs = dockerCredentials.getCredentials();
assertNull(parsedDockerAuthConfigs);
}
Aggregations