Skip to content

Commit

Permalink
Fixed some linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ipatrykx committed Oct 28, 2022
1 parent 7abef39 commit f478c93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
)

var cfg *Config
Expand Down Expand Up @@ -41,7 +41,7 @@ func newConfig() *Config {
// ReadConfig loads config
func (cfg *Config) ReadConfig(configFile string) error {
allCfg := make(map[string]json.RawMessage)
rawBytes, err := ioutil.ReadFile(configFile)
rawBytes, err := os.ReadFile(configFile)

if err != nil {
return fmt.Errorf("error reading file %s, %v", configFile, err)
Expand Down
10 changes: 6 additions & 4 deletions pkg/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const (

// Deprecated - feature that will be deprecated in 2 releases
Deprecated = string("DEPRECATED")

splitLength = 2
)

// List of supported features
Expand Down Expand Up @@ -101,7 +103,7 @@ func (fg *FeatureGate) isFeatureSupported(featureName string) bool {

func (fg *FeatureGate) set(featureName string, status bool) error {
if !fg.isFeatureSupported(featureName) {
return fmt.Errorf("Feature %s is not supported", featureName)
return fmt.Errorf("feature %s is not supported", featureName)
}
fg.enabled[featureName] = status
if status && fg.knownFeatures[featureName].Maturity == Deprecated {
Expand All @@ -125,13 +127,13 @@ func (fg *FeatureGate) SetFromMap(valuesToSet map[string]bool) error {
func (fg *FeatureGate) SetFromString(value string) error {
featureMap := make(map[string]bool)
for _, s := range strings.Split(value, ",") {
if len(s) == 0 {
if s == "" {
continue
}
splitted := strings.Split(s, "=")
key := strings.TrimSpace(splitted[0])
if len(splitted) != 2 {
if len(splitted) > 2 {
if len(splitted) != splitLength {
if len(splitted) > splitLength {
return fmt.Errorf("too many values for %s", key)
}
return fmt.Errorf("enablement value for %s is missing", key)
Expand Down

0 comments on commit f478c93

Please sign in to comment.