1
0
mirror of https://github.com/rancher/types.git synced 2025-09-23 19:07:21 +00:00

Update types

This commit is contained in:
Darren Shepherd
2017-11-29 14:38:12 -07:00
parent 4bd90956c0
commit 143e41f471
6 changed files with 188 additions and 12 deletions

View File

@@ -2,9 +2,9 @@ package schema
import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/factory"
"github.com/rancher/norman/types/mapper"
"github.com/rancher/types/apis/authorization.cattle.io/v1"
"github.com/rancher/types/factory"
)
var (

View File

@@ -15,15 +15,15 @@ type Project struct {
type ProjectSpec struct {
DisplayName string `json:"displayName,omitempty" norman:"required"`
//TODO: should be required
ClusterName string `json:"clusterName,omitempty" norman:"type=reference[/v1-cluster/schemas/cluster]"`
ClusterName string `json:"clusterName,omitempty" norman:"required,type=reference[/v1-cluster/schemas/cluster]"`
}
type ProjectRoleTemplate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Rules []rbacv1.PolicyRule `json:"rules,omitempty"`
Rules []rbacv1.PolicyRule `json:"rules,omitempty"`
Builtin bool `json:"builtin"`
ProjectRoleTemplateNames []string `json:"projectRoleTemplateNames,omitempty" norman:"type=array[reference[projectRoleTemplate]]"`
}
@@ -49,7 +49,8 @@ type ClusterRoleTemplate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Rules []rbacv1.PolicyRule `json:"rules,omitempty"`
Rules []rbacv1.PolicyRule `json:"rules,omitempty"`
Builtin bool `json:"builtin"`
ClusterRoleTemplateNames []string `json:"clusterRoleTemplateNames,omitempty" norman:"type=array[reference[clusterRoleTemplate]]"`
}

View File

@@ -2,8 +2,9 @@ package schema
import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/factory"
"github.com/rancher/norman/types/mapper"
"github.com/rancher/types/apis/cluster.cattle.io/v1"
"github.com/rancher/types/factory"
)
var (
@@ -14,6 +15,13 @@ var (
}
Schemas = factory.Schemas(&Version).
AddMapperForType(&Version, v1.Cluster{}, mapper.DisplayName{}).
AddMapperForType(&Version, v1.Machine{}, mapper.DisplayName{}).
AddMapperForType(&Version, v1.MachineDriver{}, mapper.DisplayName{}).
AddMapperForType(&Version, v1.MachineTemplate{}, mapper.DisplayName{}).
MustImport(&Version, v1.Cluster{}).
MustImport(&Version, v1.ClusterNode{})
MustImport(&Version, v1.ClusterNode{}).
MustImport(&Version, v1.Machine{}).
MustImport(&Version, v1.MachineDriver{}).
MustImport(&Version, v1.MachineTemplate{})
)

View File

