mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 02:11:09 +00:00
Fixes Golint Errors: staging/src/k8s.io/kube-aggregator (#73369)
* fixed golint errors in staging/src/k8s.io/kube-aggregator * update openapi * unexported autoRegisterController
This commit is contained in:
parent
f7c4389b79
commit
805a9e7036
2
api/openapi-spec/swagger.json
generated
2
api/openapi-spec/swagger.json
generated
@ -17251,6 +17251,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.APIServiceCondition": {
|
"io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.APIServiceCondition": {
|
||||||
|
"description": "APIServiceCondition describes the state of an APIService at a particular point",
|
||||||
"properties": {
|
"properties": {
|
||||||
"lastTransitionTime": {
|
"lastTransitionTime": {
|
||||||
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time",
|
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time",
|
||||||
@ -17416,6 +17417,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.APIServiceCondition": {
|
"io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.APIServiceCondition": {
|
||||||
|
"description": "APIServiceCondition describes the state of an APIService at a particular point",
|
||||||
"properties": {
|
"properties": {
|
||||||
"lastTransitionTime": {
|
"lastTransitionTime": {
|
||||||
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time",
|
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time",
|
||||||
|
@ -647,16 +647,7 @@ staging/src/k8s.io/code-generator/cmd/conversion-gen/generators
|
|||||||
staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf
|
staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf
|
||||||
staging/src/k8s.io/code-generator/cmd/lister-gen/generators
|
staging/src/k8s.io/code-generator/cmd/lister-gen/generators
|
||||||
staging/src/k8s.io/component-base/config/v1alpha1
|
staging/src/k8s.io/component-base/config/v1alpha1
|
||||||
staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration
|
|
||||||
staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1
|
|
||||||
staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1
|
|
||||||
staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/validation
|
|
||||||
staging/src/k8s.io/kube-aggregator/pkg/apiserver
|
|
||||||
staging/src/k8s.io/kube-aggregator/pkg/cmd/server
|
|
||||||
staging/src/k8s.io/kube-aggregator/pkg/controllers/autoregister
|
staging/src/k8s.io/kube-aggregator/pkg/controllers/autoregister
|
||||||
staging/src/k8s.io/kube-aggregator/pkg/controllers/status
|
|
||||||
staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice
|
|
||||||
staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd
|
|
||||||
staging/src/k8s.io/kube-proxy/config/v1alpha1
|
staging/src/k8s.io/kube-proxy/config/v1alpha1
|
||||||
staging/src/k8s.io/kubelet/config/v1beta1
|
staging/src/k8s.io/kubelet/config/v1beta1
|
||||||
staging/src/k8s.io/metrics/pkg/apis/custom_metrics
|
staging/src/k8s.io/metrics/pkg/apis/custom_metrics
|
||||||
|
@ -22,6 +22,7 @@ go_library(
|
|||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = [
|
||||||
"create.go",
|
"create.go",
|
||||||
|
"create_update.go",
|
||||||
"delete.go",
|
"delete.go",
|
||||||
"doc.go",
|
"doc.go",
|
||||||
"export.go",
|
"export.go",
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2019 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 (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RESTCreateUpdateStrategy is a union of RESTUpdateStrategy and RESTCreateStrategy,
|
||||||
|
// and it defines the minimum validation, accepted input, and name generation
|
||||||
|
// behavior to create and update an object that follows Kubernetes API conventions.
|
||||||
|
type RESTCreateUpdateStrategy interface {
|
||||||
|
RESTCreateStrategy
|
||||||
|
// AllowCreateOnUpdate returns true if the object can be created by a PUT.
|
||||||
|
AllowCreateOnUpdate() bool
|
||||||
|
// PrepareForUpdate is invoked on update before validation to normalize
|
||||||
|
// the object. For example: remove fields that are not to be persisted,
|
||||||
|
// sort order-insensitive list fields, etc. This should not remove fields
|
||||||
|
// whose presence would be considered a validation error.
|
||||||
|
PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
|
||||||
|
// ValidateUpdate is invoked after default fields in the object have been
|
||||||
|
// filled in before the object is persisted. This method should not mutate
|
||||||
|
// the object.
|
||||||
|
ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList
|
||||||
|
// AllowUnconditionalUpdate returns true if the object can be updated
|
||||||
|
// unconditionally (irrespective of the latest resource version), when
|
||||||
|
// there is no resource version specified in the object.
|
||||||
|
AllowUnconditionalUpdate() bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure that RESTCreateUpdateStrategy extends RESTCreateStrategy
|
||||||
|
var _ RESTCreateStrategy = (RESTCreateUpdateStrategy)(nil)
|
||||||
|
|
||||||
|
// Ensure that RESTCreateUpdateStrategy extends RESTUpdateStrategy
|
||||||
|
var _ RESTUpdateStrategy = (RESTCreateUpdateStrategy)(nil)
|
@ -17,5 +17,5 @@ limitations under the License.
|
|||||||
// +k8s:deepcopy-gen=package
|
// +k8s:deepcopy-gen=package
|
||||||
// +groupName=apiregistration.k8s.io
|
// +groupName=apiregistration.k8s.io
|
||||||
|
|
||||||
// Package api is the internal version of the API.
|
// Package apiregistration is the internal version of the API.
|
||||||
package apiregistration // import "k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
package apiregistration // import "k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
||||||
|
@ -25,6 +25,10 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/version"
|
"k8s.io/apimachinery/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SortedByGroupAndVersion sorts APIServices into their different groups, and then sorts them based on their versions.
|
||||||
|
// For example, the first element of the first array contains the APIService with the highest version number, in the
|
||||||
|
// group with the highest priority; while the last element of the last array contains the APIService with the lowest
|
||||||
|
// version number, in the group with the lowest priority.
|
||||||
func SortedByGroupAndVersion(servers []*APIService) [][]*APIService {
|
func SortedByGroupAndVersion(servers []*APIService) [][]*APIService {
|
||||||
serversByGroupPriorityMinimum := ByGroupPriorityMinimum(servers)
|
serversByGroupPriorityMinimum := ByGroupPriorityMinimum(servers)
|
||||||
sort.Sort(serversByGroupPriorityMinimum)
|
sort.Sort(serversByGroupPriorityMinimum)
|
||||||
|
@ -38,13 +38,13 @@ func TestGetAPIServiceConditionByType(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Should find a matching condition from apiService",
|
name: "Should find a matching condition from apiService",
|
||||||
apiService: makeNewApiService("v1", 100, conditionA, conditionB),
|
apiService: makeNewAPIService("v1", 100, conditionA, conditionB),
|
||||||
conditionType: a,
|
conditionType: a,
|
||||||
expectedCondition: &conditionA,
|
expectedCondition: &conditionA,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Should not find a matching condition",
|
name: "Should not find a matching condition",
|
||||||
apiService: makeNewApiService("v1", 100, conditionA),
|
apiService: makeNewAPIService("v1", 100, conditionA),
|
||||||
conditionType: b,
|
conditionType: b,
|
||||||
expectedCondition: nil,
|
expectedCondition: nil,
|
||||||
},
|
},
|
||||||
@ -69,19 +69,19 @@ func TestIsAPIServiceConditionTrue(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Should return false when condition of type is not present",
|
name: "Should return false when condition of type is not present",
|
||||||
apiService: makeNewApiService("v1", 100),
|
apiService: makeNewAPIService("v1", 100),
|
||||||
conditionType: a,
|
conditionType: a,
|
||||||
expected: false,
|
expected: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Should return false when condition of type is present but status is not ConditionTrue",
|
name: "Should return false when condition of type is present but status is not ConditionTrue",
|
||||||
apiService: makeNewApiService("v1", 100, conditionAFalse),
|
apiService: makeNewAPIService("v1", 100, conditionAFalse),
|
||||||
conditionType: a,
|
conditionType: a,
|
||||||
expected: false,
|
expected: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Should return false when condition of type is present but status is not ConditionTrue",
|
name: "Should return false when condition of type is present but status is not ConditionTrue",
|
||||||
apiService: makeNewApiService("v1", 100, conditionATrue),
|
apiService: makeNewAPIService("v1", 100, conditionATrue),
|
||||||
conditionType: a,
|
conditionType: a,
|
||||||
expected: true,
|
expected: true,
|
||||||
},
|
},
|
||||||
@ -109,7 +109,7 @@ func TestSetAPIServiceCondition(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Should set a new condition with type where previously there was no condition of that type",
|
name: "Should set a new condition with type where previously there was no condition of that type",
|
||||||
apiService: makeNewApiService("v1", 100),
|
apiService: makeNewAPIService("v1", 100),
|
||||||
conditionType: a,
|
conditionType: a,
|
||||||
initialCondition: nil,
|
initialCondition: nil,
|
||||||
setCondition: conditionA1,
|
setCondition: conditionA1,
|
||||||
@ -117,7 +117,7 @@ func TestSetAPIServiceCondition(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Should override a condition of type, when a condition of that type existed previously",
|
name: "Should override a condition of type, when a condition of that type existed previously",
|
||||||
apiService: makeNewApiService("v1", 100, conditionA1),
|
apiService: makeNewAPIService("v1", 100, conditionA1),
|
||||||
conditionType: a,
|
conditionType: a,
|
||||||
initialCondition: &conditionA1,
|
initialCondition: &conditionA1,
|
||||||
setCondition: conditionA2,
|
setCondition: conditionA2,
|
||||||
@ -175,7 +175,7 @@ func TestSortedAPIServicesByVersion(t *testing.T) {
|
|||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
apiServices := make([]*APIService, 0)
|
apiServices := make([]*APIService, 0)
|
||||||
for _, v := range tc.versions {
|
for _, v := range tc.versions {
|
||||||
apiServices = append(apiServices, makeNewApiService(v, 100))
|
apiServices = append(apiServices, makeNewAPIService(v, 100))
|
||||||
}
|
}
|
||||||
sortedServices := SortedByGroupAndVersion(apiServices)
|
sortedServices := SortedByGroupAndVersion(apiServices)
|
||||||
actual := make([]string, 0)
|
actual := make([]string, 0)
|
||||||
@ -188,7 +188,7 @@ func TestSortedAPIServicesByVersion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeNewApiService(version string, priority int32, conditions ...APIServiceCondition) *APIService {
|
func makeNewAPIService(version string, priority int32, conditions ...APIServiceCondition) *APIService {
|
||||||
status := APIServiceStatus{Conditions: conditions}
|
status := APIServiceStatus{Conditions: conditions}
|
||||||
return &APIService{Spec: APIServiceSpec{Version: version, VersionPriority: priority}, Status: status}
|
return &APIService{Spec: APIServiceSpec{Version: version, VersionPriority: priority}, Status: status}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GroupName is the API group for apiregistration
|
||||||
const GroupName = "apiregistration.k8s.io"
|
const GroupName = "apiregistration.k8s.io"
|
||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
@ -37,8 +38,10 @@ func Resource(resource string) schema.GroupResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
|
||||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||||
AddToScheme = SchemeBuilder.AddToScheme
|
// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
|
||||||
|
AddToScheme = SchemeBuilder.AddToScheme
|
||||||
)
|
)
|
||||||
|
|
||||||
// Adds the list of known types to the given scheme.
|
// Adds the list of known types to the given scheme.
|
||||||
|
@ -57,7 +57,7 @@ type APIServiceSpec struct {
|
|||||||
// +optional
|
// +optional
|
||||||
CABundle []byte
|
CABundle []byte
|
||||||
|
|
||||||
// GroupPriorityMininum is the priority this group should have at least. Higher priority means that the group is preferred by clients over lower priority ones.
|
// GroupPriorityMinimum is the priority this group should have at least. Higher priority means that the group is preferred by clients over lower priority ones.
|
||||||
// Note that other versions of this group might specify even higher GroupPriorityMininum values such that the whole group gets a higher priority.
|
// Note that other versions of this group might specify even higher GroupPriorityMininum values such that the whole group gets a higher priority.
|
||||||
// The primary sort is based on GroupPriorityMinimum, ordered highest number to lowest (20 before 10).
|
// The primary sort is based on GroupPriorityMinimum, ordered highest number to lowest (20 before 10).
|
||||||
// The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo)
|
// The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo)
|
||||||
@ -78,6 +78,7 @@ type APIServiceSpec struct {
|
|||||||
VersionPriority int32
|
VersionPriority int32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ConditionStatus indicates the status of a condition (true, false, or unknown).
|
||||||
type ConditionStatus string
|
type ConditionStatus string
|
||||||
|
|
||||||
// These are valid condition statuses. "ConditionTrue" means a resource is in the condition;
|
// These are valid condition statuses. "ConditionTrue" means a resource is in the condition;
|
||||||
@ -90,7 +91,7 @@ const (
|
|||||||
ConditionUnknown ConditionStatus = "Unknown"
|
ConditionUnknown ConditionStatus = "Unknown"
|
||||||
)
|
)
|
||||||
|
|
||||||
// APIConditionConditionType is a valid value for APIServiceCondition.Type
|
// APIServiceConditionType is a valid value for APIServiceCondition.Type
|
||||||
type APIServiceConditionType string
|
type APIServiceConditionType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GroupName is the API group for apiregistration
|
||||||
const GroupName = "apiregistration.k8s.io"
|
const GroupName = "apiregistration.k8s.io"
|
||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
@ -33,11 +34,13 @@ func Resource(resource string) schema.GroupResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
|
||||||
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
|
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
|
||||||
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
|
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
|
||||||
SchemeBuilder runtime.SchemeBuilder
|
SchemeBuilder runtime.SchemeBuilder
|
||||||
localSchemeBuilder = &SchemeBuilder
|
localSchemeBuilder = &SchemeBuilder
|
||||||
AddToScheme = localSchemeBuilder.AddToScheme
|
// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
|
||||||
|
AddToScheme = localSchemeBuilder.AddToScheme
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -81,6 +81,7 @@ type APIServiceSpec struct {
|
|||||||
// Priority int64 `json:"priority" protobuf:"varint,6,opt,name=priority"`
|
// Priority int64 `json:"priority" protobuf:"varint,6,opt,name=priority"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ConditionStatus indicates the status of a condition (true, false, or unknown).
|
||||||
type ConditionStatus string
|
type ConditionStatus string
|
||||||
|
|
||||||
// These are valid condition statuses. "ConditionTrue" means a resource is in the condition;
|
// These are valid condition statuses. "ConditionTrue" means a resource is in the condition;
|
||||||
@ -93,7 +94,7 @@ const (
|
|||||||
ConditionUnknown ConditionStatus = "Unknown"
|
ConditionUnknown ConditionStatus = "Unknown"
|
||||||
)
|
)
|
||||||
|
|
||||||
// APIConditionConditionType is a valid value for APIServiceCondition.Type
|
// APIServiceConditionType is a valid value for APIServiceCondition.Type
|
||||||
type APIServiceConditionType string
|
type APIServiceConditionType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -101,6 +102,7 @@ const (
|
|||||||
Available APIServiceConditionType = "Available"
|
Available APIServiceConditionType = "Available"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// APIServiceCondition describes the state of an APIService at a particular point
|
||||||
type APIServiceCondition struct {
|
type APIServiceCondition struct {
|
||||||
// Type is the type of the condition.
|
// Type is the type of the condition.
|
||||||
Type APIServiceConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=APIServiceConditionType"`
|
Type APIServiceConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=APIServiceConditionType"`
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GroupName is the API group for apiregistration
|
||||||
const GroupName = "apiregistration.k8s.io"
|
const GroupName = "apiregistration.k8s.io"
|
||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
@ -33,11 +34,13 @@ func Resource(resource string) schema.GroupResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
|
||||||
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
|
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
|
||||||
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
|
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
|
||||||
SchemeBuilder runtime.SchemeBuilder
|
SchemeBuilder runtime.SchemeBuilder
|
||||||
localSchemeBuilder = &SchemeBuilder
|
localSchemeBuilder = &SchemeBuilder
|
||||||
AddToScheme = localSchemeBuilder.AddToScheme
|
// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
|
||||||
|
AddToScheme = localSchemeBuilder.AddToScheme
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -81,6 +81,7 @@ type APIServiceSpec struct {
|
|||||||
// Priority int64 `json:"priority" protobuf:"varint,6,opt,name=priority"`
|
// Priority int64 `json:"priority" protobuf:"varint,6,opt,name=priority"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ConditionStatus indicates the status of a condition (true, false, or unknown).
|
||||||
type ConditionStatus string
|
type ConditionStatus string
|
||||||
|
|
||||||
// These are valid condition statuses. "ConditionTrue" means a resource is in the condition;
|
// These are valid condition statuses. "ConditionTrue" means a resource is in the condition;
|
||||||
@ -93,7 +94,7 @@ const (
|
|||||||
ConditionUnknown ConditionStatus = "Unknown"
|
ConditionUnknown ConditionStatus = "Unknown"
|
||||||
)
|
)
|
||||||
|
|
||||||
// APIConditionConditionType is a valid value for APIServiceCondition.Type
|
// APIServiceConditionType is a valid value for APIServiceCondition.Type
|
||||||
type APIServiceConditionType string
|
type APIServiceConditionType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -101,6 +102,7 @@ const (
|
|||||||
Available APIServiceConditionType = "Available"
|
Available APIServiceConditionType = "Available"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// APIServiceCondition describes the state of an APIService at a particular point
|
||||||
type APIServiceCondition struct {
|
type APIServiceCondition struct {
|
||||||
// Type is the type of the condition.
|
// Type is the type of the condition.
|
||||||
Type APIServiceConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=APIServiceConditionType"`
|
Type APIServiceConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=APIServiceConditionType"`
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ValidateAPIService validates that the APIService is correctly defined.
|
||||||
func ValidateAPIService(apiService *apiregistration.APIService) field.ErrorList {
|
func ValidateAPIService(apiService *apiregistration.APIService) field.ErrorList {
|
||||||
requiredName := apiService.Spec.Version + "." + apiService.Spec.Group
|
requiredName := apiService.Spec.Version + "." + apiService.Spec.Group
|
||||||
|
|
||||||
@ -88,6 +89,7 @@ func ValidateAPIService(apiService *apiregistration.APIService) field.ErrorList
|
|||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ValidateAPIServiceUpdate validates an update of APIService.
|
||||||
func ValidateAPIServiceUpdate(newAPIService *apiregistration.APIService, oldAPIService *apiregistration.APIService) field.ErrorList {
|
func ValidateAPIServiceUpdate(newAPIService *apiregistration.APIService, oldAPIService *apiregistration.APIService) field.ErrorList {
|
||||||
allErrs := validation.ValidateObjectMetaUpdate(&newAPIService.ObjectMeta, &oldAPIService.ObjectMeta, field.NewPath("metadata"))
|
allErrs := validation.ValidateObjectMetaUpdate(&newAPIService.ObjectMeta, &oldAPIService.ObjectMeta, field.NewPath("metadata"))
|
||||||
allErrs = append(allErrs, ValidateAPIService(newAPIService)...)
|
allErrs = append(allErrs, ValidateAPIService(newAPIService)...)
|
||||||
@ -95,6 +97,7 @@ func ValidateAPIServiceUpdate(newAPIService *apiregistration.APIService, oldAPIS
|
|||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ValidateAPIServiceStatus validates that the APIService status is one of 'True', 'False' or 'Unknown'.
|
||||||
func ValidateAPIServiceStatus(status *apiregistration.APIServiceStatus, fldPath *field.Path) field.ErrorList {
|
func ValidateAPIServiceStatus(status *apiregistration.APIServiceStatus, fldPath *field.Path) field.ErrorList {
|
||||||
allErrs := field.ErrorList{}
|
allErrs := field.ErrorList{}
|
||||||
|
|
||||||
@ -110,6 +113,7 @@ func ValidateAPIServiceStatus(status *apiregistration.APIServiceStatus, fldPath
|
|||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ValidateAPIServiceStatusUpdate validates an update of the status field of APIService.
|
||||||
func ValidateAPIServiceStatusUpdate(newAPIService *apiregistration.APIService, oldAPIService *apiregistration.APIService) field.ErrorList {
|
func ValidateAPIServiceStatusUpdate(newAPIService *apiregistration.APIService, oldAPIService *apiregistration.APIService) field.ErrorList {
|
||||||
allErrs := validation.ValidateObjectMetaUpdate(&newAPIService.ObjectMeta, &oldAPIService.ObjectMeta, field.NewPath("metadata"))
|
allErrs := validation.ValidateObjectMetaUpdate(&newAPIService.ObjectMeta, &oldAPIService.ObjectMeta, field.NewPath("metadata"))
|
||||||
allErrs = append(allErrs, ValidateAPIServiceStatus(&newAPIService.Status, field.NewPath("status"))...)
|
allErrs = append(allErrs, ValidateAPIServiceStatus(&newAPIService.Status, field.NewPath("status"))...)
|
||||||
|
@ -56,6 +56,7 @@ func init() {
|
|||||||
// legacyAPIServiceName is the fixed name of the only non-groupified API version
|
// legacyAPIServiceName is the fixed name of the only non-groupified API version
|
||||||
const legacyAPIServiceName = "v1."
|
const legacyAPIServiceName = "v1."
|
||||||
|
|
||||||
|
// ExtraConfig represents APIServices-specific configuration
|
||||||
type ExtraConfig struct {
|
type ExtraConfig struct {
|
||||||
// ProxyClientCert/Key are the client cert used to identify this proxy. Backing APIServices use
|
// ProxyClientCert/Key are the client cert used to identify this proxy. Backing APIServices use
|
||||||
// this to confirm the proxy's identity
|
// this to confirm the proxy's identity
|
||||||
@ -70,6 +71,7 @@ type ExtraConfig struct {
|
|||||||
ServiceResolver ServiceResolver
|
ServiceResolver ServiceResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Config represents the configuration needed to create an APIAggregator.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
GenericConfig *genericapiserver.RecommendedConfig
|
GenericConfig *genericapiserver.RecommendedConfig
|
||||||
ExtraConfig ExtraConfig
|
ExtraConfig ExtraConfig
|
||||||
@ -80,6 +82,7 @@ type completedConfig struct {
|
|||||||
ExtraConfig *ExtraConfig
|
ExtraConfig *ExtraConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CompletedConfig same as Config, just to swap private object.
|
||||||
type CompletedConfig struct {
|
type CompletedConfig struct {
|
||||||
// Embed a private pointer that cannot be instantiated outside of this package.
|
// Embed a private pointer that cannot be instantiated outside of this package.
|
||||||
*completedConfig
|
*completedConfig
|
||||||
@ -131,11 +134,11 @@ func (cfg *Config) Complete() CompletedConfig {
|
|||||||
return CompletedConfig{&c}
|
return CompletedConfig{&c}
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new instance of APIAggregator from the given config.
|
// NewWithDelegate returns a new instance of APIAggregator from the given config.
|
||||||
func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.DelegationTarget) (*APIAggregator, error) {
|
func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.DelegationTarget) (*APIAggregator, error) {
|
||||||
// Prevent generic API server to install OpenAPI handler. Aggregator server
|
// Prevent generic API server to install OpenAPI handler. Aggregator server
|
||||||
// has its own customized OpenAPI handler.
|
// has its own customized OpenAPI handler.
|
||||||
openApiConfig := c.GenericConfig.OpenAPIConfig
|
openAPIConfig := c.GenericConfig.OpenAPIConfig
|
||||||
c.GenericConfig.OpenAPIConfig = nil
|
c.GenericConfig.OpenAPIConfig = nil
|
||||||
|
|
||||||
genericServer, err := c.GenericConfig.New("kube-aggregator", delegationTarget)
|
genericServer, err := c.GenericConfig.New("kube-aggregator", delegationTarget)
|
||||||
@ -202,13 +205,13 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
if openApiConfig != nil {
|
if openAPIConfig != nil {
|
||||||
specDownloader := openapicontroller.NewDownloader()
|
specDownloader := openapicontroller.NewDownloader()
|
||||||
openAPIAggregator, err := openapicontroller.BuildAndRegisterAggregator(
|
openAPIAggregator, err := openapicontroller.BuildAndRegisterAggregator(
|
||||||
&specDownloader,
|
&specDownloader,
|
||||||
delegationTarget,
|
delegationTarget,
|
||||||
s.GenericAPIServer.Handler.GoRestfulContainer.RegisteredWebServices(),
|
s.GenericAPIServer.Handler.GoRestfulContainer.RegisteredWebServices(),
|
||||||
openApiConfig,
|
openAPIConfig,
|
||||||
s.GenericAPIServer.Handler.NonGoRestfulMux)
|
s.GenericAPIServer.Handler.NonGoRestfulMux)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -305,6 +308,7 @@ func (s *APIAggregator) RemoveAPIService(apiServiceName string) {
|
|||||||
// We don't need this right away because the handler properly delegates when no versions are present
|
// We don't need this right away because the handler properly delegates when no versions are present
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultAPIResourceConfigSource returns default configuration for an APIResource.
|
||||||
func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig {
|
func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig {
|
||||||
ret := serverstorage.NewResourceConfig()
|
ret := serverstorage.NewResourceConfig()
|
||||||
// NOTE: GroupVersions listed here will be enabled by default. Don't put alpha versions in the list.
|
// NOTE: GroupVersions listed here will be enabled by default. Don't put alpha versions in the list.
|
||||||
|
@ -34,11 +34,13 @@ import (
|
|||||||
"k8s.io/kube-aggregator/pkg/controllers"
|
"k8s.io/kube-aggregator/pkg/controllers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// APIHandlerManager defines the behaviour that an API handler should have.
|
||||||
type APIHandlerManager interface {
|
type APIHandlerManager interface {
|
||||||
AddAPIService(apiService *apiregistration.APIService) error
|
AddAPIService(apiService *apiregistration.APIService) error
|
||||||
RemoveAPIService(apiServiceName string)
|
RemoveAPIService(apiServiceName string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// APIServiceRegistrationController is responsible for registering and removing API services.
|
||||||
type APIServiceRegistrationController struct {
|
type APIServiceRegistrationController struct {
|
||||||
apiHandlerManager APIHandlerManager
|
apiHandlerManager APIHandlerManager
|
||||||
|
|
||||||
@ -51,6 +53,7 @@ type APIServiceRegistrationController struct {
|
|||||||
queue workqueue.RateLimitingInterface
|
queue workqueue.RateLimitingInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewAPIServiceRegistrationController returns a new APIServiceRegistrationController.
|
||||||
func NewAPIServiceRegistrationController(apiServiceInformer informers.APIServiceInformer, apiHandlerManager APIHandlerManager) *APIServiceRegistrationController {
|
func NewAPIServiceRegistrationController(apiServiceInformer informers.APIServiceInformer, apiHandlerManager APIHandlerManager) *APIServiceRegistrationController {
|
||||||
c := &APIServiceRegistrationController{
|
c := &APIServiceRegistrationController{
|
||||||
apiHandlerManager: apiHandlerManager,
|
apiHandlerManager: apiHandlerManager,
|
||||||
@ -83,6 +86,7 @@ func (c *APIServiceRegistrationController) sync(key string) error {
|
|||||||
return c.apiHandlerManager.AddAPIService(apiService)
|
return c.apiHandlerManager.AddAPIService(apiService)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run starts APIServiceRegistrationController which will process all registration requests until stopCh is closed.
|
||||||
func (c *APIServiceRegistrationController) Run(stopCh <-chan struct{}) {
|
func (c *APIServiceRegistrationController) Run(stopCh <-chan struct{}) {
|
||||||
defer utilruntime.HandleCrash()
|
defer utilruntime.HandleCrash()
|
||||||
defer c.queue.ShutDown()
|
defer c.queue.ShutDown()
|
||||||
|
@ -399,12 +399,12 @@ func TestProxyUpgrade(t *testing.T) {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
backendServer := httptest.NewUnstartedServer(backendHandler)
|
backendServer := httptest.NewUnstartedServer(backendHandler)
|
||||||
if cert, err := tls.X509KeyPair(svcCrt, svcKey); err != nil {
|
cert, err := tls.X509KeyPair(svcCrt, svcKey)
|
||||||
|
if err != nil {
|
||||||
t.Errorf("https (valid hostname): %v", err)
|
t.Errorf("https (valid hostname): %v", err)
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
backendServer.TLS = &tls.Config{Certificates: []tls.Certificate{cert}}
|
|
||||||
}
|
}
|
||||||
|
backendServer.TLS = &tls.Config{Certificates: []tls.Certificate{cert}}
|
||||||
backendServer.StartTLS()
|
backendServer.StartTLS()
|
||||||
defer backendServer.Close()
|
defer backendServer.Close()
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func (r *aggregatorEndpointRouting) ResolveEndpoint(namespace, name string) (*ur
|
|||||||
return proxy.ResolveEndpoint(r.services, r.endpoints, namespace, name)
|
return proxy.ResolveEndpoint(r.services, r.endpoints, namespace, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewEndpointServiceResolver returns a ServiceResolver that directly calls the
|
// NewClusterIPServiceResolver returns a ServiceResolver that directly calls the
|
||||||
// service's cluster IP.
|
// service's cluster IP.
|
||||||
func NewClusterIPServiceResolver(services listersv1.ServiceLister) ServiceResolver {
|
func NewClusterIPServiceResolver(services listersv1.ServiceLister) ServiceResolver {
|
||||||
return &aggregatorClusterRouting{
|
return &aggregatorClusterRouting{
|
||||||
|
@ -36,6 +36,7 @@ import (
|
|||||||
|
|
||||||
const defaultEtcdPathPrefix = "/registry/kube-aggregator.kubernetes.io/"
|
const defaultEtcdPathPrefix = "/registry/kube-aggregator.kubernetes.io/"
|
||||||
|
|
||||||
|
// AggregatorOptions contains everything necessary to create and run an API Aggregator.
|
||||||
type AggregatorOptions struct {
|
type AggregatorOptions struct {
|
||||||
RecommendedOptions *genericoptions.RecommendedOptions
|
RecommendedOptions *genericoptions.RecommendedOptions
|
||||||
APIEnablement *genericoptions.APIEnablementOptions
|
APIEnablement *genericoptions.APIEnablementOptions
|
||||||
@ -99,6 +100,7 @@ func NewDefaultOptions(out, err io.Writer) *AggregatorOptions {
|
|||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate validates all the required options.
|
||||||
func (o AggregatorOptions) Validate(args []string) error {
|
func (o AggregatorOptions) Validate(args []string) error {
|
||||||
errors := []error{}
|
errors := []error{}
|
||||||
errors = append(errors, o.RecommendedOptions.Validate()...)
|
errors = append(errors, o.RecommendedOptions.Validate()...)
|
||||||
@ -106,10 +108,12 @@ func (o AggregatorOptions) Validate(args []string) error {
|
|||||||
return utilerrors.NewAggregate(errors)
|
return utilerrors.NewAggregate(errors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Complete fills in missing Options.
|
||||||
func (o *AggregatorOptions) Complete() error {
|
func (o *AggregatorOptions) Complete() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RunAggregator runs the API Aggregator.
|
||||||
func (o AggregatorOptions) RunAggregator(stopCh <-chan struct{}) error {
|
func (o AggregatorOptions) RunAggregator(stopCh <-chan struct{}) error {
|
||||||
// TODO have a "real" external address
|
// TODO have a "real" external address
|
||||||
if err := o.RecommendedOptions.SecureServing.MaybeDefaultWithSelfSignedCerts("localhost", nil, nil); err != nil {
|
if err := o.RecommendedOptions.SecureServing.MaybeDefaultWithSelfSignedCerts("localhost", nil, nil); err != nil {
|
||||||
|
@ -39,6 +39,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// AutoRegisterManagedLabel is a label attached to the APIService that identifies how the APIService wants to be synced.
|
||||||
AutoRegisterManagedLabel = "kube-aggregator.kubernetes.io/automanaged"
|
AutoRegisterManagedLabel = "kube-aggregator.kubernetes.io/automanaged"
|
||||||
|
|
||||||
// manageOnStart is a value for the AutoRegisterManagedLabel that indicates the APIService wants to be synced one time when the controller starts.
|
// manageOnStart is a value for the AutoRegisterManagedLabel that indicates the APIService wants to be synced one time when the controller starts.
|
||||||
@ -81,6 +82,7 @@ type autoRegisterController struct {
|
|||||||
queue workqueue.RateLimitingInterface
|
queue workqueue.RateLimitingInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewAutoRegisterController creates a new autoRegisterController.
|
||||||
func NewAutoRegisterController(apiServiceInformer informers.APIServiceInformer, apiServiceClient apiregistrationclient.APIServicesGetter) *autoRegisterController {
|
func NewAutoRegisterController(apiServiceInformer informers.APIServiceInformer, apiServiceClient apiregistrationclient.APIServicesGetter) *autoRegisterController {
|
||||||
c := &autoRegisterController{
|
c := &autoRegisterController{
|
||||||
apiServiceLister: apiServiceInformer.Lister(),
|
apiServiceLister: apiServiceInformer.Lister(),
|
||||||
@ -127,6 +129,7 @@ func NewAutoRegisterController(apiServiceInformer informers.APIServiceInformer,
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run starts the autoregister controller in a loop which syncs API services until stopCh is closed.
|
||||||
func (c *autoRegisterController) Run(threadiness int, stopCh <-chan struct{}) {
|
func (c *autoRegisterController) Run(threadiness int, stopCh <-chan struct{}) {
|
||||||
// don't let panics crash the process
|
// don't let panics crash the process
|
||||||
defer utilruntime.HandleCrash()
|
defer utilruntime.HandleCrash()
|
||||||
@ -267,6 +270,7 @@ func (c *autoRegisterController) checkAPIService(name string) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAPIServiceToSync gets a single API service to sync.
|
||||||
func (c *autoRegisterController) GetAPIServiceToSync(name string) *apiregistration.APIService {
|
func (c *autoRegisterController) GetAPIServiceToSync(name string) *apiregistration.APIService {
|
||||||
c.apiServicesToSyncLock.RLock()
|
c.apiServicesToSyncLock.RLock()
|
||||||
defer c.apiServicesToSyncLock.RUnlock()
|
defer c.apiServicesToSyncLock.RUnlock()
|
||||||
@ -274,10 +278,12 @@ func (c *autoRegisterController) GetAPIServiceToSync(name string) *apiregistrati
|
|||||||
return c.apiServicesToSync[name]
|
return c.apiServicesToSync[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddAPIServiceToSyncOnStart registers an API service to sync only when the controller starts.
|
||||||
func (c *autoRegisterController) AddAPIServiceToSyncOnStart(in *apiregistration.APIService) {
|
func (c *autoRegisterController) AddAPIServiceToSyncOnStart(in *apiregistration.APIService) {
|
||||||
c.addAPIServiceToSync(in, manageOnStart)
|
c.addAPIServiceToSync(in, manageOnStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddAPIServiceToSync registers an API service to sync continuously.
|
||||||
func (c *autoRegisterController) AddAPIServiceToSync(in *apiregistration.APIService) {
|
func (c *autoRegisterController) AddAPIServiceToSync(in *apiregistration.APIService) {
|
||||||
c.addAPIServiceToSync(in, manageContinuously)
|
c.addAPIServiceToSync(in, manageContinuously)
|
||||||
}
|
}
|
||||||
@ -296,6 +302,7 @@ func (c *autoRegisterController) addAPIServiceToSync(in *apiregistration.APIServ
|
|||||||
c.queue.Add(apiService.Name)
|
c.queue.Add(apiService.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveAPIServiceToSync deletes a registered APIService.
|
||||||
func (c *autoRegisterController) RemoveAPIServiceToSync(name string) {
|
func (c *autoRegisterController) RemoveAPIServiceToSync(name string) {
|
||||||
c.apiServicesToSyncLock.Lock()
|
c.apiServicesToSyncLock.Lock()
|
||||||
defer c.apiServicesToSyncLock.Unlock()
|
defer c.apiServicesToSyncLock.Unlock()
|
||||||
|
@ -46,10 +46,12 @@ import (
|
|||||||
"k8s.io/kube-aggregator/pkg/controllers"
|
"k8s.io/kube-aggregator/pkg/controllers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ServiceResolver knows how to convert a service reference into an actual location.
|
||||||
type ServiceResolver interface {
|
type ServiceResolver interface {
|
||||||
ResolveEndpoint(namespace, name string) (*url.URL, error)
|
ResolveEndpoint(namespace, name string) (*url.URL, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AvailableConditionController handles checking the availability of registered API services.
|
||||||
type AvailableConditionController struct {
|
type AvailableConditionController struct {
|
||||||
apiServiceClient apiregistrationclient.APIServicesGetter
|
apiServiceClient apiregistrationclient.APIServicesGetter
|
||||||
|
|
||||||
@ -72,6 +74,7 @@ type AvailableConditionController struct {
|
|||||||
queue workqueue.RateLimitingInterface
|
queue workqueue.RateLimitingInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewAvailableConditionController returns a new AvailableConditionController.
|
||||||
func NewAvailableConditionController(
|
func NewAvailableConditionController(
|
||||||
apiServiceInformer informers.APIServiceInformer,
|
apiServiceInformer informers.APIServiceInformer,
|
||||||
serviceInformer v1informers.ServiceInformer,
|
serviceInformer v1informers.ServiceInformer,
|
||||||
@ -309,6 +312,7 @@ func updateAPIServiceStatus(client apiregistrationclient.APIServicesGetter, orig
|
|||||||
return newAPIService, nil
|
return newAPIService, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run starts the AvailableConditionController loop which manages the availability condition of API services.
|
||||||
func (c *AvailableConditionController) Run(threadiness int, stopCh <-chan struct{}) {
|
func (c *AvailableConditionController) Run(threadiness int, stopCh <-chan struct{}) {
|
||||||
defer utilruntime.HandleCrash()
|
defer utilruntime.HandleCrash()
|
||||||
defer c.queue.ShutDown()
|
defer c.queue.ShutDown()
|
||||||
|
@ -16,6 +16,7 @@ go_library(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
||||||
|
"//staging/src/k8s.io/apiserver/pkg/registry/rest:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/storage:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/storage:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/storage/names:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/storage/names:go_default_library",
|
||||||
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library",
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
"k8s.io/kube-aggregator/pkg/registry/apiservice"
|
"k8s.io/kube-aggregator/pkg/registry/apiservice"
|
||||||
)
|
)
|
||||||
|
|
||||||
// rest implements a RESTStorage for API services against etcd
|
// REST implements a RESTStorage for API services against etcd
|
||||||
type REST struct {
|
type REST struct {
|
||||||
*genericregistry.Store
|
*genericregistry.Store
|
||||||
}
|
}
|
||||||
@ -59,6 +59,7 @@ func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) *REST
|
|||||||
|
|
||||||
var swaggerMetadataDescriptions = metav1.ObjectMeta{}.SwaggerDoc()
|
var swaggerMetadataDescriptions = metav1.ObjectMeta{}.SwaggerDoc()
|
||||||
|
|
||||||
|
// ConvertToTable implements the TableConvertor interface for REST.
|
||||||
func (c *REST) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
|
func (c *REST) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
|
||||||
table := &metav1beta1.Table{
|
table := &metav1beta1.Table{
|
||||||
ColumnDefinitions: []metav1beta1.TableColumnDefinition{
|
ColumnDefinitions: []metav1beta1.TableColumnDefinition{
|
||||||
@ -121,12 +122,14 @@ func NewStatusREST(scheme *runtime.Scheme, rest *REST) *StatusREST {
|
|||||||
return &StatusREST{store: &statusStore}
|
return &StatusREST{store: &statusStore}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StatusREST implements the REST endpoint for changing the status of an APIService.
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = rest.Patcher(&StatusREST{})
|
var _ = rest.Patcher(&StatusREST{})
|
||||||
|
|
||||||
|
// New creates a new APIService object.
|
||||||
func (r *StatusREST) New() runtime.Object {
|
func (r *StatusREST) New() runtime.Object {
|
||||||
return &apiregistration.APIService{}
|
return &apiregistration.APIService{}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
"k8s.io/apiserver/pkg/storage"
|
"k8s.io/apiserver/pkg/storage"
|
||||||
"k8s.io/apiserver/pkg/storage/names"
|
"k8s.io/apiserver/pkg/storage/names"
|
||||||
|
|
||||||
@ -37,7 +38,11 @@ type apiServerStrategy struct {
|
|||||||
names.NameGenerator
|
names.NameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStrategy(typer runtime.ObjectTyper) apiServerStrategy {
|
// apiServerStrategy must implement rest.RESTCreateUpdateStrategy
|
||||||
|
var _ rest.RESTCreateUpdateStrategy = apiServerStrategy{}
|
||||||
|
|
||||||
|
// NewStrategy creates a new apiServerStrategy.
|
||||||
|
func NewStrategy(typer runtime.ObjectTyper) rest.RESTCreateUpdateStrategy {
|
||||||
return apiServerStrategy{typer, names.SimpleNameGenerator}
|
return apiServerStrategy{typer, names.SimpleNameGenerator}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +90,8 @@ type apiServerStatusStrategy struct {
|
|||||||
names.NameGenerator
|
names.NameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStatusStrategy(typer runtime.ObjectTyper) apiServerStatusStrategy {
|
// NewStatusStrategy creates a new apiServerStatusStrategy.
|
||||||
|
func NewStatusStrategy(typer runtime.ObjectTyper) rest.RESTUpdateStrategy {
|
||||||
return apiServerStatusStrategy{typer, names.SimpleNameGenerator}
|
return apiServerStatusStrategy{typer, names.SimpleNameGenerator}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,19 +117,22 @@ func (apiServerStatusStrategy) AllowUnconditionalUpdate() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Canonicalize normalizes the object after validation.
|
||||||
func (apiServerStatusStrategy) Canonicalize(obj runtime.Object) {
|
func (apiServerStatusStrategy) Canonicalize(obj runtime.Object) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ValidateUpdate validates an update of apiServerStatusStrategy.
|
||||||
func (apiServerStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
func (apiServerStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
return validation.ValidateAPIServiceStatusUpdate(obj.(*apiregistration.APIService), old.(*apiregistration.APIService))
|
return validation.ValidateAPIServiceStatusUpdate(obj.(*apiregistration.APIService), old.(*apiregistration.APIService))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAttrs returns the labels and fields of an API server for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
apiserver, ok := obj.(*apiregistration.APIService)
|
apiserver, ok := obj.(*apiregistration.APIService)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, fmt.Errorf("given object is not a APIService.")
|
return nil, nil, fmt.Errorf("given object is not a APIService")
|
||||||
}
|
}
|
||||||
return labels.Set(apiserver.ObjectMeta.Labels), APIServiceToSelectableFields(apiserver), nil
|
return labels.Set(apiserver.ObjectMeta.Labels), ToSelectableFields(apiserver), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchAPIService is the filter used by the generic etcd backend to watch events
|
// MatchAPIService is the filter used by the generic etcd backend to watch events
|
||||||
@ -136,7 +145,7 @@ func MatchAPIService(label labels.Selector, field fields.Selector) storage.Selec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// APIServiceToSelectableFields returns a field set that represents the object.
|
// ToSelectableFields returns a field set that represents the object.
|
||||||
func APIServiceToSelectableFields(obj *apiregistration.APIService) fields.Set {
|
func ToSelectableFields(obj *apiregistration.APIService) fields.Set {
|
||||||
return generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true)
|
return generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user