Merge pull request #183 from ibuildthecloud/helm

Various helm fixes
pull/204/head
Darren Shepherd 6 years ago committed by GitHub
commit 937b379605
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -52,21 +52,15 @@ func WatchFiles(ctx context.Context, skips []string, bases ...string) error {
addons.Enqueue("", startKey)
addons.Interface().AddHandler(ctx, "addon-start", func(key string, _ *v1.Addon) (runtime.Object, error) {
if key == startKey {
if err := w.listFiles(true); err != nil {
return nil, err
}
w.started = true
return nil, nil
go w.start(ctx)
}
return nil, nil
})
w.start(ctx)
return nil
}
type watcher struct {
started bool
addonCache v1.AddonClientCache
addons v1.AddonClient
bases []string
@ -77,14 +71,17 @@ type watcher struct {
}
func (w *watcher) start(ctx context.Context) {
force := true
for {
if err := w.listFiles(force); err == nil {
force = false
} else {
logrus.Errorf("failed to process config: %v", err)
}
select {
case <-ctx.Done():
return
case <-time.After(15 * time.Second):
if err := w.listFiles(false); err != nil {
logrus.Errorf("failed to process config: %v", err)
}
}
}
}
@ -101,10 +98,6 @@ func (w *watcher) listFiles(force bool) error {
}
func (w *watcher) listFilesIn(base string, force bool) error {
if !w.started {
return nil
}
files, err := ioutil.ReadDir(base)
if os.IsNotExist(err) {
return nil

@ -2,6 +2,8 @@ package helm
import (
"context"
"crypto/sha256"
"encoding/hex"
"fmt"
"sort"
@ -22,7 +24,7 @@ import (
const (
namespace = "kube-system"
image = "rancher/klipper-helm:v0.1.2"
image = "rancher/klipper-helm:v0.1.3"
label = "helm.k3s.cattle.io/chart"
)
@ -124,6 +126,7 @@ func (h *handler) onRemove(chart *k3s.HelmChart) (runtime.Object, error) {
func job(chart *k3s.HelmChart) (*batch.Job, *core.ConfigMap) {
oneThousand := int32(1000)
valuesHash := sha256.Sum256([]byte(chart.Spec.ValuesContent))
action := "install"
if chart.DeletionTimestamp != nil {
@ -170,6 +173,10 @@ func job(chart *k3s.HelmChart) (*batch.Job, *core.ConfigMap) {
Name: "REPO",
Value: chart.Spec.Repo,
},
{
Name: "VALUES_HASH",
Value: hex.EncodeToString(valuesHash[:]),
},
},
},
},

Loading…
Cancel
Save