1
0
mirror of https://github.com/rancher/norman.git synced 2025-08-02 07:59:20 +00:00
mirror from GitHub
Go to file
Dan Ramich 7edec77619 Add ability to generate collection actions
Problem:
Collections have actions but are not accessable through the types
clients

Solution:
Update template and generator to output actions living on collections
2018-03-31 03:13:13 -07:00
api Don't log conflicts as much 2018-03-22 15:55:44 -07:00
authorization Pass in schema to Filter/FilterList 2018-03-02 23:12:42 -07:00
clientbase Add some debug logging to see churn 2018-03-23 09:44:24 -07:00
condition Only record forgetError if there is no message at all 2018-02-06 05:03:25 +00:00
controller Add some debug logging to see churn 2018-03-23 09:44:24 -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 ability to generate collection actions 2018-03-31 03:13:13 -07:00
httperror Add IsConflict to httperror 2018-03-15 09:29:34 -07:00
leader Add leader election wrapper 2018-02-20 12:51:55 -07:00
lifecycle only update when obj is not nil 2018-02-07 13:48:17 -08:00
name Special handling for endpoints plural name 2018-01-12 19:15:37 +00:00
offspring Switch args in namespace methods 2018-01-18 23:41:45 +00:00
package Initial Commit 2017-10-11 22:48:07 -07:00
parse Ignore for nullable enums 2018-03-26 19:06:15 -07:00
pkg Fix a series of url parsing issues 2018-02-13 16:44:25 -07:00
scripts Subcontext and mapping updates 2017-11-21 15:37:22 -07:00
signal Move gorouting dump 2018-01-22 23:53:21 +00:00
store Add schema to Transformer funcs 2018-03-23 08:42:53 -07:00
types Preserve selfLink in data 2018-03-29 15:58:51 -07:00
urlbuilder actionLinkByID 2018-03-25 11:37:45 -07:00
vendor Update vendor 2018-02-20 12:51:55 -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 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.