Skip to content

Commit

Permalink
feat(registration): receive platform env map from server on registration
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Jun 6, 2023
1 parent da13d58 commit 3d7e229
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/main/java/io/cryostat/agent/Registration.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ void tryRegister() {
this.pluginInfo.isInitialized();
this.pluginInfo.copyFrom(plugin);
log.info("Registered as {}", this.pluginInfo.getId());
// FIXME remove this before merge
log.info(
"Plugin env map: {}", this.pluginInfo.getEnv());
if (previouslyRegistered) {
notify(RegistrationEvent.State.REFRESHED);
} else {
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/io/cryostat/agent/model/PluginInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,28 @@
*/
package io.cryostat.agent.model;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class PluginInfo {

private String id;
private String token;
private Map<String, String> env = new HashMap<>();

public PluginInfo() {}

public PluginInfo(String id, String token) {
public PluginInfo(String id, String token, Map<String, String> env) {
this.id = id;
this.token = token;
this.env.putAll(env);
}

public void copyFrom(PluginInfo o) {
setId(o.getId());
setToken(o.getToken());
setEnv(o.getEnv());
}

public void clear() {
Expand All @@ -72,6 +77,10 @@ public String getToken() {
return token;
}

public Map<String, String> getEnv() {
return new HashMap<>(env);
}

public void setId(String id) {
this.id = id;
}
Expand All @@ -80,9 +89,14 @@ public void setToken(String token) {
this.token = token;
}

public void setEnv(Map<String, String> env) {
this.env.clear();
this.env.putAll(env);
}

@Override
public int hashCode() {
return Objects.hash(id, token);
return Objects.hash(id, token, env);
}

@Override
Expand All @@ -97,6 +111,8 @@ public boolean equals(Object obj) {
return false;
}
PluginInfo other = (PluginInfo) obj;
return Objects.equals(id, other.id) && Objects.equals(token, other.token);
return Objects.equals(id, other.id)
&& Objects.equals(token, other.token)
&& Objects.equals(env, other.env);
}
}

0 comments on commit 3d7e229

Please sign in to comment.