Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zilla is validating env vars before replacing them #797

Merged
merged 5 commits into from
Feb 14, 2024
Merged

Zilla is validating env vars before replacing them #797

merged 5 commits into from
Feb 14, 2024

Conversation

akrambek
Copy link
Contributor

Description

Zilla is validating env vars before replacing them

Fixes #795

@@ -190,7 +190,7 @@ private boolean validateAnnotatedSchema(
validate:
try
{
final JsonObject annotatedSchemaObject = (JsonObject) annotateJsonObject(schemaObject);
final JsonObject annotatedSchemaObject = jsonAnnotator.apply(schemaObject);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final JsonObject annotatedSchemaObject = jsonAnnotator.apply(schemaObject);
final EngineConfigAnnotator annotator = new EngineConfigAnnotator();
final JsonObject annotatedSchemaObject = annotator.annotate(schemaObject);

Given the state needed by internals of annotator, suggest we just instantiate this here on stack and call the annotate method directly instead of having a field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I was thinking but then thought that you have resaon

this.schemaIndexes = new LinkedList<>();
}

public JsonObject annotateJson(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public JsonObject annotateJson(
public JsonObject annotate(


import org.agrona.collections.MutableInteger;

public final class EngineConfigAnnotator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add EngineConfigAnnotatorTest to verify some of the important scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good just wanted to check if that what you mean

{
private final LinkedList<String> schemaKeys;
private final LinkedList<Integer> schemaIndexes;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used implementation because I need an interface from both the deque and the list. Let me know if this is wrong

Comment on lines 60 to 61
private final EngineConfigAnnotator annotator;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this field.

@@ -72,6 +70,7 @@ public EngineConfigReader(
this.expressions = expressions;
this.schemaTypes = schemaTypes;
this.logger = logger;
this.annotator = new EngineConfigAnnotator();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this assignment.

@@ -190,7 +189,7 @@ private boolean validateAnnotatedSchema(
validate:
try
{
final JsonObject annotatedSchemaObject = (JsonObject) annotateJsonObject(schemaObject);
final JsonObject annotatedSchemaObject = annotator.annotate(schemaObject);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final JsonObject annotatedSchemaObject = annotator.annotate(schemaObject);
final EngineConfigAnnotator() annotator = new EngineConfigAnnotator();;
final JsonObject annotatedSchemaObject = annotator.annotate(schemaObject);

This should be local because it has internal parse state, no need to carry any potential side effects of previous read to next read.

@jfallows jfallows merged commit 8ef7aa4 into aklivity:develop Feb 14, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zilla is validating env vars before replacing them.
2 participants