Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
937b3796
Unverified
Commit
937b3796
authored
Mar 07, 2019
by
Darren Shepherd
Committed by
GitHub
Mar 07, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #183 from ibuildthecloud/helm
Various helm fixes
parents
9a862610
a6499832
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
controller.go
pkg/deploy/controller.go
+7
-14
controller.go
pkg/helm/controller.go
+8
-1
No files found.
pkg/deploy/controller.go
View file @
937b3796
...
@@ -52,21 +52,15 @@ func WatchFiles(ctx context.Context, skips []string, bases ...string) error {
...
@@ -52,21 +52,15 @@ func WatchFiles(ctx context.Context, skips []string, bases ...string) error {
addons
.
Enqueue
(
""
,
startKey
)
addons
.
Enqueue
(
""
,
startKey
)
addons
.
Interface
()
.
AddHandler
(
ctx
,
"addon-start"
,
func
(
key
string
,
_
*
v1
.
Addon
)
(
runtime
.
Object
,
error
)
{
addons
.
Interface
()
.
AddHandler
(
ctx
,
"addon-start"
,
func
(
key
string
,
_
*
v1
.
Addon
)
(
runtime
.
Object
,
error
)
{
if
key
==
startKey
{
if
key
==
startKey
{
if
err
:=
w
.
listFiles
(
true
);
err
!=
nil
{
go
w
.
start
(
ctx
)
return
nil
,
err
}
w
.
started
=
true
return
nil
,
nil
}
}
return
nil
,
nil
return
nil
,
nil
})
})
w
.
start
(
ctx
)
return
nil
return
nil
}
}
type
watcher
struct
{
type
watcher
struct
{
started
bool
addonCache
v1
.
AddonClientCache
addonCache
v1
.
AddonClientCache
addons
v1
.
AddonClient
addons
v1
.
AddonClient
bases
[]
string
bases
[]
string
...
@@ -77,14 +71,17 @@ type watcher struct {
...
@@ -77,14 +71,17 @@ type watcher struct {
}
}
func
(
w
*
watcher
)
start
(
ctx
context
.
Context
)
{
func
(
w
*
watcher
)
start
(
ctx
context
.
Context
)
{
force
:=
true
for
{
for
{
if
err
:=
w
.
listFiles
(
force
);
err
==
nil
{
force
=
false
}
else
{
logrus
.
Errorf
(
"failed to process config: %v"
,
err
)
}
select
{
select
{
case
<-
ctx
.
Done
()
:
case
<-
ctx
.
Done
()
:
return
return
case
<-
time
.
After
(
15
*
time
.
Second
)
:
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 {
...
@@ -101,10 +98,6 @@ func (w *watcher) listFiles(force bool) error {
}
}
func
(
w
*
watcher
)
listFilesIn
(
base
string
,
force
bool
)
error
{
func
(
w
*
watcher
)
listFilesIn
(
base
string
,
force
bool
)
error
{
if
!
w
.
started
{
return
nil
}
files
,
err
:=
ioutil
.
ReadDir
(
base
)
files
,
err
:=
ioutil
.
ReadDir
(
base
)
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
return
nil
return
nil
...
...
pkg/helm/controller.go
View file @
937b3796
...
@@ -2,6 +2,8 @@ package helm
...
@@ -2,6 +2,8 @@ package helm
import
(
import
(
"context"
"context"
"crypto/sha256"
"encoding/hex"
"fmt"
"fmt"
"sort"
"sort"
...
@@ -22,7 +24,7 @@ import (
...
@@ -22,7 +24,7 @@ import (
const
(
const
(
namespace
=
"kube-system"
namespace
=
"kube-system"
image
=
"rancher/klipper-helm:v0.1.
2
"
image
=
"rancher/klipper-helm:v0.1.
3
"
label
=
"helm.k3s.cattle.io/chart"
label
=
"helm.k3s.cattle.io/chart"
)
)
...
@@ -124,6 +126,7 @@ func (h *handler) onRemove(chart *k3s.HelmChart) (runtime.Object, error) {
...
@@ -124,6 +126,7 @@ func (h *handler) onRemove(chart *k3s.HelmChart) (runtime.Object, error) {
func
job
(
chart
*
k3s
.
HelmChart
)
(
*
batch
.
Job
,
*
core
.
ConfigMap
)
{
func
job
(
chart
*
k3s
.
HelmChart
)
(
*
batch
.
Job
,
*
core
.
ConfigMap
)
{
oneThousand
:=
int32
(
1000
)
oneThousand
:=
int32
(
1000
)
valuesHash
:=
sha256
.
Sum256
([]
byte
(
chart
.
Spec
.
ValuesContent
))
action
:=
"install"
action
:=
"install"
if
chart
.
DeletionTimestamp
!=
nil
{
if
chart
.
DeletionTimestamp
!=
nil
{
...
@@ -170,6 +173,10 @@ func job(chart *k3s.HelmChart) (*batch.Job, *core.ConfigMap) {
...
@@ -170,6 +173,10 @@ func job(chart *k3s.HelmChart) (*batch.Job, *core.ConfigMap) {
Name
:
"REPO"
,
Name
:
"REPO"
,
Value
:
chart
.
Spec
.
Repo
,
Value
:
chart
.
Spec
.
Repo
,
},
},
{
Name
:
"VALUES_HASH"
,
Value
:
hex
.
EncodeToString
(
valuesHash
[
:
]),
},
},
},
},
},
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment