Skip to content

Commit

Permalink
Add config validation for --ha-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
umatare5 committed May 12, 2021
1 parent c905181 commit 0da3511
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ func checkArguments(cfg *Config) error {
if cfg.Command == domain.EmptyString {
return errors.ErrMissingCommand
}
if isUsableHAMode(cfg.HAMode, cfg.ExecPlatform) {
return errors.ErrUnsupportedHAMode
}
if !isValidExecPlatform(cfg.ExecPlatform) {
return errors.ErrInvalidPlatform
}
Expand Down Expand Up @@ -129,6 +132,18 @@ func isUsableEnableMode(mode bool, platform string) bool {
return true
}

func isUsableHAMode(mode bool, platform string) bool {
if mode {
if platform == domain.ASASoftwarePlatformName {
return true
}
if platform == domain.ScreenOSPlatformName {
return true
}
}
return false
}

func isUsableUsername(username string, platform string) bool {
if username != domain.EmptyString {
if platform == domain.YamahaOSPlatformName {
Expand Down
1 change: 1 addition & 0 deletions pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var (
ErrMissingHostname = errors.New("hostname must be set")
ErrMissingCommand = errors.New("command must be set")
ErrInvalidPlatform = errors.New("exec-platform is not supported")
ErrUnsupportedHAMode = errors.New("ha-mode is not supported in this platform")
)

// Used for useca
Expand Down

0 comments on commit 0da3511

Please sign in to comment.