Skip to content

Commit 41149c3

Browse files
mkocherAlphasite
authored andcommitted
do not require --recreate with --recreate-vms-created-before
makes this feature a little nicer to use Signed-off-by: Nishad Mathur <nishad.mathur@broadcom.com>
1 parent eeb5f89 commit 41149c3

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

cmd/deploy.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ func (c DeployCmd) Run(opts DeployOpts) error {
101101
return err
102102
}
103103

104+
if opts.RecreateVMsCreatedBefore.IsSet() {
105+
opts.Recreate = true
106+
}
107+
104108
updateOpts := boshdir.UpdateOpts{
105109
RecreatePersistentDisks: opts.RecreatePersistentDisks,
106110
Recreate: opts.Recreate,

cmd/deploy_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,23 @@ var _ = Describe("DeployCmd", func() {
8888
}))
8989
})
9090

91-
It("deploys manifest allowing to recreate VMs created before a timestamp", func() {
91+
It("deploys manifest allowing to recreate VMs created before a timestamp and automatically sets recreate", func() {
92+
deployOpts.RecreateVMsCreatedBefore = opts.TimeArg{Time: time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)}
93+
94+
err := act()
95+
Expect(err).ToNot(HaveOccurred())
96+
97+
Expect(deployment.UpdateCallCount()).To(Equal(1))
98+
99+
bytes, updateOpts := deployment.UpdateArgsForCall(0)
100+
Expect(bytes).To(Equal([]byte("name: dep\n")))
101+
Expect(updateOpts).To(Equal(boshdir.UpdateOpts{
102+
Recreate: true,
103+
RecreateVMsCreatedBefore: time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC),
104+
}))
105+
})
106+
107+
It("deploys manifest with both recreate and recreate-vms-created-before set explicitly", func() {
92108
deployOpts.Recreate = true
93109
deployOpts.RecreateVMsCreatedBefore = opts.TimeArg{Time: time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)}
94110

cmd/opts/opts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ type DeployOpts struct {
505505

506506
Recreate bool `long:"recreate" description:"Recreate all VMs in deployment"`
507507
RecreatePersistentDisks bool `long:"recreate-persistent-disks" description:"Recreate all persistent disks in deployment"`
508-
RecreateVMsCreatedBefore TimeArg `long:"recreate-vms-created-before" description:"Only recreate VMs created before the given RFC 3339 timestamp (requires --recreate)"`
508+
RecreateVMsCreatedBefore TimeArg `long:"recreate-vms-created-before" description:"Only recreate VMs created before the given RFC 3339 timestamp"`
509509
Fix bool `long:"fix" description:"Recreate an instance with an unresponsive agent instead of erroring"`
510510
FixReleases bool `long:"fix-releases" description:"Reupload releases in manifest and replace corrupt or missing jobs/packages"`
511511
SkipDrain []boshdir.SkipDrain `long:"skip-drain" value-name:"[INSTANCE-GROUP[/INSTANCE-ID]]" description:"Skip running drain and pre-stop scripts for specific instance groups" optional:"true" optional-value:"*"`

0 commit comments

Comments
 (0)