mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
address lavalamp's comments
This commit is contained in:
parent
f734a6f038
commit
c733124920
@ -35,7 +35,6 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/latest"
|
||||
"k8s.io/kubernetes/pkg/api/meta"
|
||||
"k8s.io/kubernetes/pkg/api/registered"
|
||||
"k8s.io/kubernetes/pkg/apiserver"
|
||||
"k8s.io/kubernetes/pkg/capabilities"
|
||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||
@ -331,10 +330,6 @@ func (s *APIServer) Run(_ []string) error {
|
||||
// This takes preference over api/all, if specified.
|
||||
enableExp := s.getRuntimeConfigValue("experimental/v1", false)
|
||||
|
||||
if enableExp && len(registered.GroupVersionsForGroup("experimental")) == 0 {
|
||||
glog.Fatalf("experimental API is enabled in runtime config, but not registered throught environment variable KUBE_API_VERSIONS")
|
||||
}
|
||||
|
||||
clientConfig := &client.Config{
|
||||
Host: net.JoinHostPort(s.InsecureBindAddress.String(), strconv.Itoa(s.InsecurePort)),
|
||||
Version: s.StorageVersion,
|
||||
@ -351,8 +346,11 @@ func (s *APIServer) Run(_ []string) error {
|
||||
|
||||
var expEtcdStorage storage.Interface
|
||||
if enableExp {
|
||||
expEtcdStorage, err = newEtcd(s.EtcdConfigFile, s.EtcdServerList, latest.GroupOrDie("experimental").InterfacesFor, latest.GroupOrDie("experimental").Version, s.ExpStorageVersion, s.EtcdPathPrefix)
|
||||
|
||||
g, err := latest.Group("experimental")
|
||||
if err != nil {
|
||||
glog.Fatalf("experimental API is enabled in runtime config, but not enabled in the environment variable KUBE_API_VERSIONS. Error: %v", err)
|
||||
}
|
||||
expEtcdStorage, err = newEtcd(s.EtcdConfigFile, s.EtcdServerList, g.InterfacesFor, g.Version, s.ExpStorageVersion, s.EtcdPathPrefix)
|
||||
if err != nil {
|
||||
glog.Fatalf("Invalid experimental storage version or misconfigured etcd: %v", err)
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package install installs the v1 monolithic api, making it available as an
|
||||
// option to all of the API encoding/decoding machinery.
|
||||
package install
|
||||
|
||||
import (
|
||||
|
@ -25,14 +25,19 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
allGroups = GroupMetaMap{}
|
||||
Group = allGroups.Group
|
||||
allGroups = GroupMetaMap{}
|
||||
// Group is a shortcut to allGroups.Group.
|
||||
Group = allGroups.Group
|
||||
// RegisterGroup is a shortcut to allGroups.RegisterGroup.
|
||||
RegisterGroup = allGroups.RegisterGroup
|
||||
GroupOrDie = allGroups.GroupOrDie
|
||||
// GroupOrDie is a shortcut to allGroups.GroupOrDie.
|
||||
GroupOrDie = allGroups.GroupOrDie
|
||||
)
|
||||
|
||||
// GroupMetaMap is a map between group names and their metadata.
|
||||
type GroupMetaMap map[string]*GroupMeta
|
||||
|
||||
// RegisterGroup registers a group to GroupMetaMap.
|
||||
func (g GroupMetaMap) RegisterGroup(group string) (*GroupMeta, error) {
|
||||
_, found := g[group]
|
||||
if found {
|
||||
@ -45,6 +50,8 @@ func (g GroupMetaMap) RegisterGroup(group string) (*GroupMeta, error) {
|
||||
return g[group], nil
|
||||
}
|
||||
|
||||
// Group returns the metadata of a group if the gruop is registered, otherwise
|
||||
// an erorr is returned.
|
||||
func (g GroupMetaMap) Group(group string) (*GroupMeta, error) {
|
||||
groupMeta, found := g[group]
|
||||
if !found {
|
||||
@ -100,5 +107,7 @@ type GroupMeta struct {
|
||||
// Kubernetes versions.
|
||||
RESTMapper meta.RESTMapper
|
||||
|
||||
// InterfacesFor returns the default Codec and ResourceVersioner for a given version
|
||||
// string, or an error if the version is not known.
|
||||
InterfacesFor func(version string) (*meta.VersionInterfaces, error)
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// This is made a separate package and should only be imported by tests, because
|
||||
// it imports testapi
|
||||
package fake
|
||||
|
||||
import (
|
||||
|
@ -33,7 +33,6 @@ import (
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/latest"
|
||||
"k8s.io/kubernetes/pkg/api/registered"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/sets"
|
||||
@ -142,7 +141,7 @@ func New(c *Config) (*Client, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(registered.GroupVersionsForGroup("experimental")) == 0 {
|
||||
if _, err := latest.Group("experimental"); err != nil {
|
||||
return &Client{RESTClient: client, ExperimentalClient: nil}, nil
|
||||
}
|
||||
experimentalConfig := *c
|
||||
|
@ -16,6 +16,7 @@ limitations under the License.
|
||||
|
||||
package unversioned
|
||||
|
||||
// These imports are the API groups the client will support.
|
||||
import (
|
||||
_ "k8s.io/kubernetes/pkg/api/install"
|
||||
_ "k8s.io/kubernetes/pkg/expapi/install"
|
||||
|
@ -14,6 +14,8 @@ 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 (
|
||||
|
@ -16,6 +16,7 @@ limitations under the License.
|
||||
|
||||
package master
|
||||
|
||||
// These imports are the API groups the API server will support.
|
||||
import (
|
||||
_ "k8s.io/kubernetes/pkg/api/install"
|
||||
_ "k8s.io/kubernetes/pkg/expapi/install"
|
||||
|
Loading…
Reference in New Issue
Block a user