github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/apis/projectcalico/v3/tier.go (about) 1 // Copyright (c) 2017, 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 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 18 19 const ( 20 KindTier = "Tier" 21 KindTierList = "TierList" 22 ) 23 24 // +genclient 25 // +genclient:nonNamespaced 26 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 27 28 // Tier contains a set of policies that are applied to packets. Multiple tiers may 29 // be created and each tier is applied in the order specified in the tier specification. 30 // Tier is globally-scoped (i.e. not Namespaced). 31 type Tier struct { 32 metav1.TypeMeta `json:",inline"` 33 // Standard object's metadata. 34 metav1.ObjectMeta `json:"metadata,omitempty"` 35 // Specification of the Tier. 36 Spec TierSpec `json:"spec,omitempty"` 37 } 38 39 // TierSpec contains the specification for a security policy tier resource. 40 type TierSpec struct { 41 // Order is an optional field that specifies the order in which the tier is applied. 42 // Tiers with higher "order" are applied after those with lower order. If the order 43 // is omitted, it may be considered to be "infinite" - i.e. the tier will be applied 44 // last. Tiers with identical order will be applied in alphanumerical order based 45 // on the Tier "Name". 46 Order *float64 `json:"order,omitempty"` 47 } 48 49 // +genclient:nonNamespaced 50 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 51 52 // TierList contains a list of Tier resources. 53 type TierList struct { 54 metav1.TypeMeta `json:",inline"` 55 metav1.ListMeta `json:"metadata"` 56 Items []Tier `json:"items"` 57 } 58 59 // NewTier creates a new (zeroed) Tier struct with the TypeMetadata initialised to the current 60 // version. 61 func NewTier() *Tier { 62 return &Tier{ 63 TypeMeta: metav1.TypeMeta{ 64 Kind: KindTier, 65 APIVersion: GroupVersionCurrent, 66 }, 67 } 68 } 69 70 // NewTierList creates a new (zeroed) TierList struct with the TypeMetadata initialised to the current 71 // version. 72 func NewTierList() *TierList { 73 return &TierList{ 74 TypeMeta: metav1.TypeMeta{ 75 Kind: KindTierList, 76 APIVersion: GroupVersionCurrent, 77 }, 78 } 79 }