From 5953984f942623d7d626da68846e8f6a1a769d2b Mon Sep 17 00:00:00 2001 From: Hang Yan Date: Tue, 15 Jun 2021 16:31:39 +0800 Subject: [PATCH] Remove deprecated API: networking.antrea.tanzu.vmware.com v1beta1 (#2265) Signed-off-by: Hang Yan --- build/yamls/antrea-aks.yml | 26 +++----- build/yamls/antrea-eks.yml | 26 +++----- build/yamls/antrea-gke.yml | 26 +++----- build/yamls/antrea-ipsec.yml | 26 +++----- build/yamls/antrea.yml | 26 +++----- build/yamls/base/agent-rbac.yml | 1 - build/yamls/base/antctl.yml | 1 - build/yamls/base/controller-rbac.yml | 9 ++- build/yamls/base/controller.yml | 14 ----- docs/api.md | 2 +- pkg/agent/openflow/client.go | 2 +- pkg/agent/openflow/pipeline.go | 2 +- pkg/apiserver/apiserver.go | 18 ++---- .../certificate/cacert_controller.go | 1 - pkg/legacyapis/networking/doc.go | 20 ------- pkg/legacyapis/networking/install/install.go | 30 ---------- pkg/legacyapis/networking/register.go | 60 ------------------- pkg/legacyapis/networking/v1beta1/doc.go | 16 ----- pkg/legacyapis/networking/v1beta1/register.go | 57 ------------------ 19 files changed, 55 insertions(+), 308 deletions(-) delete mode 100644 pkg/legacyapis/networking/doc.go delete mode 100644 pkg/legacyapis/networking/install/install.go delete mode 100644 pkg/legacyapis/networking/register.go delete mode 100644 pkg/legacyapis/networking/v1beta1/doc.go delete mode 100644 pkg/legacyapis/networking/v1beta1/register.go diff --git a/build/yamls/antrea-aks.yml b/build/yamls/antrea-aks.yml index 183d0617362..5c8c59ef4c4 100644 --- a/build/yamls/antrea-aks.yml +++ b/build/yamls/antrea-aks.yml @@ -3088,7 +3088,6 @@ metadata: rules: - apiGroups: - controlplane.antrea.tanzu.vmware.com - - networking.antrea.tanzu.vmware.com - controlplane.antrea.io resources: - networkpolicies @@ -3197,7 +3196,6 @@ rules: - delete - apiGroups: - controlplane.antrea.tanzu.vmware.com - - networking.antrea.tanzu.vmware.com - controlplane.antrea.io resources: - networkpolicies @@ -3380,7 +3378,6 @@ rules: - v1beta1.system.antrea.tanzu.vmware.com - v1beta2.controlplane.antrea.tanzu.vmware.com - v1beta1.controlplane.antrea.tanzu.vmware.com - - v1beta1.networking.antrea.tanzu.vmware.com - v1alpha1.stats.antrea.io - v1beta1.system.antrea.io - v1beta2.controlplane.antrea.io @@ -3389,6 +3386,14 @@ rules: verbs: - get - update +- apiGroups: + - apiregistration.k8s.io + resourceNames: + - v1beta1.networking.antrea.tanzu.vmware.com + resources: + - apiservices + verbs: + - delete - apiGroups: - admissionregistration.k8s.io resourceNames: @@ -4037,21 +4042,6 @@ spec: --- apiVersion: apiregistration.k8s.io/v1 kind: APIService -metadata: - labels: - app: antrea - name: v1beta1.networking.antrea.tanzu.vmware.com -spec: - group: networking.antrea.tanzu.vmware.com - groupPriorityMinimum: 100 - service: - name: antrea - namespace: kube-system - version: v1beta1 - versionPriority: 100 ---- -apiVersion: apiregistration.k8s.io/v1 -kind: APIService metadata: labels: app: antrea diff --git a/build/yamls/antrea-eks.yml b/build/yamls/antrea-eks.yml index eb1b98e72e8..6b0a25e656c 100644 --- a/build/yamls/antrea-eks.yml +++ b/build/yamls/antrea-eks.yml @@ -3088,7 +3088,6 @@ metadata: rules: - apiGroups: - controlplane.antrea.tanzu.vmware.com - - networking.antrea.tanzu.vmware.com - controlplane.antrea.io resources: - networkpolicies @@ -3197,7 +3196,6 @@ rules: - delete - apiGroups: - controlplane.antrea.tanzu.vmware.com - - networking.antrea.tanzu.vmware.com - controlplane.antrea.io resources: - networkpolicies @@ -3380,7 +3378,6 @@ rules: - v1beta1.system.antrea.tanzu.vmware.com - v1beta2.controlplane.antrea.tanzu.vmware.com - v1beta1.controlplane.antrea.tanzu.vmware.com - - v1beta1.networking.antrea.tanzu.vmware.com - v1alpha1.stats.antrea.io - v1beta1.system.antrea.io - v1beta2.controlplane.antrea.io @@ -3389,6 +3386,14 @@ rules: verbs: - get - update +- apiGroups: + - apiregistration.k8s.io + resourceNames: + - v1beta1.networking.antrea.tanzu.vmware.com + resources: + - apiservices + verbs: + - delete - apiGroups: - admissionregistration.k8s.io resourceNames: @@ -4037,21 +4042,6 @@ spec: --- apiVersion: apiregistration.k8s.io/v1 kind: APIService -metadata: - labels: - app: antrea - name: v1beta1.networking.antrea.tanzu.vmware.com -spec: - group: networking.antrea.tanzu.vmware.com - groupPriorityMinimum: 100 - service: - name: antrea - namespace: kube-system - version: v1beta1 - versionPriority: 100 ---- -apiVersion: apiregistration.k8s.io/v1 -kind: APIService metadata: labels: app: antrea diff --git a/build/yamls/antrea-gke.yml b/build/yamls/antrea-gke.yml index 831b516c95e..21e82a208eb 100644 --- a/build/yamls/antrea-gke.yml +++ b/build/yamls/antrea-gke.yml @@ -3088,7 +3088,6 @@ metadata: rules: - apiGroups: - controlplane.antrea.tanzu.vmware.com - - networking.antrea.tanzu.vmware.com - controlplane.antrea.io resources: - networkpolicies @@ -3197,7 +3196,6 @@ rules: - delete - apiGroups: - controlplane.antrea.tanzu.vmware.com - - networking.antrea.tanzu.vmware.com - controlplane.antrea.io resources: - networkpolicies @@ -3380,7 +3378,6 @@ rules: - v1beta1.system.antrea.tanzu.vmware.com - v1beta2.controlplane.antrea.tanzu.vmware.com - v1beta1.controlplane.antrea.tanzu.vmware.com - - v1beta1.networking.antrea.tanzu.vmware.com - v1alpha1.stats.antrea.io - v1beta1.system.antrea.io - v1beta2.controlplane.antrea.io @@ -3389,6 +3386,14 @@ rules: verbs: - get - update +- apiGroups: + - apiregistration.k8s.io + resourceNames: + - v1beta1.networking.antrea.tanzu.vmware.com + resources: + - apiservices + verbs: + - delete - apiGroups: - admissionregistration.k8s.io resourceNames: @@ -4037,21 +4042,6 @@ spec: --- apiVersion: apiregistration.k8s.io/v1 kind: APIService -metadata: - labels: - app: antrea - name: v1beta1.networking.antrea.tanzu.vmware.com -spec: - group: networking.antrea.tanzu.vmware.com - groupPriorityMinimum: 100 - service: - name: antrea - namespace: kube-system - version: v1beta1 - versionPriority: 100 ---- -apiVersion: apiregistration.k8s.io/v1 -kind: APIService metadata: labels: app: antrea diff --git a/build/yamls/antrea-ipsec.yml b/build/yamls/antrea-ipsec.yml index 8fff8dfc0bc..c8958d062fc 100644 --- a/build/yamls/antrea-ipsec.yml +++ b/build/yamls/antrea-ipsec.yml @@ -3088,7 +3088,6 @@ metadata: rules: - apiGroups: - controlplane.antrea.tanzu.vmware.com - - networking.antrea.tanzu.vmware.com - controlplane.antrea.io resources: - networkpolicies @@ -3197,7 +3196,6 @@ rules: - delete - apiGroups: - controlplane.antrea.tanzu.vmware.com - - networking.antrea.tanzu.vmware.com - controlplane.antrea.io resources: - networkpolicies @@ -3380,7 +3378,6 @@ rules: - v1beta1.system.antrea.tanzu.vmware.com - v1beta2.controlplane.antrea.tanzu.vmware.com - v1beta1.controlplane.antrea.tanzu.vmware.com - - v1beta1.networking.antrea.tanzu.vmware.com - v1alpha1.stats.antrea.io - v1beta1.system.antrea.io - v1beta2.controlplane.antrea.io @@ -3389,6 +3386,14 @@ rules: verbs: - get - update +- apiGroups: + - apiregistration.k8s.io + resourceNames: + - v1beta1.networking.antrea.tanzu.vmware.com + resources: + - apiservices + verbs: + - delete - apiGroups: - admissionregistration.k8s.io resourceNames: @@ -4051,21 +4056,6 @@ spec: --- apiVersion: apiregistration.k8s.io/v1 kind: APIService -metadata: - labels: - app: antrea - name: v1beta1.networking.antrea.tanzu.vmware.com -spec: - group: networking.antrea.tanzu.vmware.com - groupPriorityMinimum: 100 - service: - name: antrea - namespace: kube-system - version: v1beta1 - versionPriority: 100 ---- -apiVersion: apiregistration.k8s.io/v1 -kind: APIService metadata: labels: app: antrea diff --git a/build/yamls/antrea.yml b/build/yamls/antrea.yml index f1a724df9bc..b75e88e6f1b 100644 --- a/build/yamls/antrea.yml +++ b/build/yamls/antrea.yml @@ -3088,7 +3088,6 @@ metadata: rules: - apiGroups: - controlplane.antrea.tanzu.vmware.com - - networking.antrea.tanzu.vmware.com - controlplane.antrea.io resources: - networkpolicies @@ -3197,7 +3196,6 @@ rules: - delete - apiGroups: - controlplane.antrea.tanzu.vmware.com - - networking.antrea.tanzu.vmware.com - controlplane.antrea.io resources: - networkpolicies @@ -3380,7 +3378,6 @@ rules: - v1beta1.system.antrea.tanzu.vmware.com - v1beta2.controlplane.antrea.tanzu.vmware.com - v1beta1.controlplane.antrea.tanzu.vmware.com - - v1beta1.networking.antrea.tanzu.vmware.com - v1alpha1.stats.antrea.io - v1beta1.system.antrea.io - v1beta2.controlplane.antrea.io @@ -3389,6 +3386,14 @@ rules: verbs: - get - update +- apiGroups: + - apiregistration.k8s.io + resourceNames: + - v1beta1.networking.antrea.tanzu.vmware.com + resources: + - apiservices + verbs: + - delete - apiGroups: - admissionregistration.k8s.io resourceNames: @@ -4042,21 +4047,6 @@ spec: --- apiVersion: apiregistration.k8s.io/v1 kind: APIService -metadata: - labels: - app: antrea - name: v1beta1.networking.antrea.tanzu.vmware.com -spec: - group: networking.antrea.tanzu.vmware.com - groupPriorityMinimum: 100 - service: - name: antrea - namespace: kube-system - version: v1beta1 - versionPriority: 100 ---- -apiVersion: apiregistration.k8s.io/v1 -kind: APIService metadata: labels: app: antrea diff --git a/build/yamls/base/agent-rbac.yml b/build/yamls/base/agent-rbac.yml index 13c94107750..61db6ab0fa4 100644 --- a/build/yamls/base/agent-rbac.yml +++ b/build/yamls/base/agent-rbac.yml @@ -57,7 +57,6 @@ rules: - delete - apiGroups: - controlplane.antrea.tanzu.vmware.com - - networking.antrea.tanzu.vmware.com - controlplane.antrea.io resources: - networkpolicies diff --git a/build/yamls/base/antctl.yml b/build/yamls/base/antctl.yml index 4a7a6ea7272..cae3ff79224 100644 --- a/build/yamls/base/antctl.yml +++ b/build/yamls/base/antctl.yml @@ -12,7 +12,6 @@ metadata: rules: - apiGroups: - controlplane.antrea.tanzu.vmware.com - - networking.antrea.tanzu.vmware.com - controlplane.antrea.io resources: - networkpolicies diff --git a/build/yamls/base/controller-rbac.yml b/build/yamls/base/controller-rbac.yml index d104ecab5da..4855d2e3fc3 100644 --- a/build/yamls/base/controller-rbac.yml +++ b/build/yamls/base/controller-rbac.yml @@ -90,13 +90,20 @@ rules: - v1beta1.system.antrea.tanzu.vmware.com - v1beta2.controlplane.antrea.tanzu.vmware.com - v1beta1.controlplane.antrea.tanzu.vmware.com - - v1beta1.networking.antrea.tanzu.vmware.com - v1alpha1.stats.antrea.io - v1beta1.system.antrea.io - v1beta2.controlplane.antrea.io verbs: - get - update + - apiGroups: + - apiregistration.k8s.io + resources: + - apiservices + resourceNames: + - v1beta1.networking.antrea.tanzu.vmware.com + verbs: + - delete - apiGroups: - admissionregistration.k8s.io resources: diff --git a/build/yamls/base/controller.yml b/build/yamls/base/controller.yml index ae71caf497c..73ae3aadf6a 100644 --- a/build/yamls/base/controller.yml +++ b/build/yamls/base/controller.yml @@ -287,20 +287,6 @@ spec: name: antrea namespace: kube-system --- -# Deprecated in v0.10 -apiVersion: apiregistration.k8s.io/v1 -kind: APIService -metadata: - name: v1beta1.networking.antrea.tanzu.vmware.com -spec: - group: networking.antrea.tanzu.vmware.com - groupPriorityMinimum: 100 - version: v1beta1 - versionPriority: 100 - service: - name: antrea - namespace: kube-system ---- # Deprecated in v1.0.0. apiVersion: apiregistration.k8s.io/v1 kind: APIService diff --git a/docs/api.md b/docs/api.md index 9503fcdfc4d..49276453a8d 100644 --- a/docs/api.md +++ b/docs/api.md @@ -17,7 +17,6 @@ These are the API group versions which are curently available when using Antrea. | `core.antrea.tanzu.vmware.com` | `v1alpha2` | No | v0.11.0 | v1.0.0 | Dec 2021 | | `controlplane.antrea.tanzu.vmware.com` | `v1beta1` | Yes | v0.10.0 | v0.11.0 | Aug 2021 | | `controlplane.antrea.tanzu.vmware.com` | `v1beta2` | Yes | v0.11.0 | v1.0.0 | Dec 2021 | -| `networking.antrea.tanzu.vmware.com` | `v1beta1` | Yes | v0.3.0 | v0.10.0 | Jun 2021 | | `ops.antrea.tanzu.vmware.com` | `v1alpha1` | No | v0.8.0 | v1.0.0 | Dec 2021 | | `security.antrea.tanzu.vmware.com` | `v1alpha1` | No | v0.8.0 | v1.0.0 | Dec 2021 | | `stats.antrea.tanzu.vmware.com` | `v1alpha1` | Yes | v0.10.0 | v1.0.0 | Dec 2021 | @@ -34,6 +33,7 @@ These are the API group versions which are curently available when using Antrea. | API group | API version | API Service? | Introduced in | Deprecated in | Removed in | |---|---|---|---|---|---| | `core.antrea.tanzu.vmware.com` | `v1alpha1` | No | v0.8.0 | v0.11.0 | v0.11.0 | +| `networking.antrea.tanzu.vmware.com` | `v1beta1` | Yes | v0.3.0 | v0.10.0 | v1.2.0 | ## API renaming from `*.antrea.tanzu.vmware.com` to `*.antrea.io` diff --git a/pkg/agent/openflow/client.go b/pkg/agent/openflow/client.go index 77fd7a001fd..18e7da2cfa9 100644 --- a/pkg/agent/openflow/client.go +++ b/pkg/agent/openflow/client.go @@ -166,7 +166,7 @@ type Client interface { // mark for a SNAT IP. UninstallSNATMarkFlows(mark uint32) error - // InstallSNATPolicyFlow installs the SNAT flows for a local Pod. If the + // InstallPodSNATFlows installs the SNAT flows for a local Pod. If the // SNAT IP for the Pod is on the local Node, a non-zero SNAT ID should // allocated for the SNAT IP, and the installed flow sets the SNAT IP // mark on the egress packets from the ofPort; if the SNAT IP is on a diff --git a/pkg/agent/openflow/pipeline.go b/pkg/agent/openflow/pipeline.go index 92da130bf73..2bda4d52499 100644 --- a/pkg/agent/openflow/pipeline.go +++ b/pkg/agent/openflow/pipeline.go @@ -1865,7 +1865,7 @@ func (c *client) snatIPFromTunnelFlow(snatIP net.IP, mark uint32) binding.Flow { } // snatRuleFlow generates a flow that applies the SNAT rule for a local Pod. If -// the SNAT IP exists on the lcoal Node, it sets the packet mark with the ID of +// the SNAT IP exists on the local Node, it sets the packet mark with the ID of // the SNAT IP, for the traffic from the ofPort to external; if the SNAT IP is // on a remote Node, it tunnels the packets to the SNAT IP. func (c *client) snatRuleFlow(ofPort uint32, snatIP net.IP, snatMark uint32, localGatewayMAC net.HardwareAddr) binding.Flow { diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index df0b70b5ff1..c668d97277c 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -59,8 +59,6 @@ import ( "antrea.io/antrea/pkg/features" legacycontrolplane "antrea.io/antrea/pkg/legacyapis/controlplane" legacycpinstall "antrea.io/antrea/pkg/legacyapis/controlplane/install" - legacynetworking "antrea.io/antrea/pkg/legacyapis/networking" - legacynetworkinginstall "antrea.io/antrea/pkg/legacyapis/networking/install" legacyapistats "antrea.io/antrea/pkg/legacyapis/stats" legacystatsinstall "antrea.io/antrea/pkg/legacyapis/stats/install" legacysysteminstall "antrea.io/antrea/pkg/legacyapis/system/install" @@ -84,7 +82,6 @@ func init() { legacycpinstall.Install(Scheme) legacysysteminstall.Install(Scheme) - legacynetworkinginstall.Install(Scheme) legacystatsinstall.Install(Scheme) // We need to add the options to empty v1, see sample-apiserver/pkg/apiserver/apiserver.go. @@ -221,15 +218,6 @@ func installAPIGroup(s *APIServer, c completedConfig) error { legacyCPv1beta2Storage["clustergroupmembers"] = clusterGroupMembershipStorage legacyCPGroup.VersionedResourcesStorageMap["v1beta2"] = legacyCPv1beta2Storage - legacyNetworkingGroup := genericapiserver.NewDefaultAPIGroupInfo(legacynetworking.GroupName, Scheme, metav1.ParameterCodec, Codecs) - // TODO: networkingGroup is the legacy group of controlplane NetworkPolicy APIs. To allow live upgrades from up to - // two minor versions, the APIs must be kept for two minor releases before it can be deleted. - legacyNetworkingStorage := map[string]rest.Storage{} - legacyNetworkingStorage["addressgroups"] = addressGroupStorage - legacyNetworkingStorage["appliedtogroups"] = appliedToGroupStorage - legacyNetworkingStorage["networkpolicies"] = networkPolicyStorage - legacyNetworkingGroup.VersionedResourcesStorageMap["v1beta1"] = legacyNetworkingStorage - legacySystemGroup := genericapiserver.NewDefaultAPIGroupInfo(legacysystem.GroupName, Scheme, metav1.ParameterCodec, Codecs) legacySystemGroup.VersionedResourcesStorageMap["v1beta1"] = systemStorage @@ -237,7 +225,7 @@ func installAPIGroup(s *APIServer, c completedConfig) error { legacyStatsGroup.VersionedResourcesStorageMap["v1alpha1"] = statsStorage // legacy API groups - groups = append(groups, &legacyCPGroup, &legacyNetworkingGroup, &legacySystemGroup, &legacyStatsGroup) + groups = append(groups, &legacyCPGroup, &legacySystemGroup, &legacyStatsGroup) for _, apiGroupInfo := range groups { if err := s.GenericAPIServer.InstallAPIGroup(apiGroupInfo); err != nil { @@ -274,7 +262,9 @@ func CleanupDeprecatedAPIServices(aggregatorClient clientset.Interface) error { // deprecates a registered APIService, the APIService should be deleted, // otherwise K8s will fail to delete an existing Namespace. // Also check: https://github.com/antrea-io/antrea/issues/494 - deprecatedAPIServices := []string{} + deprecatedAPIServices := []string{ + "v1beta1.networking.antrea.tanzu.vmware.com", + } for _, as := range deprecatedAPIServices { err := aggregatorClient.ApiregistrationV1().APIServices().Delete(context.TODO(), as, metav1.DeleteOptions{}) if err == nil { diff --git a/pkg/apiserver/certificate/cacert_controller.go b/pkg/apiserver/certificate/cacert_controller.go index 7c2104faaf0..9ababa312c4 100644 --- a/pkg/apiserver/certificate/cacert_controller.go +++ b/pkg/apiserver/certificate/cacert_controller.go @@ -51,7 +51,6 @@ var ( "v1alpha1.stats.antrea.tanzu.vmware.com", "v1beta1.controlplane.antrea.tanzu.vmware.com", "v1beta2.controlplane.antrea.tanzu.vmware.com", - "v1beta1.networking.antrea.tanzu.vmware.com", "v1beta1.system.antrea.tanzu.vmware.com", "v1alpha1.stats.antrea.io", "v1beta1.system.antrea.io", diff --git a/pkg/legacyapis/networking/doc.go b/pkg/legacyapis/networking/doc.go deleted file mode 100644 index ffe6ca8a6fb..00000000000 --- a/pkg/legacyapis/networking/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -// 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 networking contains the latest (or "internal") version of the Antrea -// NetworkPolicy API messages. This is the API messages as represented in memory. -// The contract presented to clients is located in the versioned packages, -// which are sub-directories. The first one is "v1beta1". -// It's superseded by package controlplane in v0.9.3, and planned for removal in v0.12. -package networking diff --git a/pkg/legacyapis/networking/install/install.go b/pkg/legacyapis/networking/install/install.go deleted file mode 100644 index 34f27214279..00000000000 --- a/pkg/legacyapis/networking/install/install.go +++ /dev/null @@ -1,30 +0,0 @@ -// 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 install - -import ( - "k8s.io/apimachinery/pkg/runtime" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - - "antrea.io/antrea/pkg/legacyapis/networking" - "antrea.io/antrea/pkg/legacyapis/networking/v1beta1" -) - -// Install registers the API group and adds types to a scheme -func Install(scheme *runtime.Scheme) { - utilruntime.Must(networking.AddToScheme(scheme)) - utilruntime.Must(v1beta1.AddToScheme(scheme)) - utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion)) -} diff --git a/pkg/legacyapis/networking/register.go b/pkg/legacyapis/networking/register.go deleted file mode 100644 index 64b72dd3bf0..00000000000 --- a/pkg/legacyapis/networking/register.go +++ /dev/null @@ -1,60 +0,0 @@ -// 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 networking - -import ( - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - - "antrea.io/antrea/pkg/apis/controlplane" -) - -// 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: runtime.APIVersionInternal} - -// Kind takes an unqualified kind and returns 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 points to a list of functions added to Scheme. - SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) - // AddToScheme applies all the stored functions to the scheme. - AddToScheme = SchemeBuilder.AddToScheme -) - -// Adds the list of known types to the given scheme. -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &controlplane.AppliedToGroup{}, - &controlplane.AppliedToGroupPatch{}, - &controlplane.AppliedToGroupList{}, - &controlplane.AddressGroup{}, - &controlplane.AddressGroupPatch{}, - &controlplane.AddressGroupList{}, - &controlplane.NetworkPolicy{}, - &controlplane.NetworkPolicyList{}, - ) - return nil -} diff --git a/pkg/legacyapis/networking/v1beta1/doc.go b/pkg/legacyapis/networking/v1beta1/doc.go deleted file mode 100644 index 4ffc6d287e0..00000000000 --- a/pkg/legacyapis/networking/v1beta1/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// 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 v1beta1 is the v1beta1 version of the Antrea NetworkPolicy API messages. -package v1beta1 diff --git a/pkg/legacyapis/networking/v1beta1/register.go b/pkg/legacyapis/networking/v1beta1/register.go deleted file mode 100644 index 4bd01401ca1..00000000000 --- a/pkg/legacyapis/networking/v1beta1/register.go +++ /dev/null @@ -1,57 +0,0 @@ -// 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 v1beta1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - - "antrea.io/antrea/pkg/apis/controlplane/v1beta1" -) - -// 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: "v1beta1"} - -// 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) - localSchemeBuilder = &SchemeBuilder - AddToScheme = localSchemeBuilder.AddToScheme -) - -// Adds the list of known types to the given scheme. -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &v1beta1.AppliedToGroup{}, - &v1beta1.AppliedToGroupPatch{}, - &v1beta1.AppliedToGroupList{}, - &v1beta1.AddressGroup{}, - &v1beta1.AddressGroupPatch{}, - &v1beta1.AddressGroupList{}, - &v1beta1.NetworkPolicy{}, - &v1beta1.NetworkPolicyList{}, - ) - - metav1.AddToGroupVersion(scheme, SchemeGroupVersion) - return nil -}