diff --git a/Gopkg.lock b/Gopkg.lock index 6d40e6165..d427093b8 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -224,12 +224,6 @@ ] revision = "0fb14efe8c47ae851c0034ed7a448854d3d34cf3" -[[projects]] - branch = "master" - name = "github.com/howeyc/gopass" - packages = ["."] - revision = "bf9dde6d0d2c004a008c27aaee91170c786f6db8" - [[projects]] name = "github.com/imdario/mergo" packages = ["."] @@ -251,14 +245,7 @@ [[projects]] name = "github.com/json-iterator/go" packages = ["."] - revision = "e7c7f3b33712573affdcc7a107218e7926b9a05b" - version = "1.0.6" - -[[projects]] - name = "github.com/juju/ratelimit" - packages = ["."] - revision = "59fac5042749a5afb9af70e813da1dd5474f0167" - version = "1.0.1" + revision = "f2b4162afba35581b6d4a50d3b8f34e33c144682" [[projects]] name = "github.com/kevinburke/ssh_config" @@ -284,6 +271,18 @@ packages = ["."] revision = "b8bc1bf767474819792c23f32d8286a45736f1c6" +[[projects]] + name = "github.com/modern-go/concurrent" + packages = ["."] + revision = "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94" + version = "1.0.3" + +[[projects]] + name = "github.com/modern-go/reflect2" + packages = ["."] + revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd" + version = "1.0.1" + [[projects]] name = "github.com/opencontainers/go-digest" packages = ["."] @@ -622,7 +621,6 @@ revision = "d670f9405373e636a5a2765eea47fac0c9bc91a4" [[projects]] - branch = "master" name = "k8s.io/api" packages = [ "admissionregistration/v1alpha1", @@ -649,15 +647,17 @@ "rbac/v1alpha1", "rbac/v1beta1", "scheduling/v1alpha1", + "scheduling/v1beta1", "settings/v1alpha1", "storage/v1", "storage/v1alpha1", "storage/v1beta1" ] - revision = "b378c47b2dcba7f5c3ef97d8a5a0b3821ec6a001" + revision = "072894a440bdee3a891dea811fe42902311cd2a3" + version = "kubernetes-1.11.0" [[projects]] - branch = "master" + branch = "release-1.11" name = "k8s.io/apimachinery" packages = [ "pkg/api/errors", @@ -702,7 +702,7 @@ "third_party/forked/golang/json", "third_party/forked/golang/reflect" ] - revision = "cced8e64b6ca92a8b6afcbfea3353ca016694a45" + revision = "103fd098999dc9c0c88536f5c9ad2e5da39373ae" [[projects]] name = "k8s.io/client-go" @@ -735,11 +735,16 @@ "kubernetes/typed/rbac/v1alpha1", "kubernetes/typed/rbac/v1beta1", "kubernetes/typed/scheduling/v1alpha1", + "kubernetes/typed/scheduling/v1beta1", "kubernetes/typed/settings/v1alpha1", "kubernetes/typed/storage/v1", "kubernetes/typed/storage/v1alpha1", "kubernetes/typed/storage/v1beta1", + "pkg/apis/clientauthentication", + "pkg/apis/clientauthentication/v1alpha1", + "pkg/apis/clientauthentication/v1beta1", "pkg/version", + "plugin/pkg/client/auth/exec", "rest", "rest/watch", "testing", @@ -756,16 +761,18 @@ "transport", "util/buffer", "util/cert", + "util/connrotation", "util/flowcontrol", "util/homedir", "util/integer", + "util/retry", "util/workqueue" ] - revision = "78700dec6369ba22221b72770783300f143df150" - version = "v6.0.0" + revision = "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" + version = "v8.0.0" [[projects]] - branch = "release-1.9" + branch = "release-1.11" name = "k8s.io/code-generator" packages = [ "cmd/client-gen", @@ -775,9 +782,10 @@ "cmd/client-gen/generators/scheme", "cmd/client-gen/generators/util", "cmd/client-gen/path", - "cmd/client-gen/types" + "cmd/client-gen/types", + "pkg/util" ] - revision = "91d3f6a57905178524105a085085901bb73bd3dc" + revision = "6702109cc68eb6fe6350b83e14407c8d7309fd1a" [[projects]] name = "k8s.io/gengo" @@ -815,6 +823,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "3cbcf68d471634e600092225d2a648c2e1e1ec89f293cfee1e5751c5ee39e3c2" + inputs-digest = "2096a403b53c46b36f7fd9e305a90aee8e3e83dff5a30afd381bcf367070454a" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 414afebbb..e4f99734b 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -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" diff --git a/integrations/client/clientset/versioned/clientset.go b/integrations/client/clientset/versioned/clientset.go index dbce1b993..f3df48318 100644 --- a/integrations/client/clientset/versioned/clientset.go +++ b/integrations/client/clientset/versioned/clientset.go @@ -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" @@ -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 diff --git a/integrations/client/clientset/versioned/fake/clientset_generated.go b/integrations/client/clientset/versioned/fake/clientset_generated.go index 06b63d558..1347320a2 100644 --- a/integrations/client/clientset/versioned/fake/clientset_generated.go +++ b/integrations/client/clientset/versioned/fake/clientset_generated.go @@ -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 diff --git a/integrations/client/clientset/versioned/fake/register.go b/integrations/client/clientset/versioned/fake/register.go index bc2faedd1..c5daac935 100644 --- a/integrations/client/clientset/versioned/fake/register.go +++ b/integrations/client/clientset/versioned/fake/register.go @@ -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" // ) // @@ -48,5 +48,4 @@ func init() { // correctly. func AddToScheme(scheme *runtime.Scheme) { helmv1alpha2.AddToScheme(scheme) - } diff --git a/integrations/client/clientset/versioned/scheme/register.go b/integrations/client/clientset/versioned/scheme/register.go index d91bd8b54..7d5ee1749 100644 --- a/integrations/client/clientset/versioned/scheme/register.go +++ b/integrations/client/clientset/versioned/scheme/register.go @@ -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" // ) // @@ -48,5 +48,4 @@ func init() { // correctly. func AddToScheme(scheme *runtime.Scheme) { helmv1alpha2.AddToScheme(scheme) - } diff --git a/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go index 8a03a01e7..677790542 100644 --- a/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go @@ -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) diff --git a/integrations/client/informers/externalversions/factory.go b/integrations/client/informers/externalversions/factory.go index b36b16034..242a1e6fc 100644 --- a/integrations/client/informers/externalversions/factory.go +++ b/integrations/client/informers/externalversions/factory.go @@ -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 ( @@ -31,12 +28,16 @@ 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. @@ -44,23 +45,62 @@ type sharedInformerFactory struct { 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. @@ -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 diff --git a/integrations/client/informers/externalversions/generic.go b/integrations/client/informers/externalversions/generic.go index cd3d1afa8..0bafc6566 100644 --- a/integrations/client/informers/externalversions/generic.go +++ b/integrations/client/informers/externalversions/generic.go @@ -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 ( diff --git a/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go index 90aec563e..676bb9a06 100644 --- a/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go +++ b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go @@ -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 ( diff --git a/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go index b82becb7a..4089ee71e 100644 --- a/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go +++ b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go @@ -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 ( diff --git a/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/interface.go b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/interface.go index 98dda9594..225789600 100644 --- a/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/interface.go +++ b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/interface.go @@ -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 ( diff --git a/integrations/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/integrations/client/informers/externalversions/internalinterfaces/factory_interfaces.go index 6d862922f..3ce4be153 100644 --- a/integrations/client/informers/externalversions/internalinterfaces/factory_interfaces.go +++ b/integrations/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -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 internalinterfaces import ( diff --git a/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/expansion_generated.go b/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/expansion_generated.go index 7fcba65cf..049be3ebe 100644 --- a/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/expansion_generated.go +++ b/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/expansion_generated.go @@ -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 lister-gen - package v1alpha2 // FluxHelmReleaseListerExpansion allows custom methods to be added to diff --git a/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go b/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go index 629ea3361..604659413 100644 --- a/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go +++ b/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go @@ -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 lister-gen - package v1alpha2 import ( diff --git a/integrations/helm/operator/operator.go b/integrations/helm/operator/operator.go index 825b25e73..038773e24 100644 --- a/integrations/helm/operator/operator.go +++ b/integrations/helm/operator/operator.go @@ -324,9 +324,7 @@ func (c *Controller) enqueueUpateJob(old, new interface{}) { return } - oldResVer := oldFhr.ResourceVersion - newResVer := newFhr.ResourceVersion - if newResVer != oldResVer { + if needsUpdate(oldFhr, newFhr) { c.logger.Log("info", "UPGRADING release") c.logger.Log("info", "Custom Resource driven release upgrade") c.enqueueJob(new) @@ -343,3 +341,31 @@ func (c *Controller) deleteRelease(fhr ifv1.FluxHelmRelease) { } return } + +// needsUpdate compares two FluxHelmRelease and determines if any changes occurred +func needsUpdate(old, new ifv1.FluxHelmRelease) bool { + + oldValues, err := old.Spec.Values.YAML() + if err != nil { + return false + } + + newValues, err := new.Spec.Values.YAML() + if err != nil { + return false + } + + if oldValues != newValues { + return true + } + + if old.Spec.ReleaseName != new.Spec.ReleaseName { + return true + } + + if old.Spec.ChartGitPath != new.Spec.ChartGitPath { + return true + } + + return false +}