From c15c1cf9207c9fe3a5f370eee9f82df323fac5b5 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Mon, 29 Jan 2018 16:51:02 -0800 Subject: [PATCH] PublicEndpoints to node/service/pod --- apis/cluster.cattle.io/v3/schema/schema.go | 6 +++++- apis/project.cattle.io/v3/schema/schema.go | 9 +++++++-- apis/project.cattle.io/v3/types.go | 12 ++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/apis/cluster.cattle.io/v3/schema/schema.go b/apis/cluster.cattle.io/v3/schema/schema.go index b101173c..067b507c 100644 --- a/apis/cluster.cattle.io/v3/schema/schema.go +++ b/apis/cluster.cattle.io/v3/schema/schema.go @@ -3,6 +3,7 @@ package schema import ( "github.com/rancher/norman/types" m "github.com/rancher/norman/types/mapper" + "github.com/rancher/types/apis/project.cattle.io/v3" "github.com/rancher/types/apis/project.cattle.io/v3/schema" "github.com/rancher/types/factory" "github.com/rancher/types/mapper" @@ -56,6 +57,7 @@ func NodeTypes(version *types.APIVersion, schemas *types.Schemas) *types.Schemas }}). AddMapperForType(version, v1.Node{}, &m.AnnotationField{Field: "description"}, + &m.AnnotationField{Field: "publicEndpoints", List: true}, &m.Embed{Field: "status"}, ). MustImport(version, v1.NodeStatus{}, struct { @@ -63,8 +65,10 @@ func NodeTypes(version *types.APIVersion, schemas *types.Schemas) *types.Schemas Hostname string Info NodeInfo }{}). + MustImport(version, v3.PublicEndpoint{}). MustImport(version, v1.Node{}, struct { - Description string `json:"description"` + Description string `json:"description"` + PublicEndpoints string `json:"publicEndpoints" norman:"type=array[publicEndpoint],nocreate,noupdate"` }{}) } diff --git a/apis/project.cattle.io/v3/schema/schema.go b/apis/project.cattle.io/v3/schema/schema.go index 0ea85ede..aae179b3 100644 --- a/apis/project.cattle.io/v3/schema/schema.go +++ b/apis/project.cattle.io/v3/schema/schema.go @@ -295,8 +295,10 @@ func podTypes(schemas *types.Schemas) *types.Schemas { AddMapperForType(&Version, v1.ResourceRequirements{}, mapper.PivotMapper{Plural: true}, ). + MustImport(&Version, v3.PublicEndpoint{}). AddMapperForType(&Version, v1.Pod{}, &m.AnnotationField{Field: "description"}, + &m.AnnotationField{Field: "publicEndpoints", List: true}, ). // Must import handlers before Container MustImport(&Version, v1.Capabilities{}, struct { @@ -320,8 +322,9 @@ func podTypes(schemas *types.Schemas) *types.Schemas { PullPolicy string `norman:"type=enum,options=Always|Never|IfNotPresent,default=IfNotPresent"` }{}). MustImport(&Version, v1.Pod{}, projectOverride{}, struct { - Description string `json:"description"` - WorkloadID string `norman:"type=reference[workload]"` + Description string `json:"description"` + WorkloadID string `norman:"type=reference[workload]"` + PublicEndpoints string `json:"publicEndpoints" norman:"type=array[publicEndpoint],nocreate,noupdate"` }{}) } @@ -368,6 +371,7 @@ func addServiceOrDNSRecord(dns bool) types.SchemasInitFunc { &m.AnnotationField{Field: "ipAddresses", List: true}, &m.AnnotationField{Field: "targetWorkloadIds", List: true}, &m.AnnotationField{Field: "targetDnsRecordIds", List: true}, + &m.AnnotationField{Field: "publicEndpoints", List: true}, &m.Move{From: "serviceKind", To: "kind"}, ) @@ -402,6 +406,7 @@ func addServiceOrDNSRecord(dns bool) types.SchemasInitFunc { WorkloadID string `json:"workloadId" norman:"type=reference[workload],nocreate,noupdate"` TargetWorkloadIDs string `json:"targetWorkloadIds" norman:"type=array[reference[workload]]"` TargetDNSRecordIDs string `json:"targetDnsRecordIds" norman:"type=array[reference[dnsRecord]]"` + PublicEndpoints string `json:"publicEndpoints" norman:"type=array[publicEndpoint],nocreate,noupdate"` }{}) } } diff --git a/apis/project.cattle.io/v3/types.go b/apis/project.cattle.io/v3/types.go index b6a8edb1..bb0855f0 100644 --- a/apis/project.cattle.io/v3/types.go +++ b/apis/project.cattle.io/v3/types.go @@ -141,3 +141,15 @@ type SSHAuth struct { Fingerprint string `json:"certFingerprint" norman:"nocreate,noupdate"` } type NamespacedSSHAuth SSHAuth + +type PublicEndpoint struct { + Node string `json:"node,omitempty" norman:"type=reference[node],nocreate,noupdate"` + Address string `json:"address,omitempty" norman:"nocreate,noupdate"` + Port int32 `json:"port,omitempty" norman:"nocreate,noupdate"` + Protocol string `json:"protocol,omitempty" norman:"nocreate,noupdate"` + // for node port service + Service string `json:"service,omitempty" norman:"type=reference[service],nocreate,noupdate"` + // for host port + Pod string `json:"pod,omitempty" norman:"type=reference[pod],nocreate,noupdate"` + //serviceName and podName are mutually exclusive +}