diff --git a/apis/nodecore/v1alpha1/network_intent.go b/apis/nodecore/v1alpha1/network_intent.go index 1a119a0..a278bcf 100644 --- a/apis/nodecore/v1alpha1/network_intent.go +++ b/apis/nodecore/v1alpha1/network_intent.go @@ -52,8 +52,8 @@ type ResourceSelector struct { // SourceDestination can represent either the source or destination of a network intent. type SourceDestination struct { - // IsHotCluster is true if the source/destination is a hot cluster. - IsHotCluster bool `json:"isHotCluster"` + // IsHostCluster is true if the source/destination is a hot cluster. + IsHostCluster bool `json:"isHostCluster"` // ResourceSelector is the resource selector of the source/destination. ResourceSelector ResourceSelector `json:"resourceSelector"` } diff --git a/pkg/utils/models/network-identity-models.go b/pkg/utils/models/network-identity-models.go index 49d9f63..f996c7a 100644 --- a/pkg/utils/models/network-identity-models.go +++ b/pkg/utils/models/network-identity-models.go @@ -43,7 +43,7 @@ type NetworkAuthorizations struct { // SourceDestination represents the source or destination of a network intent. type SourceDestination struct { - IsHotCluster bool `json:"isHotCluster"` + IsHostCluster bool `json:"isHostCluster"` ResourceSelector ResourceSelector `json:"resourceSelectors"` } @@ -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"` } diff --git a/pkg/utils/parseutil/parseutil.go b/pkg/utils/parseutil/parseutil.go index 93f0cf7..2786de9 100644 --- a/pkg/utils/parseutil/parseutil.go +++ b/pkg/utils/parseutil/parseutil.go @@ -489,14 +489,14 @@ func ParseSourceDestination(sourceDestination nodecorev1alpha1.SourceDestination return nil, err } resourceSelector = models.ResourceSelector{ - TypeIdentifier: models.CIDRSelectorType, + TypeIdentifier: models.PodNamespaceSelectorType, Selector: podNamespaceSelectorData, } default: return nil, fmt.Errorf("unknown resource selector type") } sourceDestinationModel := models.SourceDestination{ - IsHotCluster: sourceDestination.IsHotCluster, + IsHostCluster: sourceDestination.IsHostCluster, ResourceSelector: resourceSelector, } diff --git a/pkg/utils/resourceforge/forge.go b/pkg/utils/resourceforge/forge.go index 31ffc06..2f7864b 100644 --- a/pkg/utils/resourceforge/forge.go +++ b/pkg/utils/resourceforge/forge.go @@ -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) @@ -810,7 +794,7 @@ func ForgeSourceDestinationFromObj(sourceDestination *models.SourceDestination) return nil } return &nodecorev1alpha1.SourceDestination{ - IsHotCluster: sourceDestination.IsHotCluster, + IsHostCluster: sourceDestination.IsHostCluster, ResourceSelector: *resourceSelector, } }