Skip to content

Commit

Permalink
Merge pull request #2 from chrisruffalo/release-1.x
Browse files Browse the repository at this point in the history
Release 1.2
  • Loading branch information
chrisruffalo authored Apr 26, 2021
2 parents 087173e + 666c9f0 commit 78e67a8
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 51 deletions.
42 changes: 32 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Syndo Release Artifacts
name: Build and Release Artifacts
on:
push:
branches:
Expand All @@ -18,7 +18,7 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Set up JDK 8
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: '8'
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
- name: Create Github Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
Expand All @@ -63,30 +63,52 @@ jobs:
artifacts: "target/yyall-*.jar"
replacesArtifacts: true

- name: Delete Snapshot
- name: Delete Github Package Snapshot
if: contains(github.ref, 'refs/heads/')
uses: WyriHaximus/github-action-delete-package@master
with:
packageVersionId: ${{ env.POM_VER }}-SNAPSHOT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Delete Release
- name: Delete Github Package Release
if: "!contains(github.ref, 'refs/heads/')"
uses: WyriHaximus/github-action-delete-package@master
with:
packageVersionId: ${{ env.POM_VER }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Snapshot
- name: Publish Github Package Snapshot
if: contains(github.ref, 'refs/heads/')
run: mvn -Drevision=${{ env.POM_VER }}-SNAPSHOT --batch-mode clean deploy
run: mvn -Pgithub-distribution -Drevision=${{ env.POM_VER }}-SNAPSHOT --batch-mode clean deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Release
- name: Publish Github Package Release
if: "!contains(github.ref, 'refs/heads/')"
run: mvn --batch-mode deploy
run: mvn -Pgithub-distribution --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
server-id: ossrh
server-username: ${{ secrets.OSSRH_USERNAME }}
server-password: ${{ secrets.OSSRH_TOKEN }}

- name: Install GPG Secret Key
run: |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Publish OSSRH Package Snapshot
if: contains(github.ref, 'refs/heads/')
run: mvn -Possrh-distribution -Drevision=${{ env.POM_VER }}-SNAPSHOT --batch-mode --no-transfer-progress -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} clean deploy

- name: Publish OSSRH Package Release
if: "!contains(github.ref, 'refs/heads/')"
run: mvn -Possrh-distribution --batch-mode --no-transfer-progress -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} deploy
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,29 @@ app:
This example allows you to access both individual properties and pre-formatted strings as with the following example:
```java
final YyallConfiguration conf = YyallConfiguration.load("/path/to/file.yml");
final String port = conf.get("app.db.port");
YyallConfiguration conf = YyallConfiguration.load("/path/to/file.yml");
String port = conf.get("app.db.port");
```

You can also use the same token language to get a more complex resolution:
```java
final YyallConfiguration conf = YyallConfiguration.load("/path/to/file.yml");
final String complex = conf.format("You can go to the url @ ${app.api}/docs to see the API documents")
YyallConfiguration conf = YyallConfiguration.load("/path/to/file.yml");
String complex = conf.format("You can go to the url @ ${app.api}/docs to see the API documents")
```

The language supports more features such as multiple resolution variables, literals, and nested resolution
```java
final YyallConfiguration conf = YyallConfiguration.load("/path/to/file.yml");
// resolve opts.api (could be a passed in java option), the yaml value app.api, or use the default localhost value
final String multi = conf.get("${ opts.api | app.api | 'http://localhost:9090/api' }")
String multi = conf.format("${ opts.api | app.api | 'http://localhost:9090/api' }")
// same thing but with nested resolution of port value, notice that literals **always** go in quotes
final String multi = conf.get("${ opts.api | app.api | 'http://localhost:${app.port | '9090'}/api' }")
String nested = conf.format("${ opts.api | app.api | 'http://localhost:${app.port | '9090'}/api' }")
```

An entire YAML can be resolved all at once:
```java
final YyallConfiguration conf = YyallConfiguration.load("/path/to/file.yml");
Object yaml = conf.resolve();
String yamlString = conf.resovleString();
InputStream yamlStream = conf.resolveStream();
```
91 changes: 80 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,24 @@
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>
<groupId>com.github.chrisruffalo</groupId>
<groupId>io.github.chrisruffalo.yyall</groupId>
<artifactId>yyall</artifactId>
<packaging>jar</packaging>
<version>${revision}</version>

<properties>
<revision>1.1</revision>
<revision>1.2</revision>

<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<scm>
<developerConnection>scm:git:https://github.com/chrisruffalo/yyall.git</developerConnection>
</scm>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/chrisruffalo/yyall</url>
</repository>
</distributionManagement>

<dependencies>
<!-- yaml reading -->
<dependency>
Expand Down Expand Up @@ -57,5 +51,80 @@
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencies>

