mirror of
https://github.com/rancher/types.git
synced 2025-09-19 00:46:53 +00:00
Merge pull request #202 from alena1108/workloadlabels
Workload labels/annotations
This commit is contained in:
@@ -106,16 +106,10 @@ func workloadTypes(schemas *types.Schemas) *types.Schemas {
|
||||
continue
|
||||
}
|
||||
for name, field := range baseSchema.ResourceFields {
|
||||
if name == "template" {
|
||||
templateSchema := schemas.Schema(&Version, field.Type)
|
||||
for name, field := range templateSchema.ResourceFields {
|
||||
schema.ResourceFields[name] = field
|
||||
}
|
||||
} else {
|
||||
if name != "template" {
|
||||
schema.ResourceFields[name] = field
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -159,6 +153,7 @@ func statefulSetTypes(schemas *types.Schemas) *types.Schemas {
|
||||
From: "status",
|
||||
To: "statefulSetStatus",
|
||||
},
|
||||
NewWorkloadTypeMapper(),
|
||||
).
|
||||
MustImport(&Version, v1beta2.StatefulSetSpec{}, statefulSetConfigOverride{}).
|
||||
MustImport(&Version, v1beta2.StatefulSet{}, projectOverride{})
|
||||
@@ -183,6 +178,7 @@ func replicaSetTypes(schemas *types.Schemas) *types.Schemas {
|
||||
To: "replicaSetStatus",
|
||||
},
|
||||
&m.Embed{Field: "template"},
|
||||
NewWorkloadTypeMapper(),
|
||||
).
|
||||
MustImport(&Version, v1beta1.ReplicaSetSpec{}, replicaSetConfigOverride{}).
|
||||
MustImportAndCustomize(&Version, v1beta1.ReplicaSet{}, func(schema *types.Schema) {
|
||||
@@ -209,6 +205,7 @@ func replicationControllerTypes(schemas *types.Schemas) *types.Schemas {
|
||||
From: "status",
|
||||
To: "replicationControllerStatus",
|
||||
},
|
||||
NewWorkloadTypeMapper(),
|
||||
).
|
||||
MustImport(&Version, v1.ReplicationControllerSpec{}, replicationControllerConfigOverride{}).
|
||||
MustImportAndCustomize(&Version, v1.ReplicationController{}, func(schema *types.Schema) {
|
||||
@@ -238,6 +235,7 @@ func daemonSetTypes(schemas *types.Schemas) *types.Schemas {
|
||||
From: "status",
|
||||
To: "daemonSetStatus",
|
||||
},
|
||||
NewWorkloadTypeMapper(),
|
||||
).
|
||||
MustImport(&Version, v1beta2.DaemonSetSpec{}, daemonSetOverride{}).
|
||||
MustImportAndCustomize(&Version, v1beta2.DaemonSet{}, func(schema *types.Schema) {
|
||||
@@ -345,6 +343,7 @@ func cronJobTypes(schemas *types.Schemas) *types.Schemas {
|
||||
From: "status",
|
||||
To: "cronJobStatus",
|
||||
},
|
||||
NewWorkloadTypeMapper(),
|
||||
).
|
||||
MustImport(&Version, batchv1beta1.CronJobSpec{}, cronJobOverride{}).
|
||||
MustImportAndCustomize(&Version, batchv1beta1.CronJob{}, func(schema *types.Schema) {
|
||||
@@ -386,6 +385,7 @@ func deploymentTypes(schemas *types.Schemas) *types.Schemas {
|
||||
From: "status",
|
||||
To: "deploymentStatus",
|
||||
},
|
||||
NewWorkloadTypeMapper(),
|
||||
).
|
||||
MustImport(&Version, v1beta2.DeploymentSpec{}, deploymentConfigOverride{}).
|
||||
MustImportAndCustomize(&Version, v1beta2.Deployment{}, func(schema *types.Schema) {
|
||||
@@ -617,3 +617,13 @@ func podTemplateSpecTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
MustImport(&Version, v1.PodTemplateSpec{})
|
||||
}
|
||||
|
||||
func NewWorkloadTypeMapper() types.Mapper {
|
||||
return &types.Mappers{
|
||||
&m.Move{From: "labels", To: "workloadLabels"},
|
||||
&m.Move{From: "annotations", To: "workloadAnnotations"},
|
||||
&m.Move{From: "metadata/labels", To: "labels", NoDeleteFromField: true},
|
||||
&m.Move{From: "metadata/annotations", To: "annotations", NoDeleteFromField: true},
|
||||
&m.Drop{Field: "metadata"},
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@ const (
|
||||
CronJobFieldName = "name"
|
||||
CronJobFieldNamespaceId = "namespaceId"
|
||||
CronJobFieldNodeId = "nodeId"
|
||||
CronJobFieldObjectMeta = "metadata"
|
||||
CronJobFieldOwnerReferences = "ownerReferences"
|
||||
CronJobFieldPriority = "priority"
|
||||
CronJobFieldPriorityClassName = "priorityClassName"
|
||||
@@ -47,6 +46,8 @@ const (
|
||||
CronJobFieldUid = "uid"
|
||||
CronJobFieldUuid = "uuid"
|
||||
CronJobFieldVolumes = "volumes"
|
||||
CronJobFieldWorkloadAnnotations = "workloadAnnotations"
|
||||
CronJobFieldWorkloadLabels = "workloadLabels"
|
||||
)
|
||||
|
||||
type CronJob struct {
|
||||
@@ -72,7 +73,6 @@ type CronJob struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
NamespaceId string `json:"namespaceId,omitempty"`
|
||||
NodeId string `json:"nodeId,omitempty"`
|
||||
ObjectMeta *ObjectMeta `json:"metadata,omitempty"`
|
||||
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"`
|
||||
Priority *int64 `json:"priority,omitempty"`
|
||||
PriorityClassName string `json:"priorityClassName,omitempty"`
|
||||
@@ -92,6 +92,8 @@ type CronJob struct {
|
||||
Uid *int64 `json:"uid,omitempty"`
|
||||
Uuid string `json:"uuid,omitempty"`
|
||||
Volumes []Volume `json:"volumes,omitempty"`
|
||||
WorkloadAnnotations map[string]string `json:"workloadAnnotations,omitempty"`
|
||||
WorkloadLabels map[string]string `json:"workloadLabels,omitempty"`
|
||||
}
|
||||
type CronJobCollection struct {
|
||||
types.Collection
|
||||
|
@@ -27,7 +27,6 @@ const (
|
||||
DaemonSetFieldName = "name"
|
||||
DaemonSetFieldNamespaceId = "namespaceId"
|
||||
DaemonSetFieldNodeId = "nodeId"
|
||||
DaemonSetFieldObjectMeta = "metadata"
|
||||
DaemonSetFieldOwnerReferences = "ownerReferences"
|
||||
DaemonSetFieldPriority = "priority"
|
||||
DaemonSetFieldPriorityClassName = "priorityClassName"
|
||||
@@ -47,6 +46,8 @@ const (
|
||||
DaemonSetFieldUid = "uid"
|
||||
DaemonSetFieldUuid = "uuid"
|
||||
DaemonSetFieldVolumes = "volumes"
|
||||
DaemonSetFieldWorkloadAnnotations = "workloadAnnotations"
|
||||
DaemonSetFieldWorkloadLabels = "workloadLabels"
|
||||
)
|
||||
|
||||
type DaemonSet struct {
|
||||
@@ -72,7 +73,6 @@ type DaemonSet struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
NamespaceId string `json:"namespaceId,omitempty"`
|
||||
NodeId string `json:"nodeId,omitempty"`
|
||||
ObjectMeta *ObjectMeta `json:"metadata,omitempty"`
|
||||
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"`
|
||||
Priority *int64 `json:"priority,omitempty"`
|
||||
PriorityClassName string `json:"priorityClassName,omitempty"`
|
||||
@@ -92,6 +92,8 @@ type DaemonSet struct {
|
||||
Uid *int64 `json:"uid,omitempty"`
|
||||
Uuid string `json:"uuid,omitempty"`
|
||||
Volumes []Volume `json:"volumes,omitempty"`
|
||||
WorkloadAnnotations map[string]string `json:"workloadAnnotations,omitempty"`
|
||||
WorkloadLabels map[string]string `json:"workloadLabels,omitempty"`
|
||||
}
|
||||
type DaemonSetCollection struct {
|
||||
types.Collection
|
||||
|
@@ -27,7 +27,6 @@ const (
|
||||
DeploymentFieldName = "name"
|
||||
DeploymentFieldNamespaceId = "namespaceId"
|
||||
DeploymentFieldNodeId = "nodeId"
|
||||
DeploymentFieldObjectMeta = "metadata"
|
||||
DeploymentFieldOwnerReferences = "ownerReferences"
|
||||
DeploymentFieldPriority = "priority"
|
||||
DeploymentFieldPriorityClassName = "priorityClassName"
|
||||
@@ -48,6 +47,8 @@ const (
|
||||
DeploymentFieldUid = "uid"
|
||||
DeploymentFieldUuid = "uuid"
|
||||
DeploymentFieldVolumes = "volumes"
|
||||
DeploymentFieldWorkloadAnnotations = "workloadAnnotations"
|
||||
DeploymentFieldWorkloadLabels = "workloadLabels"
|
||||
)
|
||||
|
||||
type Deployment struct {
|
||||
@@ -73,7 +74,6 @@ type Deployment struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
NamespaceId string `json:"namespaceId,omitempty"`
|
||||
NodeId string `json:"nodeId,omitempty"`
|
||||
ObjectMeta *ObjectMeta `json:"metadata,omitempty"`
|
||||
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"`
|
||||
Priority *int64 `json:"priority,omitempty"`
|
||||
PriorityClassName string `json:"priorityClassName,omitempty"`
|
||||
@@ -94,6 +94,8 @@ type Deployment struct {
|
||||
Uid *int64 `json:"uid,omitempty"`
|
||||
Uuid string `json:"uuid,omitempty"`
|
||||
Volumes []Volume `json:"volumes,omitempty"`
|
||||
WorkloadAnnotations map[string]string `json:"workloadAnnotations,omitempty"`
|
||||
WorkloadLabels map[string]string `json:"workloadLabels,omitempty"`
|
||||
}
|
||||
type DeploymentCollection struct {
|
||||
types.Collection
|
||||
|
@@ -25,7 +25,6 @@ const (
|
||||
ReplicaSetFieldName = "name"
|
||||
ReplicaSetFieldNamespaceId = "namespaceId"
|
||||
ReplicaSetFieldNodeId = "nodeId"
|
||||
ReplicaSetFieldObjectMeta = "metadata"
|
||||
ReplicaSetFieldOwnerReferences = "ownerReferences"
|
||||
ReplicaSetFieldPriority = "priority"
|
||||
ReplicaSetFieldPriorityClassName = "priorityClassName"
|
||||
@@ -47,6 +46,8 @@ const (
|
||||
ReplicaSetFieldUid = "uid"
|
||||
ReplicaSetFieldUuid = "uuid"
|
||||
ReplicaSetFieldVolumes = "volumes"
|
||||
ReplicaSetFieldWorkloadAnnotations = "workloadAnnotations"
|
||||
ReplicaSetFieldWorkloadLabels = "workloadLabels"
|
||||
)
|
||||
|
||||
type ReplicaSet struct {
|
||||
@@ -70,7 +71,6 @@ type ReplicaSet struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
NamespaceId string `json:"namespaceId,omitempty"`
|
||||
NodeId string `json:"nodeId,omitempty"`
|
||||
ObjectMeta *ObjectMeta `json:"metadata,omitempty"`
|
||||
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"`
|
||||
Priority *int64 `json:"priority,omitempty"`
|
||||
PriorityClassName string `json:"priorityClassName,omitempty"`
|
||||
@@ -92,6 +92,8 @@ type ReplicaSet struct {
|
||||
Uid *int64 `json:"uid,omitempty"`
|
||||
Uuid string `json:"uuid,omitempty"`
|
||||
Volumes []Volume `json:"volumes,omitempty"`
|
||||
WorkloadAnnotations map[string]string `json:"workloadAnnotations,omitempty"`
|
||||
WorkloadLabels map[string]string `json:"workloadLabels,omitempty"`
|
||||
}
|
||||
type ReplicaSetCollection struct {
|
||||
types.Collection
|
||||
|
@@ -25,7 +25,6 @@ const (
|
||||
ReplicationControllerFieldName = "name"
|
||||
ReplicationControllerFieldNamespaceId = "namespaceId"
|
||||
ReplicationControllerFieldNodeId = "nodeId"
|
||||
ReplicationControllerFieldObjectMeta = "metadata"
|
||||
ReplicationControllerFieldOwnerReferences = "ownerReferences"
|
||||
ReplicationControllerFieldPriority = "priority"
|
||||
ReplicationControllerFieldPriorityClassName = "priorityClassName"
|
||||
@@ -47,6 +46,8 @@ const (
|
||||
ReplicationControllerFieldUid = "uid"
|
||||
ReplicationControllerFieldUuid = "uuid"
|
||||
ReplicationControllerFieldVolumes = "volumes"
|
||||
ReplicationControllerFieldWorkloadAnnotations = "workloadAnnotations"
|
||||
ReplicationControllerFieldWorkloadLabels = "workloadLabels"
|
||||
)
|
||||
|
||||
type ReplicationController struct {
|
||||
@@ -70,7 +71,6 @@ type ReplicationController struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
NamespaceId string `json:"namespaceId,omitempty"`
|
||||
NodeId string `json:"nodeId,omitempty"`
|
||||
ObjectMeta *ObjectMeta `json:"metadata,omitempty"`
|
||||
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"`
|
||||
Priority *int64 `json:"priority,omitempty"`
|
||||
PriorityClassName string `json:"priorityClassName,omitempty"`
|
||||
@@ -92,6 +92,8 @@ type ReplicationController struct {
|
||||
Uid *int64 `json:"uid,omitempty"`
|
||||
Uuid string `json:"uuid,omitempty"`
|
||||
Volumes []Volume `json:"volumes,omitempty"`
|
||||
WorkloadAnnotations map[string]string `json:"workloadAnnotations,omitempty"`
|
||||
WorkloadLabels map[string]string `json:"workloadLabels,omitempty"`
|
||||
}
|
||||
type ReplicationControllerCollection struct {
|
||||
types.Collection
|
||||
|
@@ -25,7 +25,6 @@ const (
|
||||
StatefulSetFieldName = "name"
|
||||
StatefulSetFieldNamespaceId = "namespaceId"
|
||||
StatefulSetFieldNodeId = "nodeId"
|
||||
StatefulSetFieldObjectMeta = "metadata"
|
||||
StatefulSetFieldOwnerReferences = "ownerReferences"
|
||||
StatefulSetFieldPriority = "priority"
|
||||
StatefulSetFieldPriorityClassName = "priorityClassName"
|
||||
@@ -47,6 +46,8 @@ const (
|
||||
StatefulSetFieldUid = "uid"
|
||||
StatefulSetFieldUuid = "uuid"
|
||||
StatefulSetFieldVolumes = "volumes"
|
||||
StatefulSetFieldWorkloadAnnotations = "workloadAnnotations"
|
||||
StatefulSetFieldWorkloadLabels = "workloadLabels"
|
||||
)
|
||||
|
||||
type StatefulSet struct {
|
||||
@@ -70,7 +71,6 @@ type StatefulSet struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
NamespaceId string `json:"namespaceId,omitempty"`
|
||||
NodeId string `json:"nodeId,omitempty"`
|
||||
ObjectMeta *ObjectMeta `json:"metadata,omitempty"`
|
||||
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"`
|
||||
Priority *int64 `json:"priority,omitempty"`
|
||||
PriorityClassName string `json:"priorityClassName,omitempty"`
|
||||
@@ -92,6 +92,8 @@ type StatefulSet struct {
|
||||
Uid *int64 `json:"uid,omitempty"`
|
||||
Uuid string `json:"uuid,omitempty"`
|
||||
Volumes []Volume `json:"volumes,omitempty"`
|
||||
WorkloadAnnotations map[string]string `json:"workloadAnnotations,omitempty"`
|
||||
WorkloadLabels map[string]string `json:"workloadLabels,omitempty"`
|
||||
}
|
||||
type StatefulSetCollection struct {
|
||||
types.Collection
|
||||
|
@@ -35,7 +35,6 @@ const (
|
||||
WorkloadFieldName = "name"
|
||||
WorkloadFieldNamespaceId = "namespaceId"
|
||||
WorkloadFieldNodeId = "nodeId"
|
||||
WorkloadFieldObjectMeta = "metadata"
|
||||
WorkloadFieldOwnerReferences = "ownerReferences"
|
||||
WorkloadFieldParallelism = "parallelism"
|
||||
WorkloadFieldPriority = "priority"
|
||||
@@ -61,6 +60,8 @@ const (
|
||||
WorkloadFieldUid = "uid"
|
||||
WorkloadFieldUuid = "uuid"
|
||||
WorkloadFieldVolumes = "volumes"
|
||||
WorkloadFieldWorkloadAnnotations = "workloadAnnotations"
|
||||
WorkloadFieldWorkloadLabels = "workloadLabels"
|
||||
)
|
||||
|
||||
type Workload struct {
|
||||
@@ -94,7 +95,6 @@ type Workload struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
NamespaceId string `json:"namespaceId,omitempty"`
|
||||
NodeId string `json:"nodeId,omitempty"`
|
||||
ObjectMeta *ObjectMeta `json:"metadata,omitempty"`
|
||||
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"`
|
||||
Parallelism *int64 `json:"parallelism,omitempty"`
|
||||
Priority *int64 `json:"priority,omitempty"`
|
||||
@@ -120,6 +120,8 @@ type Workload struct {
|
||||
Uid *int64 `json:"uid,omitempty"`
|
||||
Uuid string `json:"uuid,omitempty"`
|
||||
Volumes []Volume `json:"volumes,omitempty"`
|
||||
WorkloadAnnotations map[string]string `json:"workloadAnnotations,omitempty"`
|
||||
WorkloadLabels map[string]string `json:"workloadLabels,omitempty"`
|
||||
}
|
||||
type WorkloadCollection struct {
|
||||
types.Collection
|
||||
|
@@ -48,15 +48,17 @@ type ManagementContext struct {
|
||||
Schemas *types.Schemas
|
||||
Scheme *runtime.Scheme
|
||||
AccessControl types.AccessControl
|
||||
Project projectv3.Interface
|
||||
Management managementv3.Interface
|
||||
RBAC rbacv1.Interface
|
||||
Core corev1.Interface
|
||||
|
||||
Management managementv3.Interface
|
||||
Project projectv3.Interface
|
||||
RBAC rbacv1.Interface
|
||||
Core corev1.Interface
|
||||
}
|
||||
|
||||
func (c *ManagementContext) controllers() []controller.Starter {
|
||||
return []controller.Starter{
|
||||
c.Management,
|
||||
c.Project,
|
||||
c.RBAC,
|
||||
c.Core,
|
||||
c.Project,
|
||||
@@ -140,6 +142,11 @@ func NewManagementContext(config rest.Config) (*ManagementContext, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
context.Project, err = projectv3.NewForConfig(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
context.K8sClient, err = kubernetes.NewForConfig(&config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user