mirror of
https://github.com/rancher/types.git
synced 2025-06-29 23:16:48 +00:00
Update vendor
This commit is contained in:
parent
a77c053ef5
commit
2bbbaef679
@ -2,4 +2,4 @@
|
||||
github.com/rancher/types
|
||||
|
||||
github.com/pkg/errors v0.8.0
|
||||
github.com/rancher/norman 92a6f9ebeeff00dc5b5c981aaaf71a30bd3f2ea7 transitive=true
|
||||
github.com/rancher/norman 5bafd7b137333cb19834c530bd85e6ce05afc63c transitive=true
|
||||
|
59
vendor/github.com/rancher/norman/README.md
generated
vendored
59
vendor/github.com/rancher/norman/README.md
generated
vendored
@ -1,66 +1,11 @@
|
||||
Norman
|
||||
========
|
||||
|
||||
An API framework for Building [Rancher Style APIs](https://github.com/rancher/api-spec/) backed by K8s CustomResources.
|
||||
|
||||
## Building
|
||||
|
||||
`make`
|
||||
An API framework for Building [Rancher Style APIs](https://github.com/rancher/api-spec/) backed by K8s CustomResources and their controllers.
|
||||
|
||||
## Example
|
||||
|
||||
Refer to `examples/`
|
||||
|
||||
```go
|
||||
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)
|
||||
}
|
||||
```
|
||||
|
||||
Refer to https://github.com/rancher/go-skel for skeleton norman controller projects
|
||||
|
||||
## License
|
||||
Copyright (c) 2014-2017 [Rancher Labs, Inc.](http://rancher.com)
|
||||
|
2
vendor/github.com/rancher/norman/generator/controller_template.go
generated
vendored
2
vendor/github.com/rancher/norman/generator/controller_template.go
generated
vendored
@ -41,7 +41,7 @@ type {{.schema.CodeName}}List struct {
|
||||
Items []{{.prefix}}{{.schema.CodeName}}
|
||||
}
|
||||
|
||||
type {{.schema.CodeName}}HandlerFunc func(key string, obj *{{.prefix}}{{.schema.CodeName}}) (*{{.prefix}}{{.schema.CodeName}}, error)
|
||||
type {{.schema.CodeName}}HandlerFunc func(key string, obj *{{.prefix}}{{.schema.CodeName}}) (runtime.Object, error)
|
||||
|
||||
type {{.schema.CodeName}}Lister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*{{.prefix}}{{.schema.CodeName}}, err error)
|
||||
|
66
vendor/github.com/rancher/norman/generator/default.go
generated
vendored
Normal file
66
vendor/github.com/rancher/norman/generator/default.go
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/rancher/norman/types"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
var (
|
||||
baseCattle = "client"
|
||||
baseK8s = "apis"
|
||||
)
|
||||
|
||||
func DefaultGenerate(schemas *types.Schemas, pkgPath string, publicAPI bool, foreignTypes map[string]bool) error {
|
||||
version := getVersion(schemas)
|
||||
group := strings.Split(version.Group, ".")[0]
|
||||
|
||||
cattleOutputPackage := path.Join(pkgPath, baseCattle, group, version.Version)
|
||||
if !publicAPI {
|
||||
cattleOutputPackage = ""
|
||||
}
|
||||
k8sOutputPackage := path.Join(pkgPath, baseK8s, version.Group, version.Version)
|
||||
|
||||
if err := Generate(schemas, foreignTypes, cattleOutputPackage, k8sOutputPackage); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ControllersForForeignTypes(baseOutputPackage string, gv schema.GroupVersion, nsObjs []interface{}, objs []interface{}) error {
|
||||
version := gv.Version
|
||||
group := gv.Group
|
||||
groupPath := group
|
||||
|
||||
if groupPath == "" {
|
||||
groupPath = "core"
|
||||
}
|
||||
|
||||
k8sOutputPackage := path.Join(baseOutputPackage, baseK8s, groupPath, version)
|
||||
|
||||
return GenerateControllerForTypes(&types.APIVersion{
|
||||
Version: version,
|
||||
Group: group,
|
||||
Path: fmt.Sprintf("/k8s/%s-%s", groupPath, version),
|
||||
}, k8sOutputPackage, nsObjs, objs)
|
||||
}
|
||||
|
||||
func getVersion(schemas *types.Schemas) *types.APIVersion {
|
||||
var version types.APIVersion
|
||||
for _, schema := range schemas.Schemas() {
|
||||
if version.Group == "" {
|
||||
version = schema.Version
|
||||
continue
|
||||
}
|
||||
if version.Group != schema.Version.Group ||
|
||||
version.Version != schema.Version.Version {
|
||||
panic("schema set contains two APIVersions")
|
||||
}
|
||||
}
|
||||
|
||||
return &version
|
||||
}
|
34
vendor/github.com/rancher/norman/generator/generator.go
generated
vendored
34
vendor/github.com/rancher/norman/generator/generator.go
generated
vendored
@ -361,27 +361,33 @@ func GenerateControllerForTypes(version *types.APIVersion, k8sOutputPackage stri
|
||||
return gofmt(baseDir, k8sOutputPackage)
|
||||
}
|
||||
|
||||
func Generate(schemas *types.Schemas, backendTypes map[string]bool, cattleOutputPackage, k8sOutputPackage string) error {
|
||||
func Generate(schemas *types.Schemas, foreignTypes map[string]bool, cattleOutputPackage, k8sOutputPackage string) error {
|
||||
baseDir := args.DefaultSourceTree()
|
||||
cattleDir := path.Join(baseDir, cattleOutputPackage)
|
||||
k8sDir := path.Join(baseDir, k8sOutputPackage)
|
||||
|
||||
if cattleOutputPackage == "" {
|
||||
cattleDir = ""
|
||||
}
|
||||
|
||||
if err := prepareDirs(cattleDir, k8sDir); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
controllers := []*types.Schema{}
|
||||
var controllers []*types.Schema
|
||||
|
||||
cattleClientTypes := []*types.Schema{}
|
||||
var cattleClientTypes []*types.Schema
|
||||
for _, schema := range schemas.Schemas() {
|
||||
if blackListTypes[schema.ID] {
|
||||
continue
|
||||
}
|
||||
|
||||
_, backendType := backendTypes[schema.ID]
|
||||
_, backendType := foreignTypes[schema.ID]
|
||||
|
||||
if err := generateType(cattleDir, schema, schemas); err != nil {
|
||||
return err
|
||||
if cattleDir != "" {
|
||||
if err := generateType(cattleDir, schema, schemas); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if backendType ||
|
||||
@ -402,8 +408,10 @@ func Generate(schemas *types.Schemas, backendTypes map[string]bool, cattleOutput
|
||||
}
|
||||
}
|
||||
|
||||
if err := generateClient(cattleDir, cattleClientTypes); err != nil {
|
||||
return err
|
||||
if cattleDir != "" {
|
||||
if err := generateClient(cattleDir, cattleClientTypes); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(controllers) > 0 {
|
||||
@ -424,11 +432,19 @@ func Generate(schemas *types.Schemas, backendTypes map[string]bool, cattleOutput
|
||||
return err
|
||||
}
|
||||
|
||||
return gofmt(baseDir, cattleOutputPackage)
|
||||
if cattleOutputPackage != "" {
|
||||
return gofmt(baseDir, cattleOutputPackage)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func prepareDirs(dirs ...string) error {
|
||||
for _, dir := range dirs {
|
||||
if dir == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
10
vendor/github.com/rancher/norman/generator/lifecycle_template.go
generated
vendored
10
vendor/github.com/rancher/norman/generator/lifecycle_template.go
generated
vendored
@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
type {{.schema.CodeName}}Lifecycle interface {
|
||||
Create(obj *{{.prefix}}{{.schema.CodeName}}) (*{{.prefix}}{{.schema.CodeName}}, error)
|
||||
Remove(obj *{{.prefix}}{{.schema.CodeName}}) (*{{.prefix}}{{.schema.CodeName}}, error)
|
||||
Updated(obj *{{.prefix}}{{.schema.CodeName}}) (*{{.prefix}}{{.schema.CodeName}}, error)
|
||||
Create(obj *{{.prefix}}{{.schema.CodeName}}) (runtime.Object, error)
|
||||
Remove(obj *{{.prefix}}{{.schema.CodeName}}) (runtime.Object, error)
|
||||
Updated(obj *{{.prefix}}{{.schema.CodeName}}) (runtime.Object, error)
|
||||
}
|
||||
|
||||
type {{.schema.ID}}LifecycleAdapter struct {
|
||||
@ -46,9 +46,9 @@ func (w *{{.schema.ID}}LifecycleAdapter) Updated(obj runtime.Object) (runtime.Ob
|
||||
func New{{.schema.CodeName}}LifecycleAdapter(name string, clusterScoped bool, client {{.schema.CodeName}}Interface, l {{.schema.CodeName}}Lifecycle) {{.schema.CodeName}}HandlerFunc {
|
||||
adapter := &{{.schema.ID}}LifecycleAdapter{lifecycle: l}
|
||||
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
|
||||
return func(key string, obj *{{.prefix}}{{.schema.CodeName}}) (*{{.prefix}}{{.schema.CodeName}}, error) {
|
||||
return func(key string, obj *{{.prefix}}{{.schema.CodeName}}) (runtime.Object, error) {
|
||||
newObj, err := syncFn(key, obj)
|
||||
if o, ok := newObj.(*{{.prefix}}{{.schema.CodeName}}); ok {
|
||||
if o, ok := newObj.(runtime.Object); ok {
|
||||
return o, err
|
||||
}
|
||||
return nil, err
|
||||
|
10
vendor/github.com/rancher/norman/vendor.conf
generated
vendored
10
vendor/github.com/rancher/norman/vendor.conf
generated
vendored
@ -1,8 +1,8 @@
|
||||
# package
|
||||
github.com/rancher/norman
|
||||
|
||||
k8s.io/kubernetes v1.12.1-lite7 https://github.com/ibuildthecloud/k3s.git transitive=true,staging=true
|
||||
github.com/maruel/panicparse c0182c169410cfa80c7e8f046dad208eaef91338
|
||||
bitbucket.org/ww/goautoneg a547fc61f48d567d5b4ec6f8aee5573d8efce11d https://github.com/rancher/goautoneg.git
|
||||
golang.org/x/sync fd80eb99c8f653c847d294a001bdf2a3a6f768f5
|
||||
github.com/gorilla/mux v1.6.1
|
||||
k8s.io/kubernetes v1.12.2-lite1 https://github.com/ibuildthecloud/k3s.git transitive=true,staging=true
|
||||
github.com/maruel/panicparse c0182c169410cfa80c7e8f046dad208eaef91338
|
||||
bitbucket.org/ww/goautoneg a547fc61f48d567d5b4ec6f8aee5573d8efce11d https://github.com/rancher/goautoneg.git
|
||||
golang.org/x/sync fd80eb99c8f653c847d294a001bdf2a3a6f768f5
|
||||
github.com/gorilla/mux v1.6.1
|
||||
|
2
vendor/k8s.io/api/core/v1/types.go
generated
vendored
2
vendor/k8s.io/api/core/v1/types.go
generated
vendored
@ -5208,7 +5208,7 @@ type SecurityContext struct {
|
||||
// readonly paths and masked paths.
|
||||
// This requires the ProcMountType feature flag to be enabled.
|
||||
// +optional
|
||||
ProcMount *ProcMountType `json:"procMount,omitEmpty" protobuf:"bytes,9,opt,name=procMount"`
|
||||
ProcMount *ProcMountType `json:"procMount,omitempty" protobuf:"bytes,9,opt,name=procMount"`
|
||||
}
|
||||
|
||||
type ProcMountType string
|
||||
|
7
vendor/k8s.io/apimachinery/pkg/util/net/BUILD
generated
vendored
7
vendor/k8s.io/apimachinery/pkg/util/net/BUILD
generated
vendored
@ -16,7 +16,12 @@ go_test(
|
||||
"util_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = ["//vendor/github.com/spf13/pflag:go_default_library"],
|
||||
deps = [
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/require:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
|
18
vendor/k8s.io/apimachinery/pkg/util/net/http.go
generated
vendored
18
vendor/k8s.io/apimachinery/pkg/util/net/http.go
generated
vendored
@ -321,9 +321,10 @@ type Dialer interface {
|
||||
|
||||
// ConnectWithRedirects uses dialer to send req, following up to 10 redirects (relative to
|
||||
// originalLocation). It returns the opened net.Conn and the raw response bytes.
|
||||
func ConnectWithRedirects(originalMethod string, originalLocation *url.URL, header http.Header, originalBody io.Reader, dialer Dialer) (net.Conn, []byte, error) {
|
||||
// If requireSameHostRedirects is true, only redirects to the same host are permitted.
|
||||
func ConnectWithRedirects(originalMethod string, originalLocation *url.URL, header http.Header, originalBody io.Reader, dialer Dialer, requireSameHostRedirects bool) (net.Conn, []byte, error) {
|
||||
const (
|
||||
maxRedirects = 10
|
||||
maxRedirects = 9 // Fail on the 10th redirect
|
||||
maxResponseSize = 16384 // play it safe to allow the potential for lots of / large headers
|
||||
)
|
||||
|
||||
@ -387,10 +388,6 @@ redirectLoop:
|
||||
|
||||
resp.Body.Close() // not used
|
||||
|
||||
// Reset the connection.
|
||||
intermediateConn.Close()
|
||||
intermediateConn = nil
|
||||
|
||||
// Prepare to follow the redirect.
|
||||
redirectStr := resp.Header.Get("Location")
|
||||
if redirectStr == "" {
|
||||
@ -404,6 +401,15 @@ redirectLoop:
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("malformed Location header: %v", err)
|
||||
}
|
||||
|
||||
// Only follow redirects to the same host. Otherwise, propagate the redirect response back.
|
||||
if requireSameHostRedirects && location.Hostname() != originalLocation.Hostname() {
|
||||
break redirectLoop
|
||||
}
|
||||
|
||||
// Reset the connection.
|
||||
intermediateConn.Close()
|
||||
intermediateConn = nil
|
||||
}
|
||||
|
||||
connToReturn := intermediateConn
|
||||
|
6
vendor/k8s.io/client-go/pkg/version/base.go
generated
vendored
6
vendor/k8s.io/client-go/pkg/version/base.go
generated
vendored
@ -3,8 +3,8 @@ package version
|
||||
var (
|
||||
gitMajor = "1"
|
||||
gitMinor = "12"
|
||||
gitVersion = "v1.12.1-lite7"
|
||||
gitCommit = "b5d55f02488df0daa1399df41777aeeeaa36eabb"
|
||||
gitVersion = "v1.12.2-lite1"
|
||||
gitCommit = "44905551dd08ce1e656c9e07c4a5d90627f01774"
|
||||
gitTreeState = "clean"
|
||||
buildDate = "2018-10-24T23:26+00:00Z"
|
||||
buildDate = "2018-10-30T18:28+00:00Z"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user