github.com/cilium/cilium@v1.16.2/pkg/egressgateway/resource.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package egressgateway
     5  
     6  import (
     7  	"github.com/cilium/hive/cell"
     8  
     9  	v2 "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2"
    10  	"github.com/cilium/cilium/pkg/k8s/client"
    11  	"github.com/cilium/cilium/pkg/k8s/resource"
    12  	"github.com/cilium/cilium/pkg/k8s/utils"
    13  )
    14  
    15  type Policy = v2.CiliumEgressGatewayPolicy
    16  
    17  func newPolicyResource(lc cell.Lifecycle, c client.Clientset) resource.Resource[*Policy] {
    18  	if !c.IsEnabled() {
    19  		return nil
    20  	}
    21  	lw := utils.ListerWatcherFromTyped[*v2.CiliumEgressGatewayPolicyList](c.CiliumV2().CiliumEgressGatewayPolicies())
    22  	return resource.New[*Policy](lc, lw)
    23  }