Skip to content

Commit

Permalink
Update Kubernetes deps to 1.11 and client-go to 8.0
Browse files Browse the repository at this point in the history
- generate Helm CRD clientset, informers  and listeners for K8s 1.11
  • Loading branch information
stefanprodan committed Jul 3, 2018
1 parent 9d5eb91 commit 9b545a4
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 71 deletions.
56 changes: 32 additions & 24 deletions Gopkg.lock

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

21 changes: 15 additions & 6 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ required = ["k8s.io/code-generator/cmd/client-gen"]
name = "github.com/prometheus/client_golang"
branch = "master"

[[constraint]]
name = "k8s.io/api"
version = "kubernetes-1.11.0"

[[constraint]]
name = "k8s.io/apimachinery"
version = "kubernetes-1.11.0"

[[constraint]]
name = "k8s.io/client-go"
version = "8.0.0"

[[constraint]]
name = "k8s.io/code-generator"
branch = "release-1.9"
branch = "release-1.11"

# goland/dep does not follow k8s.io/code-generator's Godeps.json and gengo's master
# version does not work with release-1.8 k8s.io/code-generator. So we have to
# override it.
[[override]]
name = "k8s.io/gengo"
revision = "b58fc7edb82e0c6ffc9b8aef61813c7261b785d4"
name = "github.com/json-iterator/go"
revision = "f2b4162afba35581b6d4a50d3b8f34e33c144682"

[[constraint]]
name = "k8s.io/helm"
Expand Down
2 changes: 0 additions & 2 deletions integrations/client/clientset/versioned/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.
package versioned

import (
glog "github.com/golang/glog"
helmv1alpha2 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2"
discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest"
Expand Down Expand Up @@ -71,7 +70,6 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {

cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
glog.Errorf("failed to create the DiscoveryClient: %v", err)
return nil, err
}
return &cs, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,20 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
}
}

fakePtr := testing.Fake{}
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o))
fakePtr.AddWatchReactor("*", testing.DefaultWatchReactor(watch.NewFake(), nil))
cs := &Clientset{}
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
cs.AddReactor("*", "*", testing.ObjectReaction(o))
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns)
if err != nil {
return false, nil, err
}
return true, watch, nil
})

return &Clientset{fakePtr, &fakediscovery.FakeDiscovery{Fake: &fakePtr}}
return cs
}

// Clientset implements clientset.Interface. Meant to be embedded into a
Expand Down
3 changes: 1 addition & 2 deletions integrations/client/clientset/versioned/fake/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func init() {
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kuberentes/scheme"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
Expand All @@ -48,5 +48,4 @@ func init() {
// correctly.
func AddToScheme(scheme *runtime.Scheme) {
helmv1alpha2.AddToScheme(scheme)

}
3 changes: 1 addition & 2 deletions integrations/client/clientset/versioned/scheme/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func init() {
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kuberentes/scheme"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
Expand All @@ -48,5 +48,4 @@ func init() {
// correctly.
func AddToScheme(scheme *runtime.Scheme) {
helmv1alpha2.AddToScheme(scheme)

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (c *FakeFluxHelmReleases) List(opts v1.ListOptions) (result *v1alpha2.FluxH
if label == nil {
label = labels.Everything()
}
list := &v1alpha2.FluxHelmReleaseList{}
list := &v1alpha2.FluxHelmReleaseList{ListMeta: obj.(*v1alpha2.FluxHelmReleaseList).ListMeta}
for _, item := range obj.(*v1alpha2.FluxHelmReleaseList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
Expand Down
64 changes: 55 additions & 9 deletions integrations/client/informers/externalversions/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ 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.
*/

// This file was automatically generated by informer-gen

package externalversions

import (
Expand All @@ -31,36 +28,79 @@ import (
time "time"
)

// SharedInformerOption defines the functional option type for SharedInformerFactory.
type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory

type sharedInformerFactory struct {
client versioned.Interface
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
lock sync.Mutex
defaultResync time.Duration
customResync map[reflect.Type]time.Duration

informers map[reflect.Type]cache.SharedIndexInformer
// startedInformers is used for tracking which informers have been started.
// This allows Start() to be called multiple times safely.
startedInformers map[reflect.Type]bool
}

// NewSharedInformerFactory constructs a new instance of sharedInformerFactory
// WithCustomResyncConfig sets a custom resync period for the specified informer types.
func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
for k, v := range resyncConfig {
factory.customResync[reflect.TypeOf(k)] = v
}
return factory
}
}

// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory.
func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.tweakListOptions = tweakListOptions
return factory
}
}

// WithNamespace limits the SharedInformerFactory to the specified namespace.
func WithNamespace(namespace string) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.namespace = namespace
return factory
}
}

// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
return NewFilteredSharedInformerFactory(client, defaultResync, v1.NamespaceAll, nil)
return NewSharedInformerFactoryWithOptions(client, defaultResync)
}

// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory.
// Listers obtained via this SharedInformerFactory will be subject to the same filters
// as specified here.
// Deprecated: Please use NewSharedInformerFactoryWithOptions instead
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
return &sharedInformerFactory{
return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions))
}

// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options.
func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory {
factory := &sharedInformerFactory{
client: client,
namespace: namespace,
tweakListOptions: tweakListOptions,
namespace: v1.NamespaceAll,
defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool),
customResync: make(map[reflect.Type]time.Duration),
}

// Apply all options
for _, opt := range options {
factory = opt(factory)
}

return factory
}

// Start initializes all requested informers.
Expand Down Expand Up @@ -109,7 +149,13 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal
if exists {
return informer
}
informer = newFunc(f.client, f.defaultResync)

resyncPeriod, exists := f.customResync[informerType]
if !exists {
resyncPeriod = f.defaultResync
}

informer = newFunc(f.client, resyncPeriod)
f.informers[informerType] = informer

return informer
Expand Down
3 changes: 0 additions & 3 deletions integrations/client/informers/externalversions/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ 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.
*/

// This file was automatically generated by informer-gen

package externalversions

import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ 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.
*/

// This file was automatically generated by informer-gen

package helm

import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ 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.
*/

// This file was automatically generated by informer-gen

package v1alpha2

import (
Expand Down
Loading

0 comments on commit 9b545a4

Please sign in to comment.