mirror of
https://github.com/rancher/types.git
synced 2025-07-05 09:46:13 +00:00
Fix namespace attribute on native types
This commit is contained in:
parent
fe47f6246e
commit
bb9f169d59
@ -28,7 +28,7 @@ func Generate(schemas *types.Schemas) {
|
||||
}
|
||||
}
|
||||
|
||||
func GenerateNativeTypes(gv schema.GroupVersion, objs ...interface{}) {
|
||||
func GenerateNativeTypes(gv schema.GroupVersion, nsObjs []interface{}, objs []interface{}) {
|
||||
version := gv.Version
|
||||
group := gv.Group
|
||||
groupPath := group
|
||||
@ -43,7 +43,7 @@ func GenerateNativeTypes(gv schema.GroupVersion, objs ...interface{}) {
|
||||
Version: version,
|
||||
Group: group,
|
||||
Path: fmt.Sprintf("/k8s/%s-%s", groupPath, version),
|
||||
}, k8sOutputPackage, objs...); err != nil {
|
||||
}, k8sOutputPackage, nsObjs, objs); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
28
main.go
28
main.go
@ -18,10 +18,26 @@ func main() {
|
||||
generator.Generate(managementSchema.Schemas)
|
||||
generator.Generate(clusterSchema.Schemas)
|
||||
generator.Generate(projectSchema.Schemas)
|
||||
// Group by API group
|
||||
generator.GenerateNativeTypes(v1.SchemeGroupVersion, v1.Pod{}, v1.Node{}, v1.ComponentStatus{}, v1.Namespace{}, v1.Event{})
|
||||
generator.GenerateNativeTypes(v1beta2.SchemeGroupVersion, v1beta2.Deployment{})
|
||||
generator.GenerateNativeTypes(rbacv1.SchemeGroupVersion, rbacv1.RoleBinding{}, rbacv1.ClusterRoleBinding{}, rbacv1.ClusterRole{},
|
||||
rbacv1.Role{})
|
||||
generator.GenerateNativeTypes(extv1beta1.SchemeGroupVersion, extv1beta1.PodSecurityPolicy{})
|
||||
generator.GenerateNativeTypes(v1.SchemeGroupVersion, []interface{}{
|
||||
v1.Pod{},
|
||||
}, []interface{}{
|
||||
v1.Node{},
|
||||
v1.ComponentStatus{},
|
||||
v1.Namespace{},
|
||||
v1.Event{},
|
||||
})
|
||||
generator.GenerateNativeTypes(v1beta2.SchemeGroupVersion, []interface{}{
|
||||
v1beta2.Deployment{},
|
||||
}, nil)
|
||||
generator.GenerateNativeTypes(rbacv1.SchemeGroupVersion, []interface{}{
|
||||
rbacv1.RoleBinding{},
|
||||
rbacv1.Role{},
|
||||
}, []interface{}{
|
||||
rbacv1.ClusterRoleBinding{},
|
||||
rbacv1.ClusterRole{},
|
||||
})
|
||||
generator.GenerateNativeTypes(extv1beta1.SchemeGroupVersion, nil,
|
||||
[]interface{}{
|
||||
extv1beta1.PodSecurityPolicy{},
|
||||
})
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ func (e InitContainerMapper) FromInternal(data map[string]interface{}) {
|
||||
}
|
||||
|
||||
func (e InitContainerMapper) ToInternal(data map[string]interface{}) {
|
||||
newContainers := []interface{}{}
|
||||
newInitContainers := []interface{}{}
|
||||
var newContainers []interface{}
|
||||
var newInitContainers []interface{}
|
||||
|
||||
for _, container := range convert.ToMapSlice(data["containers"]) {
|
||||
if convert.ToBool(container["initContainer"]) {
|
||||
|
@ -26,7 +26,11 @@ func (e NamespaceMapper) FromInternal(data map[string]interface{}) {
|
||||
|
||||
func (e NamespaceMapper) ToInternal(data map[string]interface{}) {
|
||||
for name, friendlyName := range namespaceMapping {
|
||||
value := convert.ToString(data[friendlyName])
|
||||
obj, ok := data[friendlyName]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
value := convert.ToString(obj)
|
||||
if value == "host" {
|
||||
data[name] = true
|
||||
} else {
|
||||
|
@ -42,10 +42,14 @@ var conditionMappings = []conditionMapping{
|
||||
{Name: "KernelHasNoDeadlock", Error: true, FalseIsGood: true},
|
||||
{Name: "Unschedulable", Error: true, FalseIsGood: true},
|
||||
{Name: "ReplicaFailure", Error: true, FalseIsGood: true},
|
||||
{Name: "Ready", Transition: false, State: "unavailable"},
|
||||
{Name: "Ready", Transition: false, State: "activating"},
|
||||
}
|
||||
|
||||
func Set(data map[string]interface{}) {
|
||||
if data == nil {
|
||||
return
|
||||
}
|
||||
|
||||
val, ok := values.GetValue(data, "metadata", "removed")
|
||||
if ok && val != "" && val != nil {
|
||||
data["state"] = "removing"
|
||||
|
Loading…
Reference in New Issue
Block a user