Skip to content

Commit

Permalink
Console logging enhancements (#58)
Browse files Browse the repository at this point in the history
* Simplify console capture some.
* Reduce length of STDERR_TOKEN by removing its predictable part ("STDERR_"), which makes it less likely to get split on a packet boundary
* Resolve some minor code quality warnings
* Switch to Java 11 tool chain (but compile 1.8 byte code)

Co-authored-by: Karl DeBisschop <[email protected]>
  • Loading branch information
kdebisschop and Karl DeBisschop authored Oct 17, 2020
1 parent ad3f453 commit de7969f
Show file tree
Hide file tree
Showing 24 changed files with 267 additions and 247 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Bug report
name: Bug Report
about: Create a report to help us improve
title: ''
labels: ''
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
A clear and concise description of what the problem is. Ex. I'm always frustrated when...

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
Expand Down
43 changes: 27 additions & 16 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,30 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Run unit tests
run: ./gradlew test
- name: Determine coverage
run: ./gradlew jacocoTestReport
- name: Scan with Sonar
run: ./gradlew sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Build with Gradle
run: ./gradlew build
- uses: actions/checkout@v2
with:
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build and analyze
run: ./gradlew build jacocoTestReport sonarqube --info
env:
# Needed to get some information about the pull request, if any
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SonarCloud access token should be generated from https://sonarcloud.io/account/security/
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
22 changes: 12 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
/.java-version

# Eclipse
.classpath
.project
.settings/
/.classpath
/.project
/.settings/

# Intellij
.idea/
/.idea/
*.iml
*.iws

# Mac
.DS_Store

# Maven
log/
target/
.gradle/
build/
out/
/log/
/target/
/.gradle/
/build/
/out/

# Integration tests
build.log
/build.log

/bin/
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
Expand Down
17 changes: 12 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@

#### **Did you find a bug?**

* **Do not open up a GitHub issue if the bug is a security vulnerability**, and instead communicate directly with the maintainer(s).
* **Do not open up a GitHub issue if the bug is a security vulnerability**,
and instead communicate directly with the maintainer(s).

* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/kdebisschop/rundeck-rancher-node-plugin/issues).
* **Ensure the bug was not already reported** by searching on GitHub under
[Issues](https://github.com/kdebisschop/rundeck-rancher-node-plugin/issues).

* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/kdebisschop/rundeck-rancher-node-plugin/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
* If you're unable to find an open issue addressing the problem,
[open a new one](https://github.com/kdebisschop/rundeck-rancher-node-plugin/issues/new).
Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample**
or **executable test case** demonstrating the expected behavior that is not occurring.

#### **Did you write a patch that fixes a bug or intorduces a new feature?**

* Open a new GitHub pull request with the patch.

* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
* Ensure the PR description clearly describes the problem and solution.
Include the relevant issue number if applicable.

#### **Do you have questions about the source code?**

* Ask any question about this plugin on the [ServerFault Rundeck tag](https://serverfault.com/questions/tagged/rundeck).
* Ask any question about this plugin on the
[ServerFault Rundeck tag](https://serverfault.com/questions/tagged/rundeck).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Features:
### Rancher File Copier

Copies files to a node. Can be configured to use Rancher CLI if it is installed and
available. Otherwise assembles file from Base64-encoded parts transmitted via Rancher
available. Otherwise, assembles files from Base64-encoded parts transmitted via Rancher
API.

To distribute to all containers in a stack's service, omit the filter for "seen".
Expand Down
36 changes: 21 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ java {
targetCompatibility = JavaVersion.VERSION_1_8
}

compileJava {
options.release.set(8)
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

compileTestJava {
options.release.set(8)
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

defaultTasks 'clean','test','jacocoTestReport','build'
ext.rundeckPluginVersion = '1.2'
ext.pluginClassNames='com.bioraft.rundeck.rancher.RancherNodeExecutorPlugin,' +
Expand Down Expand Up @@ -75,23 +85,19 @@ configurations {
}

dependencies {
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.10.1'

implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.12.0'

implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.2'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.13.2'

implementation (
'org.rundeck:rundeck-core:3.3.+',
'org.rundeck:rundeck-storage-api:3.3.+',
'com.fasterxml.jackson.core:jackson-databind:2.10.1',
'com.squareup.okhttp3:okhttp:3.14.9',
'org.apache.logging.log4j:log4j-api:2.13.2',
'org.apache.logging.log4j:log4j-core:2.13.2',
'org.rundeck:rundeck-core:3.3.4-20201007',
'org.rundeck:rundeck-storage-api:3.3.4-20201007',
)

testImplementation group: 'junit', name: 'junit', version:'4.12'

testImplementation (
'org.mockito:mockito-core:3.+',
'com.squareup.okhttp3:mockwebserver:3.13.1'
'com.squareup.okhttp3:mockwebserver:3.11.0',
'junit:junit:4.12',
'org.mockito:mockito-core:3.+',
'org.slf4j:slf4j-simple:1.7.30+',
)
}

Expand Down Expand Up @@ -128,5 +134,5 @@ jar {
}

wrapper {
gradleVersion = '6.5.1'
gradleVersion = '6.6.1'
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri May 29 14:32:58 EDT 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
21 changes: 3 additions & 18 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,29 +64,14 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/bioraft/rundeck/rancher/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ private Constants() {

public static final int INTERVAL_MILLIS = 2000;

@SuppressWarnings("SpellCheckingInspection")
public static final String STDERR_TOKEN = "STDERR_6v9ZvwThpU1FtyrlIBf4UIC8";

// These are fields in JSON from Rancher API.
public static final String NODE_ID = "id";
public static final String NODE_NAME = "name";
Expand Down Expand Up @@ -71,7 +74,10 @@ private Constants() {
public static final String DISPLAY_CODE = "CODE";
public static final String SYNTAX_MODE_JSON = "json";

public static final String PATH_PROJECTS = "/projects/";
// Project path in Rancher.
public static final String FILE_SEP = System.getProperty("file.separator");
public static final String PATH_PROJECTS = FILE_SEP + "projects" + FILE_SEP;

public static final String JSON_PAGINATION = "pagination";

public static final String OPT_DATA_VOLUMES = "dataVolumes";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public class RancherAddService implements StepPlugin {
@RenderingOption(key = CODE_SYNTAX_MODE, value = SYNTAX_MODE_JSON)
private String ports;


private final HttpClient client;

public RancherAddService () {
Expand Down Expand Up @@ -125,6 +124,8 @@ public void executeStep(final PluginStepContext context, final Map<String, Objec

secrets = (String) configuration.getOrDefault(OPT_SECRETS, defaultString(secrets));

ports = (String) configuration.getOrDefault(OPT_CONTAINER_PORTS, defaultString(ports));

Framework framework = context.getFramework();
String project = context.getFrameworkProject();
PluginLogger logger = context.getLogger();
Expand Down
Loading

0 comments on commit de7969f

Please sign in to comment.