@@ -35,6 +35,8 @@ type Cluster struct {
}
type ClusterSpec struct {
DisplayName string `json:"displayName"`
Description string `json:"description"`
GoogleKubernetesEngineConfig *GoogleKubernetesEngineConfig `json:"googleKubernetesEngineConfig,omitempty"`
AzureKubernetesServiceConfig *AzureKubernetesServiceConfig `json:"azureKubernetesServiceConfig,omitempty"`
RancherKubernetesEngineConfig *RancherKubernetesEngineConfig `json:"rancherKubernetesEngineConfig,omitempty"`
@@ -56,7 +58,7 @@ type ClusterStatus struct {
}
type ClusterComponentStatus struct {
Name string
Name string `json:"name"`
Conditions []v1.ComponentCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,2,rep,name=conditions"`
}
@@ -216,3 +218,152 @@ type AuthConfig struct {
type ClusterNode struct {
v1.Node
}
type MachineTemplate struct {
metav1.TypeMeta `json:",inline"`
// Standard objects metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Spec MachineTemplateSpec `json:"spec"`
// Most recent observed status of the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Status MachineTemplateStatus `json:"status"`
}
type MachineTemplateStatus struct {
Conditions []MachineTemplateCondition `json:"conditions"`
}
type MachineTemplateCondition struct {
// Type of cluster condition.
Type string `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
}
type MachineTemplateSpec struct {
DisplayName string `json:"displayName"`
Description string `json:"description"`
FlavorPrefix string `json:"flavorPrefix"`
Driver string `json:"driver"`
SecretValues map[string]string `json:"secretValues"`
SecretName string `norman:"type=reference[/v1-cluster/schemas/globalSecret]"`
PublicValues map[string]string `json:"publicValues"`
}
type Machine struct {
metav1.TypeMeta `json:",inline"`
// Standard objects metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Spec MachineSpec `json:"spec"`
// Most recent observed status of the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Status MachineStatus `json:"status"`
}
type MachineStatus struct {
Conditions []MachineCondition `json:"conditions"`
}
type MachineCondition struct {
// Type of cluster condition.
Type string `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
}
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"`
MachineGeneralParams `json:",inline"`
AmazonEC2Config AmazonEC2Config `json:"amazonEc2Config"`
AzureConfig AzureConfig `json:"azureConfig"`
DigitalOceanConfig DigitalOceanConfig `json:"digitalOceanConfig"`
}
type AmazonEC2Config struct {
}
type AzureConfig struct {
}
type DigitalOceanConfig struct {
}
type MachineGeneralParams 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"`
}
type MachineDriver struct {
metav1.TypeMeta `json:",inline"`
// Standard objects metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Spec MachineDriverSpec `json:"spec"`
// Most recent observed status of the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Status MachineDriverStatus `json:"status"`
}
type MachineDriverStatus struct {
Conditions []MachineDriverCondition `json:"conditions"`
}
type MachineDriverCondition struct {
// Type of cluster condition.
Type string `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
}
type MachineDriverSpec struct {
DisplayName string `json:"displayName"`
Description string `json:"description"`
URL string `json:"url"`
ExternalID string `json:"externalId"`
Builtin bool `json:"builtin"`
DefaultActive bool `json:"defaultActive"`
ActivateOnCreate bool `json:"activateOnCreate"`
Checksum string `json:"checksum"`
UIURL string `json:"uiUrl"`
}

View File

@@ -2,10 +2,10 @@ package schema
import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/factory"
m "github.com/rancher/norman/types/mapper"
workloadv1 "github.com/rancher/types/apis/workload.cattle.io/v1"
"github.com/rancher/types/apis/workload.cattle.io/v1/schema/mapper"
"github.com/rancher/types/factory"
"github.com/rancher/types/mapper"
"k8s.io/api/core/v1"
"k8s.io/kubernetes/staging/src/k8s.io/api/apps/v1beta2"
)
@@ -188,7 +188,6 @@ func nodeTypes(schemas *types.Schemas) *types.Schemas {
&m.SliceToMap{Field: "volumesAttached", Key: "devicePath"},
).
AddMapperForType(&Version, v1.Node{},
mapper.Status{},
&m.Embed{Field: "status"},
&m.Drop{Field: "conditions"},
).
@@ -294,7 +293,6 @@ func podTypes(schemas *types.Schemas) *types.Schemas {
mapper.PivotMapper{Plural: true},
).
AddMapperForType(&Version, v1.Pod{},
mapper.Status{},
&mapper.NamespaceIDMapper{},
).
// Must import handlers before Container

18
factory/schemas.go Normal file
View File

@@ -0,0 +1,18 @@
package factory
import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/factory"
"github.com/rancher/types/mapper"
)
func Schemas(version *types.APIVersion) *types.Schemas {
schemas := factory.Schemas(version)
baseFunc := schemas.DefaultMappers
schemas.DefaultMappers = func() []types.Mapper {
return append([]types.Mapper{
mapper.Status{},
}, baseFunc()...)
}
return schemas
}