Skip to content

Commit

Permalink
feat(core): make EncryptedString looks like a String
Browse files Browse the repository at this point in the history
An EncryptedString is an implementation detail of a string encrypted. It is only used on outputs and will be automatically decrypted.
To hide this implementation detail, we replace it with String in the JSON Schema.
Fixes #5527
  • Loading branch information
loicmathieu committed Nov 6, 2024
1 parent 4cda597 commit 4259466
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.kestra.core.models.conditions.ScheduleCondition;
import io.kestra.core.models.tasks.Output;
import io.kestra.core.models.tasks.Task;
import io.kestra.core.models.tasks.common.EncryptedString;
import io.kestra.core.models.tasks.runners.TaskRunner;
import io.kestra.core.models.triggers.AbstractTrigger;
import io.kestra.core.plugins.PluginRegistry;
Expand Down Expand Up @@ -211,7 +212,7 @@ public CustomDefinition provideCustomSchemaDefinition(ResolvedType javaType, Sch
}
});

// resolve dynamic types from Property
// resolve dynamic types from Property and make EncryptedString looks like a string
builder.forFields().withTargetTypeOverridesResolver(target -> {
ResolvedType javaType = target.getType();
if (javaType.isInstanceOf(Property.class)) {
Expand Down Expand Up @@ -239,6 +240,11 @@ public CustomDefinition provideCustomSchemaDefinition(ResolvedType javaType, Sch
context.resolve(String.class)
);
}
} else if (javaType.isInstanceOf(EncryptedString.class)) {
TypeContext context = target.getContext();
return List.of(
context.resolve(String.class)
);
}

return null;
Expand Down

0 comments on commit 4259466

Please sign in to comment.