Skip to content

Commit

Permalink
contrib: correct parameter name
Browse files Browse the repository at this point in the history
Signed-off-by: Junduo Dong <[email protected]>
  • Loading branch information
An-DJ committed Nov 3, 2023
1 parent 240af3e commit 8f11688
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions contrib/nydusify/cmd/nydusify.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,27 @@ func parseBackendConfig(backendConfigJSON, backendConfigFile string) (string, er
return backendConfigJSON, nil
}

func getBackendConfig(c *cli.Context, suffix string, required bool) (string, string, error) {
backendType := c.String(suffix + "backend-type")
func getBackendConfig(c *cli.Context, prefix string, required bool) (string, string, error) {
backendType := c.String(prefix + "backend-type")
if backendType == "" {
if required {
return "", "", errors.Errorf("backend type is empty, please specify option '--%sbackend-type'", suffix)
return "", "", errors.Errorf("backend type is empty, please specify option '--%sbackend-type'", prefix)
}
return "", "", nil
}

possibleBackendTypes := []string{"oss", "s3"}
if !isPossibleValue(possibleBackendTypes, backendType) {
return "", "", fmt.Errorf("--%sbackend-type should be one of %v", suffix, possibleBackendTypes)
return "", "", fmt.Errorf("--%sbackend-type should be one of %v", prefix, possibleBackendTypes)
}

backendConfig, err := parseBackendConfig(
c.String(suffix+"backend-config"), c.String(suffix+"backend-config-file"),
c.String(prefix+"backend-config"), c.String(prefix+"backend-config-file"),
)
if err != nil {
return "", "", err
} else if (backendType == "oss" || backendType == "s3") && strings.TrimSpace(backendConfig) == "" {
return "", "", errors.Errorf("backend configuration is empty, please specify option '--%sbackend-config'", suffix)
return "", "", errors.Errorf("backend configuration is empty, please specify option '--%sbackend-config'", prefix)
}

return backendType, backendConfig, nil
Expand Down

0 comments on commit 8f11688

Please sign in to comment.