diff --git a/hack/update-codegen-dockerized.sh b/hack/update-codegen-dockerized.sh index 59d465c62cc..0f2289b09b6 100755 --- a/hack/update-codegen-dockerized.sh +++ b/hack/update-codegen-dockerized.sh @@ -32,9 +32,10 @@ $GOPATH/bin/client-gen \ --input "clusterinformation/v1beta1" \ --input "controlplane/v1beta1" \ --input "system/v1beta1" \ - --input "security/v1alpha1" \ --input "core/v1alpha1" \ + --input "networking/v1alpha1" \ --input "ops/v1alpha1" \ + --input "security/v1alpha1" \ --input "stats/v1alpha1" \ --output-package "${ANTREA_PKG}/pkg/client/clientset" \ --plural-exceptions "NetworkPolicyStats:NetworkPolicyStats" \ @@ -44,15 +45,15 @@ $GOPATH/bin/client-gen \ # Generate listers with K8s codegen tools. $GOPATH/bin/lister-gen \ - --input-dirs "${ANTREA_PKG}/pkg/apis/security/v1alpha1,${ANTREA_PKG}/pkg/apis/core/v1alpha1" \ - --input-dirs "${ANTREA_PKG}/pkg/apis/ops/v1alpha1" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/core/v1alpha1,${ANTREA_PKG}/pkg/apis/networking/v1alpha1" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/ops/v1alpha1,${ANTREA_PKG}/pkg/apis/security/v1alpha1" \ --output-package "${ANTREA_PKG}/pkg/client/listers" \ --go-header-file hack/boilerplate/license_header.go.txt # Generate informers with K8s codegen tools. $GOPATH/bin/informer-gen \ - --input-dirs "${ANTREA_PKG}/pkg/apis/security/v1alpha1,${ANTREA_PKG}/pkg/apis/core/v1alpha1" \ - --input-dirs "${ANTREA_PKG}/pkg/apis/ops/v1alpha1" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/core/v1alpha1,${ANTREA_PKG}/pkg/apis/networking/v1alpha1" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/ops/v1alpha1,${ANTREA_PKG}/pkg/apis/security/v1alpha1" \ --versioned-clientset-package "${ANTREA_PKG}/pkg/client/clientset/versioned" \ --listers-package "${ANTREA_PKG}/pkg/client/listers" \ --output-package "${ANTREA_PKG}/pkg/client/informers" \ @@ -63,9 +64,10 @@ $GOPATH/bin/deepcopy-gen \ --input-dirs "${ANTREA_PKG}/pkg/apis/controlplane" \ --input-dirs "${ANTREA_PKG}/pkg/apis/controlplane/v1beta1" \ --input-dirs "${ANTREA_PKG}/pkg/apis/system/v1beta1" \ - --input-dirs "${ANTREA_PKG}/pkg/apis/security/v1alpha1" \ --input-dirs "${ANTREA_PKG}/pkg/apis/core/v1alpha1" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/networking/v1alpha1" \ --input-dirs "${ANTREA_PKG}/pkg/apis/ops/v1alpha1" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/security/v1alpha1" \ --input-dirs "${ANTREA_PKG}/pkg/apis/stats" \ --input-dirs "${ANTREA_PKG}/pkg/apis/stats/v1alpha1" \ -O zz_generated.deepcopy \ diff --git a/pkg/apis/core/v1alpha1/types.go b/pkg/apis/core/v1alpha1/types.go index ec4b0657e4d..7f083ef5289 100644 --- a/pkg/apis/core/v1alpha1/types.go +++ b/pkg/apis/core/v1alpha1/types.go @@ -74,3 +74,17 @@ type ExternalEntityList struct { Items []ExternalEntity `json:"items,omitempty"` } + +// AppliedTo defines the workloads to which a policy is applied. +type AppliedTo struct { + // Select Pods matched by this selector. If set with NamespaceSelector, + // Pods are matched from Namespaces matched by the NamespaceSelector; + // otherwise, Pods are matched from all Namespaces. + // +optional + PodSelector *metav1.LabelSelector `json:"podSelector,omitempty"` + // Select all Pods from Namespaces matched by this selector, as + // workloads in To/From fields. If set with PodSelector, + // Pods are matched from Namespaces matched by the NamespaceSelector. + // +optional + NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"` +} diff --git a/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go index 670754f1ac4..0a04dcd515a 100644 --- a/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -19,9 +19,36 @@ package v1alpha1 import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AppliedTo) DeepCopyInto(out *AppliedTo) { + *out = *in + if in.PodSelector != nil { + in, out := &in.PodSelector, &out.PodSelector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.NamespaceSelector != nil { + in, out := &in.NamespaceSelector, &out.NamespaceSelector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppliedTo. +func (in *AppliedTo) DeepCopy() *AppliedTo { + if in == nil { + return nil + } + out := new(AppliedTo) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Endpoint) DeepCopyInto(out *Endpoint) { *out = *in diff --git a/pkg/apis/networking/v1alpha1/doc.go b/pkg/apis/networking/v1alpha1/doc.go new file mode 100644 index 00000000000..3819e840128 --- /dev/null +++ b/pkg/apis/networking/v1alpha1/doc.go @@ -0,0 +1,19 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package +// +groupName=networking.antrea.tanzu.vmware.com + +package v1alpha1 // import "github.com/vmware-tanzu/antrea/pkg/apis/networking/v1alpha1" diff --git a/pkg/apis/networking/v1alpha1/register.go b/pkg/apis/networking/v1alpha1/register.go new file mode 100644 index 00000000000..c4ed8b06d2f --- /dev/null +++ b/pkg/apis/networking/v1alpha1/register.go @@ -0,0 +1,53 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name used in this package. +const GroupName = "networking.antrea.tanzu.vmware.com" + +// SchemeGroupVersion is group version used to register these objects. +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource. +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &SNATPolicy{}, + &SNATPolicyList{}, + ) + + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/networking/v1alpha1/types.go b/pkg/apis/networking/v1alpha1/types.go new file mode 100644 index 00000000000..5c9f91348b5 --- /dev/null +++ b/pkg/apis/networking/v1alpha1/types.go @@ -0,0 +1,52 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + antreacore "github.com/vmware-tanzu/antrea/pkg/apis/core/v1alpha1" +) + +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type SNATPolicy struct { + metav1.TypeMeta `json:",inline"` + // Standard metadata of the object. + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Specification of the desired behavior of SNATPolicy. + Spec SNATPolicySpec `json:"spec"` +} + +// SNATPolicySpec defines the desired state for SNATPolicy. +type SNATPolicySpec struct { + // AppliedTo selects workloads to which the SNATPolicy will be applied. + AppliedTo antreacore.AppliedTo `json:"appliedTo"` + // SNATIP specifies the SNAT IP address for the selected workloads. + SNATIP string +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type SNATPolicyList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + Items []SNATPolicy `json:"items"` +} diff --git a/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..126ce0cb427 --- /dev/null +++ b/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,100 @@ +// +build !ignore_autogenerated + +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SNATPolicy) DeepCopyInto(out *SNATPolicy) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SNATPolicy. +func (in *SNATPolicy) DeepCopy() *SNATPolicy { + if in == nil { + return nil + } + out := new(SNATPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SNATPolicy) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SNATPolicyList) DeepCopyInto(out *SNATPolicyList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SNATPolicy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SNATPolicyList. +func (in *SNATPolicyList) DeepCopy() *SNATPolicyList { + if in == nil { + return nil + } + out := new(SNATPolicyList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SNATPolicyList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SNATPolicySpec) DeepCopyInto(out *SNATPolicySpec) { + *out = *in + in.AppliedTo.DeepCopyInto(&out.AppliedTo) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SNATPolicySpec. +func (in *SNATPolicySpec) DeepCopy() *SNATPolicySpec { + if in == nil { + return nil + } + out := new(SNATPolicySpec) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 339988f6d52..ff86afc13b4 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -22,6 +22,7 @@ import ( clusterinformationv1beta1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/clusterinformation/v1beta1" controlplanev1beta1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/controlplane/v1beta1" corev1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/core/v1alpha1" + networkingv1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/networking/v1alpha1" opsv1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/ops/v1alpha1" securityv1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/security/v1alpha1" statsv1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/stats/v1alpha1" @@ -36,6 +37,7 @@ type Interface interface { ClusterinformationV1beta1() clusterinformationv1beta1.ClusterinformationV1beta1Interface ControlplaneV1beta1() controlplanev1beta1.ControlplaneV1beta1Interface CoreV1alpha1() corev1alpha1.CoreV1alpha1Interface + NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1Interface OpsV1alpha1() opsv1alpha1.OpsV1alpha1Interface SecurityV1alpha1() securityv1alpha1.SecurityV1alpha1Interface StatsV1alpha1() statsv1alpha1.StatsV1alpha1Interface @@ -49,6 +51,7 @@ type Clientset struct { clusterinformationV1beta1 *clusterinformationv1beta1.ClusterinformationV1beta1Client controlplaneV1beta1 *controlplanev1beta1.ControlplaneV1beta1Client coreV1alpha1 *corev1alpha1.CoreV1alpha1Client + networkingV1alpha1 *networkingv1alpha1.NetworkingV1alpha1Client opsV1alpha1 *opsv1alpha1.OpsV1alpha1Client securityV1alpha1 *securityv1alpha1.SecurityV1alpha1Client statsV1alpha1 *statsv1alpha1.StatsV1alpha1Client @@ -70,6 +73,11 @@ func (c *Clientset) CoreV1alpha1() corev1alpha1.CoreV1alpha1Interface { return c.coreV1alpha1 } +// NetworkingV1alpha1 retrieves the NetworkingV1alpha1Client +func (c *Clientset) NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1Interface { + return c.networkingV1alpha1 +} + // OpsV1alpha1 retrieves the OpsV1alpha1Client func (c *Clientset) OpsV1alpha1() opsv1alpha1.OpsV1alpha1Interface { return c.opsV1alpha1 @@ -123,6 +131,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.networkingV1alpha1, err = networkingv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.opsV1alpha1, err = opsv1alpha1.NewForConfig(&configShallowCopy) if err != nil { return nil, err @@ -154,6 +166,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { cs.clusterinformationV1beta1 = clusterinformationv1beta1.NewForConfigOrDie(c) cs.controlplaneV1beta1 = controlplanev1beta1.NewForConfigOrDie(c) cs.coreV1alpha1 = corev1alpha1.NewForConfigOrDie(c) + cs.networkingV1alpha1 = networkingv1alpha1.NewForConfigOrDie(c) cs.opsV1alpha1 = opsv1alpha1.NewForConfigOrDie(c) cs.securityV1alpha1 = securityv1alpha1.NewForConfigOrDie(c) cs.statsV1alpha1 = statsv1alpha1.NewForConfigOrDie(c) @@ -169,6 +182,7 @@ func New(c rest.Interface) *Clientset { cs.clusterinformationV1beta1 = clusterinformationv1beta1.New(c) cs.controlplaneV1beta1 = controlplanev1beta1.New(c) cs.coreV1alpha1 = corev1alpha1.New(c) + cs.networkingV1alpha1 = networkingv1alpha1.New(c) cs.opsV1alpha1 = opsv1alpha1.New(c) cs.securityV1alpha1 = securityv1alpha1.New(c) cs.statsV1alpha1 = statsv1alpha1.New(c) diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index d777d5e69cc..eb899eb67d8 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -24,6 +24,8 @@ import ( fakecontrolplanev1beta1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/controlplane/v1beta1/fake" corev1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/core/v1alpha1" fakecorev1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/core/v1alpha1/fake" + networkingv1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/networking/v1alpha1" + fakenetworkingv1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake" opsv1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/ops/v1alpha1" fakeopsv1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/ops/v1alpha1/fake" securityv1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/security/v1alpha1" @@ -101,6 +103,11 @@ func (c *Clientset) CoreV1alpha1() corev1alpha1.CoreV1alpha1Interface { return &fakecorev1alpha1.FakeCoreV1alpha1{Fake: &c.Fake} } +// NetworkingV1alpha1 retrieves the NetworkingV1alpha1Client +func (c *Clientset) NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1Interface { + return &fakenetworkingv1alpha1.FakeNetworkingV1alpha1{Fake: &c.Fake} +} + // OpsV1alpha1 retrieves the OpsV1alpha1Client func (c *Clientset) OpsV1alpha1() opsv1alpha1.OpsV1alpha1Interface { return &fakeopsv1alpha1.FakeOpsV1alpha1{Fake: &c.Fake} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index b8cc51121e6..2d299c79345 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -20,6 +20,7 @@ import ( clusterinformationv1beta1 "github.com/vmware-tanzu/antrea/pkg/apis/clusterinformation/v1beta1" controlplanev1beta1 "github.com/vmware-tanzu/antrea/pkg/apis/controlplane/v1beta1" corev1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/core/v1alpha1" + networkingv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/networking/v1alpha1" opsv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/ops/v1alpha1" securityv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/security/v1alpha1" statsv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/stats/v1alpha1" @@ -38,6 +39,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ clusterinformationv1beta1.AddToScheme, controlplanev1beta1.AddToScheme, corev1alpha1.AddToScheme, + networkingv1alpha1.AddToScheme, opsv1alpha1.AddToScheme, securityv1alpha1.AddToScheme, statsv1alpha1.AddToScheme, diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index a939b04f67c..232fcf3be3c 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -20,6 +20,7 @@ import ( clusterinformationv1beta1 "github.com/vmware-tanzu/antrea/pkg/apis/clusterinformation/v1beta1" controlplanev1beta1 "github.com/vmware-tanzu/antrea/pkg/apis/controlplane/v1beta1" corev1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/core/v1alpha1" + networkingv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/networking/v1alpha1" opsv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/ops/v1alpha1" securityv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/security/v1alpha1" statsv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/stats/v1alpha1" @@ -38,6 +39,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ clusterinformationv1beta1.AddToScheme, controlplanev1beta1.AddToScheme, corev1alpha1.AddToScheme, + networkingv1alpha1.AddToScheme, opsv1alpha1.AddToScheme, securityv1alpha1.AddToScheme, statsv1alpha1.AddToScheme, diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/doc.go new file mode 100644 index 00000000000..16e4506b415 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/networking/v1alpha1/doc.go @@ -0,0 +1,18 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/doc.go new file mode 100644 index 00000000000..ed1b262831b --- /dev/null +++ b/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/doc.go @@ -0,0 +1,18 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go new file mode 100644 index 00000000000..d46bd53dad6 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go @@ -0,0 +1,38 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/networking/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeNetworkingV1alpha1 struct { + *testing.Fake +} + +func (c *FakeNetworkingV1alpha1) SNATPolicies(namespace string) v1alpha1.SNATPolicyInterface { + return &FakeSNATPolicies{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeNetworkingV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_snatpolicy.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_snatpolicy.go new file mode 100644 index 00000000000..c79197a3893 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_snatpolicy.go @@ -0,0 +1,128 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeSNATPolicies implements SNATPolicyInterface +type FakeSNATPolicies struct { + Fake *FakeNetworkingV1alpha1 + ns string +} + +var snatpoliciesResource = schema.GroupVersionResource{Group: "networking.antrea.tanzu.vmware.com", Version: "v1alpha1", Resource: "snatpolicies"} + +var snatpoliciesKind = schema.GroupVersionKind{Group: "networking.antrea.tanzu.vmware.com", Version: "v1alpha1", Kind: "SNATPolicy"} + +// Get takes name of the sNATPolicy, and returns the corresponding sNATPolicy object, and an error if there is any. +func (c *FakeSNATPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SNATPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(snatpoliciesResource, c.ns, name), &v1alpha1.SNATPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SNATPolicy), err +} + +// List takes label and field selectors, and returns the list of SNATPolicies that match those selectors. +func (c *FakeSNATPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SNATPolicyList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(snatpoliciesResource, snatpoliciesKind, c.ns, opts), &v1alpha1.SNATPolicyList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.SNATPolicyList{ListMeta: obj.(*v1alpha1.SNATPolicyList).ListMeta} + for _, item := range obj.(*v1alpha1.SNATPolicyList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested sNATPolicies. +func (c *FakeSNATPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(snatpoliciesResource, c.ns, opts)) + +} + +// Create takes the representation of a sNATPolicy and creates it. Returns the server's representation of the sNATPolicy, and an error, if there is any. +func (c *FakeSNATPolicies) Create(ctx context.Context, sNATPolicy *v1alpha1.SNATPolicy, opts v1.CreateOptions) (result *v1alpha1.SNATPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(snatpoliciesResource, c.ns, sNATPolicy), &v1alpha1.SNATPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SNATPolicy), err +} + +// Update takes the representation of a sNATPolicy and updates it. Returns the server's representation of the sNATPolicy, and an error, if there is any. +func (c *FakeSNATPolicies) Update(ctx context.Context, sNATPolicy *v1alpha1.SNATPolicy, opts v1.UpdateOptions) (result *v1alpha1.SNATPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(snatpoliciesResource, c.ns, sNATPolicy), &v1alpha1.SNATPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SNATPolicy), err +} + +// Delete takes name of the sNATPolicy and deletes it. Returns an error if one occurs. +func (c *FakeSNATPolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(snatpoliciesResource, c.ns, name), &v1alpha1.SNATPolicy{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSNATPolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(snatpoliciesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.SNATPolicyList{}) + return err +} + +// Patch applies the patch and returns the patched sNATPolicy. +func (c *FakeSNATPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SNATPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(snatpoliciesResource, c.ns, name, pt, data, subresources...), &v1alpha1.SNATPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SNATPolicy), err +} diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go new file mode 100644 index 00000000000..35b038fa2cd --- /dev/null +++ b/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go @@ -0,0 +1,19 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type SNATPolicyExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go new file mode 100644 index 00000000000..b816cf0ed24 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go @@ -0,0 +1,87 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/networking/v1alpha1" + "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type NetworkingV1alpha1Interface interface { + RESTClient() rest.Interface + SNATPoliciesGetter +} + +// NetworkingV1alpha1Client is used to interact with features provided by the networking.antrea.tanzu.vmware.com group. +type NetworkingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *NetworkingV1alpha1Client) SNATPolicies(namespace string) SNATPolicyInterface { + return newSNATPolicies(c, namespace) +} + +// NewForConfig creates a new NetworkingV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*NetworkingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &NetworkingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new NetworkingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *NetworkingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new NetworkingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *NetworkingV1alpha1Client { + return &NetworkingV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *NetworkingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/snatpolicy.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/snatpolicy.go new file mode 100644 index 00000000000..75c2c8419eb --- /dev/null +++ b/pkg/client/clientset/versioned/typed/networking/v1alpha1/snatpolicy.go @@ -0,0 +1,176 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/networking/v1alpha1" + scheme "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// SNATPoliciesGetter has a method to return a SNATPolicyInterface. +// A group's client should implement this interface. +type SNATPoliciesGetter interface { + SNATPolicies(namespace string) SNATPolicyInterface +} + +// SNATPolicyInterface has methods to work with SNATPolicy resources. +type SNATPolicyInterface interface { + Create(ctx context.Context, sNATPolicy *v1alpha1.SNATPolicy, opts v1.CreateOptions) (*v1alpha1.SNATPolicy, error) + Update(ctx context.Context, sNATPolicy *v1alpha1.SNATPolicy, opts v1.UpdateOptions) (*v1alpha1.SNATPolicy, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.SNATPolicy, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.SNATPolicyList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SNATPolicy, err error) + SNATPolicyExpansion +} + +// sNATPolicies implements SNATPolicyInterface +type sNATPolicies struct { + client rest.Interface + ns string +} + +// newSNATPolicies returns a SNATPolicies +func newSNATPolicies(c *NetworkingV1alpha1Client, namespace string) *sNATPolicies { + return &sNATPolicies{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the sNATPolicy, and returns the corresponding sNATPolicy object, and an error if there is any. +func (c *sNATPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SNATPolicy, err error) { + result = &v1alpha1.SNATPolicy{} + err = c.client.Get(). + Namespace(c.ns). + Resource("snatpolicies"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SNATPolicies that match those selectors. +func (c *sNATPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SNATPolicyList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.SNATPolicyList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("snatpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested sNATPolicies. +func (c *sNATPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("snatpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a sNATPolicy and creates it. Returns the server's representation of the sNATPolicy, and an error, if there is any. +func (c *sNATPolicies) Create(ctx context.Context, sNATPolicy *v1alpha1.SNATPolicy, opts v1.CreateOptions) (result *v1alpha1.SNATPolicy, err error) { + result = &v1alpha1.SNATPolicy{} + err = c.client.Post(). + Namespace(c.ns). + Resource("snatpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(sNATPolicy). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a sNATPolicy and updates it. Returns the server's representation of the sNATPolicy, and an error, if there is any. +func (c *sNATPolicies) Update(ctx context.Context, sNATPolicy *v1alpha1.SNATPolicy, opts v1.UpdateOptions) (result *v1alpha1.SNATPolicy, err error) { + result = &v1alpha1.SNATPolicy{} + err = c.client.Put(). + Namespace(c.ns). + Resource("snatpolicies"). + Name(sNATPolicy.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(sNATPolicy). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the sNATPolicy and deletes it. Returns an error if one occurs. +func (c *sNATPolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("snatpolicies"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *sNATPolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("snatpolicies"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched sNATPolicy. +func (c *sNATPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SNATPolicy, err error) { + result = &v1alpha1.SNATPolicy{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("snatpolicies"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index 57f83a57ad8..71d303ace19 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -24,6 +24,7 @@ import ( versioned "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned" core "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/core" internalinterfaces "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/internalinterfaces" + networking "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/networking" ops "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/ops" security "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/security" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -173,6 +174,7 @@ type SharedInformerFactory interface { WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool Core() core.Interface + Networking() networking.Interface Ops() ops.Interface Security() security.Interface } @@ -181,6 +183,10 @@ func (f *sharedInformerFactory) Core() core.Interface { return core.New(f, f.namespace, f.tweakListOptions) } +func (f *sharedInformerFactory) Networking() networking.Interface { + return networking.New(f, f.namespace, f.tweakListOptions) +} + func (f *sharedInformerFactory) Ops() ops.Interface { return ops.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 70e798e27e7..f73637b9948 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -20,6 +20,7 @@ import ( "fmt" v1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/core/v1alpha1" + networkingv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/networking/v1alpha1" opsv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/ops/v1alpha1" securityv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/security/v1alpha1" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -56,6 +57,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha1.SchemeGroupVersion.WithResource("externalentities"): return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().ExternalEntities().Informer()}, nil + // Group=networking.antrea.tanzu.vmware.com, Version=v1alpha1 + case networkingv1alpha1.SchemeGroupVersion.WithResource("snatpolicies"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().SNATPolicies().Informer()}, nil + // Group=ops.antrea.tanzu.vmware.com, Version=v1alpha1 case opsv1alpha1.SchemeGroupVersion.WithResource("traceflows"): return &genericInformer{resource: resource.GroupResource(), informer: f.Ops().V1alpha1().Traceflows().Informer()}, nil diff --git a/pkg/client/informers/externalversions/networking/interface.go b/pkg/client/informers/externalversions/networking/interface.go new file mode 100644 index 00000000000..9f6395ad567 --- /dev/null +++ b/pkg/client/informers/externalversions/networking/interface.go @@ -0,0 +1,44 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by informer-gen. DO NOT EDIT. + +package networking + +import ( + internalinterfaces "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/networking/v1alpha1" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/networking/v1alpha1/interface.go b/pkg/client/informers/externalversions/networking/v1alpha1/interface.go new file mode 100644 index 00000000000..5f3942b799e --- /dev/null +++ b/pkg/client/informers/externalversions/networking/v1alpha1/interface.go @@ -0,0 +1,43 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // SNATPolicies returns a SNATPolicyInformer. + SNATPolicies() SNATPolicyInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// SNATPolicies returns a SNATPolicyInformer. +func (v *version) SNATPolicies() SNATPolicyInformer { + return &sNATPolicyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/networking/v1alpha1/snatpolicy.go b/pkg/client/informers/externalversions/networking/v1alpha1/snatpolicy.go new file mode 100644 index 00000000000..c014691d81a --- /dev/null +++ b/pkg/client/informers/externalversions/networking/v1alpha1/snatpolicy.go @@ -0,0 +1,88 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + networkingv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/networking/v1alpha1" + versioned "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned" + internalinterfaces "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/listers/networking/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// SNATPolicyInformer provides access to a shared informer and lister for +// SNATPolicies. +type SNATPolicyInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.SNATPolicyLister +} + +type sNATPolicyInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewSNATPolicyInformer constructs a new informer for SNATPolicy type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewSNATPolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredSNATPolicyInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredSNATPolicyInformer constructs a new informer for SNATPolicy type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredSNATPolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().SNATPolicies(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().SNATPolicies(namespace).Watch(context.TODO(), options) + }, + }, + &networkingv1alpha1.SNATPolicy{}, + resyncPeriod, + indexers, + ) +} + +func (f *sNATPolicyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredSNATPolicyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *sNATPolicyInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&networkingv1alpha1.SNATPolicy{}, f.defaultInformer) +} + +func (f *sNATPolicyInformer) Lister() v1alpha1.SNATPolicyLister { + return v1alpha1.NewSNATPolicyLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/listers/networking/v1alpha1/expansion_generated.go b/pkg/client/listers/networking/v1alpha1/expansion_generated.go new file mode 100644 index 00000000000..cd4d713bf5f --- /dev/null +++ b/pkg/client/listers/networking/v1alpha1/expansion_generated.go @@ -0,0 +1,25 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// SNATPolicyListerExpansion allows custom methods to be added to +// SNATPolicyLister. +type SNATPolicyListerExpansion interface{} + +// SNATPolicyNamespaceListerExpansion allows custom methods to be added to +// SNATPolicyNamespaceLister. +type SNATPolicyNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/networking/v1alpha1/snatpolicy.go b/pkg/client/listers/networking/v1alpha1/snatpolicy.go new file mode 100644 index 00000000000..f0cffad8a78 --- /dev/null +++ b/pkg/client/listers/networking/v1alpha1/snatpolicy.go @@ -0,0 +1,92 @@ +// Copyright 2020 Antrea Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/networking/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// SNATPolicyLister helps list SNATPolicies. +type SNATPolicyLister interface { + // List lists all SNATPolicies in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.SNATPolicy, err error) + // SNATPolicies returns an object that can list and get SNATPolicies. + SNATPolicies(namespace string) SNATPolicyNamespaceLister + SNATPolicyListerExpansion +} + +// sNATPolicyLister implements the SNATPolicyLister interface. +type sNATPolicyLister struct { + indexer cache.Indexer +} + +// NewSNATPolicyLister returns a new SNATPolicyLister. +func NewSNATPolicyLister(indexer cache.Indexer) SNATPolicyLister { + return &sNATPolicyLister{indexer: indexer} +} + +// List lists all SNATPolicies in the indexer. +func (s *sNATPolicyLister) List(selector labels.Selector) (ret []*v1alpha1.SNATPolicy, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.SNATPolicy)) + }) + return ret, err +} + +// SNATPolicies returns an object that can list and get SNATPolicies. +func (s *sNATPolicyLister) SNATPolicies(namespace string) SNATPolicyNamespaceLister { + return sNATPolicyNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// SNATPolicyNamespaceLister helps list and get SNATPolicies. +type SNATPolicyNamespaceLister interface { + // List lists all SNATPolicies in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.SNATPolicy, err error) + // Get retrieves the SNATPolicy from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.SNATPolicy, error) + SNATPolicyNamespaceListerExpansion +} + +// sNATPolicyNamespaceLister implements the SNATPolicyNamespaceLister +// interface. +type sNATPolicyNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all SNATPolicies in the indexer for a given namespace. +func (s sNATPolicyNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.SNATPolicy, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.SNATPolicy)) + }) + return ret, err +} + +// Get retrieves the SNATPolicy from the indexer for a given namespace and name. +func (s sNATPolicyNamespaceLister) Get(name string) (*v1alpha1.SNATPolicy, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("snatpolicy"), name) + } + return obj.(*v1alpha1.SNATPolicy), nil +}