in pkg/cmd/install.go [702:793]
func (o *installCmdOptions) validate(_ *cobra.Command, _ []string) error {
var result error
if o.OperatorID == "" {
result = multierr.Append(result, fmt.Errorf("cannot use empty operator id"))
}
if len(o.MavenRepositories) > 0 && o.MavenSettings != "" {
err := fmt.Errorf("incompatible options combinations: you cannot set both mavenRepository and mavenSettings")
result = multierr.Append(result, err)
}
if o.TraitProfile != "" {
tp := v1.TraitProfileByName(o.TraitProfile)
if tp == v1.TraitProfile("") {
err := fmt.Errorf("unknown trait profile %s", o.TraitProfile)
result = multierr.Append(result, err)
}
}
if o.registry.Secret != "" && (o.registryAuth.IsSet() || o.RegistryAuthFile != "") {
err := fmt.Errorf("incompatible options combinations: you cannot set both registry-secret and registry-auth-[*] settings")
result = multierr.Append(result, err)
}
if o.registryAuth.IsSet() && o.RegistryAuthFile != "" {
err := fmt.Errorf("incompatible options combinations: you cannot set registry-auth-file with other registry-auth-[*] settings")
result = multierr.Append(result, err)
}
if o.RegistryAuthFile != "" {
nfo, err := os.Stat(o.RegistryAuthFile)
if err != nil {
result = multierr.Append(result, err)
} else if nfo.IsDir() {
result = multierr.Append(result, fmt.Errorf("registry file cannot be a directory: %s: %w", o.RegistryAuthFile, err))
}
}
if o.BuildStrategy != "" {
found := false
for _, s := range v1.BuildStrategies {
if string(s) == o.BuildStrategy {
found = true
break
}
}
if !found {
var strategies []string
for _, s := range v1.BuildStrategies {
strategies = append(strategies, string(s))
}
return fmt.Errorf("unknown build strategy: %s. One of [%s] is expected", o.BuildStrategy, strings.Join(strategies, ", "))
}
}
if o.BuildOrderStrategy != "" {
found := false
for _, s := range v1.BuildOrderStrategies {
if string(s) == o.BuildOrderStrategy {
found = true
break
}
}
if !found {
var strategies []string
for _, s := range v1.BuildOrderStrategies {
strategies = append(strategies, string(s))
}
return fmt.Errorf("unknown build order strategy: %s. One of [%s] is expected", o.BuildOrderStrategy, strings.Join(strategies, ", "))
}
}
if o.BuildPublishStrategy != "" {
found := false
for _, s := range v1.IntegrationPlatformBuildPublishStrategies {
if string(s) == o.BuildPublishStrategy {
found = true
break
}
}
if !found {
var strategies []string
for _, s := range v1.IntegrationPlatformBuildPublishStrategies {
strategies = append(strategies, string(s))
}
return fmt.Errorf("unknown build publish strategy: %s. One of [%s] is expected", o.BuildPublishStrategy, strings.Join(strategies, ", "))
}
}
return result
}