-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aggregated annotations and labels. (#2027)
- Loading branch information
1 parent
ee215e8
commit 1310535
Showing
9 changed files
with
250 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
pkg/yurtmanager/controller/loadbalancerset/loadbalancerset/aggregatetoannotations.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright 2024 The OpenYurt Authors. | ||
Licensed under the Apache License, Version 2.0 (the License); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an AS IS BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package loadbalancerset | ||
|
||
import ( | ||
"reflect" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
|
||
netv1alpha1 "github.com/openyurtio/openyurt/pkg/apis/network/v1alpha1" | ||
) | ||
|
||
func aggregatePoolServicesAnnotations(poolServices []netv1alpha1.PoolService) map[string]string { | ||
var annotationsList []map[string]string | ||
for _, ps := range poolServices { | ||
annotationsList = append(annotationsList, ps.Status.AggregateToAnnotations) | ||
} | ||
|
||
return aggregatedMaps(annotationsList...) | ||
} | ||
|
||
func compareAndUpdateServiceAnnotations(svc *corev1.Service, aggregatedAnnotations map[string]string) bool { | ||
currentAggregatedAnnotations := filterIgnoredKeys(svc.Annotations) | ||
|
||
if reflect.DeepEqual(currentAggregatedAnnotations, aggregatedAnnotations) { | ||
return false | ||
} | ||
|
||
svc.Annotations = mergeAndPurgeMap(svc.Annotations, aggregatedAnnotations) | ||
|
||
return true | ||
} |
46 changes: 46 additions & 0 deletions
46
pkg/yurtmanager/controller/loadbalancerset/loadbalancerset/aggregatetolabels.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright 2024 The OpenYurt Authors. | ||
Licensed under the Apache License, Version 2.0 (the License); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an AS IS BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package loadbalancerset | ||
|
||
import ( | ||
"reflect" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
|
||
"github.com/openyurtio/openyurt/pkg/apis/network/v1alpha1" | ||
) | ||
|
||
func aggregatePoolServicesLabels(poolServices []v1alpha1.PoolService) map[string]string { | ||
var labelList []map[string]string | ||
for _, ps := range poolServices { | ||
labelList = append(labelList, ps.Status.AggregateToLabels) | ||
} | ||
|
||
return aggregatedMaps(labelList...) | ||
} | ||
|
||
func compareAndUpdateServiceLabels(svc *v1.Service, aggregatedLabels map[string]string) bool { | ||
currentAggregatedLabels := filterIgnoredKeys(svc.Labels) | ||
|
||
if reflect.DeepEqual(currentAggregatedLabels, aggregatedLabels) { | ||
return false | ||
} | ||
|
||
svc.Labels = mergeAndPurgeMap(svc.Labels, aggregatedLabels) | ||
|
||
return true | ||
} |
167 changes: 0 additions & 167 deletions
167
pkg/yurtmanager/controller/loadbalancerset/loadbalancerset/annotations.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.