1
0
mirror of https://github.com/rancher/norman.git synced 2025-08-01 23:41:24 +00:00
mirror from GitHub
Go to file
2018-01-16 05:10:36 +00:00
api API-UI 1.1.4 2018-01-04 04:56:03 +00:00
authorization Enable access control 2017-12-18 13:59:56 -07:00
clientbase Fix namespacing error in client 2018-01-12 14:39:58 +00:00
condition Handle non-nil interfaces with nil values 2018-01-16 05:10:36 +00:00
controller Add name to handlers 2018-01-16 05:10:36 +00:00
event Add event framework 2017-12-16 01:42:53 -07:00
example Add offspring controller 2017-12-19 21:44:02 -07:00
generator Add name to handlers 2018-01-16 05:10:36 +00:00
httperror Add status to error reponses 2018-01-03 05:46:29 +00:00
lifecycle Allow namespaces to have finalizers 2018-01-15 10:31:34 -07:00
name Special handling for endpoints plural name 2018-01-12 19:15:37 +00:00
offspring Send ping events 2018-01-12 14:39:58 +00:00
package Initial Commit 2017-10-11 22:48:07 -07:00
parse return errors where appropriate 2018-01-02 19:20:18 -07:00
pkg/subscribe Send ping events 2018-01-12 14:39:58 +00:00
scripts Subcontext and mapping updates 2017-11-21 15:37:22 -07:00
signal Add signal 2017-11-28 17:33:13 -07:00
store Set namespace and name on object always 2018-01-16 05:06:10 +00:00
types Don't generate the ID field 2018-01-16 05:10:36 +00:00
urlbuilder add resourceLinkById 2017-12-16 02:06:31 -07:00
vendor Update vendor 2018-01-03 05:46:29 +00:00
.dockerignore More initial dev 2017-11-10 21:46:30 -07:00
.drone.yml Initial Commit 2017-10-11 22:48:07 -07:00
.gitignore More initial dev 2017-11-10 21:46:30 -07:00
Dockerfile.dapper Initial Commit 2017-10-11 22:48:07 -07:00
LICENSE Initial Commit 2017-10-11 22:48:07 -07:00
Makefile Initial Commit 2017-10-11 22:48:07 -07:00
README.md Update example 2017-11-10 21:50:42 -07:00
vendor.conf Vendor bump 2017-11-10 21:46:33 -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.