Skip to content

Commit

Permalink
add mesh rule check
Browse files Browse the repository at this point in the history
  • Loading branch information
haoyann committed Jul 29, 2021
1 parent de02071 commit f615b49
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
import org.apache.dubbo.admin.common.util.ConvertUtil;
import org.apache.dubbo.admin.common.util.YamlParser;
import org.apache.dubbo.admin.model.dto.MeshRouteDTO;
import org.apache.dubbo.admin.model.store.mesh.destination.DestinationRule;
import org.apache.dubbo.admin.model.store.mesh.virtualservice.VirtualServiceRule;
import org.apache.dubbo.admin.service.MeshRouteService;

import org.springframework.stereotype.Service;

import java.util.Map;


@Service
public class MeshRouteServiceImpl extends AbstractService implements MeshRouteService {
Expand All @@ -49,7 +53,15 @@ public boolean updateMeshRule(MeshRouteDTO meshRoute) {
}

private void checkMeshRule(String meshRule) {
YamlParser.loadAll(meshRule);
Iterable<Object> objectIterable = YamlParser.loadAll(meshRule);
for (Object result : objectIterable) {
Map resultMap = (Map) result;
if ("DestinationRule".equals(resultMap.get("kind"))) {
YamlParser.loadObject(YamlParser.dumpObject(result), DestinationRule.class);
} else if ("VirtualService".equals(resultMap.get("kind"))) {
YamlParser.loadObject(YamlParser.dumpObject(result), VirtualServiceRule.class);
}
}
}

@Override
Expand Down

0 comments on commit f615b49

Please sign in to comment.