| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
package v1 |
| 20 |
|
| 21 |
import ( |
| 22 |
networkingv1 "k8s.io/api/networking/v1" |
| 23 |
apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 24 |
types "k8s.io/apimachinery/pkg/types" |
| 25 |
managedfields "k8s.io/apimachinery/pkg/util/managedfields" |
| 26 |
internal "k8s.io/client-go/applyconfigurations/internal" |
| 27 |
metav1 "k8s.io/client-go/applyconfigurations/meta/v1" |
| 28 |
) |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
type NetworkPolicyApplyConfiguration struct { |
| 33 |
metav1.TypeMetaApplyConfiguration `json:",inline"` |
| 34 |
*metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` |
| 35 |
Spec *NetworkPolicySpecApplyConfiguration `json:"spec,omitempty"` |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
func NetworkPolicy(name, namespace string) *NetworkPolicyApplyConfiguration { |
| 41 |
b := &NetworkPolicyApplyConfiguration{} |
| 42 |
b.WithName(name) |
| 43 |
b.WithNamespace(namespace) |
| 44 |
b.WithKind("NetworkPolicy") |
| 45 |
b.WithAPIVersion("networking.k8s.io/v1") |
| 46 |
return b |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
func ExtractNetworkPolicy(networkPolicy *networkingv1.NetworkPolicy, fieldManager string) (*NetworkPolicyApplyConfiguration, error) { |
| 61 |
return extractNetworkPolicy(networkPolicy, fieldManager, "") |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
func ExtractNetworkPolicyStatus(networkPolicy *networkingv1.NetworkPolicy, fieldManager string) (*NetworkPolicyApplyConfiguration, error) { |
| 68 |
return extractNetworkPolicy(networkPolicy, fieldManager, "status") |
| 69 |
} |
| 70 |
|
| 71 |
func extractNetworkPolicy(networkPolicy *networkingv1.NetworkPolicy, fieldManager string, subresource string) (*NetworkPolicyApplyConfiguration, error) { |
| 72 |
b := &NetworkPolicyApplyConfiguration{} |
| 73 |
err := managedfields.ExtractInto(networkPolicy, internal.Parser().Type("io.k8s.api.networking.v1.NetworkPolicy"), fieldManager, b, subresource) |
| 74 |
if err != nil { |
| 75 |
return nil, err |
| 76 |
} |
| 77 |
b.WithName(networkPolicy.Name) |
| 78 |
b.WithNamespace(networkPolicy.Namespace) |
| 79 |
|
| 80 |
b.WithKind("NetworkPolicy") |
| 81 |
b.WithAPIVersion("networking.k8s.io/v1") |
| 82 |
return b, nil |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
func (b *NetworkPolicyApplyConfiguration) WithKind(value string) *NetworkPolicyApplyConfiguration { |
| 89 |
b.TypeMetaApplyConfiguration.Kind = &value |
| 90 |
return b |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
func (b *NetworkPolicyApplyConfiguration) WithAPIVersion(value string) *NetworkPolicyApplyConfiguration { |
| 97 |
b.TypeMetaApplyConfiguration.APIVersion = &value |
| 98 |
return b |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
func (b *NetworkPolicyApplyConfiguration) WithName(value string) *NetworkPolicyApplyConfiguration { |
| 105 |
b.ensureObjectMetaApplyConfigurationExists() |
| 106 |
b.ObjectMetaApplyConfiguration.Name = &value |
| 107 |
return b |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
func (b *NetworkPolicyApplyConfiguration) WithGenerateName(value string) *NetworkPolicyApplyConfiguration { |
| 114 |
b.ensureObjectMetaApplyConfigurationExists() |
| 115 |
b.ObjectMetaApplyConfiguration.GenerateName = &value |
| 116 |
return b |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
func (b *NetworkPolicyApplyConfiguration) WithNamespace(value string) *NetworkPolicyApplyConfiguration { |
| 123 |
b.ensureObjectMetaApplyConfigurationExists() |
| 124 |
b.ObjectMetaApplyConfiguration.Namespace = &value |
| 125 |
return b |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
func (b *NetworkPolicyApplyConfiguration) WithUID(value types.UID) *NetworkPolicyApplyConfiguration { |
| 132 |
b.ensureObjectMetaApplyConfigurationExists() |
| 133 |
b.ObjectMetaApplyConfiguration.UID = &value |
| 134 |
return b |
| 135 |
} |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
func (b *NetworkPolicyApplyConfiguration) WithResourceVersion(value string) *NetworkPolicyApplyConfiguration { |
| 141 |
b.ensureObjectMetaApplyConfigurationExists() |
| 142 |
b.ObjectMetaApplyConfiguration.ResourceVersion = &value |
| 143 |
return b |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
func (b *NetworkPolicyApplyConfiguration) WithGeneration(value int64) *NetworkPolicyApplyConfiguration { |
| 150 |
b.ensureObjectMetaApplyConfigurationExists() |
| 151 |
b.ObjectMetaApplyConfiguration.Generation = &value |
| 152 |
return b |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
func (b *NetworkPolicyApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *NetworkPolicyApplyConfiguration { |
| 159 |
b.ensureObjectMetaApplyConfigurationExists() |
| 160 |
b.ObjectMetaApplyConfiguration.CreationTimestamp = &value |
| 161 |
return b |
| 162 |
} |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
func (b *NetworkPolicyApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *NetworkPolicyApplyConfiguration { |
| 168 |
b.ensureObjectMetaApplyConfigurationExists() |
| 169 |
b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value |
| 170 |
return b |
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
func (b *NetworkPolicyApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *NetworkPolicyApplyConfiguration { |
| 177 |
b.ensureObjectMetaApplyConfigurationExists() |
| 178 |
b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value |
| 179 |
return b |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
func (b *NetworkPolicyApplyConfiguration) WithLabels(entries map[string]string) *NetworkPolicyApplyConfiguration { |
| 187 |
b.ensureObjectMetaApplyConfigurationExists() |
| 188 |
if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 { |
| 189 |
b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries)) |
| 190 |
} |
| 191 |
for k, v := range entries { |
| 192 |
b.ObjectMetaApplyConfiguration.Labels[k] = v |
| 193 |
} |
| 194 |
return b |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
func (b *NetworkPolicyApplyConfiguration) WithAnnotations(entries map[string]string) *NetworkPolicyApplyConfiguration { |
| 202 |
b.ensureObjectMetaApplyConfigurationExists() |
| 203 |
if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 { |
| 204 |
b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries)) |
| 205 |
} |
| 206 |
for k, v := range entries { |
| 207 |
b.ObjectMetaApplyConfiguration.Annotations[k] = v |
| 208 |
} |
| 209 |
return b |
| 210 |
} |
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
func (b *NetworkPolicyApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *NetworkPolicyApplyConfiguration { |
| 216 |
b.ensureObjectMetaApplyConfigurationExists() |
| 217 |
for i := range values { |
| 218 |
if values[i] == nil { |
| 219 |
panic("nil value passed to WithOwnerReferences") |
| 220 |
} |
| 221 |
b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i]) |
| 222 |
} |
| 223 |
return b |
| 224 |
} |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
func (b *NetworkPolicyApplyConfiguration) WithFinalizers(values ...string) *NetworkPolicyApplyConfiguration { |
| 230 |
b.ensureObjectMetaApplyConfigurationExists() |
| 231 |
for i := range values { |
| 232 |
b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) |
| 233 |
} |
| 234 |
return b |
| 235 |
} |
| 236 |
|
| 237 |
func (b *NetworkPolicyApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { |
| 238 |
if b.ObjectMetaApplyConfiguration == nil { |
| 239 |
b.ObjectMetaApplyConfiguration = &metav1.ObjectMetaApplyConfiguration{} |
| 240 |
} |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
func (b *NetworkPolicyApplyConfiguration) WithSpec(value *NetworkPolicySpecApplyConfiguration) *NetworkPolicyApplyConfiguration { |
| 247 |
b.Spec = value |
| 248 |
return b |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
func (b *NetworkPolicyApplyConfiguration) GetName() *string { |
| 253 |
b.ensureObjectMetaApplyConfigurationExists() |
| 254 |
return b.ObjectMetaApplyConfiguration.Name |
| 255 |
} |