(ctx context.Context, cli client.Reader, synthesizedComp *SynthesizedComponent, compName string)
| 104 | } |
| 105 | |
| 106 | func isHostNetworkEnabled(ctx context.Context, cli client.Reader, synthesizedComp *SynthesizedComponent, compName string) (bool, error) { |
| 107 | // fast path: refer to self |
| 108 | if compName == synthesizedComp.Name { |
| 109 | return IsHostNetworkEnabled(synthesizedComp), nil |
| 110 | } |
| 111 | |
| 112 | // check the component object that whether the host-network is enabled |
| 113 | compKey := types.NamespacedName{ |
| 114 | Namespace: synthesizedComp.Namespace, |
| 115 | Name: constant.GenerateClusterComponentName(synthesizedComp.ClusterName, compName), |
| 116 | } |
| 117 | comp := &appsv1.Component{} |
| 118 | if err := cli.Get(ctx, compKey, comp, inDataContext()); err != nil { |
| 119 | return false, err |
| 120 | } |
| 121 | if !hasHostNetworkEnabled(comp.Annotations, compName) { |
| 122 | return false, nil |
| 123 | } |
| 124 | |
| 125 | // check the component definition that whether it has the host-network capability |
| 126 | if len(comp.Spec.CompDef) > 0 { |
| 127 | compDef := &appsv1.ComponentDefinition{} |
| 128 | if err := cli.Get(ctx, types.NamespacedName{Name: comp.Spec.CompDef}, compDef); err != nil { |
| 129 | return false, err |
| 130 | } |
| 131 | if hasHostNetworkCapability(nil, compDef) { |
| 132 | return true, nil |
| 133 | } |
| 134 | } |
| 135 | return false, nil |
| 136 | } |
| 137 | |
| 138 | func hasHostNetworkCapability(synthesizedComp *SynthesizedComponent, compDef *appsv1.ComponentDefinition) bool { |
| 139 | switch { |
no test coverage detected
searching dependent graphs…