Skip to content

Commit 6332eb3

Browse files
committed
fixup! Rework the gitconfig configmap configurator
1 parent 5599a48 commit 6332eb3

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironmentFactory;
4949
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.RemoveNamespaceOnWorkspaceRemove;
5050
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.CredentialsSecretConfigurator;
51-
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.GitconfigConfigmapConfigurator;
51+
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.GitconfigConfigurator;
5252
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.NamespaceConfigurator;
5353
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.OAuthTokenSecretsConfigurator;
5454
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.PreferencesConfigMapConfigurator;
@@ -109,7 +109,7 @@ protected void configure() {
109109
namespaceConfigurators.addBinding().to(WorkspaceServiceAccountConfigurator.class);
110110
namespaceConfigurators.addBinding().to(UserProfileConfigurator.class);
111111
namespaceConfigurators.addBinding().to(UserPreferencesConfigurator.class);
112-
namespaceConfigurators.addBinding().to(GitconfigConfigmapConfigurator.class);
112+
namespaceConfigurators.addBinding().to(GitconfigConfigurator.class);
113113

114114
bind(AuthorizationChecker.class).to(KubernetesAuthorizationCheckerImpl.class);
115115
bind(PermissionsCleaner.class).asEagerSingleton();
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
import org.slf4j.Logger;
3939
import org.slf4j.LoggerFactory;
4040

41-
public class GitconfigConfigmapConfigurator implements NamespaceConfigurator {
41+
public class GitconfigConfigurator implements NamespaceConfigurator {
4242
private final CheServerKubernetesClientFactory cheServerKubernetesClientFactory;
4343
private final Set<GitUserDataFetcher> gitUserDataFetchers;
44-
private static final Logger LOG = LoggerFactory.getLogger(GitconfigConfigmapConfigurator.class);
44+
private static final Logger LOG = LoggerFactory.getLogger(GitconfigConfigurator.class);
4545
private static final String CONFIGMAP_DATA_KEY = "gitconfig";
4646
// TODO: rename to a more generic name, since it is not only for user data
4747
private static final String GITCONFIG_CONFIGMAP_NAME = "workspace-userdata-gitconfig-configmap";
@@ -63,7 +63,7 @@ public class GitconfigConfigmapConfigurator implements NamespaceConfigurator {
6363
Pattern.compile("\\[(?<sectionName>[a-zA-Z0-9]+)](\\n\\s*\\S*\\s*=.*)*");
6464

6565
@Inject
66-
public GitconfigConfigmapConfigurator(
66+
public GitconfigConfigurator(
6767
CheServerKubernetesClientFactory cheServerKubernetesClientFactory,
6868
Set<GitUserDataFetcher> gitUserDataFetchers) {
6969
this.cheServerKubernetesClientFactory = cheServerKubernetesClientFactory;
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import org.testng.annotations.Test;
3838

3939
@Listeners(MockitoTestNGListener.class)
40-
public class GitconfigConfigmapConfiguratorTest {
40+
public class GitconfigConfiguratorTest {
4141

4242
private NamespaceConfigurator configurator;
4343

@@ -65,8 +65,7 @@ public class GitconfigConfigmapConfiguratorTest {
6565
public void setUp()
6666
throws InfrastructureException, ScmCommunicationException, ScmUnauthorizedException {
6767
configurator =
68-
new GitconfigConfigmapConfigurator(
69-
cheServerKubernetesClientFactory, Collections.emptySet());
68+
new GitconfigConfigurator(cheServerKubernetesClientFactory, Collections.emptySet());
7069

7170
serverMock = new KubernetesServer(true, true);
7271
serverMock.before();
@@ -83,8 +82,7 @@ public void shouldCreateGitconfigConfigmapWithUserSection() throws Exception {
8382
when(gitUserDataFetcher.fetchGitUserData())
8483
.thenReturn(new GitUserData("username", "userEmail"));
8584
configurator =
86-
new GitconfigConfigmapConfigurator(
87-
cheServerKubernetesClientFactory, Set.of(gitUserDataFetcher));
85+
new GitconfigConfigurator(cheServerKubernetesClientFactory, Set.of(gitUserDataFetcher));
8886
// when
8987
configurator.configure(namespaceResolutionContext, TEST_NAMESPACE_NAME);
9088
// then
@@ -125,8 +123,7 @@ public void shouldUpdateGitconfigConfigmapWithUserSection()
125123
Collections.singletonMap("gitconfig", "[user]\n\tname = \"\"\n\temail= \"\""));
126124
serverMock.getClient().configMaps().inNamespace(TEST_NAMESPACE_NAME).create(gitconfigConfigmap);
127125
configurator =
128-
new GitconfigConfigmapConfigurator(
129-
cheServerKubernetesClientFactory, Set.of(gitUserDataFetcher));
126+
new GitconfigConfigurator(cheServerKubernetesClientFactory, Set.of(gitUserDataFetcher));
130127
when(gitUserDataFetcher.fetchGitUserData())
131128
.thenReturn(new GitUserData("username", "userEmail"));
132129
// when
@@ -160,8 +157,7 @@ public void shouldUpdateGitconfigConfigmapWithStoredSectionsWithUserSection()
160157
"[other]\n\tkey = value\n[other1]\n\tkey = value\n[user]\n\tname = \"\"\n\temail= \"\""));
161158
serverMock.getClient().configMaps().inNamespace(TEST_NAMESPACE_NAME).create(gitconfigConfigmap);
162159
configurator =
163-
new GitconfigConfigmapConfigurator(
164-
cheServerKubernetesClientFactory, Set.of(gitUserDataFetcher));
160+
new GitconfigConfigurator(cheServerKubernetesClientFactory, Set.of(gitUserDataFetcher));
165161
when(gitUserDataFetcher.fetchGitUserData())
166162
.thenReturn(new GitUserData("username", "userEmail"));
167163
// when
@@ -195,8 +191,7 @@ public void shouldNotUpdateGitconfigConfigmapWithUserSection()
195191
"gitconfig", "[user]\n\tname = gitconfig-username\n\temail = gitconfig-email"));
196192
serverMock.getClient().configMaps().inNamespace(TEST_NAMESPACE_NAME).create(gitconfigConfigmap);
197193
configurator =
198-
new GitconfigConfigmapConfigurator(
199-
cheServerKubernetesClientFactory, Set.of(gitUserDataFetcher));
194+
new GitconfigConfigurator(cheServerKubernetesClientFactory, Set.of(gitUserDataFetcher));
200195
when(gitUserDataFetcher.fetchGitUserData())
201196
.thenReturn(new GitUserData("fetcher-username", "fetcher-userEmail"));
202197
// when

infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
import org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironmentFactory;
5252
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesNamespaceFactory;
5353
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.CredentialsSecretConfigurator;
54-
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.GitconfigConfigmapConfigurator;
54+
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.GitconfigConfigurator;
5555
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.NamespaceConfigurator;
5656
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.OAuthTokenSecretsConfigurator;
5757
import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.PreferencesConfigMapConfigurator;
@@ -115,7 +115,7 @@ protected void configure() {
115115
namespaceConfigurators.addBinding().to(OAuthTokenSecretsConfigurator.class);
116116
namespaceConfigurators.addBinding().to(PreferencesConfigMapConfigurator.class);
117117
namespaceConfigurators.addBinding().to(OpenShiftWorkspaceServiceAccountConfigurator.class);
118-
namespaceConfigurators.addBinding().to(GitconfigConfigmapConfigurator.class);
118+
namespaceConfigurators.addBinding().to(GitconfigConfigurator.class);
119119

120120
bind(AuthorizationChecker.class).to(OpenShiftAuthorizationCheckerImpl.class);
121121
bind(PermissionsCleaner.class).asEagerSingleton();

0 commit comments

Comments
 (0)