forked from RedHatInsights/insights-java-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split agent to separate module (RedHatInsights#29)
* Move to a separate module. One Disabled test. * Tests pass * Add in Apache HTTP Client for agent * Add token support to agent * Add docs
- Loading branch information
Showing
15 changed files
with
713 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Compiled Go code | ||
jboss-cert-helper/jboss-cert-helper | ||
jboss-cert-helper/bin | ||
|
||
# Compiled class file | ||
*.class | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.redhat.insights</groupId> | ||
<artifactId>runtimes-java</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>runtimes-java-agent</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.release>8</maven.compiler.release> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
|
||
<apache.httpclient.version>4.5.14</apache.httpclient.version> | ||
<apache.httpcore.version>4.4.16</apache.httpcore.version> | ||
<apache.httpmime.version>4.5.14</apache.httpmime.version> | ||
|
||
<!-- Test libraries versions --> | ||
<byte-buddy.version>1.14.0</byte-buddy.version> | ||
|
||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>runtimes-java-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.datatype</groupId> | ||
<artifactId>jackson-datatype-jsr310</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.wildfly.security</groupId> | ||
<artifactId>wildfly-elytron-x500-cert</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>${apache.httpclient.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpcore</artifactId> | ||
<version>${apache.httpcore.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpmime</artifactId> | ||
<version>${apache.httpmime.version}</version> | ||
</dependency> | ||
|
||
<!-- Test dependencies --> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>runtimes-java-api</artifactId> | ||
<version>${project.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Byte Buddy is used for testing the agent --> | ||
<dependency> | ||
<groupId>net.bytebuddy</groupId> | ||
<artifactId>byte-buddy</artifactId> | ||
<version>${byte-buddy.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>net.bytebuddy</groupId> | ||
<artifactId>byte-buddy-agent</artifactId> | ||
<version>${byte-buddy.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
<build> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
<phase>package</phase> | ||
<configuration> | ||
<archive> | ||
<manifest></manifest> | ||
<manifestEntries> | ||
<Premain-Class>com.redhat.insights.agent.AgentMain</Premain-Class> | ||
</manifestEntries> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${maven-surefire-plugin.version}</version> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>com.diffplug.spotless</groupId> | ||
<artifactId>spotless-maven-plugin</artifactId> | ||
<version>${spotless-maven-plugin.version}</version> | ||
<configuration> | ||
<skip>${skip.spotless}</skip> | ||
<!-- optional: limit format enforcement to just the files changed by this feature branch --> | ||
<ratchetFrom>origin/main</ratchetFrom> | ||
<formats> | ||
<!-- you can define as many formats as you want, each is independent --> | ||
<format> | ||
<!-- define the files to apply to --> | ||
<includes> | ||
<include>*.md</include> | ||
<include>.gitignore</include> | ||
</includes> | ||
<!-- define the steps to apply to those files --> | ||
<trimTrailingWhitespace></trimTrailingWhitespace> | ||
<endWithNewline></endWithNewline> | ||
<indent> | ||
<tabs>true</tabs> | ||
<spacesPerTab>4</spacesPerTab> | ||
</indent> | ||
</format> | ||
</formats> | ||
<!-- define a language-specific format --> | ||
<java> | ||
<!-- no need to specify files, inferred automatically, but you can if you want --> | ||
|
||
<!-- apply a specific flavor of google-java-format and reflow long strings --> | ||
<googleJavaFormat> | ||
<version>${google-java-format.version}</version> | ||
<style>GOOGLE</style> | ||
<reflowLongStrings>true</reflowLongStrings> | ||
<groupArtifact>com.google.googlejavaformat:google-java-format</groupArtifact> | ||
</googleJavaFormat> | ||
|
||
<!-- make sure every file has the following copyright header. | ||
optionally, Spotless can set copyright years by digging | ||
through git history (see "license" section below) --> | ||
<licenseHeader> | ||
<content>/* Copyright (C) Red Hat $YEAR */</content> | ||
<!-- or <file>${project.basedir}/license-header</file> --> | ||
</licenseHeader> | ||
</java> | ||
<pom> | ||
<includes> | ||
<include>pom.xml</include> | ||
</includes> | ||
<sortPom></sortPom> | ||
</pom> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
<phase>compile</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
</plugins> | ||
|
||
</build> | ||
</project> |
33 changes: 33 additions & 0 deletions
33
agent/src/main/java/com/redhat/insights/agent/AgentBasicReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* Copyright (C) Red Hat 2023 */ | ||
package com.redhat.insights.agent; | ||
|
||
import com.redhat.insights.AbstractTopLevelReportBase; | ||
import com.redhat.insights.InsightsSubreport; | ||
import com.redhat.insights.config.InsightsConfiguration; | ||
import com.redhat.insights.logging.InsightsLogger; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
public class AgentBasicReport extends AbstractTopLevelReportBase { | ||
private AgentBasicReport( | ||
InsightsLogger logger, | ||
InsightsConfiguration config, | ||
Map<String, InsightsSubreport> subReports) { | ||
super(logger, config, subReports); | ||
} | ||
|
||
public static AgentBasicReport of(InsightsLogger logger, InsightsConfiguration configuration) { | ||
return new AgentBasicReport(logger, configuration, Collections.emptyMap()); | ||
} | ||
|
||
@Override | ||
protected long getProcessPID() { | ||
return Long.parseLong( | ||
java.lang.management.ManagementFactory.getRuntimeMXBean().getName().split("@")[0]); | ||
} | ||
|
||
@Override | ||
protected Package[] getPackages() { | ||
return Package.getPackages(); | ||
} | ||
} |
Oops, something went wrong.