diff --git a/hack/update-codegen-dockerized.sh b/hack/update-codegen-dockerized.sh index 06ffd0cd3ef..0589cf84d68 100755 --- a/hack/update-codegen-dockerized.sh +++ b/hack/update-codegen-dockerized.sh @@ -33,10 +33,11 @@ $GOPATH/bin/client-gen \ --input "controlplane/v1beta1" \ --input "controlplane/v1beta2" \ --input "system/v1beta1" \ - --input "security/v1alpha1" \ --input "core/v1alpha2" \ + --input "security/v1alpha1" \ --input "ops/v1alpha1" \ --input "stats/v1alpha1" \ + --input "egress/v1alpha1" \ --output-package "${ANTREA_PKG}/pkg/client/clientset" \ --plural-exceptions "NetworkPolicyStats:NetworkPolicyStats" \ --plural-exceptions "AntreaNetworkPolicyStats:AntreaNetworkPolicyStats" \ @@ -45,17 +46,21 @@ $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/v1alpha2" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/core/v1alpha2" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/security/v1alpha1" \ --input-dirs "${ANTREA_PKG}/pkg/apis/ops/v1alpha1" \ --input-dirs "${ANTREA_PKG}/pkg/apis/clusterinformation/v1beta1" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/egress/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/v1alpha2" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/core/v1alpha2" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/security/v1alpha1" \ --input-dirs "${ANTREA_PKG}/pkg/apis/ops/v1alpha1" \ --input-dirs "${ANTREA_PKG}/pkg/apis/clusterinformation/v1beta1" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/egress/v1alpha1" \ --versioned-clientset-package "${ANTREA_PKG}/pkg/client/clientset/versioned" \ --listers-package "${ANTREA_PKG}/pkg/client/listers" \ --output-package "${ANTREA_PKG}/pkg/client/informers" \ @@ -67,11 +72,12 @@ $GOPATH/bin/deepcopy-gen \ --input-dirs "${ANTREA_PKG}/pkg/apis/controlplane/v1beta1" \ --input-dirs "${ANTREA_PKG}/pkg/apis/controlplane/v1beta2" \ --input-dirs "${ANTREA_PKG}/pkg/apis/system/v1beta1" \ - --input-dirs "${ANTREA_PKG}/pkg/apis/security/v1alpha1" \ --input-dirs "${ANTREA_PKG}/pkg/apis/core/v1alpha2" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/security/v1alpha1" \ --input-dirs "${ANTREA_PKG}/pkg/apis/ops/v1alpha1" \ --input-dirs "${ANTREA_PKG}/pkg/apis/stats" \ --input-dirs "${ANTREA_PKG}/pkg/apis/stats/v1alpha1" \ + --input-dirs "${ANTREA_PKG}/pkg/apis/egress/v1alpha1" \ -O zz_generated.deepcopy \ --go-header-file hack/boilerplate/license_header.go.txt diff --git a/pkg/apis/core/v1alpha2/types.go b/pkg/apis/core/v1alpha2/types.go index aba9d7b2780..1fcf371d354 100644 --- a/pkg/apis/core/v1alpha2/types.go +++ b/pkg/apis/core/v1alpha2/types.go @@ -155,3 +155,20 @@ type ClusterGroupList struct { Items []ClusterGroup `json:"items,omitempty"` } + +// AppliedTo selects the entities 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. If set with + // PodSelector, Pods are matched from Namespaces matched by the + // NamespaceSelector. + // +optional + NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"` + // Groups is the set of ClusterGroup names. + // +optional + Groups []string `json:"groups,omitempty"` +} diff --git a/pkg/apis/core/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/core/v1alpha2/zz_generated.deepcopy.go index 5477a785e1f..41f97311df2 100644 --- a/pkg/apis/core/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/apis/core/v1alpha2/zz_generated.deepcopy.go @@ -24,6 +24,37 @@ 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 *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) + } + if in.Groups != nil { + in, out := &in.Groups, &out.Groups + *out = make([]string, len(*in)) + copy(*out, *in) + } + 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 *ClusterGroup) DeepCopyInto(out *ClusterGroup) { *out = *in diff --git a/pkg/apis/egress/doc.go b/pkg/apis/egress/doc.go new file mode 100644 index 00000000000..50b1c8199fb --- /dev/null +++ b/pkg/apis/egress/doc.go @@ -0,0 +1,18 @@ +// Copyright 2021 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:deepcopy-gen=package +// +groupName=egress.antrea.tanzu.vmware.com + +package egress diff --git a/pkg/apis/egress/register.go b/pkg/apis/egress/register.go new file mode 100644 index 00000000000..36b3ed9d648 --- /dev/null +++ b/pkg/apis/egress/register.go @@ -0,0 +1,20 @@ +// Copyright 2021 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 egress + +// GroupName is the group name used in this package +const ( + GroupName = "egress.antrea.tanzu.vmware.com" +) diff --git a/pkg/apis/egress/v1alpha1/doc.go b/pkg/apis/egress/v1alpha1/doc.go new file mode 100644 index 00000000000..76f24976263 --- /dev/null +++ b/pkg/apis/egress/v1alpha1/doc.go @@ -0,0 +1,19 @@ +// Copyright 2021 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=egress.antrea.tanzu.vmware.com + +package v1alpha1 // import "github.com/vmware-tanzu/antrea/pkg/apis/egress/v1alpha1" diff --git a/pkg/apis/egress/v1alpha1/register.go b/pkg/apis/egress/v1alpha1/register.go new file mode 100644 index 00000000000..354f8cb9685 --- /dev/null +++ b/pkg/apis/egress/v1alpha1/register.go @@ -0,0 +1,53 @@ +// Copyright 2021 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 = "egress.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, + &Egress{}, + &EgressList{}, + ) + + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/egress/v1alpha1/types.go b/pkg/apis/egress/v1alpha1/types.go new file mode 100644 index 00000000000..2929172e873 --- /dev/null +++ b/pkg/apis/egress/v1alpha1/types.go @@ -0,0 +1,55 @@ +// Copyright 2021 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/v1alpha2" +) + +// +genclient +// +genclient:nonNamespaced +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Egress defines which egress (SNAT) IP the traffic from the selected Pods to +// the external network should use. +type Egress struct { + metav1.TypeMeta `json:",inline"` + // Standard metadata of the object. + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Specification of the desired behavior of Egress. + Spec EgressSpec `json:"spec"` +} + +// EgressSpec defines the desired state for Egress. +type EgressSpec struct { + // AppliedTo selects Pods to which the Egress will be applied. + AppliedTo antreacore.AppliedTo `json:"appliedTo"` + // EgressIP specifies the SNAT IP address for the selected workloads. + EgressIP string `json:"egressIP"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type EgressList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + Items []Egress `json:"items"` +} diff --git a/pkg/apis/egress/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/egress/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..36014ab82e5 --- /dev/null +++ b/pkg/apis/egress/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,100 @@ +// +build !ignore_autogenerated + +// Copyright 2021 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 *Egress) DeepCopyInto(out *Egress) { + *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 Egress. +func (in *Egress) DeepCopy() *Egress { + if in == nil { + return nil + } + out := new(Egress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Egress) 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 *EgressList) DeepCopyInto(out *EgressList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Egress, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EgressList. +func (in *EgressList) DeepCopy() *EgressList { + if in == nil { + return nil + } + out := new(EgressList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *EgressList) 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 *EgressSpec) DeepCopyInto(out *EgressSpec) { + *out = *in + in.AppliedTo.DeepCopyInto(&out.AppliedTo) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EgressSpec. +func (in *EgressSpec) DeepCopy() *EgressSpec { + if in == nil { + return nil + } + out := new(EgressSpec) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 955fe053c50..e7353918b77 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -1,4 +1,4 @@ -// Copyright 2020 Antrea Authors +// Copyright 2021 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import ( controlplanev1beta1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/controlplane/v1beta1" controlplanev1beta2 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/controlplane/v1beta2" corev1alpha2 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/core/v1alpha2" + egressv1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/egress/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" @@ -38,6 +39,7 @@ type Interface interface { ControlplaneV1beta1() controlplanev1beta1.ControlplaneV1beta1Interface ControlplaneV1beta2() controlplanev1beta2.ControlplaneV1beta2Interface CoreV1alpha2() corev1alpha2.CoreV1alpha2Interface + EgressV1alpha1() egressv1alpha1.EgressV1alpha1Interface OpsV1alpha1() opsv1alpha1.OpsV1alpha1Interface SecurityV1alpha1() securityv1alpha1.SecurityV1alpha1Interface StatsV1alpha1() statsv1alpha1.StatsV1alpha1Interface @@ -52,6 +54,7 @@ type Clientset struct { controlplaneV1beta1 *controlplanev1beta1.ControlplaneV1beta1Client controlplaneV1beta2 *controlplanev1beta2.ControlplaneV1beta2Client coreV1alpha2 *corev1alpha2.CoreV1alpha2Client + egressV1alpha1 *egressv1alpha1.EgressV1alpha1Client opsV1alpha1 *opsv1alpha1.OpsV1alpha1Client securityV1alpha1 *securityv1alpha1.SecurityV1alpha1Client statsV1alpha1 *statsv1alpha1.StatsV1alpha1Client @@ -78,6 +81,11 @@ func (c *Clientset) CoreV1alpha2() corev1alpha2.CoreV1alpha2Interface { return c.coreV1alpha2 } +// EgressV1alpha1 retrieves the EgressV1alpha1Client +func (c *Clientset) EgressV1alpha1() egressv1alpha1.EgressV1alpha1Interface { + return c.egressV1alpha1 +} + // OpsV1alpha1 retrieves the OpsV1alpha1Client func (c *Clientset) OpsV1alpha1() opsv1alpha1.OpsV1alpha1Interface { return c.opsV1alpha1 @@ -135,6 +143,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.egressV1alpha1, err = egressv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.opsV1alpha1, err = opsv1alpha1.NewForConfig(&configShallowCopy) if err != nil { return nil, err @@ -167,6 +179,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { cs.controlplaneV1beta1 = controlplanev1beta1.NewForConfigOrDie(c) cs.controlplaneV1beta2 = controlplanev1beta2.NewForConfigOrDie(c) cs.coreV1alpha2 = corev1alpha2.NewForConfigOrDie(c) + cs.egressV1alpha1 = egressv1alpha1.NewForConfigOrDie(c) cs.opsV1alpha1 = opsv1alpha1.NewForConfigOrDie(c) cs.securityV1alpha1 = securityv1alpha1.NewForConfigOrDie(c) cs.statsV1alpha1 = statsv1alpha1.NewForConfigOrDie(c) @@ -183,6 +196,7 @@ func New(c rest.Interface) *Clientset { cs.controlplaneV1beta1 = controlplanev1beta1.New(c) cs.controlplaneV1beta2 = controlplanev1beta2.New(c) cs.coreV1alpha2 = corev1alpha2.New(c) + cs.egressV1alpha1 = egressv1alpha1.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 35c9e010cc1..7842f67699a 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -1,4 +1,4 @@ -// Copyright 2020 Antrea Authors +// Copyright 2021 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -26,6 +26,8 @@ import ( fakecontrolplanev1beta2 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/controlplane/v1beta2/fake" corev1alpha2 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/core/v1alpha2" fakecorev1alpha2 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/core/v1alpha2/fake" + egressv1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/egress/v1alpha1" + fakeegressv1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/typed/egress/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" @@ -108,6 +110,11 @@ func (c *Clientset) CoreV1alpha2() corev1alpha2.CoreV1alpha2Interface { return &fakecorev1alpha2.FakeCoreV1alpha2{Fake: &c.Fake} } +// EgressV1alpha1 retrieves the EgressV1alpha1Client +func (c *Clientset) EgressV1alpha1() egressv1alpha1.EgressV1alpha1Interface { + return &fakeegressv1alpha1.FakeEgressV1alpha1{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 d209f5a2eb5..a296edd2655 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -1,4 +1,4 @@ -// Copyright 2020 Antrea Authors +// Copyright 2021 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import ( controlplanev1beta1 "github.com/vmware-tanzu/antrea/pkg/apis/controlplane/v1beta1" controlplanev1beta2 "github.com/vmware-tanzu/antrea/pkg/apis/controlplane/v1beta2" corev1alpha2 "github.com/vmware-tanzu/antrea/pkg/apis/core/v1alpha2" + egressv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/egress/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" @@ -40,6 +41,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ controlplanev1beta1.AddToScheme, controlplanev1beta2.AddToScheme, corev1alpha2.AddToScheme, + egressv1alpha1.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 a1c5055a5ed..b1e53444122 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -1,4 +1,4 @@ -// Copyright 2020 Antrea Authors +// Copyright 2021 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import ( controlplanev1beta1 "github.com/vmware-tanzu/antrea/pkg/apis/controlplane/v1beta1" controlplanev1beta2 "github.com/vmware-tanzu/antrea/pkg/apis/controlplane/v1beta2" corev1alpha2 "github.com/vmware-tanzu/antrea/pkg/apis/core/v1alpha2" + egressv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/egress/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" @@ -40,6 +41,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ controlplanev1beta1.AddToScheme, controlplanev1beta2.AddToScheme, corev1alpha2.AddToScheme, + egressv1alpha1.AddToScheme, opsv1alpha1.AddToScheme, securityv1alpha1.AddToScheme, statsv1alpha1.AddToScheme, diff --git a/pkg/client/clientset/versioned/typed/egress/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/egress/v1alpha1/doc.go new file mode 100644 index 00000000000..a66b4592246 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/egress/v1alpha1/doc.go @@ -0,0 +1,18 @@ +// Copyright 2021 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/egress/v1alpha1/egress.go b/pkg/client/clientset/versioned/typed/egress/v1alpha1/egress.go new file mode 100644 index 00000000000..1163444d3ef --- /dev/null +++ b/pkg/client/clientset/versioned/typed/egress/v1alpha1/egress.go @@ -0,0 +1,166 @@ +// Copyright 2021 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/egress/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" +) + +// EgressesGetter has a method to return a EgressInterface. +// A group's client should implement this interface. +type EgressesGetter interface { + Egresses() EgressInterface +} + +// EgressInterface has methods to work with Egress resources. +type EgressInterface interface { + Create(ctx context.Context, egress *v1alpha1.Egress, opts v1.CreateOptions) (*v1alpha1.Egress, error) + Update(ctx context.Context, egress *v1alpha1.Egress, opts v1.UpdateOptions) (*v1alpha1.Egress, 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.Egress, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.EgressList, 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.Egress, err error) + EgressExpansion +} + +// egresses implements EgressInterface +type egresses struct { + client rest.Interface +} + +// newEgresses returns a Egresses +func newEgresses(c *EgressV1alpha1Client) *egresses { + return &egresses{ + client: c.RESTClient(), + } +} + +// Get takes name of the egress, and returns the corresponding egress object, and an error if there is any. +func (c *egresses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Egress, err error) { + result = &v1alpha1.Egress{} + err = c.client.Get(). + Resource("egresses"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Egresses that match those selectors. +func (c *egresses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.EgressList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.EgressList{} + err = c.client.Get(). + Resource("egresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested egresses. +func (c *egresses) 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(). + Resource("egresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a egress and creates it. Returns the server's representation of the egress, and an error, if there is any. +func (c *egresses) Create(ctx context.Context, egress *v1alpha1.Egress, opts v1.CreateOptions) (result *v1alpha1.Egress, err error) { + result = &v1alpha1.Egress{} + err = c.client.Post(). + Resource("egresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(egress). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a egress and updates it. Returns the server's representation of the egress, and an error, if there is any. +func (c *egresses) Update(ctx context.Context, egress *v1alpha1.Egress, opts v1.UpdateOptions) (result *v1alpha1.Egress, err error) { + result = &v1alpha1.Egress{} + err = c.client.Put(). + Resource("egresses"). + Name(egress.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(egress). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the egress and deletes it. Returns an error if one occurs. +func (c *egresses) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("egresses"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *egresses) 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(). + Resource("egresses"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched egress. +func (c *egresses) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Egress, err error) { + result = &v1alpha1.Egress{} + err = c.client.Patch(pt). + Resource("egresses"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/egress/v1alpha1/egress_client.go b/pkg/client/clientset/versioned/typed/egress/v1alpha1/egress_client.go new file mode 100644 index 00000000000..3d34b246a50 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/egress/v1alpha1/egress_client.go @@ -0,0 +1,87 @@ +// Copyright 2021 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/egress/v1alpha1" + "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type EgressV1alpha1Interface interface { + RESTClient() rest.Interface + EgressesGetter +} + +// EgressV1alpha1Client is used to interact with features provided by the egress.antrea.tanzu.vmware.com group. +type EgressV1alpha1Client struct { + restClient rest.Interface +} + +func (c *EgressV1alpha1Client) Egresses() EgressInterface { + return newEgresses(c) +} + +// NewForConfig creates a new EgressV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*EgressV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &EgressV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new EgressV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *EgressV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new EgressV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *EgressV1alpha1Client { + return &EgressV1alpha1Client{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 *EgressV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/egress/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/egress/v1alpha1/fake/doc.go new file mode 100644 index 00000000000..5807b680f75 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/egress/v1alpha1/fake/doc.go @@ -0,0 +1,18 @@ +// Copyright 2021 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/egress/v1alpha1/fake/fake_egress.go b/pkg/client/clientset/versioned/typed/egress/v1alpha1/fake/fake_egress.go new file mode 100644 index 00000000000..0c9e67d48dd --- /dev/null +++ b/pkg/client/clientset/versioned/typed/egress/v1alpha1/fake/fake_egress.go @@ -0,0 +1,120 @@ +// Copyright 2021 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/egress/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" +) + +// FakeEgresses implements EgressInterface +type FakeEgresses struct { + Fake *FakeEgressV1alpha1 +} + +var egressesResource = schema.GroupVersionResource{Group: "egress.antrea.tanzu.vmware.com", Version: "v1alpha1", Resource: "egresses"} + +var egressesKind = schema.GroupVersionKind{Group: "egress.antrea.tanzu.vmware.com", Version: "v1alpha1", Kind: "Egress"} + +// Get takes name of the egress, and returns the corresponding egress object, and an error if there is any. +func (c *FakeEgresses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Egress, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(egressesResource, name), &v1alpha1.Egress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Egress), err +} + +// List takes label and field selectors, and returns the list of Egresses that match those selectors. +func (c *FakeEgresses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.EgressList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(egressesResource, egressesKind, opts), &v1alpha1.EgressList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.EgressList{ListMeta: obj.(*v1alpha1.EgressList).ListMeta} + for _, item := range obj.(*v1alpha1.EgressList).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 egresses. +func (c *FakeEgresses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(egressesResource, opts)) +} + +// Create takes the representation of a egress and creates it. Returns the server's representation of the egress, and an error, if there is any. +func (c *FakeEgresses) Create(ctx context.Context, egress *v1alpha1.Egress, opts v1.CreateOptions) (result *v1alpha1.Egress, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(egressesResource, egress), &v1alpha1.Egress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Egress), err +} + +// Update takes the representation of a egress and updates it. Returns the server's representation of the egress, and an error, if there is any. +func (c *FakeEgresses) Update(ctx context.Context, egress *v1alpha1.Egress, opts v1.UpdateOptions) (result *v1alpha1.Egress, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(egressesResource, egress), &v1alpha1.Egress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Egress), err +} + +// Delete takes name of the egress and deletes it. Returns an error if one occurs. +func (c *FakeEgresses) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(egressesResource, name), &v1alpha1.Egress{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeEgresses) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(egressesResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.EgressList{}) + return err +} + +// Patch applies the patch and returns the patched egress. +func (c *FakeEgresses) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Egress, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(egressesResource, name, pt, data, subresources...), &v1alpha1.Egress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Egress), err +} diff --git a/pkg/client/clientset/versioned/typed/egress/v1alpha1/fake/fake_egress_client.go b/pkg/client/clientset/versioned/typed/egress/v1alpha1/fake/fake_egress_client.go new file mode 100644 index 00000000000..8e86c105d1a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/egress/v1alpha1/fake/fake_egress_client.go @@ -0,0 +1,38 @@ +// Copyright 2021 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/egress/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeEgressV1alpha1 struct { + *testing.Fake +} + +func (c *FakeEgressV1alpha1) Egresses() v1alpha1.EgressInterface { + return &FakeEgresses{c} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeEgressV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/egress/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/egress/v1alpha1/generated_expansion.go new file mode 100644 index 00000000000..a788a740ed1 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/egress/v1alpha1/generated_expansion.go @@ -0,0 +1,19 @@ +// Copyright 2021 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 EgressExpansion interface{} diff --git a/pkg/client/informers/externalversions/egress/interface.go b/pkg/client/informers/externalversions/egress/interface.go new file mode 100644 index 00000000000..0dc7193444a --- /dev/null +++ b/pkg/client/informers/externalversions/egress/interface.go @@ -0,0 +1,44 @@ +// Copyright 2021 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 egress + +import ( + v1alpha1 "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/egress/v1alpha1" + internalinterfaces "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/internalinterfaces" +) + +// 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/egress/v1alpha1/egress.go b/pkg/client/informers/externalversions/egress/v1alpha1/egress.go new file mode 100644 index 00000000000..7d25a815767 --- /dev/null +++ b/pkg/client/informers/externalversions/egress/v1alpha1/egress.go @@ -0,0 +1,87 @@ +// Copyright 2021 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" + + egressv1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/egress/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/egress/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" +) + +// EgressInformer provides access to a shared informer and lister for +// Egresses. +type EgressInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.EgressLister +} + +type egressInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewEgressInformer constructs a new informer for Egress 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 NewEgressInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredEgressInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredEgressInformer constructs a new informer for Egress 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 NewFilteredEgressInformer(client versioned.Interface, 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.EgressV1alpha1().Egresses().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.EgressV1alpha1().Egresses().Watch(context.TODO(), options) + }, + }, + &egressv1alpha1.Egress{}, + resyncPeriod, + indexers, + ) +} + +func (f *egressInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredEgressInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *egressInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&egressv1alpha1.Egress{}, f.defaultInformer) +} + +func (f *egressInformer) Lister() v1alpha1.EgressLister { + return v1alpha1.NewEgressLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/egress/v1alpha1/interface.go b/pkg/client/informers/externalversions/egress/v1alpha1/interface.go new file mode 100644 index 00000000000..8223bda48cf --- /dev/null +++ b/pkg/client/informers/externalversions/egress/v1alpha1/interface.go @@ -0,0 +1,43 @@ +// Copyright 2021 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 { + // Egresses returns a EgressInformer. + Egresses() EgressInformer +} + +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} +} + +// Egresses returns a EgressInformer. +func (v *version) Egresses() EgressInformer { + return &egressInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index 82a863b64d6..93fcbc6217f 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -1,4 +1,4 @@ -// Copyright 2020 Antrea Authors +// Copyright 2021 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import ( versioned "github.com/vmware-tanzu/antrea/pkg/client/clientset/versioned" clusterinformation "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/clusterinformation" core "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/core" + egress "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/egress" internalinterfaces "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/internalinterfaces" ops "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/ops" security "github.com/vmware-tanzu/antrea/pkg/client/informers/externalversions/security" @@ -175,6 +176,7 @@ type SharedInformerFactory interface { Clusterinformation() clusterinformation.Interface Core() core.Interface + Egress() egress.Interface Ops() ops.Interface Security() security.Interface } @@ -187,6 +189,10 @@ func (f *sharedInformerFactory) Core() core.Interface { return core.New(f, f.namespace, f.tweakListOptions) } +func (f *sharedInformerFactory) Egress() egress.Interface { + return egress.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 3a6e0920205..04d12403c62 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -1,4 +1,4 @@ -// Copyright 2020 Antrea Authors +// Copyright 2021 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,7 +21,8 @@ import ( v1beta1 "github.com/vmware-tanzu/antrea/pkg/apis/clusterinformation/v1beta1" v1alpha2 "github.com/vmware-tanzu/antrea/pkg/apis/core/v1alpha2" - v1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/ops/v1alpha1" + v1alpha1 "github.com/vmware-tanzu/antrea/pkg/apis/egress/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" cache "k8s.io/client-go/tools/cache" @@ -65,8 +66,12 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha2.SchemeGroupVersion.WithResource("externalentities"): return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha2().ExternalEntities().Informer()}, nil + // Group=egress.antrea.tanzu.vmware.com, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("egresses"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Egress().V1alpha1().Egresses().Informer()}, nil + // Group=ops.antrea.tanzu.vmware.com, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("traceflows"): + case opsv1alpha1.SchemeGroupVersion.WithResource("traceflows"): return &genericInformer{resource: resource.GroupResource(), informer: f.Ops().V1alpha1().Traceflows().Informer()}, nil // Group=security.antrea.tanzu.vmware.com, Version=v1alpha1 diff --git a/pkg/client/listers/egress/v1alpha1/egress.go b/pkg/client/listers/egress/v1alpha1/egress.go new file mode 100644 index 00000000000..37a6f8e0600 --- /dev/null +++ b/pkg/client/listers/egress/v1alpha1/egress.go @@ -0,0 +1,63 @@ +// Copyright 2021 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/egress/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// EgressLister helps list Egresses. +type EgressLister interface { + // List lists all Egresses in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Egress, err error) + // Get retrieves the Egress from the index for a given name. + Get(name string) (*v1alpha1.Egress, error) + EgressListerExpansion +} + +// egressLister implements the EgressLister interface. +type egressLister struct { + indexer cache.Indexer +} + +// NewEgressLister returns a new EgressLister. +func NewEgressLister(indexer cache.Indexer) EgressLister { + return &egressLister{indexer: indexer} +} + +// List lists all Egresses in the indexer. +func (s *egressLister) List(selector labels.Selector) (ret []*v1alpha1.Egress, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Egress)) + }) + return ret, err +} + +// Get retrieves the Egress from the index for a given name. +func (s *egressLister) Get(name string) (*v1alpha1.Egress, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("egress"), name) + } + return obj.(*v1alpha1.Egress), nil +} diff --git a/pkg/client/listers/egress/v1alpha1/expansion_generated.go b/pkg/client/listers/egress/v1alpha1/expansion_generated.go new file mode 100644 index 00000000000..2897ff06e72 --- /dev/null +++ b/pkg/client/listers/egress/v1alpha1/expansion_generated.go @@ -0,0 +1,21 @@ +// Copyright 2021 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 + +// EgressListerExpansion allows custom methods to be added to +// EgressLister. +type EgressListerExpansion interface{}