diff --git a/clients/rancher/v1/client.go b/clients/rancher/v1/client.go index 7b99632a..c23cc1f6 100644 --- a/clients/rancher/v1/client.go +++ b/clients/rancher/v1/client.go @@ -131,10 +131,6 @@ func (c *Client) ProxyDownstream(clusterID string) (*Client, error) { updatedOpts.URL = proxyHost baseClient, err := clientbase.NewAPIClient(&updatedOpts) - if err != nil { - return nil, err - } - if err != nil { return nil, fmt.Errorf("failed creating Proxy Client. Backoff error: %v", err) } @@ -219,9 +215,7 @@ func (c *SteveClient) ListAll(params url.Values) (*SteveCollection, error) { resp = next resp.Data = data } - if err != nil { - return resp, err - } + return resp, err } @@ -375,9 +369,7 @@ func (c *NamespacedSteveClient) ListAll(params url.Values) (*SteveCollection, er resp = next resp.Data = data } - if err != nil { - return resp, err - } + return resp, err } diff --git a/pkg/config/config.go b/pkg/config/config.go index 21b995a8..9d21cf53 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -35,7 +35,10 @@ func LoadConfig(key string, config interface{}) { panic(err) } - scoped := all[key] + scoped, ok := all[key] + if !ok { + logrus.Infof("Key %s not present in provided config", key) + } scopedString, err := yaml.Marshal(scoped) if err != nil { panic(err) diff --git a/pkg/config/operations/operations.go b/pkg/config/operations/operations.go index 21b48e8e..68f7feff 100644 --- a/pkg/config/operations/operations.go +++ b/pkg/config/operations/operations.go @@ -2,9 +2,9 @@ package operations import ( "encoding/json" - "errors" "fmt" + "github.com/sirupsen/logrus" "sigs.k8s.io/yaml" ) @@ -42,7 +42,7 @@ func GetValue(keyPath []string, searchMap map[string]any) (any, error) { if len(keyPath) == 1 { keypathvalues, ok := searchMap[keyPath[0]] if !ok { - err = errors.New(fmt.Sprintf("expected key does not exist: %s", keyPath[0])) + err = fmt.Errorf("expected key does not exist: %s", keyPath[0]) } return keypathvalues, err } else { @@ -66,7 +66,11 @@ func GetValue(keyPath []string, searchMap map[string]any) (any, error) { // LoadObjectFromMap unmarshals a specific key's value into an object func LoadObjectFromMap(key string, config map[string]any, object any) { - keyConfig := config[key] + keyConfig, ok := config[key] + if !ok { + logrus.Infof("Key %s not present in provided config", key) + } + scopedString, err := yaml.Marshal(keyConfig) if err != nil { panic(err)