-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introducing a cluster-scoped resource in the wardle.k8s.io group. #48444
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,8 @@ import ( | |
"k8s.io/sample-apiserver/pkg/apis/wardle" | ||
"k8s.io/sample-apiserver/pkg/apis/wardle/install" | ||
"k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" | ||
wardlestorage "k8s.io/sample-apiserver/pkg/registry/wardle" | ||
fischerstorage "k8s.io/sample-apiserver/pkg/registry/wardle/fischer" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I broke up wardle pkg into two(per resource). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
good call. |
||
flunderstorage "k8s.io/sample-apiserver/pkg/registry/wardle/flunder" | ||
) | ||
|
||
var ( | ||
|
@@ -102,7 +103,8 @@ func (c completedConfig) New() (*WardleServer, error) { | |
apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(wardle.GroupName, registry, Scheme, metav1.ParameterCodec, Codecs) | ||
apiGroupInfo.GroupMeta.GroupVersion = v1alpha1.SchemeGroupVersion | ||
v1alpha1storage := map[string]rest.Storage{} | ||
v1alpha1storage["flunders"] = wardlestorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter) | ||
v1alpha1storage["flunders"] = flunderstorage.RESTInPeace(Scheme, c.GenericConfig.RESTOptionsGetter) | ||
v1alpha1storage["fischers"] = fischerstorage.RESTInPeace(Scheme, c.GenericConfig.RESTOptionsGetter) | ||
apiGroupInfo.VersionedResourcesStorageMap["v1alpha1"] = v1alpha1storage | ||
|
||
if err := s.GenericAPIServer.InstallAPIGroup(&apiGroupInfo); err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
licenses(["notice"]) | ||
|
||
load( | ||
"@io_bazel_rules_go//go:def.bzl", | ||
"go_library", | ||
) | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["registry.go"], | ||
tags = ["automanaged"], | ||
deps = ["//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library"], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
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 registry | ||
|
||
import genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" | ||
|
||
// rest implements a RESTStorage for API services against etcd | ||
type REST struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the spot I expected |
||
*genericregistry.Store | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
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 fischer | ||
|
||
import ( | ||
"fmt" | ||
|
||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apiserver/pkg/registry/generic" | ||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" | ||
"k8s.io/sample-apiserver/pkg/apis/wardle" | ||
"k8s.io/sample-apiserver/pkg/registry" | ||
) | ||
|
||
// RESTInPeace returns a RESTStorage object that will work against API services. | ||
func RESTInPeace(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) *registry.REST { | ||
strategy := NewStrategy(scheme) | ||
|
||
store := &genericregistry.Store{ | ||
Copier: scheme, | ||
NewFunc: func() runtime.Object { return &wardle.Fischer{} }, | ||
NewListFunc: func() runtime.Object { return &wardle.FischerList{} }, | ||
PredicateFunc: MatchFischer, | ||
QualifiedResource: wardle.Resource("fischers"), | ||
|
||
CreateStrategy: strategy, | ||
UpdateStrategy: strategy, | ||
DeleteStrategy: strategy, | ||
} | ||
options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} | ||
if err := store.CompleteWithOptions(options); err != nil { | ||
err = fmt.Errorf("Unable to create REST storage for fischer resource due to %v. Committing suicide.", err) | ||
panic(err) | ||
} | ||
return ®istry.REST{store} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like
APIService
was unnecessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, bad copy/paste