Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions pkg/utils/models/network-identity-models.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ type CIDRSelector string

// PodNamespaceSelector represents the pod namespace selector of a SourceDestination.
type PodNamespaceSelector struct {
Pod []keyValuePair `json:"pod"`
Namespace []keyValuePair `json:"namespace"`
}

type keyValuePair struct {
Key string `json:"key"`
Value string `json:"value"`
Pod map[string]string `json:"pod"`
Namespace map[string]string `json:"namespace"`
}
2 changes: 1 addition & 1 deletion pkg/utils/parseutil/parseutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ func ParseSourceDestination(sourceDestination nodecorev1alpha1.SourceDestination
return nil, err
}
resourceSelector = models.ResourceSelector{
TypeIdentifier: models.CIDRSelectorType,
TypeIdentifier: models.PodNamespaceSelectorType,
Selector: podNamespaceSelectorData,
}
default:
Expand Down
20 changes: 2 additions & 18 deletions pkg/utils/resourceforge/forge.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,24 +766,8 @@ func ForgeResourceSelectorFromObj(resourceSelector *models.ResourceSelector) *no
}
// Create PodNamespaceSelector nodecorev1alpha1
podNamespaceSelectorCR := nodecorev1alpha1.PodNamespaceSelector{
// Copy map of models.PodNamespaceSelector.Pod to nodecorev1alpha1.PodNamespaceSelector.Pod
Pod: func() map[string]string {
podMap := make(map[string]string)
for i := range resourceSelectorStruct.Pod {
keyValuePair := resourceSelectorStruct.Pod[i]
podMap[keyValuePair.Key] = keyValuePair.Value
}
return podMap
}(),
// Copy map of models.PodNamespaceSelector.Namespace to nodecorev1alpha1.PodNamespaceSelector.Namespace
Namespace: func() map[string]string {
namespaceMap := make(map[string]string)
for i := range resourceSelectorStruct.Namespace {
keyValuePair := resourceSelectorStruct.Namespace[i]
namespaceMap[keyValuePair.Key] = keyValuePair.Value
}
return namespaceMap
}(),
Pod: resourceSelectorStruct.Pod,
Namespace: resourceSelectorStruct.Namespace,
}
// Marshal PodNamespaceSelector to JSON
resourceSelectorData, err := json.Marshal(podNamespaceSelectorCR)
Expand Down
Loading