Skip to content

Commit 2fc5373

Browse files
rawlingsjl0rd
authored andcommitted
kubernetes-client will autodetect auth details both inside and outside openshift so no need to use config
for more information including the order configuration is decided see https://github.com/fabric8io/kubernetes-client#configuring-the-client fixes https://issues.jboss.org/browse/CHE-117 Signed-off-by: rawlingsj <rawlingsj80@gmail.com>
1 parent 3a63f1b commit 2fc5373

4 files changed

Lines changed: 2 additions & 94 deletions

File tree

assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/codenvy/che.properties

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,6 @@ db.schema.flyway.scripts.locations=classpath:che-schema
279279
db.jndi.datasource.name=java:/comp/env/jdbc/che
280280

281281
# OpenShift related properties
282-
che.openshift.endpoint=https://192.168.64.2:8443/
283-
che.openshift.token=
284-
che.openshift.username=openshift-dev
285-
che.openshift.password=devel
286282
che.openshift.project=eclipse-che
287283
che.openshift.serviceaccountname=cheserviceaccount
288284
che.openshift.liveness.probe.delay=300

plugins/plugin-docker/che-plugin-openshift-client/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@
5555
<groupId>javax.inject</groupId>
5656
<artifactId>javax.inject</artifactId>
5757
</dependency>
58-
<dependency>
59-
<groupId>org.eclipse.che.core</groupId>
60-
<artifactId>che-core-commons-annotations</artifactId>
61-
</dependency>
6258
<dependency>
6359
<groupId>org.eclipse.che.plugin</groupId>
6460
<artifactId>che-plugin-docker-client</artifactId>

plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnector.java

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ public OpenShiftConnector(ConfigBuilder configBuilder,
143143
DockerConnectionFactory connectionFactory,
144144
DockerRegistryAuthResolver authResolver,
145145
DockerApiVersionPathPrefixProvider dockerApiVersionPathPrefixProvider,
146-
@Named("che.openshift.endpoint") String openShiftApiEndpoint,
147-
@Nullable @Named("che.openshift.token") String openShiftToken,
148-
@Nullable @Named("che.openshift.username") String openShiftUserName,
149-
@Nullable @Named("che.openshift.password") String openShiftUserPassword,
150146
@Named("che.openshift.project") String openShiftCheProjectName,
151147
@Named("che.openshift.serviceaccountname") String openShiftCheServiceAccount,
152148
@Named("che.openshift.liveness.probe.delay") int openShiftLivenessProbeDelay,
@@ -158,28 +154,7 @@ public OpenShiftConnector(ConfigBuilder configBuilder,
158154
this.openShiftLivenessProbeDelay = openShiftLivenessProbeDelay;
159155
this.openShiftLivenessProbeTimeout = openShiftLivenessProbeTimeout;
160156

161-
Config config = getOpenShiftConfig(configBuilder,
162-
openShiftApiEndpoint,
163-
openShiftToken,
164-
openShiftUserName,
165-
openShiftUserPassword);
166-
this.openShiftClient = new DefaultOpenShiftClient(config);
167-
}
168-
169-
private Config getOpenShiftConfig(ConfigBuilder configBuilder,
170-
String openShiftApiEndpoint,
171-
String openShiftToken,
172-
String openShiftUserName,
173-
String openShiftUserPassword) {
174-
if (isNullOrEmpty(openShiftToken)) {
175-
return configBuilder.withMasterUrl(openShiftApiEndpoint)
176-
.withUsername(openShiftUserName)
177-
.withPassword(openShiftUserPassword).build();
178-
} else {
179-
return configBuilder.withMasterUrl(openShiftApiEndpoint)
180-
.withOauthToken(openShiftToken)
181-
.build();
182-
}
157+
this.openShiftClient = new DefaultOpenShiftClient();
183158
}
184159

185160
/**

plugins/plugin-docker/che-plugin-openshift-client/src/test/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnectorTest.java

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,9 @@ public class OpenShiftConnectorTest {
3636
private static final String[] CONTAINER_ENV_VARIABLES = {"CHE_WORKSPACE_ID=abcd1234"};
3737
private static final String CHE_DEFAULT_OPENSHIFT_PROJECT_NAME = "eclipse-che";
3838
private static final String CHE_DEFAULT_OPENSHIFT_SERVICEACCOUNT = "cheserviceaccount";
39-
private static final String OPENSHIFT_API_ENDPOINT_MINISHIFT = "https://192.168.64.2:8443/";
40-
private static final String OPENSHIFT_DEFAULT_USER_NAME = "openshift-dev";
41-
private static final String OPENSHIFT_DEFAULT_USER_PASSWORD = "devel";
4239
private static final int OPENSHIFT_LIVENESS_PROBE_DELAY = 300;
4340
private static final int OPENSHIFT_LIVENESS_PROBE_TIMEOUT = 1;
44-
private static final String OPENSHIFT_DEFAULT_TOKEN = "91XMfu-FuNDkGjcIh6b0y1EtCvztGeSsSqRrWhBfyL8";
45-
41+
4642
@Mock
4743
private DockerConnectorConfiguration dockerConnectorConfiguration;
4844
@Mock
@@ -71,10 +67,6 @@ public void shouldGetWorkspaceIDWhenAValidOneIsProvidedInCreateContainerParams()
7167
dockerConnectionFactory,
7268
authManager,
7369
dockerApiVersionPathPrefixProvider,
74-
OPENSHIFT_API_ENDPOINT_MINISHIFT,
75-
OPENSHIFT_DEFAULT_TOKEN,
76-
OPENSHIFT_DEFAULT_USER_NAME,
77-
OPENSHIFT_DEFAULT_USER_PASSWORD,
7870
CHE_DEFAULT_OPENSHIFT_PROJECT_NAME,
7971
CHE_DEFAULT_OPENSHIFT_SERVICEACCOUNT,
8072
OPENSHIFT_LIVENESS_PROBE_DELAY,
@@ -84,55 +76,4 @@ public void shouldGetWorkspaceIDWhenAValidOneIsProvidedInCreateContainerParams()
8476
//Then
8577
assertEquals(workspaceID, expectedWorkspaceID);
8678
}
87-
88-
@Test
89-
public void shouldUseTokenWhenProvided() {
90-
// Given
91-
ConfigBuilder configBuilder = spy(new ConfigBuilder());
92-
93-
// When
94-
openShiftConnector = new OpenShiftConnector(configBuilder,
95-
dockerConnectorConfiguration,
96-
dockerConnectionFactory,
97-
authManager,
98-
dockerApiVersionPathPrefixProvider,
99-
OPENSHIFT_API_ENDPOINT_MINISHIFT,
100-
OPENSHIFT_DEFAULT_TOKEN,
101-
OPENSHIFT_DEFAULT_USER_NAME,
102-
OPENSHIFT_DEFAULT_USER_PASSWORD,
103-
CHE_DEFAULT_OPENSHIFT_PROJECT_NAME,
104-
CHE_DEFAULT_OPENSHIFT_SERVICEACCOUNT,
105-
OPENSHIFT_LIVENESS_PROBE_DELAY,
106-
OPENSHIFT_LIVENESS_PROBE_TIMEOUT);
107-
108-
// Then
109-
verify(configBuilder,times(1)).withOauthToken(OPENSHIFT_DEFAULT_TOKEN);
110-
verify(configBuilder,times(0)).withUsername(OPENSHIFT_DEFAULT_USER_NAME);
111-
}
112-
113-
@Test
114-
public void shouldUsePasswordWhenTokenIsNotProvided() {
115-
// Given
116-
ConfigBuilder configBuilder = spy(new ConfigBuilder());
117-
118-
// When
119-
openShiftConnector = new OpenShiftConnector(configBuilder,
120-
dockerConnectorConfiguration,
121-
dockerConnectionFactory,
122-
authManager,
123-
dockerApiVersionPathPrefixProvider,
124-
OPENSHIFT_API_ENDPOINT_MINISHIFT,
125-
"",
126-
OPENSHIFT_DEFAULT_USER_NAME,
127-
OPENSHIFT_DEFAULT_USER_PASSWORD,
128-
CHE_DEFAULT_OPENSHIFT_PROJECT_NAME,
129-
CHE_DEFAULT_OPENSHIFT_SERVICEACCOUNT,
130-
OPENSHIFT_LIVENESS_PROBE_DELAY,
131-
OPENSHIFT_LIVENESS_PROBE_TIMEOUT);
132-
133-
// Then
134-
verify(configBuilder,times(0)).withOauthToken(OPENSHIFT_DEFAULT_TOKEN);
135-
verify(configBuilder,times(1)).withUsername(OPENSHIFT_DEFAULT_USER_NAME);
136-
}
137-
13879
}

0 commit comments

Comments
 (0)