1
0
mirror of https://github.com/rancher/rke.git synced 2025-07-02 10:12:12 +00:00
rke/vendor/github.com/rancher/norman
2018-07-19 14:30:51 -07:00
..
condition Vendor Update 2018-04-03 12:38:37 -07:00
controller vendor update 2018-07-19 14:30:51 -07:00
httperror vendor update 2018-07-19 14:30:51 -07:00
lifecycle vendor update 2018-04-04 00:18:31 +02:00
name Vendor update 2018-01-22 21:30:53 +02:00
objectclient K8s Vendor update to 1.10.5 2018-07-11 17:05:55 -07:00
restwatch Vendor Update 2018-04-03 12:38:37 -07:00
types vendor update 2018-07-19 14:30:51 -07:00
.dockerignore Vendor update 2017-11-13 23:23:16 +02:00
.drone.yml Vendor update 2017-11-13 23:23:16 +02:00
.gitignore K8s Vendor update to 1.10.5 2018-07-11 17:05:55 -07:00
Dockerfile.dapper Vendor update 2017-11-13 23:23:16 +02:00
LICENSE Vendor update 2017-11-13 23:23:16 +02:00
Makefile Vendor update 2017-11-13 23:23:16 +02:00
README.md Vendor update 2017-11-13 23:23:16 +02:00
vendor.conf K8s Vendor update to 1.10.5 2018-07-11 17:05:55 -07:00

Norman

An API framework for Building Rancher Style APIs backed by K8s CustomResources.

Building

make

Example

Refer to examples/

package main

import (
	"context"
	"fmt"
	"net/http"
	"os"

	"github.com/rancher/norman/generator"
	"github.com/rancher/norman/server"
	"github.com/rancher/norman/types"
)

type Foo struct {
	types.Resource
	Name     string `json:"name"`
	Foo      string `json:"foo"`
	SubThing Baz    `json:"subThing"`
}

type Baz struct {
	Name string `json:"name"`
}

var (
	version = types.APIVersion{
		Version: "v1",
		Group:   "io.cattle.core.example",
		Path:    "/example/v1",
	}

	Schemas = types.NewSchemas()
)

func main() {
	if _, err := Schemas.Import(&version, Foo{}); err != nil {
		panic(err)
	}

	server, err := server.NewAPIServer(context.Background(), os.Getenv("KUBECONFIG"), Schemas)
	if err != nil {
		panic(err)
	}

	fmt.Println("Listening on 0.0.0.0:1234")
	http.ListenAndServe("0.0.0.0:1234", server)
}

License

Copyright (c) 2014-2017 Rancher Labs, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.