-
Notifications
You must be signed in to change notification settings - Fork 34
/
clioptions.go
44 lines (35 loc) · 1.26 KB
/
clioptions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package parse
import (
"github.com/kubevirt/kubevirt-tekton-tasks/modules/shared/pkg/zutils"
"go.uber.org/zap/zapcore"
)
const (
sysprepCommandsOptionName = "sysprep-commands"
sysprepCommandsEnvVarName = "SYSPREP_COMMANDS"
)
type CLIOptions struct {
SysprepCommands string `arg:"--sysprep-commands,env:SYSPREP_COMMANDS" placeholder:"COMMANDS" help:"virt-sysprep script in --commands-from-file format to execute on target pvc."`
AdditionalVirtSysprepOptions string `arg:"--additional-virt-sysprep-options,env:ADDITIONAL_VIRT_SYSPREP_OPTIONS" placeholder:"OPTIONS" help:"additional options to pass to virt-sysprepr."`
Verbose string `arg:"--verbose" placeholder:"true|false" help:"Enable verbose mode and tracing of libguestfs API calls."`
}
func (c *CLIOptions) GetDebugLevel() zapcore.Level {
if c.IsVerbose() {
return zapcore.DebugLevel
}
return zapcore.InfoLevel
}
func (c *CLIOptions) IsVerbose() bool {
return zutils.IsTrue(c.Verbose)
}
func (c *CLIOptions) GetSysprepCommands() string {
return c.SysprepCommands
}
func (c *CLIOptions) GetAdditionalVirtSysprepOptions() string {
return c.AdditionalVirtSysprepOptions
}
func (c *CLIOptions) Init() error {
if err := c.validateCommands(); err != nil {
return err
}
return nil
}