corso/src/cli/flags/retention.go
ashmrtn 179edfc08e
Add hidden flags for setting retention during repo init (#3932)
Add, parse, and configure info about retention
when initializing a repo. These flags are
currently marked as hidden

Medium-term, they can be used in longevity
tests when making the repo for the first time
(we can configure this out of band if needed
though)

Long-term, they can be exposed to the user
for immutable backup support

---

#### Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [x] 🕐 Yes, but in a later PR
- [ ]  No

#### Type of change

- [x] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [x] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Issue(s)

* #3799

#### Test Plan

- [x] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
2023-08-04 19:08:04 +00:00

51 lines
1.2 KiB
Go

package flags
import (
"time"
"github.com/spf13/cobra"
"github.com/alcionai/corso/src/pkg/control/repository"
)
const (
RetentionModeFN = "retention-mode"
RetentionDurationFN = "retention-duration"
ExtendRetentionFN = "extend-retention"
)
var (
RetentionModeFV string
RetentionDurationFV time.Duration
ExtendRetentionFV bool
)
// AddRetentionConfigFlags adds the retention config flag set.
func AddRetentionConfigFlags(cmd *cobra.Command) {
fs := cmd.Flags()
fs.StringVar(
&RetentionModeFV,
RetentionModeFN,
repository.NoRetention.String(),
"Sets object locking mode (if any) to use in remote storage: "+
repository.NoRetention.String()+", "+
repository.GovernanceRetention.String()+", or "+
repository.ComplianceRetention.String())
cobra.CheckErr(fs.MarkHidden(RetentionModeFN))
fs.DurationVar(
&RetentionDurationFV,
RetentionDurationFN,
time.Duration(0),
"Set the amount of time to lock individual objects in remote storage")
cobra.CheckErr(fs.MarkHidden(RetentionDurationFN))
fs.BoolVar(
&ExtendRetentionFV,
ExtendRetentionFN,
false,
"Extends object locks during maintenance. "+
"Extends locks by the most recently set value of "+RetentionDurationFN)
cobra.CheckErr(fs.MarkHidden(ExtendRetentionFN))
}