未验证 提交 bf55d23d 编写于 作者: Z zryfish 提交者: GitHub

add missing federated resources (#2728)

Signed-off-by: NJeff <zw0948@gmail.com>
上级 4702beb6
/*
Copyright 2019 The KubeSphere 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 federatedingress
import (
"k8s.io/apimachinery/pkg/runtime"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apis/types/v1beta1"
"kubesphere.io/kubesphere/pkg/apiserver/query"
informers "kubesphere.io/kubesphere/pkg/client/informers/externalversions"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3"
)
type fedIngressGetter struct {
sharedInformers informers.SharedInformerFactory
}
func New(sharedInformers informers.SharedInformerFactory) v1alpha3.Interface {
return &fedIngressGetter{sharedInformers: sharedInformers}
}
func (g *fedIngressGetter) Get(namespace, name string) (runtime.Object, error) {
return g.sharedInformers.Types().V1beta1().FederatedIngresses().Lister().FederatedIngresses(namespace).Get(name)
}
func (g *fedIngressGetter) List(namespace string, query *query.Query) (*api.ListResult, error) {
// first retrieves all deployments within given namespace
ingresses, err := g.sharedInformers.Types().V1beta1().FederatedIngresses().Lister().FederatedIngresses(namespace).List(query.Selector())
if err != nil {
return nil, err
}
var result []runtime.Object
for _, ingress := range ingresses {
result = append(result, ingress)
}
return v1alpha3.DefaultList(result, query, g.compare, g.filter), nil
}
func (g *fedIngressGetter) compare(left runtime.Object, right runtime.Object, field query.Field) bool {
leftIngress, ok := left.(*v1beta1.FederatedIngress)
if !ok {
return false
}
rightIngress, ok := right.(*v1beta1.FederatedIngress)
if !ok {
return false
}
return v1alpha3.DefaultObjectMetaCompare(leftIngress.ObjectMeta, rightIngress.ObjectMeta, field)
}
func (g *fedIngressGetter) filter(object runtime.Object, filter query.Filter) bool {
deployment, ok := object.(*v1beta1.FederatedIngress)
if !ok {
return false
}
switch filter.Field {
default:
return v1alpha3.DefaultObjectMetaFilter(deployment.ObjectMeta, filter)
}
}
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package statefulset
package federatedstatefulset
import (
"k8s.io/apimachinery/pkg/runtime"
......
......@@ -18,7 +18,6 @@ package networkpolicy
import (
v1 "k8s.io/api/networking/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/informers"
"kubesphere.io/kubesphere/pkg/api"
......@@ -39,7 +38,7 @@ func (n networkpolicyGetter) Get(namespace, name string) (runtime.Object, error)
}
func (n networkpolicyGetter) List(namespace string, query *query.Query) (*api.ListResult, error) {
nps, err := n.informers.Networking().V1().NetworkPolicies().Lister().NetworkPolicies(namespace).List(labels.Everything())
nps, err := n.informers.Networking().V1().NetworkPolicies().Lister().NetworkPolicies(namespace).List(query.Selector())
if err != nil {
return nil, err
}
......
......@@ -76,7 +76,7 @@ func (c nodesGetter) List(_ string, query *query.Query) (*api.ListResult, error)
}
// ignore the error, skip annotating process if error happened
pods, _ := c.informers.Core().V1().Pods().Lister().Pods("").List(labels.Everything())
pods, _ := c.informers.Core().V1().Pods().Lister().Pods("").List(query.Selector())
var nonTerminatedPodsList []*v1.Pod
for _, pod := range pods {
if pod.Status.Phase != v1.PodSucceeded && pod.Status.Phase != v1.PodFailed {
......
......@@ -43,10 +43,12 @@ import (
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/federatedapplication"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/federatedconfigmap"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/federateddeployment"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/federatedingress"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/federatednamespace"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/federatedpersistentvolumeclaim"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/federatedsecret"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/federatedservice"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/federatedstatefulset"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/globalrole"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/globalrolebinding"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/ingress"
......@@ -114,6 +116,8 @@ func NewResourceGetter(factory informers.InformerFactory) *ResourceGetter {
getters[typesv1beta1.SchemeGroupVersion.WithResource(typesv1beta1.ResourcePluralFederatedService)] = federatedservice.New(factory.KubeSphereSharedInformerFactory())
getters[typesv1beta1.SchemeGroupVersion.WithResource(typesv1beta1.ResourcePluralFederatedApplication)] = federatedapplication.New(factory.KubeSphereSharedInformerFactory())
getters[typesv1beta1.SchemeGroupVersion.WithResource(typesv1beta1.ResourcePluralFederatedPersistentVolumeClaim)] = federatedpersistentvolumeclaim.New(factory.KubeSphereSharedInformerFactory())
getters[typesv1beta1.SchemeGroupVersion.WithResource(typesv1beta1.ResourcePluralFederatedStatefulSet)] = federatedstatefulset.New(factory.KubeSphereSharedInformerFactory())
getters[typesv1beta1.SchemeGroupVersion.WithResource(typesv1beta1.ResourcePluralFederatedIngress)] = federatedingress.New(factory.KubeSphereSharedInformerFactory())
return &ResourceGetter{
getters: getters,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册