diff --git a/cmd/cmd.go b/cmd/cmd.go index 978391f71..3f0832b6a 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -72,7 +72,7 @@ func (c Cmd) Execute() (cmdErr error) { case *CreateEnvOpts: envProvider := func(manifestPath string, statePath string, vars boshtpl.Variables, op patch.Op) DeploymentPreparer { - return NewEnvFactory(deps, manifestPath, statePath, vars, op, opts.RecreatePersistentDisks).Preparer() + return NewEnvFactory(deps, manifestPath, statePath, vars, op, opts.RecreatePersistentDisks, opts.PackageDir).Preparer() } stage := boshui.NewStage(deps.UI, deps.Time, deps.Logger) @@ -80,7 +80,7 @@ func (c Cmd) Execute() (cmdErr error) { case *DeleteEnvOpts: envProvider := func(manifestPath string, statePath string, vars boshtpl.Variables, op patch.Op) DeploymentDeleter { - return NewEnvFactory(deps, manifestPath, statePath, vars, op, false).Deleter() + return NewEnvFactory(deps, manifestPath, statePath, vars, op, false, opts.PackageDir).Deleter() } stage := boshui.NewStage(deps.UI, deps.Time, deps.Logger) @@ -88,7 +88,7 @@ func (c Cmd) Execute() (cmdErr error) { case *StopEnvOpts: envProvider := func(manifestPath string, statePath string, vars boshtpl.Variables, op patch.Op) DeploymentStateManager { - return NewEnvFactory(deps, manifestPath, statePath, vars, op, false).StateManager() + return NewEnvFactory(deps, manifestPath, statePath, vars, op, false, "").StateManager() } stage := boshui.NewStage(deps.UI, deps.Time, deps.Logger) @@ -96,7 +96,7 @@ func (c Cmd) Execute() (cmdErr error) { case *StartEnvOpts: envProvider := func(manifestPath string, statePath string, vars boshtpl.Variables, op patch.Op) DeploymentStateManager { - return NewEnvFactory(deps, manifestPath, statePath, vars, op, false).StateManager() + return NewEnvFactory(deps, manifestPath, statePath, vars, op, false, "").StateManager() } stage := boshui.NewStage(deps.UI, deps.Time, deps.Logger) diff --git a/cmd/env_factory.go b/cmd/env_factory.go index 555e54e22..c0a50f4c1 100644 --- a/cmd/env_factory.go +++ b/cmd/env_factory.go @@ -71,6 +71,7 @@ func NewEnvFactory( manifestVars boshtpl.Variables, manifestOp patch.Op, recreatePersistentDisks bool, + packageDir string, ) *envFactory { f := envFactory{ deps: deps, @@ -126,7 +127,7 @@ func NewEnvFactory( } f.targetProvider = boshinst.NewTargetProvider( - f.deploymentStateService, deps.UUIDGen, filepath.Join(workspaceRootPath, "installations")) + f.deploymentStateService, deps.UUIDGen, filepath.Join(workspaceRootPath, "installations"), packageDir) { diskRepo := biconfig.NewDiskRepo(f.deploymentStateService, deps.UUIDGen) diff --git a/cmd/opts/opts.go b/cmd/opts/opts.go index b57e2fba4..2d8413c16 100644 --- a/cmd/opts/opts.go +++ b/cmd/opts/opts.go @@ -197,6 +197,7 @@ type CreateEnvOpts struct { StatePath string `long:"state" value-name:"PATH" description:"State file path"` Recreate bool `long:"recreate" description:"Recreate VM in deployment"` RecreatePersistentDisks bool `long:"recreate-persistent-disks" description:"Recreate persistent disks in the deployment"` + PackageDir string `long:"package-dir" value-name:"DIR" description:"Overrides default package cache location"` cmd } @@ -208,8 +209,9 @@ type DeleteEnvOpts struct { Args DeleteEnvArgs `positional-args:"true" required:"true"` VarFlags OpsFlags - SkipDrain bool `long:"skip-drain" description:"Skip running drain and pre-stop scripts"` - StatePath string `long:"state" value-name:"PATH" description:"State file path"` + SkipDrain bool `long:"skip-drain" description:"Skip running drain and pre-stop scripts"` + StatePath string `long:"state" value-name:"PATH" description:"State file path"` + PackageDir string `long:"package-dir" value-name:"DIR" description:"Overrides default package cache location"` cmd } diff --git a/installation/target.go b/installation/target.go index 31e8725e1..a9e008844 100644 --- a/installation/target.go +++ b/installation/target.go @@ -5,12 +5,14 @@ import ( ) type Target struct { - path string + path string + packageDir string } -func NewTarget(path string) Target { +func NewTarget(path string, packageDir string) Target { return Target{ path, + packageDir, } } @@ -31,7 +33,11 @@ func (t Target) TemplatesIndexPath() string { } func (t Target) PackagesPath() string { - return filepath.Join(t.path, "packages") + if t.packageDir != "" { + return t.packageDir + } else { + return filepath.Join(t.path, "packages") + } } func (t Target) JobsPath() string { diff --git a/installation/target_provider.go b/installation/target_provider.go index decb3d2ae..916acffd2 100644 --- a/installation/target_provider.go +++ b/installation/target_provider.go @@ -17,17 +17,20 @@ type targetProvider struct { deploymentStateService biconfig.DeploymentStateService uuidGenerator boshuuid.Generator installationsRootPath string + packageDir string } func NewTargetProvider( deploymentStateService biconfig.DeploymentStateService, uuidGenerator boshuuid.Generator, installationsRootPath string, + packageDir string, ) TargetProvider { return &targetProvider{ deploymentStateService: deploymentStateService, uuidGenerator: uuidGenerator, installationsRootPath: installationsRootPath, + packageDir: packageDir, } } @@ -51,5 +54,5 @@ func (p *targetProvider) NewTarget() (Target, error) { } } - return NewTarget(filepath.Join(p.installationsRootPath, installationID)), nil + return NewTarget(filepath.Join(p.installationsRootPath, installationID), p.packageDir), nil }