<profiles>
<!-- profile configured for github distribution -->
<profile>
<id>github-distribution</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/chrisruffalo/yyall</url>
</repository>
</distributionManagement>
</profile>

<!-- profile configured for sonatype/maven central distribution -->
<profile>
<id>ossrh-distribution</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<distributionManagement>
<repository>
<id>ossrh</id>
<name>OSSRH Sonatype Nexus</name>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>ossrh</id>
<name>OSSRH Sonatype Nexus</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<!-- gpg signing -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>

<!-- ossh deployment -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.github.chrisruffalo.yyall;
package io.github.chrisruffalo.yyall;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
Expand All @@ -14,13 +11,12 @@
import java.util.Map;
import java.util.Set;

import io.github.chrisruffalo.yyall.resolver.DefaultStringResolver;
import org.apache.commons.beanutils.BeanUtils;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;

import com.github.chrisruffalo.yyall.resolver.DefaultStringResolver;
import com.github.chrisruffalo.yyall.resolver.StringResolver;
import io.github.chrisruffalo.yyall.resolver.StringResolver;

public class YyallConfiguration {

Expand Down Expand Up @@ -104,6 +100,10 @@ public InputStream resolveStream() {
return new ByteArrayInputStream(resolvedString.getBytes());
}

public String resolveString() {
return YAML.dump(this.resolve());
}

private Object resolve(final String property) {
final HashSet<String> guardSet = new HashSet<>();
guardSet.add(property);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chrisruffalo.yyall.resolver;
package io.github.chrisruffalo.yyall.resolver;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chrisruffalo.yyall.resolver;
package io.github.chrisruffalo.yyall.resolver;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chrisruffalo.yyall.verification;
package io.github.chrisruffalo.yyall.verification;

public interface ConfigurationVerification {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.github.chrisruffalo.yyall;
package io.github.chrisruffalo.yyall;

import com.github.chrisruffalo.yyall.model.Root;
import io.github.chrisruffalo.yyall.model.Root;
import org.junit.Assert;
import org.junit.Test;
import org.yaml.snakeyaml.Yaml;

import java.io.InputStream;

Expand All @@ -22,7 +21,7 @@ public void testFormat() {
}

@Test
public void testResolve() {
public void testResolveAs() {
final YyallConfiguration conf = YyallConfiguration.load(this.getClass().getResourceAsStream("/featuretest.yml"));
final Root root = conf.resolveAs(Root.class);

Expand All @@ -41,13 +40,24 @@ public void testResolve() {
}

@Test
public void testResolveStream() {
public void testResolveTo() {
final YyallConfiguration conf = YyallConfiguration.load(this.getClass().getResourceAsStream("/featuretest.yml"));
final InputStream resolvedStream = conf.resolveStream();
final YyallConfiguration conf2 = YyallConfiguration.load(resolvedStream);
final YyallConfiguration conf3 = YyallConfiguration.load(conf.resolveString());

Assert.assertEquals("Nonsense does not resolve", "no resolution", conf2.get("reference.nonsense"));
Assert.assertEquals("Format works on non-variable stream", conf.format("${reference.home}"), conf2.format("${reference.home}"));

Assert.assertEquals("Nonsense does not resolve", "no resolution", conf3.get("reference.nonsense"));
Assert.assertEquals("Format works on non-variable stream", conf.format("${reference.home}"), conf3.format("${reference.home}"));
}

@Test
public void testResolveNested() {
final YyallConfiguration conf = YyallConfiguration.load(this.getClass().getResourceAsStream("/featuretest.yml"));
Assert.assertEquals("Nested literal and variable are resolved correctly", "http://localhost:8080/api", conf.format("${ given.host | 'http://localhost:${vars.port | '9090'}/api'}"));

}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chrisruffalo.yyall.model;
package io.github.chrisruffalo.yyall.model;

public class Application {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chrisruffalo.yyall.model;
package io.github.chrisruffalo.yyall.model;

public class Middleware {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chrisruffalo.yyall.model;
package io.github.chrisruffalo.yyall.model;

public class Reference {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chrisruffalo.yyall.model;
package io.github.chrisruffalo.yyall.model;

public class Root {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chrisruffalo.yyall.model;
package io.github.chrisruffalo.yyall.model;

public class Storage {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chrisruffalo.yyall.model;
package io.github.chrisruffalo.yyall.model;

public class Variables {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.chrisruffalo.yyall.resolver;
package io.github.chrisruffalo.yyall.resolver;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -8,8 +8,6 @@
import org.junit.Test;
import org.yaml.snakeyaml.Yaml;

import com.github.chrisruffalo.yyall.resolver.DefaultStringResolver;

public class DefaultStringResolverTest {

@Test
Expand Down

0 comments on commit 78e67a8

Please sign in to comment.