1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-09 02:59:19 +00:00
This commit is contained in:
Darren Shepherd
2017-11-28 14:28:25 -07:00
parent faa1fb2148
commit 389d27b3e5
28 changed files with 490 additions and 159 deletions

View File

@@ -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)
}