Skip to content

Commit

Permalink
fix service host missing bug
Browse files Browse the repository at this point in the history
Signed-off-by: allenshen <[email protected]>
  • Loading branch information
AllenShen committed Dec 16, 2021
1 parent 34efeca commit e3c6e38
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/koderover/zadig/pkg/shared/kube/resource"
"github.com/koderover/zadig/pkg/shared/kube/wrapper"
e "github.com/koderover/zadig/pkg/tool/errors"
"github.com/koderover/zadig/pkg/tool/kube/getter"
"github.com/koderover/zadig/pkg/tool/kube/serializer"
"github.com/koderover/zadig/pkg/util"
)
Expand Down Expand Up @@ -151,13 +152,27 @@ func GetIngressInfo(product *commonmodels.Product, service *commonmodels.Service
parsedYaml = util.ReplaceWrapLine(parsedYaml)
yamlContentArray := releaseutil.SplitManifests(parsedYaml)
hostInfos := make([]resource.HostInfo, 0)

for _, item := range yamlContentArray {
ing, err := serializer.NewDecoder().YamlToIngress([]byte(item))
if err != nil || ing == nil {
u, err := serializer.NewDecoder().YamlToUnstructured([]byte(item))
if err != nil {
log.Warnf("Failed to decode yaml to Unstructured, err: %s", err)
continue
}

hostInfos = append(hostInfos, wrapper.Ingress(ing).HostInfo()...)
switch u.GetKind() {
case setting.Ingress:
kubeClient, err := kubeclient.GetKubeClient(config.HubServerAddress(), product.ClusterID)
if err != nil {
log.Errorf("failed to init kubeClient, clusterID: %s", product.ClusterID)
return nil
}
ing, found, err := getter.GetIngress(product.Namespace, u.GetName(), kubeClient)
if err != nil || !found {
log.Warnf("no ingress %s found in %s:%s %v", u.GetName(), service.ServiceName, product.Namespace, err)
continue
}
hostInfos = append(hostInfos, wrapper.Ingress(ing).HostInfo()...)
}
}
ingressInfo.HostInfo = hostInfos
return ingressInfo
Expand Down

0 comments on commit e3c6e38

Please sign in to comment.