Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
54 changes: 42 additions & 12 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 18 additions & 11 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ required = [
branch = "v2"
name = "gopkg.in/yaml.v2"

[[constraint]]
branch = "master"
name = "k8s.io/client-go"

[[constraint]]
branch = "master"
name = "k8s.io/apiserver"

[[constraint]]
branch = "master"
name = "github.com/grpc-ecosystem/go-grpc-prometheus"
Expand All @@ -60,7 +52,22 @@ required = [
name = "github.com/jetstack-experimental/vault-helper"
revision = "f7506c9c9ab6cb68dfbb3be12161cae30336875c"

[[override]]
name = "google.golang.org/grpc"
version = "=1.2.1"
[[constraint]]
name = "k8s.io/client-go"
branch = "release-5.0"

[[constraint]]
name = "k8s.io/apimachinery"
branch = "release-1.8"

[[constraint]]
name = "k8s.io/api"
branch = "release-1.8"

[[constraint]]
name = "k8s.io/apiserver"
branch = "release-1.8"

[[constraint]]
name = "k8s.io/code-generator"
branch = "release-1.8"
3 changes: 2 additions & 1 deletion pkg/apis/wing/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ type InstanceStatusManifest struct {

type InstanceList struct {
metav1.TypeMeta
metav1.ObjectMeta
// +optional
metav1.ListMeta
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Items []Instance
}
4 changes: 2 additions & 2 deletions pkg/apis/wing/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ type InstanceStatusManifest struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type InstanceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`

Items []Instance `json:"items"`
}
4 changes: 2 additions & 2 deletions pkg/apis/wing/v1alpha1/zz_generated.conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func Convert_wing_Instance_To_v1alpha1_Instance(in *wing.Instance, out *Instance
}

func autoConvert_v1alpha1_InstanceList_To_wing_InstanceList(in *InstanceList, out *wing.InstanceList, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.ListMeta = in.ListMeta
out.Items = *(*[]wing.Instance)(unsafe.Pointer(&in.Items))
return nil
}
Expand All @@ -76,7 +76,7 @@ func Convert_v1alpha1_InstanceList_To_wing_InstanceList(in *InstanceList, out *w
}

func autoConvert_wing_InstanceList_To_v1alpha1_InstanceList(in *wing.InstanceList, out *InstanceList, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.ListMeta = in.ListMeta
out.Items = *(*[]Instance)(unsafe.Pointer(&in.Items))
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/wing/v1alpha1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (in *Instance) DeepCopyObject() runtime.Object {
func (in *InstanceList) DeepCopyInto(out *InstanceList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Instance, len(*in))
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/wing/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (in *Instance) DeepCopyObject() runtime.Object {
func (in *InstanceList) DeepCopyInto(out *InstanceList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Instance, len(*in))
Expand Down
43 changes: 43 additions & 0 deletions pkg/wing/admission/winginitializer/winginitializer_test.go
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{}
24 changes: 13 additions & 11 deletions pkg/wing/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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 completedConfig structure returned from cfg.GenericConfig.Complete, which meant we had to re-construct this completed configuration (albeit this time without calling Complete - I assume this was okay because Complete was originally called on a pointer? Not sure as I've not checked the code for Complete yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted someone to double check

if err != nil {
return nil, err
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/wing/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ func (o WingServerOptions) Config() (*apiserver.Config, error) {
return nil, fmt.Errorf("error creating self-signed certificates: %v", err)
}

serverConfig := genericapiserver.NewConfig(apiserver.Codecs)
if err := o.RecommendedOptions.Etcd.ApplyTo(serverConfig); err != nil {
serverConfig := genericapiserver.NewRecommendedConfig(apiserver.Codecs)
if err := o.RecommendedOptions.Etcd.ApplyTo(&serverConfig.Config); err != nil {
return nil, err
}
if err := o.RecommendedOptions.SecureServing.ApplyTo(serverConfig); err != nil {
if err := o.RecommendedOptions.SecureServing.ApplyTo(&serverConfig.Config); err != nil {
return nil, err
}

Expand All @@ -109,7 +109,8 @@ func (o WingServerOptions) Config() (*apiserver.Config, error) {
if err != nil {
return nil, err
}
if err := o.Admission.ApplyTo(serverConfig, admissionInitializer); err != nil {

if err := o.Admission.ApplyTo(&serverConfig.Config, serverConfig.SharedInformerFactory, admissionInitializer); err != nil {
return nil, err
}

Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/google/btree/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading