func istioWhitelistHandler()

in appconfigmgrv2/controllers/istio_handlers.go [83:114]


func istioWhitelistHandler(
	cfg Config,
	t *appconfig.AppEnvConfigTemplateV2,
	i int,
) (*unstructured.Unstructured, error) {
	var allowedClients types.ListValue
	for _, allowed := range t.Spec.Services[i].AllowedClients {
		val := allowed.Name
		if !strings.Contains(val, "/") {
			// Append a default namespace.
			val = t.Namespace + "/" + val
		}
		allowedClients.Values = append(allowedClients.Values, &types.Value{Kind: &types.Value_StringValue{StringValue: val}})
	}

	meta := map[string]interface{}{
		"name":      istioWhitelistHandlerName(t, i),
		"namespace": t.Namespace,
	}
	spec := &istiopolicy.Handler{
		CompiledAdapter: "listchecker",
		Params: &types.Struct{
			Fields: map[string]*types.Value{
				"overrides":       {Kind: &types.Value_ListValue{ListValue: &allowedClients}},
				"blacklist":       {Kind: &types.Value_BoolValue{BoolValue: false}},
				"cachingInterval": {Kind: &types.Value_StringValue{StringValue: cfg.PolicyCachingInterval}},
			},
		},
	}

	return unstructuredFromProto(istioHandlerGVK(), meta, spec)
}