istio

Форк
0
51 строка · 1.5 Кб
1
// Copyright Istio Authors
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
package serviceentry
16

17
import (
18
	"k8s.io/apimachinery/pkg/types"
19

20
	networking "istio.io/api/networking/v1alpha3"
21
	"istio.io/istio/pkg/config"
22
	"istio.io/istio/pkg/config/labels"
23
)
24

25
func getWorkloadServiceEntries(ses []config.Config, wle *networking.WorkloadEntry) map[types.NamespacedName]*config.Config {
26
	out := make(map[types.NamespacedName]*config.Config)
27
	for i, cfg := range ses {
28
		se := cfg.Spec.(*networking.ServiceEntry)
29
		if se.WorkloadSelector != nil && labels.Instance(se.WorkloadSelector.Labels).Match(wle.Labels) {
30
			out[cfg.NamespacedName()] = &ses[i]
31
		}
32
	}
33

34
	return out
35
}
36

37
// returns a set of objects that are in `old` but not in `curr`
38
// For example:
39
// old = {a1, a2, a3}
40
// curr = {a1, a2, a4, a5}
41
// difference(old, curr) = {a3}
42
func difference(old, curr map[types.NamespacedName]*config.Config) []types.NamespacedName {
43
	var out []types.NamespacedName
44
	for key := range old {
45
		if _, ok := curr[key]; !ok {
46
			out = append(out, key)
47
		}
48
	}
49

50
	return out
51
}
52

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.