genericapiserver: move packages

Towards a sane k8s.io/apiserver package structure.
This commit is contained in:
Dr. Stefan Schimanski
2017-01-18 11:13:07 +01:00
parent f8ed5c36aa
commit e3b6235dee
165 changed files with 265 additions and 68 deletions

View File

@@ -1,42 +0,0 @@
/*
Copyright 2014 The Kubernetes Authors.
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.
*/
package rest
import (
"k8s.io/apimachinery/pkg/runtime"
)
// ObjectFunc is a function to act on a given object. An error may be returned
// if the hook cannot be completed. An ObjectFunc may transform the provided
// object.
type ObjectFunc func(obj runtime.Object) error
// AllFuncs returns an ObjectFunc that attempts to run all of the provided functions
// in order, returning early if there are any errors.
func AllFuncs(fns ...ObjectFunc) ObjectFunc {
return func(obj runtime.Object) error {
for _, fn := range fns {
if fn == nil {
continue
}
if err := fn(obj); err != nil {
return err
}
}
return nil
}
}

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package api package endpoints
import ( import (
"k8s.io/apiserver/pkg/metrics" "k8s.io/apiserver/pkg/metrics"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package api package endpoints
import ( import (
"bytes" "bytes"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package api package endpoints
import ( import (
"bytes" "bytes"

View File

@@ -0,0 +1,19 @@
/*
Copyright 2014 The Kubernetes Authors.
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.
*/
// Package endpoints contains the generic code that provides a RESTful Kubernetes-style API service.
package endpoints // import "k8s.io/kubernetes/pkg/genericapiserver/endpoints"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package api package endpoints
import ( import (
"fmt" "fmt"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package api package endpoints
import ( import (
"bytes" "bytes"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package api package endpoints
import ( import (
"bytes" "bytes"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package api package endpoints
import ( import (
"bytes" "bytes"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package api package endpoints
import ( import (
"encoding/json" "encoding/json"

View File

@@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
// Package api contains the code that provides a rest.ful api service. // Package registry contains the generic implementation of the storage and system logic.
package api // import "k8s.io/kubernetes/pkg/genericapiserver/api" package registry // import "k8s.io/kubernetes/pkg/genericapiserver/registry"

View File

@@ -28,12 +28,12 @@ import (
type decoratedWatcher struct { type decoratedWatcher struct {
w watch.Interface w watch.Interface
decorator rest.ObjectFunc decorator ObjectFunc
cancel context.CancelFunc cancel context.CancelFunc
resultCh chan watch.Event resultCh chan watch.Event
} }
func newDecoratedWatcher(w watch.Interface, decorator rest.ObjectFunc) *decoratedWatcher { func newDecoratedWatcher(w watch.Interface, decorator ObjectFunc) *decoratedWatcher {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
d := &decoratedWatcher{ d := &decoratedWatcher{
w: w, w: w,

View File

@@ -45,6 +45,11 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
) )
// ObjectFunc is a function to act on a given object. An error may be returned
// if the hook cannot be completed. An ObjectFunc may transform the provided
// object.
type ObjectFunc func(obj runtime.Object) error
// Store implements pkg/api/rest.StandardStorage. // Store implements pkg/api/rest.StandardStorage.
// It's intended to be embeddable, so that you can implement any // It's intended to be embeddable, so that you can implement any
// non-generic functions if needed. // non-generic functions if needed.
@@ -105,19 +110,19 @@ type Store struct {
// Decorator is intended for integrations that are above storage and // Decorator is intended for integrations that are above storage and
// should only be used for specific cases where storage of the value is // should only be used for specific cases where storage of the value is
// not appropriate, since they cannot be watched. // not appropriate, since they cannot be watched.
Decorator rest.ObjectFunc Decorator ObjectFunc
// Allows extended behavior during creation, required // Allows extended behavior during creation, required
CreateStrategy rest.RESTCreateStrategy CreateStrategy rest.RESTCreateStrategy
// On create of an object, attempt to run a further operation. // On create of an object, attempt to run a further operation.
AfterCreate rest.ObjectFunc AfterCreate ObjectFunc
// Allows extended behavior during updates, required // Allows extended behavior during updates, required
UpdateStrategy rest.RESTUpdateStrategy UpdateStrategy rest.RESTUpdateStrategy
// On update of an object, attempt to run a further operation. // On update of an object, attempt to run a further operation.
AfterUpdate rest.ObjectFunc AfterUpdate ObjectFunc
// Allows extended behavior during updates, optional // Allows extended behavior during updates, optional
DeleteStrategy rest.RESTDeleteStrategy DeleteStrategy rest.RESTDeleteStrategy
// On deletion of an object, attempt to run a further operation. // On deletion of an object, attempt to run a further operation.
AfterDelete rest.ObjectFunc AfterDelete ObjectFunc
// If true, return the object that was deleted. Otherwise, return a generic // If true, return the object that was deleted. Otherwise, return a generic
// success status response. // success status response.
ReturnDeletedObject bool ReturnDeletedObject bool

View File

@@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
// Package rest defines common logic around changes to Kubernetes resources. // Package rest defines common logic around changes to Kubernetes-style resources.
package rest // import "k8s.io/kubernetes/pkg/genericapiserver/api/rest" package rest // import "k8s.io/kubernetes/pkg/genericapiserver/api/rest"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package rest package registry
import ( import (
"io" "io"

View File

@@ -0,0 +1,23 @@
/*
Copyright 2015 The Kubernetes Authors.
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.
*/
// Package genericapiserver contains code to setup a generic kubernetes-like API server.
// This does not contain any kubernetes API specific code.
// Note that this is a work in progress. We are pulling out generic code (specifically from
// pkg/master) here.
// We plan to move this package into a separate repo on github once it is done.
// For more details: https://github.com/kubernetes/kubernetes/issues/2742
package genericapiserver // import "k8s.io/kubernetes/pkg/genericapiserver"

Some files were not shown because too many files have changed in this diff Show More