Skip to content

Commit

Permalink
Merge branch 'release/0.9.59'
Browse files Browse the repository at this point in the history
  • Loading branch information
jfallows committed Nov 21, 2023
2 parents 0e96f7a + 8b20d66 commit b6bf6be
Show file tree
Hide file tree
Showing 143 changed files with 1,307 additions and 350 deletions.
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,32 @@

## [Unreleased](https://github.com/aklivity/zilla/tree/HEAD)

[Full Changelog](https://github.com/aklivity/zilla/compare/0.9.57...HEAD)
[Full Changelog](https://github.com/aklivity/zilla/compare/0.9.58...HEAD)

**Implemented enhancements:**

- Generate `http` server request `validators` from `AsyncAPI` specification [\#460](https://github.com/aklivity/zilla/issues/460)

**Fixed bugs:**

- MQTT topic routing doesn't correctly reject pub/sub requests [\#572](https://github.com/aklivity/zilla/issues/572)
- Fix producing empty message to retained topic [\#577](https://github.com/aklivity/zilla/pull/577) ([bmaidics](https://github.com/bmaidics))
- Fix MQTT topic routing doesn't correctly reject pub/sub requests [\#573](https://github.com/aklivity/zilla/pull/573) ([bmaidics](https://github.com/bmaidics))

**Closed issues:**

- Empty messages on `retained` topic for all MQTT messages [\#575](https://github.com/aklivity/zilla/issues/575)
- \[DOCS\] Fix typos in README file [\#540](https://github.com/aklivity/zilla/issues/540)

**Merged pull requests:**

- Consumer group session timeout defaults [\#584](https://github.com/aklivity/zilla/pull/584) ([jfallows](https://github.com/jfallows))
- Fix json validator to also accept arrays [\#576](https://github.com/aklivity/zilla/pull/576) ([attilakreiner](https://github.com/attilakreiner))
- Include validation in the `asyncapi.http.proxy` generator [\#574](https://github.com/aklivity/zilla/pull/574) ([attilakreiner](https://github.com/attilakreiner))

## [0.9.58](https://github.com/aklivity/zilla/tree/0.9.58) (2023-11-13)

[Full Changelog](https://github.com/aklivity/zilla/compare/0.9.57...0.9.58)

**Implemented enhancements:**

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Returns an `etag` header with `HTTP` response. Supports conditional `GET if-none

- **[Zilla Documentation](https://docs.aklivity.io/zilla/latest/how-tos/install.html):** Guides, tutorials and references to help understand how to use Zilla and configure it for your use case.
- **[Product Roadmap][zilla-roadmap]:** Check out our plan for upcoming releases.
- **[Zilla Examples](https://github.com/aklivity/zilla-examples)**: A repo of sample Zilla configurations for different use cases running on Kubernetes.
- **[Zilla Examples](https://github.com/aklivity/zilla-examples)**: A collection of pre-canned Zilla feature demos.
- **[Todo Application](https://docs.aklivity.io/zilla/latest/tutorials/todo-app/build.html):** Follow the tutorial and see how Zilla and Kafka can be used to build a Todo app based on streaming and CQRS.

### 📝 Check out blog posts
Expand Down
2 changes: 1 addition & 1 deletion build/flyweight-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>build</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>zilla</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion cloud/docker-image/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>cloud</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion cloud/helm-chart/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>cloud</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion cloud/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>zilla</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion conf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>zilla</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion incubator/binding-amqp.spec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>incubator</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion incubator/binding-amqp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>incubator</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion incubator/catalog-inline.spec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>incubator</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion incubator/catalog-inline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>incubator</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion incubator/catalog-schema-registry.spec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>incubator</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion incubator/catalog-schema-registry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>incubator</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion incubator/command-dump/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>incubator</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion incubator/command-generate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.aklivity.zilla</groupId>
<artifactId>incubator</artifactId>
<version>0.9.58</version>
<version>0.9.59</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,134 @@
*/
package io.aklivity.zilla.runtime.command.generate.internal.airline;

import static com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature.MINIMIZE_QUOTES;
import static com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature.WRITE_DOC_START_MARKER;
import static org.agrona.LangUtil.rethrowUnchecked;

import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;

import io.aklivity.zilla.runtime.catalog.inline.config.InlineOptionsConfig;
import io.aklivity.zilla.runtime.catalog.inline.config.InlineSchemaConfigBuilder;
import io.aklivity.zilla.runtime.command.generate.internal.asyncapi.model.AsyncApi;
import io.aklivity.zilla.runtime.command.generate.internal.asyncapi.model.Message;
import io.aklivity.zilla.runtime.command.generate.internal.asyncapi.model.Schema;
import io.aklivity.zilla.runtime.command.generate.internal.asyncapi.view.MessageView;
import io.aklivity.zilla.runtime.engine.config.NamespaceConfig;
import io.aklivity.zilla.runtime.engine.config.NamespaceConfigBuilder;
import io.aklivity.zilla.runtime.engine.config.ValidatorConfig;
import io.aklivity.zilla.runtime.validator.core.config.IntegerValidatorConfig;
import io.aklivity.zilla.runtime.validator.core.config.StringValidatorConfig;

public abstract class ConfigGenerator
{
protected static final String INLINE_CATALOG_NAME = "catalog0";
protected static final String INLINE_CATALOG_TYPE = "inline";
protected static final String APPLICATION_JSON = "application/json";
protected static final String VERSION_LATEST = "latest";
protected static final Pattern JSON_CONTENT_TYPE = Pattern.compile("^application/(?:.+\\+)?json$");

protected final Map<String, ValidatorConfig> validators = Map.of(
"string", StringValidatorConfig.builder().build(),
"integer", IntegerValidatorConfig.builder().build()
);
protected final Matcher jsonContentType = JSON_CONTENT_TYPE.matcher("");

protected AsyncApi asyncApi;

public abstract String generate();

protected boolean hasJsonContentType()
{
String contentType = resolveContentType();
return contentType != null && jsonContentType.reset(contentType).matches();
}

private String resolveContentType()
{
String contentType = null;
if (asyncApi.components != null && asyncApi.components.messages != null && !asyncApi.components.messages.isEmpty())
{
Message firstMessage = asyncApi.components.messages.entrySet().stream().findFirst().get().getValue();
contentType = MessageView.of(asyncApi.components.messages, firstMessage).contentType();
}
return contentType;
}

protected NamespaceConfigBuilder<NamespaceConfig> injectCatalog(
NamespaceConfigBuilder<NamespaceConfig> namespace)
{
if (asyncApi.components != null && asyncApi.components.schemas != null && !asyncApi.components.schemas.isEmpty())
{
namespace
.catalog()
.name(INLINE_CATALOG_NAME)
.type(INLINE_CATALOG_TYPE)
.options(InlineOptionsConfig::builder)
.subjects()
.inject(this::injectSubjects)
.build()
.build()
.build();

}
return namespace;
}

private <C> InlineSchemaConfigBuilder<C> injectSubjects(
InlineSchemaConfigBuilder<C> subjects)
{
try (Jsonb jsonb = JsonbBuilder.create())
{
YAMLMapper yaml = YAMLMapper.builder()
.disable(WRITE_DOC_START_MARKER)
.enable(MINIMIZE_QUOTES)
.build();
for (Map.Entry<String, Schema> entry : asyncApi.components.schemas.entrySet())
{
subjects
.subject(entry.getKey())
.version(VERSION_LATEST)
.schema(writeSchemaYaml(jsonb, yaml, entry.getValue()))
.build();
}
}
catch (Exception ex)
{
rethrowUnchecked(ex);
}
return subjects;
}

private static String writeSchemaYaml(
Jsonb jsonb,
YAMLMapper yaml,
Schema schema)
{
String result = null;
try
{
String schemaJson = jsonb.toJson(schema);
JsonNode json = new ObjectMapper().readTree(schemaJson);
result = yaml.writeValueAsString(json);
}
catch (JsonProcessingException ex)
{
rethrowUnchecked(ex);
}
return result;
}

protected final String unquoteEnvVars(
String yaml,
List<String> unquotedEnvVars)
Expand Down
Loading

0 comments on commit b6bf6be

Please sign in to comment.