corso/src/cli/flags/maintenance.go
2024-02-07 11:46:51 -07:00

61 lines
1.4 KiB
Go

package flags
import (
"github.com/spf13/cobra"
"github.com/alcionai/canario/src/pkg/control/repository"
)
const (
MaintenanceModeFN = "mode"
ForceMaintenanceFN = "force"
UserMaintenanceFN = "user"
HostnameMaintenanceFN = "host"
)
var (
MaintenanceModeFV string
ForceMaintenanceFV bool
UserMaintenanceFV string
HostnameMaintenanceFV string
)
func AddMaintenanceModeFlag(cmd *cobra.Command) {
fs := cmd.Flags()
fs.StringVar(
&MaintenanceModeFV,
MaintenanceModeFN,
repository.CompleteMaintenance.String(),
"Type of maintenance operation to run ('"+
repository.MetadataMaintenance.String()+"' | '"+
repository.CompleteMaintenance.String()+"' )")
}
func AddForceMaintenanceFlag(cmd *cobra.Command) {
fs := cmd.Flags()
fs.BoolVar(
&ForceMaintenanceFV,
ForceMaintenanceFN,
false,
"Force maintenance. Caution: user must ensure this is not run concurrently on a single repo")
cobra.CheckErr(fs.MarkHidden(ForceMaintenanceFN))
}
func AddMaintenanceUserFlag(cmd *cobra.Command) {
fs := cmd.Flags()
fs.StringVar(
&UserMaintenanceFV,
UserMaintenanceFN,
"",
"Attempt to run maintenance as the specified user for the repo owner user")
}
func AddMaintenanceHostnameFlag(cmd *cobra.Command) {
fs := cmd.Flags()
fs.StringVar(
&HostnameMaintenanceFV,
HostnameMaintenanceFN,
"",
"Attempt to run maintenance with the specified hostname for the repo owner hostname")
}