mirror of https://github.com/halo-dev/halo
fix: secret data cannot be used in YAML (#5917)
#### What type of PR is this? /kind bug /area core /milestone 2.16.x #### What this PR does / why we need it: 修复 Secret 的 data 字段无法在 YAML 使用的问题 #### Does this PR introduce a user-facing change? ```release-note None ```pull/5928/head
parent
2341905323
commit
983e70d50d
|
@ -10,6 +10,7 @@ import io.swagger.v3.core.util.Json;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Optional;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.openapi4j.core.exception.ResolutionException;
|
import org.openapi4j.core.exception.ResolutionException;
|
||||||
import org.openapi4j.core.model.v3.OAI3;
|
import org.openapi4j.core.model.v3.OAI3;
|
||||||
|
@ -54,8 +55,14 @@ public class JSONExtensionConverter implements ExtensionConverter {
|
||||||
var scheme = schemeManager.get(gvk);
|
var scheme = schemeManager.get(gvk);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
var convertedExtension = Optional.of(extension)
|
||||||
|
.map(item -> scheme.type().isAssignableFrom(item.getClass()) ? item
|
||||||
|
: objectMapper.convertValue(item, scheme.type())
|
||||||
|
)
|
||||||
|
.orElseThrow();
|
||||||
var validation = new ValidationData<>(extension);
|
var validation = new ValidationData<>(extension);
|
||||||
var extensionJsonNode = objectMapper.valueToTree(extension);
|
|
||||||
|
var extensionJsonNode = objectMapper.valueToTree(convertedExtension);
|
||||||
var validator = getValidator(scheme);
|
var validator = getValidator(scheme);
|
||||||
validator.validate(extensionJsonNode, validation);
|
validator.validate(extensionJsonNode, validation);
|
||||||
if (!validation.isValid()) {
|
if (!validation.isValid()) {
|
||||||
|
|
Loading…
Reference in New Issue