1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-25 06:42:35 +00:00

Add namespace filtering

This commit is contained in:
Darren Shepherd
2020-02-27 10:34:51 -07:00
parent ae42b9422b
commit 6b6ff53373
11 changed files with 194 additions and 99 deletions

View File

@@ -29,16 +29,30 @@ func (a *APISchemas) MustAddSchema(obj APISchema) *APISchemas {
return a
}
func (a *APISchemas) MustImportAndCustomize(obj interface{}, f func(*APISchema)) {
schema, err := a.InternalSchemas.Import(obj)
if err != nil {
panic(err)
}
func (a *APISchemas) addInternalSchema(schema *schemas.Schema) *APISchema {
apiSchema := &APISchema{
Schema: schema,
}
a.Schemas[schema.ID] = apiSchema
a.addToIndex(apiSchema)
for _, f := range schema.ResourceFields {
if subType := a.InternalSchemas.Schema(f.Type); subType == nil {
continue
} else if _, ok := a.Schemas[subType.ID]; !ok {
a.addInternalSchema(subType)
}
}
return apiSchema
}
func (a *APISchemas) MustImportAndCustomize(obj interface{}, f func(*APISchema)) {
schema, err := a.InternalSchemas.Import(obj)
if err != nil {
panic(err)
}
apiSchema := a.addInternalSchema(schema)
f(apiSchema)
}