1
0
mirror of https://github.com/rancher/types.git synced 2025-09-18 16:10:58 +00:00

Combine ClusterNode and Machine

This commit is contained in:
Darren Shepherd
2017-12-05 09:29:49 -07:00
parent 66eaf237f9
commit 5579f880d0
4 changed files with 75 additions and 14 deletions

View File

@@ -59,12 +59,11 @@ type Machine struct {
}
type MachineStatus struct {
Conditions []MachineCondition `json:"conditions"`
Node v1.Node `json:"node"`
NodeName string `json:"nodeName"`
ClusterName string `json:"clusterName" norman:"reference[cluster]"`
Requested v1.ResourceList `json:"requested,omitempty"`
Limits v1.ResourceList `json:"limits,omitempty"`
Conditions []MachineCondition `json:"conditions"`
NodeStatus v1.NodeStatus `json:"nodeStatus"`
NodeName string `json:"nodeName"`
Requested v1.ResourceList `json:"requested,omitempty"`
Limits v1.ResourceList `json:"limits,omitempty"`
}
type MachineCondition struct {
@@ -81,13 +80,11 @@ type MachineCondition struct {
}
type MachineSpec struct {
ClusterName string `norman:"type=reference[cluster]"`
ExternalID string `json:"externalId"`
MachineTemplateName string `norman:"type=reference[machineTemplate]"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
Hostname string `json:"hostname"`
Driver string `json:"driver"`
NodeSpec v1.NodeSpec `json:"nodeSpec"`
ClusterName string `json:"clusterName" norman:"type=reference[cluster]"`
MachineTemplateName string `json:"machineTemplateName" norman:"type=reference[machineTemplate]"`
Description string `json:"description"`
Driver string `json:"driver"`
MachineCommonParams `json:",inline"`
AmazonEC2Config AmazonEC2Config `json:"amazonEc2Config"`

View File

@@ -5,6 +5,8 @@ import (
m "github.com/rancher/norman/types/mapper"
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/factory"
"github.com/rancher/types/mapper"
"k8s.io/api/core/v1"
)
var (
@@ -15,11 +17,37 @@ var (
}
Schemas = factory.Schemas(&Version).
Init(nodeTypes).
Init(machineTypes).
Init(authTypes).
Init(clusterTypes)
)
func nodeTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
AddMapperForType(&Version, v1.NodeStatus{},
&mapper.NodeAddressMapper{},
&mapper.OSInfo{},
&m.Drop{Field: "addresses"},
&m.Drop{Field: "daemonEndpoints"},
&m.Drop{Field: "images"},
&m.Drop{Field: "nodeInfo"},
&m.SliceToMap{Field: "volumesAttached", Key: "devicePath"},
).
AddMapperForType(&Version, v1.NodeSpec{},
&m.Move{From: "externalID", To: "externalId"}).
AddMapperForType(&Version, v1.Node{},
&m.Embed{Field: "status"},
&m.Drop{Field: "conditions"},
).
MustImport(&Version, v1.NodeStatus{}, struct {
IPAddress string
Hostname string
Info NodeInfo
}{}).
MustImport(&Version, v1.Node{})
}
func clusterTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
AddMapperForType(&Version, v3.Cluster{},
@@ -62,7 +90,14 @@ func authTypes(schemas *types.Schemas) *types.Schemas {
func machineTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
AddMapperForType(&Version, v3.Machine{}, m.DisplayName{}).
AddMapperForType(&Version, v3.MachineSpec{}, &m.Embed{Field: "nodeSpec"}).
AddMapperForType(&Version, v3.MachineStatus{},
&m.Drop{Field: "conditions"},
&m.Embed{Field: "nodeStatus"}).
AddMapperForType(&Version, v3.Machine{},
&m.Embed{Field: "status"},
&m.Move{From: "name", To: "id"},
&m.Move{From: "nodeName", To: "name"}).
AddMapperForType(&Version, v3.MachineDriver{}, m.DisplayName{}).
AddMapperForType(&Version, v3.MachineTemplate{}, m.DisplayName{}).
MustImport(&Version, v3.Machine{}).

View File

@@ -0,0 +1,27 @@
package schema
type NodeInfo struct {
CPU CPUInfo
Memory MemoryInfo
OS OSInfo
Kubernetes KubernetesInfo
}
type CPUInfo struct {
Count int64
}
type MemoryInfo struct {
MemTotalKiB int64
}
type OSInfo struct {
DockerVersion string
KernelVersion string
OperatingSystem string
}
type KubernetesInfo struct {
KubeletVersion string
KubeProxyVersion string
}