Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
384c8739
Commit
384c8739
authored
Jan 31, 2017
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unneeded storage options
parent
de2493e7
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
153 additions
and
103 deletions
+153
-103
options.go
cmd/kube-apiserver/app/options/options.go
+9
-6
server.go
cmd/kube-apiserver/app/server.go
+1
-1
options.go
federation/cmd/federation-apiserver/app/options/options.go
+9
-6
server.go
federation/cmd/federation-apiserver/app/server.go
+1
-1
BUILD
pkg/genericapiserver/server/BUILD
+0
-2
BUILD
pkg/genericapiserver/server/options/BUILD
+0
-2
server_run_options.go
pkg/genericapiserver/server/options/server_run_options.go
+2
-72
BUILD
pkg/kubeapiserver/options/BUILD
+12
-0
storage_versions.go
pkg/kubeapiserver/options/storage_versions.go
+110
-0
storage_versions_test.go
pkg/kubeapiserver/options/storage_versions_test.go
+9
-13
No files found.
cmd/kube-apiserver/app/options/options.go
View file @
384c8739
...
@@ -47,6 +47,7 @@ type ServerRunOptions struct {
...
@@ -47,6 +47,7 @@ type ServerRunOptions struct {
Authentication
*
kubeoptions
.
BuiltInAuthenticationOptions
Authentication
*
kubeoptions
.
BuiltInAuthenticationOptions
Authorization
*
kubeoptions
.
BuiltInAuthorizationOptions
Authorization
*
kubeoptions
.
BuiltInAuthorizationOptions
CloudProvider
*
kubeoptions
.
CloudProviderOptions
CloudProvider
*
kubeoptions
.
CloudProviderOptions
StorageSerialization
*
kubeoptions
.
StorageSerializationOptions
AllowPrivileged
bool
AllowPrivileged
bool
EventTTL
time
.
Duration
EventTTL
time
.
Duration
...
@@ -64,12 +65,13 @@ type ServerRunOptions struct {
...
@@ -64,12 +65,13 @@ type ServerRunOptions struct {
func
NewServerRunOptions
()
*
ServerRunOptions
{
func
NewServerRunOptions
()
*
ServerRunOptions
{
s
:=
ServerRunOptions
{
s
:=
ServerRunOptions
{
GenericServerRunOptions
:
genericoptions
.
NewServerRunOptions
(),
GenericServerRunOptions
:
genericoptions
.
NewServerRunOptions
(),
Etcd
:
genericoptions
.
NewEtcdOptions
(),
Etcd
:
genericoptions
.
NewEtcdOptions
(),
SecureServing
:
genericoptions
.
NewSecureServingOptions
(),
SecureServing
:
genericoptions
.
NewSecureServingOptions
(),
InsecureServing
:
genericoptions
.
NewInsecureServingOptions
(),
InsecureServing
:
genericoptions
.
NewInsecureServingOptions
(),
Authentication
:
kubeoptions
.
NewBuiltInAuthenticationOptions
()
.
WithAll
(),
Authentication
:
kubeoptions
.
NewBuiltInAuthenticationOptions
()
.
WithAll
(),
Authorization
:
kubeoptions
.
NewBuiltInAuthorizationOptions
(),
Authorization
:
kubeoptions
.
NewBuiltInAuthorizationOptions
(),
CloudProvider
:
kubeoptions
.
NewCloudProviderOptions
(),
CloudProvider
:
kubeoptions
.
NewCloudProviderOptions
(),
StorageSerialization
:
kubeoptions
.
NewStorageSerializationOptions
(),
EventTTL
:
1
*
time
.
Hour
,
EventTTL
:
1
*
time
.
Hour
,
MasterCount
:
1
,
MasterCount
:
1
,
...
@@ -104,6 +106,7 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) {
...
@@ -104,6 +106,7 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) {
s
.
Authentication
.
AddFlags
(
fs
)
s
.
Authentication
.
AddFlags
(
fs
)
s
.
Authorization
.
AddFlags
(
fs
)
s
.
Authorization
.
AddFlags
(
fs
)
s
.
CloudProvider
.
AddFlags
(
fs
)
s
.
CloudProvider
.
AddFlags
(
fs
)
s
.
StorageSerialization
.
AddFlags
(
fs
)
// Note: the weird ""+ in below lines seems to be the only way to get gofmt to
// Note: the weird ""+ in below lines seems to be the only way to get gofmt to
// arrange these text blocks sensibly. Grrr.
// arrange these text blocks sensibly. Grrr.
...
...
cmd/kube-apiserver/app/server.go
View file @
384c8739
...
@@ -189,7 +189,7 @@ func Run(s *options.ServerRunOptions) error {
...
@@ -189,7 +189,7 @@ func Run(s *options.ServerRunOptions) error {
}
}
}
}
storageGroupsToEncodingVersion
,
err
:=
s
.
GenericServerRunOptions
.
StorageGroupsToEncodingVersion
()
storageGroupsToEncodingVersion
,
err
:=
s
.
StorageSerialization
.
StorageGroupsToEncodingVersion
()
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error generating storage version map: %s"
,
err
)
return
fmt
.
Errorf
(
"error generating storage version map: %s"
,
err
)
}
}
...
...
federation/cmd/federation-apiserver/app/options/options.go
View file @
384c8739
...
@@ -38,6 +38,7 @@ type ServerRunOptions struct {
...
@@ -38,6 +38,7 @@ type ServerRunOptions struct {
Authentication
*
kubeoptions
.
BuiltInAuthenticationOptions
Authentication
*
kubeoptions
.
BuiltInAuthenticationOptions
Authorization
*
kubeoptions
.
BuiltInAuthorizationOptions
Authorization
*
kubeoptions
.
BuiltInAuthorizationOptions
CloudProvider
*
kubeoptions
.
CloudProviderOptions
CloudProvider
*
kubeoptions
.
CloudProviderOptions
StorageSerialization
*
kubeoptions
.
StorageSerializationOptions
EventTTL
time
.
Duration
EventTTL
time
.
Duration
}
}
...
@@ -46,12 +47,13 @@ type ServerRunOptions struct {
...
@@ -46,12 +47,13 @@ type ServerRunOptions struct {
func
NewServerRunOptions
()
*
ServerRunOptions
{
func
NewServerRunOptions
()
*
ServerRunOptions
{
s
:=
ServerRunOptions
{
s
:=
ServerRunOptions
{
GenericServerRunOptions
:
genericoptions
.
NewServerRunOptions
(),
GenericServerRunOptions
:
genericoptions
.
NewServerRunOptions
(),
Etcd
:
genericoptions
.
NewEtcdOptions
(),
Etcd
:
genericoptions
.
NewEtcdOptions
(),
SecureServing
:
genericoptions
.
NewSecureServingOptions
(),
SecureServing
:
genericoptions
.
NewSecureServingOptions
(),
InsecureServing
:
genericoptions
.
NewInsecureServingOptions
(),
InsecureServing
:
genericoptions
.
NewInsecureServingOptions
(),
Authentication
:
kubeoptions
.
NewBuiltInAuthenticationOptions
()
.
WithAll
(),
Authentication
:
kubeoptions
.
NewBuiltInAuthenticationOptions
()
.
WithAll
(),
Authorization
:
kubeoptions
.
NewBuiltInAuthorizationOptions
(),
Authorization
:
kubeoptions
.
NewBuiltInAuthorizationOptions
(),
CloudProvider
:
kubeoptions
.
NewCloudProviderOptions
(),
CloudProvider
:
kubeoptions
.
NewCloudProviderOptions
(),
StorageSerialization
:
kubeoptions
.
NewStorageSerializationOptions
(),
EventTTL
:
1
*
time
.
Hour
,
EventTTL
:
1
*
time
.
Hour
,
}
}
...
@@ -70,6 +72,7 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) {
...
@@ -70,6 +72,7 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) {
s
.
Authentication
.
AddFlags
(
fs
)
s
.
Authentication
.
AddFlags
(
fs
)
s
.
Authorization
.
AddFlags
(
fs
)
s
.
Authorization
.
AddFlags
(
fs
)
s
.
CloudProvider
.
AddFlags
(
fs
)
s
.
CloudProvider
.
AddFlags
(
fs
)
s
.
StorageSerialization
.
AddFlags
(
fs
)
fs
.
DurationVar
(
&
s
.
EventTTL
,
"event-ttl"
,
s
.
EventTTL
,
fs
.
DurationVar
(
&
s
.
EventTTL
,
"event-ttl"
,
s
.
EventTTL
,
"Amount of time to retain events. Default is 1h."
)
"Amount of time to retain events. Default is 1h."
)
...
...
federation/cmd/federation-apiserver/app/server.go
View file @
384c8739
...
@@ -104,7 +104,7 @@ func Run(s *options.ServerRunOptions) error {
...
@@ -104,7 +104,7 @@ func Run(s *options.ServerRunOptions) error {
// When size of cache is not explicitly set, set it to 50000
// When size of cache is not explicitly set, set it to 50000
s
.
Etcd
.
StorageConfig
.
DeserializationCacheSize
=
50000
s
.
Etcd
.
StorageConfig
.
DeserializationCacheSize
=
50000
}
}
storageGroupsToEncodingVersion
,
err
:=
s
.
GenericServerRunOptions
.
StorageGroupsToEncodingVersion
()
storageGroupsToEncodingVersion
,
err
:=
s
.
StorageSerialization
.
StorageGroupsToEncodingVersion
()
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error generating storage version map: %s"
,
err
)
return
fmt
.
Errorf
(
"error generating storage version map: %s"
,
err
)
}
}
...
...
pkg/genericapiserver/server/BUILD
View file @
384c8739
...
@@ -14,7 +14,6 @@ go_test(
...
@@ -14,7 +14,6 @@ go_test(
"genericapiserver_test.go",
"genericapiserver_test.go",
"resource_config_test.go",
"resource_config_test.go",
"serve_test.go",
"serve_test.go",
"server_run_options_test.go",
"storage_factory_test.go",
"storage_factory_test.go",
],
],
library = ":go_default_library",
library = ":go_default_library",
...
@@ -23,7 +22,6 @@ go_test(
...
@@ -23,7 +22,6 @@ go_test(
"//pkg/api:go_default_library",
"//pkg/api:go_default_library",
"//pkg/api/testapi:go_default_library",
"//pkg/api/testapi:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/client/clientset_generated/clientset:go_default_library",
"//pkg/client/clientset_generated/clientset:go_default_library",
"//pkg/generated/openapi:go_default_library",
"//pkg/generated/openapi:go_default_library",
...
...
pkg/genericapiserver/server/options/BUILD
View file @
384c8739
...
@@ -19,11 +19,9 @@ go_library(
...
@@ -19,11 +19,9 @@ go_library(
],
],
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//pkg/api:go_default_library",
"//vendor:github.com/golang/glog",
"//vendor:github.com/golang/glog",
"//vendor:github.com/spf13/pflag",
"//vendor:github.com/spf13/pflag",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
"//vendor:k8s.io/apimachinery/pkg/util/net",
"//vendor:k8s.io/apimachinery/pkg/util/net",
"//vendor:k8s.io/apiserver/pkg/admission",
"//vendor:k8s.io/apiserver/pkg/admission",
"//vendor:k8s.io/apiserver/pkg/authentication/authenticatorfactory",
"//vendor:k8s.io/apiserver/pkg/authentication/authenticatorfactory",
...
...
pkg/genericapiserver/server/options/server_run_options.go
View file @
384c8739
...
@@ -22,11 +22,9 @@ import (
...
@@ -22,11 +22,9 @@ import (
"strings"
"strings"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/admission"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
utilflag
"k8s.io/apiserver/pkg/util/flag"
utilflag
"k8s.io/apiserver/pkg/util/flag"
"k8s.io/kubernetes/pkg/api"
// add the generic feature gates
// add the generic feature gates
_
"k8s.io/apiserver/pkg/features"
_
"k8s.io/apiserver/pkg/features"
...
@@ -59,20 +57,14 @@ type ServerRunOptions struct {
...
@@ -59,20 +57,14 @@ type ServerRunOptions struct {
MaxMutatingRequestsInFlight
int
MaxMutatingRequestsInFlight
int
MinRequestTimeout
int
MinRequestTimeout
int
RuntimeConfig
utilflag
.
ConfigurationMap
RuntimeConfig
utilflag
.
ConfigurationMap
StorageVersions
string
TargetRAMMB
int
// The default values for StorageVersions. StorageVersions overrides
WatchCacheSizes
[]
string
// these; you can change this if you want to change the defaults (e.g.,
// for testing). This is not actually exposed as a flag.
DefaultStorageVersions
string
TargetRAMMB
int
WatchCacheSizes
[]
string
}
}
func
NewServerRunOptions
()
*
ServerRunOptions
{
func
NewServerRunOptions
()
*
ServerRunOptions
{
return
&
ServerRunOptions
{
return
&
ServerRunOptions
{
AdmissionControl
:
"AlwaysAdmit"
,
AdmissionControl
:
"AlwaysAdmit"
,
DefaultStorageMediaType
:
"application/json"
,
DefaultStorageMediaType
:
"application/json"
,
DefaultStorageVersions
:
api
.
Registry
.
AllPreferredGroupVersions
(),
DeleteCollectionWorkers
:
1
,
DeleteCollectionWorkers
:
1
,
EnableGarbageCollection
:
true
,
EnableGarbageCollection
:
true
,
EnableProfiling
:
true
,
EnableProfiling
:
true
,
...
@@ -82,7 +74,6 @@ func NewServerRunOptions() *ServerRunOptions {
...
@@ -82,7 +74,6 @@ func NewServerRunOptions() *ServerRunOptions {
MaxMutatingRequestsInFlight
:
200
,
MaxMutatingRequestsInFlight
:
200
,
MinRequestTimeout
:
1800
,
MinRequestTimeout
:
1800
,
RuntimeConfig
:
make
(
utilflag
.
ConfigurationMap
),
RuntimeConfig
:
make
(
utilflag
.
ConfigurationMap
),
StorageVersions
:
api
.
Registry
.
AllPreferredGroupVersions
(),
}
}
}
}
...
@@ -114,52 +105,6 @@ func (s *ServerRunOptions) DefaultAdvertiseAddress(secure *SecureServingOptions,
...
@@ -114,52 +105,6 @@ func (s *ServerRunOptions) DefaultAdvertiseAddress(secure *SecureServingOptions,
return
nil
return
nil
}
}
// StorageGroupsToEncodingVersion returns a map from group name to group version,
// computed from s.StorageVersions flag.
func
(
s
*
ServerRunOptions
)
StorageGroupsToEncodingVersion
()
(
map
[
string
]
schema
.
GroupVersion
,
error
)
{
storageVersionMap
:=
map
[
string
]
schema
.
GroupVersion
{}
// First, get the defaults.
if
err
:=
mergeGroupVersionIntoMap
(
s
.
DefaultStorageVersions
,
storageVersionMap
);
err
!=
nil
{
return
nil
,
err
}
// Override any defaults with the user settings.
if
err
:=
mergeGroupVersionIntoMap
(
s
.
StorageVersions
,
storageVersionMap
);
err
!=
nil
{
return
nil
,
err
}
return
storageVersionMap
,
nil
}
// dest must be a map of group to groupVersion.
func
mergeGroupVersionIntoMap
(
gvList
string
,
dest
map
[
string
]
schema
.
GroupVersion
)
error
{
for
_
,
gvString
:=
range
strings
.
Split
(
gvList
,
","
)
{
if
gvString
==
""
{
continue
}
// We accept two formats. "group/version" OR
// "group=group/version". The latter is used when types
// move between groups.
if
!
strings
.
Contains
(
gvString
,
"="
)
{
gv
,
err
:=
schema
.
ParseGroupVersion
(
gvString
)
if
err
!=
nil
{
return
err
}
dest
[
gv
.
Group
]
=
gv
}
else
{
parts
:=
strings
.
SplitN
(
gvString
,
"="
,
2
)
gv
,
err
:=
schema
.
ParseGroupVersion
(
parts
[
1
])
if
err
!=
nil
{
return
err
}
dest
[
parts
[
0
]]
=
gv
}
}
return
nil
}
// AddFlags adds flags for a specific APIServer to the specified FlagSet
// AddFlags adds flags for a specific APIServer to the specified FlagSet
func
(
s
*
ServerRunOptions
)
AddUniversalFlags
(
fs
*
pflag
.
FlagSet
)
{
func
(
s
*
ServerRunOptions
)
AddUniversalFlags
(
fs
*
pflag
.
FlagSet
)
{
// Note: the weird ""+ in below lines seems to be the only way to get gofmt to
// Note: the weird ""+ in below lines seems to be the only way to get gofmt to
...
@@ -250,21 +195,6 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) {
...
@@ -250,21 +195,6 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) {
"apis/<groupVersion>/<resource> can be used to turn on/off specific resources. api/all and "
+
"apis/<groupVersion>/<resource> can be used to turn on/off specific resources. api/all and "
+
"api/legacy are special keys to control all and legacy api versions respectively."
)
"api/legacy are special keys to control all and legacy api versions respectively."
)
deprecatedStorageVersion
:=
""
fs
.
StringVar
(
&
deprecatedStorageVersion
,
"storage-version"
,
deprecatedStorageVersion
,
"DEPRECATED: the version to store the legacy v1 resources with. Defaults to server preferred."
)
fs
.
MarkDeprecated
(
"storage-version"
,
"--storage-version is deprecated and will be removed when the v1 API "
+
"is retired. Setting this has no effect. See --storage-versions instead."
)
fs
.
StringVar
(
&
s
.
StorageVersions
,
"storage-versions"
,
s
.
StorageVersions
,
""
+
"The per-group version to store resources in. "
+
"Specified in the format
\"
group1/version1,group2/version2,...
\"
. "
+
"In the case where objects are moved from one group to the other, "
+
"you may specify the format
\"
group1=group2/v1beta1,group3/v1beta1,...
\"
. "
+
"You only need to pass the groups you wish to change from the defaults. "
+
"It defaults to a list of preferred versions of all registered groups, "
+
"which is derived from the KUBE_API_VERSIONS environment variable."
)
fs
.
StringSliceVar
(
&
s
.
WatchCacheSizes
,
"watch-cache-sizes"
,
s
.
WatchCacheSizes
,
""
+
fs
.
StringSliceVar
(
&
s
.
WatchCacheSizes
,
"watch-cache-sizes"
,
s
.
WatchCacheSizes
,
""
+
"List of watch cache sizes for every resource (pods, nodes, etc.), comma separated. "
+
"List of watch cache sizes for every resource (pods, nodes, etc.), comma separated. "
+
"The individual override format: resource#size, where size is a number. It takes effect "
+
"The individual override format: resource#size, where size is a number. It takes effect "
+
...
...
pkg/kubeapiserver/options/BUILD
View file @
384c8739
...
@@ -5,6 +5,7 @@ licenses(["notice"])
...
@@ -5,6 +5,7 @@ licenses(["notice"])
load(
load(
"@io_bazel_rules_go//go:def.bzl",
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_library",
"go_test",
)
)
go_library(
go_library(
...
@@ -13,9 +14,11 @@ go_library(
...
@@ -13,9 +14,11 @@ go_library(
"authentication.go",
"authentication.go",
"authorization.go",
"authorization.go",
"cloudprovider.go",
"cloudprovider.go",
"storage_versions.go",
],
],
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//pkg/api:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/cloudprovider:go_default_library",
"//pkg/cloudprovider:go_default_library",
"//pkg/controller/informers:go_default_library",
"//pkg/controller/informers:go_default_library",
...
@@ -25,6 +28,7 @@ go_library(
...
@@ -25,6 +28,7 @@ go_library(
"//pkg/kubeapiserver/authorizer:go_default_library",
"//pkg/kubeapiserver/authorizer:go_default_library",
"//vendor:github.com/golang/glog",
"//vendor:github.com/golang/glog",
"//vendor:github.com/spf13/pflag",
"//vendor:github.com/spf13/pflag",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
],
],
)
)
...
@@ -40,3 +44,11 @@ filegroup(
...
@@ -40,3 +44,11 @@ filegroup(
srcs = [":package-srcs"],
srcs = [":package-srcs"],
tags = ["automanaged"],
tags = ["automanaged"],
)
)
go_test(
name = "go_default_test",
srcs = ["storage_versions_test.go"],
library = ":go_default_library",
tags = ["automanaged"],
deps = ["//vendor:k8s.io/apimachinery/pkg/runtime/schema"],
)
pkg/kubeapiserver/options/storage_versions.go
0 → 100644
View file @
384c8739
/*
Copyright 2017 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
options
import
(
"strings"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/api"
"github.com/spf13/pflag"
)
// StorageSerializationOptions contains the options for encoding resources.
type
StorageSerializationOptions
struct
{
StorageVersions
string
// The default values for StorageVersions. StorageVersions overrides
// these; you can change this if you want to change the defaults (e.g.,
// for testing). This is not actually exposed as a flag.
DefaultStorageVersions
string
}
func
NewStorageSerializationOptions
()
*
StorageSerializationOptions
{
return
&
StorageSerializationOptions
{
DefaultStorageVersions
:
api
.
Registry
.
AllPreferredGroupVersions
(),
StorageVersions
:
api
.
Registry
.
AllPreferredGroupVersions
(),
}
}
// StorageGroupsToEncodingVersion returns a map from group name to group version,
// computed from s.StorageVersions flag.
func
(
s
*
StorageSerializationOptions
)
StorageGroupsToEncodingVersion
()
(
map
[
string
]
schema
.
GroupVersion
,
error
)
{
storageVersionMap
:=
map
[
string
]
schema
.
GroupVersion
{}
// First, get the defaults.
if
err
:=
mergeGroupVersionIntoMap
(
s
.
DefaultStorageVersions
,
storageVersionMap
);
err
!=
nil
{
return
nil
,
err
}
// Override any defaults with the user settings.
if
err
:=
mergeGroupVersionIntoMap
(
s
.
StorageVersions
,
storageVersionMap
);
err
!=
nil
{
return
nil
,
err
}
return
storageVersionMap
,
nil
}
// dest must be a map of group to groupVersion.
func
mergeGroupVersionIntoMap
(
gvList
string
,
dest
map
[
string
]
schema
.
GroupVersion
)
error
{
for
_
,
gvString
:=
range
strings
.
Split
(
gvList
,
","
)
{
if
gvString
==
""
{
continue
}
// We accept two formats. "group/version" OR
// "group=group/version". The latter is used when types
// move between groups.
if
!
strings
.
Contains
(
gvString
,
"="
)
{
gv
,
err
:=
schema
.
ParseGroupVersion
(
gvString
)
if
err
!=
nil
{
return
err
}
dest
[
gv
.
Group
]
=
gv
}
else
{
parts
:=
strings
.
SplitN
(
gvString
,
"="
,
2
)
gv
,
err
:=
schema
.
ParseGroupVersion
(
parts
[
1
])
if
err
!=
nil
{
return
err
}
dest
[
parts
[
0
]]
=
gv
}
}
return
nil
}
// AddFlags adds flags for a specific APIServer to the specified FlagSet
func
(
s
*
StorageSerializationOptions
)
AddFlags
(
fs
*
pflag
.
FlagSet
)
{
// Note: the weird ""+ in below lines seems to be the only way to get gofmt to
// arrange these text blocks sensibly. Grrr.
deprecatedStorageVersion
:=
""
fs
.
StringVar
(
&
deprecatedStorageVersion
,
"storage-version"
,
deprecatedStorageVersion
,
"DEPRECATED: the version to store the legacy v1 resources with. Defaults to server preferred."
)
fs
.
MarkDeprecated
(
"storage-version"
,
"--storage-version is deprecated and will be removed when the v1 API "
+
"is retired. Setting this has no effect. See --storage-versions instead."
)
fs
.
StringVar
(
&
s
.
StorageVersions
,
"storage-versions"
,
s
.
StorageVersions
,
""
+
"The per-group version to store resources in. "
+
"Specified in the format
\"
group1/version1,group2/version2,...
\"
. "
+
"In the case where objects are moved from one group to the other, "
+
"you may specify the format
\"
group1=group2/v1beta1,group3/v1beta1,...
\"
. "
+
"You only need to pass the groups you wish to change from the defaults. "
+
"It defaults to a list of preferred versions of all registered groups, "
+
"which is derived from the KUBE_API_VERSIONS environment variable."
)
}
pkg/
genericapiserver/server/server_run_opt
ions_test.go
→
pkg/
kubeapiserver/options/storage_vers
ions_test.go
View file @
384c8739
...
@@ -14,17 +14,13 @@ See the License for the specific language governing permissions and
...
@@ -14,17 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
server
package
options
import
(
import
(
"reflect"
"reflect"
"testing"
"testing"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/genericapiserver/server/options"
)
)
func
TestGenerateStorageVersionMap
(
t
*
testing
.
T
)
{
func
TestGenerateStorageVersionMap
(
t
*
testing
.
T
)
{
...
@@ -38,16 +34,16 @@ func TestGenerateStorageVersionMap(t *testing.T) {
...
@@ -38,16 +34,16 @@ func TestGenerateStorageVersionMap(t *testing.T) {
legacyVersion
:
"v1"
,
legacyVersion
:
"v1"
,
storageVersions
:
"v1,extensions/v1beta1"
,
storageVersions
:
"v1,extensions/v1beta1"
,
expectedMap
:
map
[
string
]
schema
.
GroupVersion
{
expectedMap
:
map
[
string
]
schema
.
GroupVersion
{
api
.
GroupName
:
{
Version
:
"v1"
},
""
:
{
Version
:
"v1"
},
extensions
.
GroupName
:
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
"extensions"
:
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
},
},
},
},
{
{
legacyVersion
:
""
,
legacyVersion
:
""
,
storageVersions
:
"extensions/v1beta1,v1"
,
storageVersions
:
"extensions/v1beta1,v1"
,
expectedMap
:
map
[
string
]
schema
.
GroupVersion
{
expectedMap
:
map
[
string
]
schema
.
GroupVersion
{
api
.
GroupName
:
{
Version
:
"v1"
},
""
:
{
Version
:
"v1"
},
extensions
.
GroupName
:
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
"extensions"
:
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
},
},
},
},
{
{
...
@@ -55,9 +51,9 @@ func TestGenerateStorageVersionMap(t *testing.T) {
...
@@ -55,9 +51,9 @@ func TestGenerateStorageVersionMap(t *testing.T) {
storageVersions
:
"autoscaling=extensions/v1beta1,v1"
,
storageVersions
:
"autoscaling=extensions/v1beta1,v1"
,
defaultVersions
:
"extensions/v1beta1,v1,autoscaling/v1"
,
defaultVersions
:
"extensions/v1beta1,v1,autoscaling/v1"
,
expectedMap
:
map
[
string
]
schema
.
GroupVersion
{
expectedMap
:
map
[
string
]
schema
.
GroupVersion
{
api
.
GroupName
:
{
Version
:
"v1"
},
""
:
{
Version
:
"v1"
},
autoscaling
.
GroupName
:
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
"autoscaling"
:
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
extensions
.
GroupName
:
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
"extensions"
:
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
},
},
},
},
{
{
...
@@ -67,7 +63,7 @@ func TestGenerateStorageVersionMap(t *testing.T) {
...
@@ -67,7 +63,7 @@ func TestGenerateStorageVersionMap(t *testing.T) {
},
},
}
}
for
i
,
test
:=
range
testCases
{
for
i
,
test
:=
range
testCases
{
s
:=
options
.
ServerRu
nOptions
{
s
:=
&
StorageSerializatio
nOptions
{
StorageVersions
:
test
.
storageVersions
,
StorageVersions
:
test
.
storageVersions
,
DefaultStorageVersions
:
test
.
defaultVersions
,
DefaultStorageVersions
:
test
.
defaultVersions
,
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment