From 25d1c5eda0b2f684eebc1d54215cf3b56b07ab33 Mon Sep 17 00:00:00 2001 From: Josh Wolf Date: Tue, 22 Jun 2021 10:10:29 -0600 Subject: [PATCH 1/2] bug: fix error when running a package with 0 bundles --- pkg/bootstrap/booter.go | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/pkg/bootstrap/booter.go b/pkg/bootstrap/booter.go index 4924fd6..6e1a1cc 100644 --- a/pkg/bootstrap/booter.go +++ b/pkg/bootstrap/booter.go @@ -55,22 +55,28 @@ func (b booter) PreBoot(ctx context.Context, d driver.Driver) error { return err } - if err := b.moveBin(); err != nil { + //TODO: Don't hardcode this + binPath := filepath.Join("/opt/hauler/bin") + if err := b.move(b.fs.Bin(), binPath, os.ModePerm); err != nil { return err } + bundlesPath := d.DataPath("server/manifests/hauler") + if err := b.move(b.fs.Bundle(), bundlesPath, 0700); err != nil { + return err + } + + chartsPath := d.DataPath("server/static/charts/hauler") + if err := b.move(b.fs.Chart(), chartsPath, 0700); err != nil { + return err + } + + //Images are slightly different b/c we convert before move as well + //TODO: refactor this better if err := b.moveImages(d); err != nil { return err } - if err := b.moveBundles(d); err != nil { - return err - } - - if err := b.moveCharts(d); err != nil { - return err - } - b.logger.Debugf("Writing %s config", d.Name()) if err := d.WriteConfig(); err != nil { return err @@ -139,13 +145,17 @@ func (b booter) PostBoot(ctx context.Context, d driver.Driver) error { } //TODO: Move* will actually just copy. This is more expensive, but is much safer/easier at handling deep merges, should this change? -func (b booter) moveBin() error { - path := filepath.Join("/opt/hauler/bin") - if err := os.MkdirAll(path, os.ModePerm); err != nil { +func (b booter) move(fsys fs.PkgFs, path string, mode os.FileMode) error { + if err := os.MkdirAll(path, mode); err != nil { return err } - return copy.Copy(b.fs.Bin().Path(), path) + err := copy.Copy(fsys.Path(), path) + if !os.IsNotExist(err) && err != nil { + return err + } + + return nil } func (b booter) moveImages(d driver.Driver) error { From 39e37cc04afbd107dc6374bc613c69b9c96026f1 Mon Sep 17 00:00:00 2001 From: Josh Wolf Date: Thu, 24 Jun 2021 07:39:20 -0600 Subject: [PATCH 2/2] clean up unused move fns --- pkg/bootstrap/booter.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/pkg/bootstrap/booter.go b/pkg/bootstrap/booter.go index 6e1a1cc..97f3a05 100644 --- a/pkg/bootstrap/booter.go +++ b/pkg/bootstrap/booter.go @@ -172,19 +172,3 @@ func (b booter) moveImages(d driver.Driver) error { return tarball.MultiRefWriteToFile(filepath.Join(path, "hauler.tar"), refs) } - -func (b booter) moveBundles(d driver.Driver) error { - path := d.DataPath("server/manifests/hauler") - if err := os.MkdirAll(path, 0700); err != nil { - return err - } - return copy.Copy(b.fs.Bundle().Path(), path) -} - -func (b booter) moveCharts(d driver.Driver) error { - path := d.DataPath("server/static/charts/hauler") - if err := os.MkdirAll(path, 0700); err != nil { - return err - } - return copy.Copy(b.fs.Chart().Path(), path) -}