Fixed golangci-lint issues: /fission/pkg (#1902)

This commit is contained in:
Gaurav Gahlot
2021-01-19 23:29:20 +05:30
committed by GitHub
parent 6dbdf4d88b
commit 695b0759e4
21 changed files with 178 additions and 66 deletions
@@ -95,9 +95,9 @@ func optionalFlags(cmd *cobra.Command, flags ...flag.Flag) {
toCobraFlag(cmd, f, false)
if f.Deprecated {
usage := fmt.Sprintf("Use --%v instead. The flag still works for now and will be removed in future", f.Substitute)
cmd.Flags().MarkDeprecated(f.Name, usage)
cmd.Flags().MarkDeprecated(f.Name, usage) //nolint: errCheck
} else if f.Hidden {
cmd.Flags().MarkHidden(f.Name)
cmd.Flags().MarkHidden(f.Name) //nolint: errCheck
}
}
}
@@ -105,7 +105,7 @@ func optionalFlags(cmd *cobra.Command, flags ...flag.Flag) {
func requiredFlags(cmd *cobra.Command, flags ...flag.Flag) {
for _, f := range flags {
toCobraFlag(cmd, f, false)
cmd.MarkFlagRequired(f.Name)
cmd.MarkFlagRequired(f.Name) //nolint: errCheck
}
}
+5 -5
View File
@@ -441,7 +441,7 @@ func (fr *FissionResources) Validate(input cli.Input) ([]string, error) {
}
if len(t.Spec.Host) > 0 {
warnings = append(warnings, (fmt.Sprintf("Host in HTTPTrigger spec.Host is now marked as deprecated, see 'help' for details")))
warnings = append(warnings, "Host in HTTPTrigger spec.Host is now marked as deprecated, see 'help' for details")
}
result = multierror.Append(result, t.Validate())
}
@@ -475,25 +475,25 @@ func (fr *FissionResources) Validate(input cli.Input) ([]string, error) {
for _, e := range fr.Environments {
environments[fmt.Sprintf("%s:%s", e.ObjectMeta.Name, e.ObjectMeta.Namespace)] = struct{}{}
if ((e.Spec.Runtime.Container != nil) && (e.Spec.Runtime.PodSpec != nil)) || ((e.Spec.Builder.Container != nil) && (e.Spec.Builder.PodSpec != nil)) {
warnings = append(warnings, fmt.Sprintf("You have provided both - container spec and pod spec and while merging the pod spec will take precedence."))
warnings = append(warnings, "You have provided both - container spec and pod spec and while merging the pod spec will take precedence.")
}
// Unlike CLI can change the environment version silently,
// we have to warn the user to modify spec file when this takes place.
if e.Spec.Poolsize != 3 && e.Spec.Version < 3 {
warnings = append(warnings, fmt.Sprintf("Poolsize can only be configured when environment version equals to 3, default poolsize 3 will be used for creating environment pool."))
warnings = append(warnings, "Poolsize can only be configured when environment version equals to 3, default poolsize 3 will be used for creating environment pool.")
}
}
for _, f := range fr.Functions {
if _, ok := environments[fmt.Sprintf("%s:%s", f.Spec.Environment.Name, f.Spec.Environment.Namespace)]; !ok {
warnings = append(warnings, fmt.Sprintf("Environment %s is referenced in function %s but not declared in specs", f.Spec.Environment.Name, f.ObjectMeta.Name))
warnings = append(warnings, "Environment %s is referenced in function %s but not declared in specs", f.Spec.Environment.Name, f.ObjectMeta.Name)
}
strategy := f.Spec.InvokeStrategy.ExecutionStrategy
if strategy.ExecutorType == fv1.ExecutorTypeNewdeploy && strategy.SpecializationTimeout < fv1.DefaultSpecializationTimeOut {
warnings = append(warnings, fmt.Sprintf("SpecializationTimeout in function spec.InvokeStrategy.ExecutionStrategy should be a value equal to or greater than %v", fv1.DefaultSpecializationTimeOut))
}
if f.Spec.FunctionTimeout <= 0 {
warnings = append(warnings, fmt.Sprintf("FunctionTimeout in function spec should be a field which should have a value greater than 0"))
warnings = append(warnings, "FunctionTimeout in function spec should be a field which should have a value greater than 0")
}
}
// (ErrorOrNil returns nil if there were no errors appended.)