1
0
mirror of https://github.com/rancher/norman.git synced 2025-07-12 06:39:59 +00:00
mirror from GitHub
Go to file
Darren Shepherd c580ac3ab0
Merge pull request #201 from ukinau/Enable-fine-grained-control-for-controller-related-metrics
Enable fine-grained control for Controller related metrics
2018-10-04 14:18:49 -07:00
api API-UI 1.1.5 2018-07-24 14:33:56 -07:00
authorization Add CanDo function to AccessControl interface 2018-04-25 20:14:41 -07:00
clientbase Add ability to pass in WebSocket dialer 2018-07-31 14:10:23 -07:00
condition Allow to put Reason in controller.ForgetError 2018-10-03 02:44:42 +09:00
controller Merge pull request #201 from ukinau/Enable-fine-grained-control-for-controller-related-metrics 2018-10-04 14:18:49 -07:00
event Disable event logging for the moment 2018-02-06 05:03:25 +00:00
example Major refactor of subcontexts 2018-02-09 13:45:22 -07:00
generator Add method to client to get GenericController 2018-09-24 09:00:20 -07:00
httperror Add Conflict constant 2018-07-19 10:23:17 -07:00
leader Change some logging to debug 2018-07-19 10:23:17 -07:00
lifecycle Move ObjectClient to different package 2018-04-03 14:09:16 -07:00
name Special handling for endpoints plural name 2018-01-12 19:15:37 +00:00
objectclient Return proper v1.Status error, not masking marshaling error 2018-09-20 09:34:36 -07:00
package Initial Commit 2017-10-11 22:48:07 -07:00
parse Revert "Revert "Don't strip strings on output"" 2018-09-10 20:34:17 -07:00
pkg Trigger resolve in changeset on deleted objects 2018-10-04 14:07:41 -07:00
restwatch Add timeouts to rest clients 2018-04-02 15:46:10 -07:00
scripts Switch to go 1.11 2018-09-25 11:43:11 -07:00
signal Move gorouting dump 2018-01-22 23:53:21 +00:00
store Ensure that closed watchers are always stopped 2018-09-21 16:47:57 -07:00
types Breakout merge that allows changing metadata and status 2018-10-04 14:08:16 -07:00
urlbuilder Allow API to run through k8s service proxy 2018-07-19 10:23:17 -07:00
vendor Switch to modules 2018-09-25 11:26:23 -07: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 Fixes to adapt to 1.10.5 2018-07-11 16:44:45 -07:00
Dockerfile.dapper Switch to go 1.11 2018-09-25 11:43:11 -07:00
go.mod Switch to modules 2018-09-25 11:26:23 -07:00
go.sum Switch to modules 2018-09-25 11:26:23 -07:00
LICENSE Initial Commit 2017-10-11 22:48:07 -07:00
Makefile Switch to go 1.11 2018-09-25 11:43:11 -07:00
README.md Update example 2017-11-10 21:50:42 -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.