Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions apis/nodecore/v1alpha1/network_intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
11 changes: 3 additions & 8 deletions pkg/utils/models/network-identity-models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand All @@ -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"`
}
4 changes: 2 additions & 2 deletions pkg/utils/parseutil/parseutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
22 changes: 3 additions & 19 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 All @@ -810,7 +794,7 @@ func ForgeSourceDestinationFromObj(sourceDestination *models.SourceDestination)
return nil
}
return &nodecorev1alpha1.SourceDestination{
IsHotCluster: sourceDestination.IsHotCluster,
IsHostCluster: sourceDestination.IsHostCluster,
ResourceSelector: *resourceSelector,
}
}
Expand Down