Commit 9033891f authored by Morten Lied Johansen's avatar Morten Lied Johansen

Skip writing manifest when using `--no-deploy`

Instead of skipping the manifest when listing the directory, we now skip creating it in the first place. This allows users to deploy manifests that replaces the ones bundled, without having to come up with a new name. Fixes #230.
parent 08afcfdc
...@@ -35,14 +35,13 @@ const ( ...@@ -35,14 +35,13 @@ const (
startKey = "_start_" startKey = "_start_"
) )
func WatchFiles(ctx context.Context, skips []string, bases ...string) error { func WatchFiles(ctx context.Context, bases ...string) error {
server := norman.GetServer(ctx) server := norman.GetServer(ctx)
addons := v1.ClientsFrom(ctx).Addon addons := v1.ClientsFrom(ctx).Addon
w := &watcher{ w := &watcher{
addonCache: addons.Cache(), addonCache: addons.Cache(),
addons: addons, addons: addons,
skips: skips,
bases: bases, bases: bases,
restConfig: *server.Runtime.LocalConfig, restConfig: *server.Runtime.LocalConfig,
discovery: server.K8sClient.Discovery(), discovery: server.K8sClient.Discovery(),
...@@ -64,7 +63,6 @@ type watcher struct { ...@@ -64,7 +63,6 @@ type watcher struct {
addonCache v1.AddonClientCache addonCache v1.AddonClientCache
addons v1.AddonClient addons v1.AddonClient
bases []string bases []string
skips []string
restConfig rest.Config restConfig rest.Config
discovery discovery.DiscoveryInterface discovery discovery.DiscoveryInterface
clients map[schema.GroupVersionKind]*objectclient.ObjectClient clients map[schema.GroupVersionKind]*objectclient.ObjectClient
...@@ -107,9 +105,6 @@ func (w *watcher) listFilesIn(base string, force bool) error { ...@@ -107,9 +105,6 @@ func (w *watcher) listFilesIn(base string, force bool) error {
} }
skips := map[string]bool{} skips := map[string]bool{}
for _, skip := range w.skips {
skips[skip] = true
}
for _, file := range files { for _, file := range files {
if strings.HasSuffix(file.Name(), ".skip") { if strings.HasSuffix(file.Name(), ".skip") {
skips[strings.TrimSuffix(file.Name(), ".skip")] = true skips[strings.TrimSuffix(file.Name(), ".skip")] = true
......
...@@ -9,10 +9,18 @@ import ( ...@@ -9,10 +9,18 @@ import (
"path/filepath" "path/filepath"
) )
func Stage(dataDir string, templateVars map[string]string) error { func Stage(dataDir string, templateVars map[string]string, skipList []string) error {
os.MkdirAll(dataDir, 0700) os.MkdirAll(dataDir, 0700)
skips := map[string]bool{}
for _, skip := range skipList {
skips[skip] = true
}
for _, name := range AssetNames() { for _, name := range AssetNames() {
if skips[name] {
continue
}
content, err := Asset(name) content, err := Asset(name)
if err != nil { if err != nil {
return err return err
......
...@@ -126,10 +126,10 @@ func startNorman(ctx context.Context, config *Config) (string, error) { ...@@ -126,10 +126,10 @@ func startNorman(ctx context.Context, config *Config) (string, error) {
func(ctx context.Context) error { func(ctx context.Context) error {
dataDir := filepath.Join(controlConfig.DataDir, "manifests") dataDir := filepath.Join(controlConfig.DataDir, "manifests")
templateVars := map[string]string{"%{CLUSTER_DNS}%": controlConfig.ClusterDNS.String()} templateVars := map[string]string{"%{CLUSTER_DNS}%": controlConfig.ClusterDNS.String()}
if err := deploy.Stage(dataDir, templateVars); err != nil { if err := deploy.Stage(dataDir, templateVars, controlConfig.Skips); err != nil {
return err return err
} }
if err := deploy.WatchFiles(ctx, controlConfig.Skips, dataDir); err != nil { if err := deploy.WatchFiles(ctx, dataDir); err != nil {
return err return err
} }
return nil return nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment