mirror of
https://github.com/rancher/norman.git
synced 2025-09-09 02:59:19 +00:00
Updates
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/rancher/norman/server"
|
||||
"github.com/rancher/norman/api"
|
||||
"github.com/rancher/norman/store/crd"
|
||||
"github.com/rancher/norman/types"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
)
|
||||
|
||||
type Foo struct {
|
||||
@@ -32,15 +33,25 @@ var (
|
||||
)
|
||||
|
||||
func main() {
|
||||
if _, err := Schemas.Import(&version, Foo{}); err != nil {
|
||||
kubeConfig, err := clientcmd.BuildConfigFromFlags("", os.Getenv("KUBECONFIG"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
server, err := server.NewAPIServer(context.Background(), os.Getenv("KUBECONFIG"), Schemas)
|
||||
store, err := crd.NewCRDStoreFromConfig(*kubeConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Schemas.MustImportAndCustomize(&version, Foo{}, func(schema *types.Schema) {
|
||||
schema.Store = store
|
||||
})
|
||||
|
||||
server := api.NewAPIServer()
|
||||
if err := server.AddSchemas(Schemas); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Println("Listening on 0.0.0.0:1234")
|
||||
http.ListenAndServe("0.0.0.0:1234", server)
|
||||
}
|
||||
|
Reference in New Issue
Block a user