Skip to content

Commit

Permalink
Handle creating new configmap for authorized_keys
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmalloy committed Jan 7, 2024
1 parent 89a5ba5 commit 9d364fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<jsoup.version>1.16.1</jsoup.version>
<scim2-client.version>2.3.8</scim2-client.version>
<openai-gpt.version>0.18.2</openai-gpt.version>
<fabric8.version>6.4.1</fabric8.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -383,6 +384,13 @@

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client-bom</artifactId>
<version>${fabric8.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/jasper/component/k8s/TunnelServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class TunnelServer {
timeUnit = TimeUnit.SECONDS)
public void generateConfig() {
var changed = false;
StringBuilder result = new StringBuilder();
var result = new StringBuilder();
for (var origin : props.getSshOrigins()) {
var cursor = userRepository.getCursor(origin);
if (cursor != null) {
Expand Down Expand Up @@ -65,8 +65,15 @@ public void generateConfig() {
}
}
try (var client = new DefaultKubernetesClient()) {
client.configMaps().inNamespace(props.getSshConfigNamespace()).withName(props.getSshConfigMapName())
.edit(c -> new ConfigMapBuilder(c).addToData("authorized_keys", result.toString()).build());
client.configMaps()
.inNamespace(props.getSshConfigNamespace())
.resource(new ConfigMapBuilder()
.withNewMetadata()
.withName(props.getSshConfigMapName())
.and()
.addToData("authorized_keys", result.toString())
.build())
.serverSideApply();
}
}

Expand Down

0 comments on commit 9d364fc

Please sign in to comment.