github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/apis/projectcalico/v3/globalnetworkset.go (about)

     1  // Copyright (c) 2018, 2021 Tigera, Inc. All rights reserved.
     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 v3
    16  
    17  import (
    18  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    19  )
    20  
    21  const (
    22  	KindGlobalNetworkSet     = "GlobalNetworkSet"
    23  	KindGlobalNetworkSetList = "GlobalNetworkSetList"
    24  )
    25  
    26  // +genclient:nonNamespaced
    27  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    28  
    29  // GlobalNetworkSetList is a list of NetworkSet objects.
    30  type GlobalNetworkSetList struct {
    31  	metav1.TypeMeta `json:",inline"`
    32  	metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    33  
    34  	Items []GlobalNetworkSet `json:"items" protobuf:"bytes,2,rep,name=items"`
    35  }
    36  
    37  // +genclient
    38  // +genclient:nonNamespaced
    39  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    40  
    41  // GlobalNetworkSet contains a set of arbitrary IP sub-networks/CIDRs and domain names that share
    42  // labels to allow rules to refer to them via selectors.  The labels of GlobalNetworkSet are not
    43  // namespaced.
    44  type GlobalNetworkSet struct {
    45  	metav1.TypeMeta   `json:",inline"`
    46  	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    47  
    48  	Spec GlobalNetworkSetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
    49  }
    50  
    51  // GlobalNetworkSetSpec contains the specification for a NetworkSet resource.
    52  type GlobalNetworkSetSpec struct {
    53  	// The list of IP networks that belong to this set.
    54  	Nets []string `json:"nets,omitempty" validate:"omitempty,dive,cidr"`
    55  	// The list of domain names that belong to this set and are honored in egress allow rules
    56  	// only.  Domain names specified here only work to allow egress traffic from the cluster to
    57  	// external destinations.  They don't work to _deny_ traffic to destinations specified by
    58  	// domain name, or to allow ingress traffic from _sources_ specified by domain name.
    59  	AllowedEgressDomains []string `json:"allowedEgressDomains,omitempty" validate:"omitempty,dive,wildname"`
    60  }
    61  
    62  // NewGlobalNetworkSet creates a new (zeroed) NetworkSet struct with the TypeMetadata initialised to the current
    63  // version.
    64  func NewGlobalNetworkSet() *GlobalNetworkSet {
    65  	return &GlobalNetworkSet{
    66  		TypeMeta: metav1.TypeMeta{
    67  			Kind:       KindGlobalNetworkSet,
    68  			APIVersion: GroupVersionCurrent,
    69  		},
    70  	}
    71  }