mirror of
https://github.com/rancher/types.git
synced 2025-07-30 20:44:34 +00:00
Address issues in node types
This commit is contained in:
parent
5773f84304
commit
f4e5f9a114
@ -27,28 +27,42 @@ func namespaceTypes(schemas *types.Schemas) *types.Schemas {
|
||||
}
|
||||
|
||||
func nodeTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return NodeTypes(&Version, schemas)
|
||||
}
|
||||
|
||||
func NodeTypes(version *types.APIVersion, schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
AddMapperForType(&Version, v1.NodeStatus{},
|
||||
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.Drop{Field: "conditions"},
|
||||
&m.Drop{Field: "phase"},
|
||||
&m.SliceToMap{Field: "volumesAttached", Key: "devicePath"},
|
||||
).
|
||||
AddMapperForType(&Version, v1.NodeSpec{},
|
||||
&m.Move{From: "externalID", To: "externalId"}).
|
||||
AddMapperForType(&Version, v1.Node{},
|
||||
AddMapperForType(version, v1.NodeSpec{},
|
||||
&m.Drop{Field: "externalID"},
|
||||
&m.Drop{Field: "configSource"},
|
||||
&m.Move{From: "providerID", To: "providerId"},
|
||||
&m.Move{From: "podCIDR", To: "podCidr"},
|
||||
m.Access{Fields: map[string]string{
|
||||
"podCidr": "r",
|
||||
"providerId": "r",
|
||||
"taints": "ru",
|
||||
"unschedulable": "ru",
|
||||
}}).
|
||||
AddMapperForType(version, v1.Node{},
|
||||
&m.Embed{Field: "status"},
|
||||
&m.Drop{Field: "conditions"},
|
||||
).
|
||||
MustImport(&Version, v1.NodeStatus{}, struct {
|
||||
MustImport(version, v1.NodeStatus{}, struct {
|
||||
IPAddress string
|
||||
Hostname string
|
||||
Info NodeInfo
|
||||
}{}).
|
||||
MustImport(&Version, v1.Node{})
|
||||
MustImport(version, v1.Node{})
|
||||
}
|
||||
|
||||
func volumeTypes(schemas *types.Schemas) *types.Schemas {
|
||||
|
@ -57,15 +57,16 @@ type Machine struct {
|
||||
}
|
||||
|
||||
type MachineStatus struct {
|
||||
Conditions []MachineCondition `json:"conditions"`
|
||||
NodeStatus v1.NodeStatus `json:"nodeStatus"`
|
||||
NodeName string `json:"nodeName"`
|
||||
Conditions []MachineCondition `json:"conditions,omitempty"`
|
||||
NodeStatus v1.NodeStatus `json:"nodeStatus,omitempty"`
|
||||
NodeName string `json:"nodeName,omitempty"`
|
||||
ClusterName string `json:"clusterName,omitempty" norman:"type=reference[cluster]"`
|
||||
Requested v1.ResourceList `json:"requested,omitempty"`
|
||||
Limits v1.ResourceList `json:"limits,omitempty"`
|
||||
MachineTemplateSpec *MachineTemplateSpec `json:"machineTemplateSpec"`
|
||||
NodeConfig *RKEConfigNode `json:"rkeNode"`
|
||||
SSHUser string `json:"sshUser"`
|
||||
MachineDriverConfig string `json:"machineDriverConfig"`
|
||||
MachineTemplateSpec *MachineTemplateSpec `json:"machineTemplateSpec,omitempty"`
|
||||
NodeConfig *RKEConfigNode `json:"rkeNode,omitempty"`
|
||||
SSHUser string `json:"sshUser,omitempty"`
|
||||
MachineDriverConfig string `json:"machineDriverConfig,omitempty"`
|
||||
}
|
||||
|
||||
var (
|
||||
@ -91,24 +92,26 @@ type MachineCondition struct {
|
||||
}
|
||||
|
||||
type MachineSpec struct {
|
||||
NodeSpec v1.NodeSpec `json:"nodeSpec"`
|
||||
ClusterName string `json:"clusterName" norman:"type=reference[cluster]"`
|
||||
Roles []string `json:"roles"`
|
||||
MachineTemplateName string `json:"machineTemplateName" norman:"type=reference[machineTemplate]"`
|
||||
Description string `json:"description"`
|
||||
NodeSpec v1.NodeSpec `json:"nodeSpec"`
|
||||
DisplayName string `json:"displayName,omitempty"`
|
||||
RequestedHostname string `json:"requestedHostname,omitempty" norman:"noupdate"`
|
||||
RequestedClusterName string `json:"requestedClusterName,omitempty" norman:"type=reference[cluster],noupdate"`
|
||||
RequestedRoles []string `json:"requestedRoles,omitempty" norman:"noupdate"`
|
||||
MachineTemplateName string `json:"machineTemplateName,omitempty" norman:"type=reference[machineTemplate],noupdate"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
type MachineCommonParams struct {
|
||||
AuthCertificateAuthority string `json:"authCertificateAuthority"`
|
||||
AuthKey string `json:"authKey"`
|
||||
EngineInstallURL string `json:"engineInstallURL"`
|
||||
DockerVersion string `json:"dockerVersion"`
|
||||
EngineOpt map[string]string `json:"engineOpt"`
|
||||
EngineInsecureRegistry []string `json:"engineInsecureRegistry"`
|
||||
EngineRegistryMirror []string `json:"engineRegistryMirror"`
|
||||
EngineLabel map[string]string `json:"engineLabel"`
|
||||
EngineStorageDriver string `json:"engineStorageDriver"`
|
||||
EngineEnv map[string]string `json:"engineEnv"`
|
||||
AuthCertificateAuthority string `json:"authCertificateAuthority,omitempty"`
|
||||
AuthKey string `json:"authKey,omitempty"`
|
||||
EngineInstallURL string `json:"engineInstallURL,omitempty"`
|
||||
DockerVersion string `json:"dockerVersion,omitempty"`
|
||||
EngineOpt map[string]string `json:"engineOpt,omitempty"`
|
||||
EngineInsecureRegistry []string `json:"engineInsecureRegistry,omitempty"`
|
||||
EngineRegistryMirror []string `json:"engineRegistryMirror,omitempty"`
|
||||
EngineLabel map[string]string `json:"engineLabel,omitempty"`
|
||||
EngineStorageDriver string `json:"engineStorageDriver,omitempty"`
|
||||
EngineEnv map[string]string `json:"engineEnv,omitempty"`
|
||||
}
|
||||
|
||||
type MachineDriver struct {
|
||||
|
@ -3,10 +3,10 @@ package schema
|
||||
import (
|
||||
"github.com/rancher/norman/types"
|
||||
m "github.com/rancher/norman/types/mapper"
|
||||
"github.com/rancher/types/apis/cluster.cattle.io/v3/schema"
|
||||
"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 (
|
||||
@ -42,28 +42,7 @@ func catalogTypes(schemas *types.Schemas) *types.Schemas {
|
||||
}
|
||||
|
||||
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{})
|
||||
return schema.NodeTypes(&Version, schemas)
|
||||
}
|
||||
|
||||
func clusterTypes(schemas *types.Schemas) *types.Schemas {
|
||||
@ -148,19 +127,16 @@ func machineTypes(schemas *types.Schemas) *types.Schemas {
|
||||
AddMapperForType(&Version, v3.MachineSpec{}, &m.Embed{Field: "nodeSpec"}).
|
||||
AddMapperForType(&Version, v3.MachineStatus{},
|
||||
&m.Drop{Field: "conditions"},
|
||||
&m.Drop{Field: "rkeNode"},
|
||||
&m.Drop{Field: "machineTemplateSpec"},
|
||||
&m.Drop{Field: "machineDriverConfig"},
|
||||
&m.Embed{Field: "nodeStatus"}).
|
||||
AddMapperForType(&Version, v3.Machine{},
|
||||
&m.Embed{Field: "status"},
|
||||
&m.Move{From: "name", To: "id"},
|
||||
&m.Move{From: "nodeName", To: "name"}).
|
||||
m.DisplayName{}).
|
||||
AddMapperForType(&Version, v3.MachineDriver{}).
|
||||
AddMapperForType(&Version, v3.MachineTemplate{}, m.DisplayName{}).
|
||||
MustImportAndCustomize(&Version, v3.Machine{}, func(schema *types.Schema) {
|
||||
schema.MustCustomizeField("name", func(f types.Field) types.Field {
|
||||
f.Create = true
|
||||
return f
|
||||
})
|
||||
}).
|
||||
MustImport(&Version, v3.Machine{}).
|
||||
MustImport(&Version, v3.MachineDriver{}).
|
||||
MustImport(&Version, v3.MachineTemplate{})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user