-
Notifications
You must be signed in to change notification settings - Fork 41
Update vendored k8s.io packages to target release-1.8/release-5.0 branches #15
Changes from all commits
2fd5302
3f62505
5e23f82
40390ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Copyright Jetstack Ltd. See LICENSE for details. | ||
| package winginitializer_test | ||
|
|
||
| import ( | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/jetstack/tarmak/pkg/wing/admission/winginitializer" | ||
| "github.com/jetstack/tarmak/pkg/wing/clients/internalclientset/fake" | ||
| informers "github.com/jetstack/tarmak/pkg/wing/informers/internalversion" | ||
| "k8s.io/apiserver/pkg/admission" | ||
| ) | ||
|
|
||
| // TestWantsInternalWingInformerFactory ensures that the informer factory is injected | ||
| // when the WantsInternalWingInformerFactory interface is implemented by a plugin. | ||
| func TestWantsInternalWingInformerFactory(t *testing.T) { | ||
| cs := &fake.Clientset{} | ||
| sf := informers.NewSharedInformerFactory(cs, time.Duration(1)*time.Second) | ||
| target, err := winginitializer.New(sf) | ||
| if err != nil { | ||
| t.Fatalf("expected to create an instance of initializer but got an error = %s", err.Error()) | ||
| } | ||
| wantWingInformerFactory := &wantInternalWingInformerFactory{} | ||
| target.Initialize(wantWingInformerFactory) | ||
| if wantWingInformerFactory.sf != sf { | ||
| t.Errorf("expected informer factory to be initialized") | ||
| } | ||
| } | ||
|
|
||
| // wantInternalWingInformerFactory is a test stub that fulfills the WantsInternalWingInformerFactory interface | ||
| type wantInternalWingInformerFactory struct { | ||
| sf informers.SharedInformerFactory | ||
| } | ||
|
|
||
| func (self *wantInternalWingInformerFactory) SetInternalWingInformerFactory(sf informers.SharedInformerFactory) { | ||
| self.sf = sf | ||
| } | ||
| func (self *wantInternalWingInformerFactory) Admit(a admission.Attributes) error { return nil } | ||
| func (self *wantInternalWingInformerFactory) Handles(o admission.Operation) bool { return false } | ||
| func (self *wantInternalWingInformerFactory) Validate() error { return nil } | ||
|
|
||
| var _ admission.Interface = &wantInternalWingInformerFactory{} | ||
| var _ winginitializer.WantsInternalWingInformerFactory = &wantInternalWingInformerFactory{} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ func init() { | |
| } | ||
|
|
||
| type Config struct { | ||
| GenericConfig *genericapiserver.Config | ||
| GenericConfig *genericapiserver.RecommendedConfig | ||
| } | ||
|
|
||
| // WingServer contains state for a Kubernetes cluster master/api server. | ||
|
|
@@ -55,29 +55,31 @@ type WingServer struct { | |
| } | ||
|
|
||
| type completedConfig struct { | ||
| *Config | ||
| GenericConfig genericapiserver.CompletedConfig | ||
| } | ||
|
|
||
| type CompletedConfig struct { | ||
| // Embed a private pointer that cannot be instantiated outside of this package. | ||
| *completedConfig | ||
| } | ||
|
|
||
| // Complete fills in any fields not set that are required to have valid data. It's mutating the receiver. | ||
| func (c *Config) Complete() completedConfig { | ||
| c.GenericConfig.Complete() | ||
| func (cfg *Config) Complete() CompletedConfig { | ||
| c := completedConfig{ | ||
| cfg.GenericConfig.Complete(), | ||
| } | ||
|
|
||
| c.GenericConfig.Version = &version.Info{ | ||
| Major: "1", | ||
| Minor: "0", | ||
| } | ||
|
|
||
| return completedConfig{c} | ||
| } | ||
|
|
||
| // SkipComplete provides a way to construct a server instance without config completion. | ||
| func (c *Config) SkipComplete() completedConfig { | ||
| return completedConfig{c} | ||
| return CompletedConfig{&c} | ||
| } | ||
|
|
||
| // New returns a new instance of WingServer from the given config. | ||
| func (c completedConfig) New() (*WingServer, error) { | ||
| genericServer, err := c.Config.GenericConfig.SkipComplete().New("wing", genericapiserver.EmptyDelegate) // completion is done in Complete, no need for a second time | ||
| genericServer, err := c.GenericConfig.New("wing", genericapiserver.EmptyDelegate) | ||
|
Contributor
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. Not using 'SkipComplete' looks good to me, as we already store a reference to the completed config on L68 (40390ed#diff-eeee2947c8ccb06990948a4196759b69R68). In the previous code we threw away the
Contributor
Author
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. Just wanted someone to double check |
||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Don't think this is, or should be, optional?
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.
Just copied from the core:
https://github.com/kubernetes/kubernetes/blob/master/pkg/api/types.go#L3409