forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
17 changed files
with
557 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
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. | ||
*/ | ||
|
||
// +k8s:deepcopy-gen=package | ||
// +groupName=flowcontrol.apiserver.k8s.io | ||
|
||
// Package flowcontrol provides api definitions for the "flowcontrol.apiserver.k8s.io" api group. | ||
package flowcontrol // import "k8s.io/kubernetes/pkg/apis/flowcontrol" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load( | ||
"@io_bazel_rules_go//go:def.bzl", | ||
"go_library", | ||
) | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["install.go"], | ||
importpath = "k8s.io/kubernetes/pkg/apis/flowcontrol/install", | ||
deps = [ | ||
"//pkg/api/legacyscheme:go_default_library", | ||
"//pkg/apis/flowcontrol:go_default_library", | ||
"//pkg/apis/flowcontrol/v1alpha1:go_default_library", | ||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", | ||
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "package-srcs", | ||
srcs = glob(["**"]), | ||
tags = ["automanaged"], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
filegroup( | ||
name = "all-srcs", | ||
srcs = [":package-srcs"], | ||
tags = ["automanaged"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
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 install installs the experimental API group, making it available as | ||
// an option to all of the API encoding/decoding machinery. | ||
package install | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime" | ||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
"k8s.io/kubernetes/pkg/api/legacyscheme" | ||
"k8s.io/kubernetes/pkg/apis/flowcontrol" | ||
flowcontrolv1alpha1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1alpha1" | ||
) | ||
|
||
func init() { | ||
Install(legacyscheme.Scheme) | ||
} | ||
|
||
// Install registers the API group and adds types to a scheme | ||
func Install(scheme *runtime.Scheme) { | ||
utilruntime.Must(flowcontrol.AddToScheme(scheme)) | ||
utilruntime.Must(flowcontrolv1alpha1.AddToScheme(scheme)) | ||
utilruntime.Must(scheme.SetVersionPriority(flowcontrolv1alpha1.SchemeGroupVersion)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
Copyright 2016 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 flowcontrol | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
// GroupName is the name of api group | ||
const GroupName = "flowcontrol.apiserver.k8s.io" | ||
|
||
// SchemeGroupVersion is group version used to register these objects | ||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} | ||
|
||
// Kind takes an unqualified kind and returns a Group qualified GroupKind | ||
func Kind(kind string) schema.GroupKind { | ||
return SchemeGroupVersion.WithKind(kind).GroupKind() | ||
} | ||
|
||
// Resource takes an unqualified resource and returns a Group qualified GroupResource | ||
func Resource(resource string) schema.GroupResource { | ||
return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
} | ||
|
||
var ( | ||
// SchemeBuilder installs the api group to a scheme | ||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) | ||
// AddToScheme adds api to a scheme | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) | ||
|
||
// Adds the list of known types to the given scheme. | ||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes(SchemeGroupVersion, | ||
&FlowSchema{}, | ||
&FlowSchemaList{}, | ||
&PriorityLevelConfiguration{}, | ||
&PriorityLevelConfigurationList{}, | ||
) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["helpers.go"], | ||
importpath = "k8s.io/kubernetes/pkg/apis/flowcontrol/util", | ||
visibility = ["//visibility:public"], | ||
deps = ["//pkg/apis/flowcontrol:go_default_library"], | ||
) | ||
|
||
filegroup( | ||
name = "package-srcs", | ||
srcs = glob(["**"]), | ||
tags = ["automanaged"], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
filegroup( | ||
name = "all-srcs", | ||
srcs = [":package-srcs"], | ||
tags = ["automanaged"], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright 2016 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 util | ||
|
||
import ( | ||
"sort" | ||
|
||
"k8s.io/kubernetes/pkg/apis/flowcontrol" | ||
) | ||
|
||
var _ sort.Interface = FlowSchemaSequence{} | ||
|
||
// FlowSchemaSequence holds sorted set of pointers to FlowSchema objects. | ||
// FlowSchemaSequence implements `sort.Interface` | ||
type FlowSchemaSequence []*flowcontrol.FlowSchema | ||
|
||
func (s FlowSchemaSequence) Len() int { | ||
return len(s) | ||
} | ||
|
||
func (s FlowSchemaSequence) Less(i, j int) bool { | ||
// the flow-schema w/ lower matching-precedence is prior | ||
if ip, jp := s[i].Spec.MatchingPrecedence, s[j].Spec.MatchingPrecedence; ip != jp { | ||
return ip < jp | ||
} | ||
// sort alphabetically | ||
return s[i].Name < s[j].Name | ||
} | ||
|
||
func (s FlowSchemaSequence) Swap(i, j int) { | ||
s[i], s[j] = s[j], s[i] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
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 v1alpha1 | ||
|
||
import ( | ||
"k8s.io/api/flowcontrol/v1alpha1" | ||
) | ||
|
||
// Default settings for flow-schema | ||
const ( | ||
FlowSchemaDefaultMatchingPrecedence int32 = 1000 | ||
) | ||
|
||
// Default settings for priority-level-configuration | ||
const ( | ||
PriorityLevelConfigurationDefaultHandSize int32 = 8 | ||
PriorityLevelConfigurationDefaultQueues int32 = 64 | ||
PriorityLevelConfigurationDefaultQueueLengthLimit int32 = 50 | ||
PriorityLevelConfigurationDefaultAssuredConcurrencyShares int32 = 30 | ||
) | ||
|
||
// SetDefaults_FlowSchema sets default values for flow schema | ||
func SetDefaults_FlowSchemaSpec(spec *v1alpha1.FlowSchemaSpec) { | ||
if spec.MatchingPrecedence == 0 { | ||
spec.MatchingPrecedence = FlowSchemaDefaultMatchingPrecedence | ||
} | ||
} | ||
|
||
// SetDefaults_FlowSchema sets default values for flow schema | ||
func SetDefaults_QueuingConfiguration(cfg *v1alpha1.QueuingConfiguration) { | ||
if cfg.HandSize == 0 { | ||
cfg.HandSize = PriorityLevelConfigurationDefaultHandSize | ||
} | ||
if cfg.Queues == 0 { | ||
cfg.Queues = PriorityLevelConfigurationDefaultQueues | ||
} | ||
if cfg.QueueLengthLimit == 0 { | ||
cfg.QueueLengthLimit = PriorityLevelConfigurationDefaultQueueLengthLimit | ||
} | ||
if cfg.AssuredConcurrencyShares == 0 { | ||
cfg.AssuredConcurrencyShares = PriorityLevelConfigurationDefaultAssuredConcurrencyShares | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
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. | ||
*/ | ||
|
||
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/flowcontrol | ||
// +k8s:conversion-gen-external-types=k8s.io/api/flowcontrol/v1alpha1 | ||
// +k8s:defaulter-gen=TypeMeta | ||
// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/flowcontrol/v1alpha1 | ||
|
||
// +groupName=flowcontrol.apiserver.k8s.io | ||
|
||
package v1alpha1 // import "k8s.io/kubernetes/pkg/apis/flowcontrol/v1alpha1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
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 v1alpha1 | ||
|
||
import ( | ||
flowcontrolv1alpha1 "k8s.io/api/flowcontrol/v1alpha1" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
// GroupName is the group name use in this package | ||
const GroupName = "flowcontrol.apiserver.k8s.io" | ||
|
||
// SchemeGroupVersion is group version used to register these objects | ||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} | ||
|
||
// Resource takes an unqualified resource and returns a Group qualified GroupResource | ||
func Resource(resource string) schema.GroupResource { | ||
return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
} | ||
|
||
var ( | ||
localSchemeBuilder = &flowcontrolv1alpha1.SchemeBuilder | ||
// AddToScheme adds api to a scheme | ||
AddToScheme = localSchemeBuilder.AddToScheme | ||
) | ||
|
||
func init() { | ||
// We only register manually written functions here. The registration of the | ||
// generated functions takes place in the generated files. The separation | ||
// makes the code compile even when the generated files are missing. | ||
localSchemeBuilder.Register(RegisterDefaults) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.