mirror of
https://github.com/rancher/types.git
synced 2025-09-01 05:09:10 +00:00
Update vendor
This commit is contained in:
6
vendor/github.com/rancher/norman/generator/controller_template.go
generated
vendored
6
vendor/github.com/rancher/norman/generator/controller_template.go
generated
vendored
@@ -63,7 +63,7 @@ type {{.schema.CodeName}}Interface interface {
|
||||
Get(name string, opts metav1.GetOptions) (*{{.prefix}}{{.schema.CodeName}}, error)
|
||||
Update(*{{.prefix}}{{.schema.CodeName}}) (*{{.prefix}}{{.schema.CodeName}}, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*{{.prefix}}{{.schema.CodeName}}List, error)
|
||||
List(opts metav1.ListOptions) (*{{.schema.CodeName}}List, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
Controller() {{.schema.CodeName}}Controller
|
||||
@@ -181,9 +181,9 @@ func (s *{{.schema.ID}}Client) Delete(name string, options *metav1.DeleteOptions
|
||||
return s.objectClient.Delete(name, options)
|
||||
}
|
||||
|
||||
func (s *{{.schema.ID}}Client) List(opts metav1.ListOptions) (*{{.prefix}}{{.schema.CodeName}}List, error) {
|
||||
func (s *{{.schema.ID}}Client) List(opts metav1.ListOptions) (*{{.schema.CodeName}}List, error) {
|
||||
obj, err := s.objectClient.List(opts)
|
||||
return obj.(*{{.prefix}}{{.schema.CodeName}}List), err
|
||||
return obj.(*{{.schema.CodeName}}List), err
|
||||
}
|
||||
|
||||
func (s *{{.schema.ID}}Client) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
|
15
vendor/github.com/rancher/norman/types/definition/definition.go
generated
vendored
15
vendor/github.com/rancher/norman/types/definition/definition.go
generated
vendored
@@ -1,6 +1,10 @@
|
||||
package definition
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/rancher/norman/types/convert"
|
||||
)
|
||||
|
||||
func IsMapType(fieldType string) bool {
|
||||
return strings.HasPrefix(fieldType, "map[") && strings.HasSuffix(fieldType, "]")
|
||||
@@ -26,3 +30,12 @@ func SubType(fieldType string) string {
|
||||
|
||||
return fieldType[i+1 : len(fieldType)-1]
|
||||
}
|
||||
|
||||
func GetType(data map[string]interface{}) string {
|
||||
parts := strings.Split(GetFullType(data), "/")
|
||||
return parts[len(parts)-1]
|
||||
}
|
||||
|
||||
func GetFullType(data map[string]interface{}) string {
|
||||
return convert.ToString(data["type"])
|
||||
}
|
||||
|
12
vendor/github.com/rancher/norman/types/factory/schemas.go
generated
vendored
12
vendor/github.com/rancher/norman/types/factory/schemas.go
generated
vendored
@@ -8,11 +8,15 @@ import (
|
||||
|
||||
func Schemas(version *types.APIVersion) *types.Schemas {
|
||||
s := types.NewSchemas()
|
||||
s.DefaultMappers = []types.Mapper{
|
||||
mapper.NewObject(),
|
||||
s.DefaultMappers = func() []types.Mapper {
|
||||
return []types.Mapper{
|
||||
mapper.NewObject(),
|
||||
}
|
||||
}
|
||||
s.DefaultPostMappers = []types.Mapper{
|
||||
&mapper.RenameReference{},
|
||||
s.DefaultPostMappers = func() []types.Mapper {
|
||||
return []types.Mapper{
|
||||
&mapper.RenameReference{},
|
||||
}
|
||||
}
|
||||
s.AddMapperForType(version, v1.ObjectMeta{}, mapper.NewMetadataMapper())
|
||||
return s
|
||||
|
9
vendor/github.com/rancher/norman/types/mapper/label_field.go
generated
vendored
9
vendor/github.com/rancher/norman/types/mapper/label_field.go
generated
vendored
@@ -1,13 +1,16 @@
|
||||
package mapper
|
||||
|
||||
import "github.com/rancher/norman/types"
|
||||
import (
|
||||
"github.com/rancher/norman/types"
|
||||
"github.com/rancher/norman/types/values"
|
||||
)
|
||||
|
||||
type LabelField struct {
|
||||
Field string
|
||||
}
|
||||
|
||||
func (e LabelField) FromInternal(data map[string]interface{}) {
|
||||
v, ok := RemoveValue(data, "labels", "io.cattle.field."+e.Field)
|
||||
v, ok := values.RemoveValue(data, "labels", "io.cattle.field."+e.Field)
|
||||
if ok {
|
||||
data[e.Field] = v
|
||||
}
|
||||
@@ -16,7 +19,7 @@ func (e LabelField) FromInternal(data map[string]interface{}) {
|
||||
func (e LabelField) ToInternal(data map[string]interface{}) {
|
||||
v, ok := data[e.Field]
|
||||
if ok {
|
||||
PutValue(data, v, "labels", "io.cattle.field."+e.Field)
|
||||
values.PutValue(data, v, "labels", "io.cattle.field."+e.Field)
|
||||
}
|
||||
}
|
||||
|
||||
|
9
vendor/github.com/rancher/norman/types/mapper/move.go
generated
vendored
9
vendor/github.com/rancher/norman/types/mapper/move.go
generated
vendored
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/rancher/norman/types"
|
||||
"github.com/rancher/norman/types/convert"
|
||||
"github.com/rancher/norman/types/definition"
|
||||
"github.com/rancher/norman/types/values"
|
||||
)
|
||||
|
||||
type Move struct {
|
||||
@@ -17,14 +18,14 @@ type Move struct {
|
||||
}
|
||||
|
||||
func (m Move) FromInternal(data map[string]interface{}) {
|
||||
if v, ok := RemoveValue(data, strings.Split(m.From, "/")...); ok {
|
||||
PutValue(data, v, strings.Split(m.To, "/")...)
|
||||
if v, ok := values.RemoveValue(data, strings.Split(m.From, "/")...); ok {
|
||||
values.PutValue(data, v, strings.Split(m.To, "/")...)
|
||||
}
|
||||
}
|
||||
|
||||
func (m Move) ToInternal(data map[string]interface{}) {
|
||||
if v, ok := RemoveValue(data, strings.Split(m.To, "/")...); ok {
|
||||
PutValue(data, v, strings.Split(m.From, "/")...)
|
||||
if v, ok := values.RemoveValue(data, strings.Split(m.To, "/")...); ok {
|
||||
values.PutValue(data, v, strings.Split(m.From, "/")...)
|
||||
}
|
||||
}
|
||||
|
||||
|
8
vendor/github.com/rancher/norman/types/mapper/object.go
generated
vendored
8
vendor/github.com/rancher/norman/types/mapper/object.go
generated
vendored
@@ -1,6 +1,8 @@
|
||||
package mapper
|
||||
|
||||
import "github.com/rancher/norman/types"
|
||||
import (
|
||||
"github.com/rancher/norman/types"
|
||||
)
|
||||
|
||||
type Object struct {
|
||||
types.Mappers
|
||||
@@ -12,8 +14,8 @@ func NewObject(mappers ...types.Mapper) Object {
|
||||
&Embed{Field: "metadata"},
|
||||
&Embed{Field: "spec", Optional: true},
|
||||
&ReadOnly{Field: "status", Optional: true},
|
||||
&Drop{"kind"},
|
||||
&Drop{"apiVersion"},
|
||||
Drop{"kind"},
|
||||
Drop{"apiVersion"},
|
||||
&Scope{
|
||||
IfNot: types.NamespaceScope,
|
||||
Mappers: []types.Mapper{
|
||||
|
9
vendor/github.com/rancher/norman/types/mapper/set_value.go
generated
vendored
9
vendor/github.com/rancher/norman/types/mapper/set_value.go
generated
vendored
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/rancher/norman/types"
|
||||
"github.com/rancher/norman/types/values"
|
||||
)
|
||||
|
||||
type SetValue struct {
|
||||
@@ -15,24 +16,24 @@ type SetValue struct {
|
||||
}
|
||||
|
||||
func (s SetValue) FromInternal(data map[string]interface{}) {
|
||||
v, ok := GetValue(data, strings.Split(s.From, "/")...)
|
||||
v, ok := values.GetValue(data, strings.Split(s.From, "/")...)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
if v == s.IfEq {
|
||||
PutValue(data, s.Value, strings.Split(s.To, "/")...)
|
||||
values.PutValue(data, s.Value, strings.Split(s.To, "/")...)
|
||||
}
|
||||
}
|
||||
|
||||
func (s SetValue) ToInternal(data map[string]interface{}) {
|
||||
v, ok := GetValue(data, strings.Split(s.To, "/")...)
|
||||
v, ok := values.GetValue(data, strings.Split(s.To, "/")...)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
if v == s.Value {
|
||||
PutValue(data, s.IfEq, strings.Split(s.From, "/")...)
|
||||
values.PutValue(data, s.IfEq, strings.Split(s.From, "/")...)
|
||||
}
|
||||
}
|
||||
|
||||
|
10
vendor/github.com/rancher/norman/types/reflection.go
generated
vendored
10
vendor/github.com/rancher/norman/types/reflection.go
generated
vendored
@@ -142,10 +142,14 @@ func (s *Schemas) importType(version *APIVersion, t reflect.Type, overrides ...r
|
||||
}
|
||||
|
||||
mappers := s.mapper(&schema.Version, schema.ID)
|
||||
if schema.CanList() {
|
||||
mappers = append(s.DefaultMappers, mappers...)
|
||||
if s.DefaultMappers != nil {
|
||||
if schema.CanList() {
|
||||
mappers = append(s.DefaultMappers(), mappers...)
|
||||
}
|
||||
}
|
||||
if s.DefaultPostMappers != nil {
|
||||
mappers = append(mappers, s.DefaultPostMappers()...)
|
||||
}
|
||||
mappers = append(mappers, s.DefaultPostMappers...)
|
||||
|
||||
if len(mappers) > 0 {
|
||||
copy, err := s.newSchemaFromType(version, t, typeName)
|
||||
|
6
vendor/github.com/rancher/norman/types/schemas.go
generated
vendored
6
vendor/github.com/rancher/norman/types/schemas.go
generated
vendored
@@ -15,12 +15,14 @@ type SchemaCollection struct {
|
||||
|
||||
type SchemaInitFunc func(*Schemas) *Schemas
|
||||
|
||||
type MappersFactory func() []Mapper
|
||||
|
||||
type Schemas struct {
|
||||
schemasByPath map[string]map[string]*Schema
|
||||
schemasBySubContext map[string]*Schema
|
||||
mappers map[string]map[string][]Mapper
|
||||
DefaultMappers []Mapper
|
||||
DefaultPostMappers []Mapper
|
||||
DefaultMappers MappersFactory
|
||||
DefaultPostMappers MappersFactory
|
||||
versions []APIVersion
|
||||
schemas []*Schema
|
||||
errors []error
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package mapper
|
||||
package values
|
||||
|
||||
func RemoveValue(data map[string]interface{}, keys ...string) (interface{}, bool) {
|
||||
for i, key := range keys {
|
Reference in New Issue
Block a user