github.phpd.cn/cilium/cilium@v1.6.12/pkg/k8s/types/types.go (about)

     1  // Copyright 2019 Authors of Cilium
     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 types
    16  
    17  import (
    18  	"github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2"
    19  
    20  	"k8s.io/api/core/v1"
    21  	"k8s.io/api/extensions/v1beta1"
    22  	networkingv1 "k8s.io/api/networking/v1"
    23  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    24  )
    25  
    26  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    27  type NetworkPolicy struct {
    28  	*networkingv1.NetworkPolicy
    29  }
    30  
    31  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    32  type Service struct {
    33  	*v1.Service
    34  }
    35  
    36  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    37  type Endpoints struct {
    38  	*v1.Endpoints
    39  }
    40  
    41  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    42  type Ingress struct {
    43  	*v1beta1.Ingress
    44  }
    45  
    46  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    47  type SlimCNP struct {
    48  	*v2.CiliumNetworkPolicy
    49  }
    50  
    51  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    52  type Pod struct {
    53  	metav1.TypeMeta
    54  	metav1.ObjectMeta
    55  	StatusPodIP     string
    56  	StatusHostIP    string
    57  	SpecHostNetwork bool
    58  }
    59  
    60  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    61  type Node struct {
    62  	metav1.TypeMeta
    63  	metav1.ObjectMeta
    64  	Type            v1.NodeAddressType
    65  	StatusAddresses []v1.NodeAddress
    66  	SpecPodCIDR     string
    67  	SpecTaints      []v1.Taint
    68  }
    69  
    70  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    71  type Namespace struct {
    72  	metav1.TypeMeta
    73  	metav1.ObjectMeta
    74  }
    75  
    76  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    77  type Identity struct {
    78  	*v2.CiliumIdentity
    79  }
    80  
    81  // ConvertToIdentity converts a *v1.Namespace into a *types.Namespace.
    82  // WARNING calling this function will set *all* fields of the given Namespace as
    83  // empty.
    84  func ConvertToIdentity(obj interface{}) interface{} {
    85  	identity, ok := obj.(*v2.CiliumIdentity)
    86  	if !ok {
    87  		return nil
    88  	}
    89  	return &Identity{
    90  		CiliumIdentity: identity,
    91  	}
    92  }
    93  
    94  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    95  type CiliumEndpoint struct {
    96  	metav1.TypeMeta
    97  	metav1.ObjectMeta
    98  	Identity   *v2.EndpointIdentity
    99  	Networking *v2.EndpointNetworking
   100  	Encryption *v2.EncryptionSpec
   101  }