1
0
mirror of https://github.com/rancher/types.git synced 2025-05-08 07:06:19 +00:00

Add istio VirtualService and DestinationRule types

This commit is contained in:
gitlawr 2019-06-17 10:50:12 +08:00
parent 22e321a584
commit bd5a9e3e53
3 changed files with 41 additions and 1 deletions
apis/project.cattle.io/v3/schema
config
main.go

View File

@ -4,6 +4,7 @@ import (
"net/http"
monitoringv1 "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1"
istiov1alpha3 "github.com/knative/pkg/apis/istio/v1alpha3"
"github.com/rancher/norman/types"
m "github.com/rancher/norman/types/mapper"
v3 "github.com/rancher/types/apis/project.cattle.io/v3"
@ -46,7 +47,8 @@ var (
Init(appTypes).
Init(pipelineTypes).
Init(monitoringTypes).
Init(autoscalingTypes)
Init(autoscalingTypes).
Init(istioTypes)
)
func configMapTypes(schemas *types.Schemas) *types.Schemas {
@ -1088,3 +1090,19 @@ func autoscalingTypes(schemas *types.Schemas) *types.Schemas {
Description string `json:"description,omitempty"`
}{})
}
func istioTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
MustImport(&Version, istiov1alpha3.HTTPMatchRequest{}, struct {
Port *uint32 `json:"port,omitempty"`
}{}).
MustImport(&Version, istiov1alpha3.HTTPRoute{}, struct {
WebsocketUpgrade *bool `json:"websocketUpgrade,omitempty"`
}{}).
MustImport(&Version, istiov1alpha3.VirtualService{}, projectOverride{}, struct {
Status interface{}
}{}).
MustImport(&Version, istiov1alpha3.DestinationRule{}, projectOverride{}, struct {
Status interface{}
}{})
}

View File

@ -20,6 +20,7 @@ import (
managementv3 "github.com/rancher/types/apis/management.cattle.io/v3"
managementSchema "github.com/rancher/types/apis/management.cattle.io/v3/schema"
monitoringv1 "github.com/rancher/types/apis/monitoring.coreos.com/v1"
istiov1alpha3 "github.com/rancher/types/apis/networking.istio.io/v1alpha3"
knetworkingv1 "github.com/rancher/types/apis/networking.k8s.io/v1"
projectv3 "github.com/rancher/types/apis/project.cattle.io/v3"
projectSchema "github.com/rancher/types/apis/project.cattle.io/v3/schema"
@ -189,6 +190,7 @@ type UserContext struct {
Networking knetworkingv1.Interface
Monitoring monitoringv1.Interface
Cluster clusterv3.Interface
Istio istiov1alpha3.Interface
}
func (w *UserContext) controllers() []controller.Starter {
@ -224,6 +226,7 @@ func (w *UserContext) UserOnlyContext() *UserOnlyContext {
BatchV1Beta1: w.BatchV1Beta1,
Monitoring: w.Monitoring,
Cluster: w.Cluster,
Istio: w.Istio,
}
}
@ -244,6 +247,7 @@ type UserOnlyContext struct {
BatchV1Beta1 batchv1beta1.Interface
Monitoring monitoringv1.Interface
Cluster clusterv3.Interface
Istio istiov1alpha3.Interface
}
func (w *UserOnlyContext) controllers() []controller.Starter {
@ -408,6 +412,11 @@ func NewUserContext(scaledContext *ScaledContext, config rest.Config, clusterNam
return nil, err
}
context.Istio, err = istiov1alpha3.NewForConfig(config)
if err != nil {
return nil, err
}
dynamicConfig := config
if dynamicConfig.NegotiatedSerializer == nil {
dynamicConfig.NegotiatedSerializer = dynamic.NegotiatedSerializer
@ -497,6 +506,11 @@ func NewUserOnlyContext(config rest.Config) (*UserOnlyContext, error) {
return nil, err
}
context.Istio, err = istiov1alpha3.NewForConfig(config)
if err != nil {
return nil, err
}
dynamicConfig := config
if dynamicConfig.NegotiatedSerializer == nil {
dynamicConfig.NegotiatedSerializer = dynamic.NegotiatedSerializer

View File

@ -5,6 +5,7 @@ package main
import (
monitoringv1 "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1"
istiov1alpha3 "github.com/knative/pkg/apis/istio/v1alpha3"
clusterSchema "github.com/rancher/types/apis/cluster.cattle.io/v3/schema"
managementSchema "github.com/rancher/types/apis/management.cattle.io/v3/schema"
publicSchema "github.com/rancher/types/apis/management.cattle.io/v3public/schema"
@ -96,4 +97,11 @@ func main() {
},
[]interface{}{},
)
generator.GenerateNativeTypes(istiov1alpha3.SchemeGroupVersion,
[]interface{}{
istiov1alpha3.VirtualService{},
istiov1alpha3.DestinationRule{},
},
[]interface{}{},
)
}